:root {
    --bg: #14151b;
    --surface: #1b1d25;
    --surface-raised: #21232d;
    --border: #2c2f3a;
    --gold: #c9a86a;
    --gold-soft: rgba(201, 168, 106, 0.12);
    --text: #ece8de;
    --text-muted: #9b9aa5;
    --success: #6fbf8b;
    --success-bg: rgba(111, 191, 139, 0.12);
    --error: #d97b6c;
    --error-bg: rgba(217, 123, 108, 0.12);
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
    font-weight: 600;
    letter-spacing: 0.01em;
    margin: 0 0 0.5em;
    color: #fff;
}

a {
    color: var(--gold);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---------- Auth screens ---------- */
.auth-shell {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 50% -10%, rgba(201, 168, 106, 0.10), transparent 60%),
        var(--bg);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.auth-lang-switch {
    position: absolute;
    top: 20px;
    right: 24px;
    margin: 0;
    padding: 0;
}

.auth-card .brand {
    text-align: center;
    margin-bottom: 28px;
}

.auth-card .brand .mark {
    display: inline-block;
    width: 44px;
    height: 44px;
    border: 1px solid var(--gold);
    border-radius: 50%;
    line-height: 42px;
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 20px;
    margin-bottom: 12px;
}

.auth-card .brand h1 {
    font-size: 20px;
    margin-bottom: 2px;
}

.auth-card .brand p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

.auth-card .switch {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.hint-box {
    margin-top: 20px;
    padding: 12px 14px;
    background: var(--gold-soft);
    border: 1px solid rgba(201, 168, 106, 0.3);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ---------- App shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: 232px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    /* Pinned to the viewport and capped to its height — without this, the
       sidebar (a grid item) stretches to match the main column's height,
       which can be much taller than the screen, and the "margin-top: auto"
       footer below ends up pinned to the bottom of that oversized box
       instead of the bottom of the visible viewport. */
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 20px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar .brand .mark {
    width: 30px;
    height: 30px;
    border: 1px solid var(--gold);
    border-radius: 50%;
    color: var(--gold);
    font-family: Georgia, serif;
    text-align: center;
    line-height: 28px;
    font-size: 14px;
}

.sidebar .brand span {
    font-family: Georgia, serif;
    font-size: 14px;
    color: #fff;
    letter-spacing: 0.03em;
}

.nav-group {
    margin-top: 18px;
}

.nav-group-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 0 12px 8px;
}

.nav-link {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 13.5px;
    margin-bottom: 2px;
    text-decoration: none;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text);
    background: var(--surface-raised);
    text-decoration: none;
}

.nav-link.active {
    color: var(--gold);
    background: var(--gold-soft);
    border-color: rgba(201, 168, 106, 0.25);
}

.lang-switch {
    margin-top: 18px;
    padding: 0 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.lang-switch a {
    color: var(--text-muted);
}

.lang-switch a.active {
    color: var(--gold);
    font-weight: 600;
}

.lang-switch span {
    margin: 0 4px;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-footer .user {
    color: var(--text);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main {
    padding: 32px 40px 60px;
    max-width: 1100px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header p {
    color: var(--text-muted);
    margin: 4px 0 0;
    font-size: 13.5px;
}

/* ---------- Flash ---------- */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13.5px;
    border: 1px solid transparent;
    word-break: break-word;
}

.flash-success {
    background: var(--success-bg);
    border-color: rgba(111, 191, 139, 0.35);
    color: var(--success);
}

.flash-error {
    background: var(--error-bg);
    border-color: rgba(217, 123, 108, 0.35);
    color: var(--error);
}

/* ---------- Cards / grid ---------- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
}

.card h3 {
    font-size: 15.5px;
    margin-bottom: 4px;
}

.card .card-desc {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-bottom: 16px;
}

.quick-link {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    text-decoration: none;
    transition: border-color 0.15s ease;
}

.quick-link:hover {
    border-color: var(--gold);
    text-decoration: none;
}

.quick-link .qty {
    font-family: Georgia, serif;
    color: var(--gold);
    font-size: 13px;
    display: block;
    margin-bottom: 4px;
}

.quick-link h3 {
    font-size: 14.5px;
    margin-bottom: 4px;
    color: var(--text);
}

.quick-link p {
    color: var(--text-muted);
    font-size: 12.5px;
    margin: 0;
}

/* ---------- Forms ---------- */
label {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 5px;
    margin-top: 14px;
}

label:first-child {
    margin-top: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 13.5px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0 16px;
}

/* Type-to-filter overlay for <select class="js-searchable"> — see
   assets/js/searchable-select.js. The real <select> is hidden (not
   removed) right below this, so it still carries the submitted value. */
.searchable-select {
    position: relative;
}

.searchable-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    margin-top: 4px;
    max-height: 220px;
    overflow-y: auto;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 7px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.searchable-select-option {
    padding: 8px 12px;
    font-size: 13.5px;
    cursor: pointer;
}

.searchable-select-option:hover,
.searchable-select-option.active {
    background: var(--gold-soft);
    color: var(--gold);
}

.searchable-select-empty {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.searchable-select-hint {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.item-row-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0 12px;
    padding: 12px;
    margin-top: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.item-row-grid .row-label {
    grid-column: 1 / -1;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-top: 0;
}

button, .btn {
    display: inline-block;
    margin-top: 20px;
    padding: 10px 20px;
    background: var(--gold);
    color: #1a1408;
    border: none;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
}

button:hover, .btn:hover {
    background: #d8b87c;
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-ghost:hover {
    border-color: var(--gold);
    background: transparent;
    color: var(--gold);
}

.btn-danger {
    background: #7a2c2c;
    color: #f5e6e6;
}

.btn-danger:hover {
    background: #983636;
}

form + form,
.card + .card {
    margin-top: 20px;
}

hr.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

/* ---------- Tables ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10.5px;
    letter-spacing: 0.06em;
}

td {
    color: var(--text);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 16px;
}

.table-wrap table {
    margin: 0;
}

.table-wrap th:first-child, .table-wrap td:first-child {
    padding-left: 16px;
}

.empty-state {
    color: var(--text-muted);
    font-size: 13px;
    padding: 16px;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    background: var(--gold-soft);
    color: var(--gold);
    border: 1px solid rgba(201, 168, 106, 0.3);
}

code {
    background: var(--surface-raised);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.actions-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.inline-form {
    display: inline-block;
}

.inline-form button {
    padding: 4px 10px;
    font-size: 12px;
}

.permission-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 12px;
}

.permission-group legend {
    padding: 0 6px;
    font-weight: 600;
    color: var(--gold);
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-weight: 400;
    font-size: 13px;
    margin: 6px 0;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 3px;
    width: auto;
}

.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.search-bar input[type="text"] {
    flex: 1;
}

.search-bar button {
    flex-shrink: 0;
}

.add-panel {
    margin-top: 8px;
}

.add-panel > summary {
    display: inline-block;
    list-style: none;
    cursor: pointer;
    background: var(--gold);
    color: #1a1408;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 7px;
    font-size: 13.5px;
    letter-spacing: 0.02em;
}

.add-panel > summary:hover {
    background: #d8b87c;
}

.add-panel > summary::-webkit-details-marker {
    display: none;
}

.add-panel > summary::marker {
    content: '';
}

.add-panel[open] > summary {
    margin-bottom: 20px;
}
