@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ════════════════════════════════════════════════════════════
   Queue Manager — design system
   ════════════════════════════════════════════════════════════ */

:root {
    /* Sidebar (dark) */
    --sidebar-bg:          #14161F;
    --sidebar-border:      rgba(255,255,255,0.07);
    --sidebar-text:        #9AA4B2;
    --sidebar-text-dim:    #667085;
    --sidebar-hover-bg:    rgba(255,255,255,0.05);
    --sidebar-active-bg:   rgba(255,255,255,0.09);
    --sidebar-active-text: #FFFFFF;

    /* Accent — neutral monochrome */
    --accent:              #111827;
    --accent-hover:        #000000;
    --accent-soft:         rgba(16,24,40,0.05);
    --accent-ring:         rgba(16,24,40,0.08);

    /* Canvas */
    --bg:                  #F7F8FA;
    --surface:             #FFFFFF;
    --surface-subtle:      #F9FAFB;
    --border:              #E4E7EC;
    --border-strong:       #D0D5DD;

    /* Text */
    --text:                #101828;
    --text-secondary:      #344054;
    --text-muted:          #667085;
    --text-faint:          #98A2B3;

    /* Status */
    --danger:              #D92D20;
    --danger-hover:        #B42318;
    --danger-text:         #B42318;
    --danger-bg:           #FEF3F2;
    --danger-border:       #FECDCA;
    --success:             #12B76A;
    --success-text:        #067647;
    --success-bg:          #ECFDF3;
    --success-border:      #ABEFC6;

    /* Shape — flat design, no elevation */
    --radius-sm:           6px;
    --radius:              8px;
    --radius-lg:           10px;
    --shadow-xs:           none;
    --shadow-sm:           none;
    --shadow-md:           none;
    --shadow-lg:           none;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ────────────────────────────────────────────────── */

html, body {
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'cv05', 'cv11';
}

body {
    display: flex;
    overflow: hidden;
}

::selection {
    background: rgba(16,24,40,0.12);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── Scrollbars ──────────────────────────────────────────── */

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(152,162,179,0.45) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(152,162,179,0.4);
    border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(152,162,179,0.65); }

#aside::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
#aside::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.22); }

/* ── Sidebar ─────────────────────────────────────────────── */

#aside {
    position: relative;
    width: max-content;
    min-width: 208px;
    flex-shrink: 0;
    height: 100%;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
}

.sidebar-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 210;
}

.sidebar-resizer::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 2px;
    width: 2px;
    background: transparent;
    transition: background 0.12s ease;
}

.sidebar-resizer:hover::after,
body.sidebar-resizing .sidebar-resizer::after {
    background: rgba(152,162,179,0.55);
}

body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}

body.sidebar-resizing #main { pointer-events: none; }

#aside nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 4px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 64px;
    padding: 0 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}

.brand-logo {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #374151 0%, #111827 100%);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-logo svg { display: block; }

.brand-name {
    font-size: 13px;
    font-weight: 600;
    color: #FFFFFF;
    letter-spacing: 0.01em;
}

#aside ul {
    list-style: none;
    padding: 8px;
}

#aside ul li a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    transition: background 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}

#aside ul li a:hover {
    background: var(--sidebar-hover-bg);
    color: #E7EAF0;
}

#aside ul li.active a {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

.nav-icon {
    flex-shrink: 0;
    opacity: 0.45;
    transition: opacity 0.12s ease;
}

#aside ul li.active .nav-icon { opacity: 1; color: #FFFFFF; }
#aside ul li a:hover .nav-icon { opacity: 0.8; }

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-count {
    flex-shrink: 0;
    margin-left: 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--sidebar-text-dim);
    background: rgba(255,255,255,0.06);
    padding: 1px 7px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
    transition: color 0.12s ease, background 0.12s ease;
}

#aside ul li a:hover .nav-count {
    color: var(--sidebar-text);
    background: rgba(255,255,255,0.1);
}

#aside ul li.active .nav-count {
    color: rgba(255,255,255,0.75);
    background: rgba(255,255,255,0.14);
}

/* ── Sidebar settings ────────────────────────────────────── */

.sidebar-settings {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-top: 1px solid var(--sidebar-border);
}

.settings-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-text-dim);
    margin-bottom: 5px;
}

.settings-select {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    padding: 7px 32px 7px 10px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: #E7EAF0;
    background-color: rgba(255,255,255,0.05);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%239AA4B2' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}

.settings-select:hover { background-color: var(--sidebar-hover-bg); }

.settings-select:focus {
    border-color: rgba(255,255,255,0.35);
}

.settings-select option {
    color: var(--text);
    background: #FFFFFF;
}

.settings-apply {
    margin-top: 8px;
    width: 100%;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    color: #E7EAF0;
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.settings-apply:hover { background: rgba(255,255,255,0.12); }

/* ── Sidebar logout ──────────────────────────────────────── */

.sidebar-logout {
    padding: 12px 16px;
    border-top: 1px solid var(--sidebar-border);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--sidebar-text);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}

.logout-btn:hover {
    background: var(--sidebar-hover-bg);
    color: #E7EAF0;
}

.logout-btn svg { opacity: 0.6; }

/* ── Main ────────────────────────────────────────────────── */

#main {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(1.8) blur(10px);
    -webkit-backdrop-filter: saturate(1.8) blur(10px);
    border-bottom: 1px solid var(--border);
    height: 64px;
    padding: 0 28px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.header-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-width: 0;
}

.header-row h1 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
    transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.back-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-subtle);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.count-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1px 8px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
}


/* ── Record filter (segmented control) ───────────────────── */

.filter-toggle {
    display: inline-flex;
    align-items: stretch;
    flex-shrink: 0;
    height: 34px;
    padding: 3px;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
}

.filter-seg {
    display: inline-flex;
    align-items: center;
    padding: 0 11px;
    border-radius: 4px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.12s ease, color 0.12s ease;
}

.filter-seg:hover { color: var(--text); }

.filter-seg.is-active {
    background: var(--accent);
    color: #FFFFFF;
}

.filter-seg.is-active:hover { color: #FFFFFF; }

/* ── Columns picker ──────────────────────────────────────── */

.columns-popover {
    position: relative;
    flex-shrink: 0;
}

.tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-muted);
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.12s ease, border-color 0.12s ease;
}

.tool-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.tool-btn svg { opacity: 0.55; }

.tool-badge {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0 6px;
    line-height: 1.6;
}

.columns-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: min(260px, calc(100vw - 32px));
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    z-index: 60;
    overflow: clip;
}

.columns-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
}

.columns-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.1s ease;
}

.columns-item:hover { background: var(--surface-subtle); }

.columns-item input {
    accent-color: var(--accent);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.columns-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.columns-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    background: var(--surface-subtle);
}

.columns-selectall {
    border: none;
    background: none;
    font-size: 12.5px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    transition: color 0.12s ease;
}

.columns-selectall:hover { color: var(--text); }

.columns-apply {
    padding: 5px 12px;
    font-size: 12.5px;
}

/* ── Search ──────────────────────────────────────────────── */

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    color: var(--text-faint);
    box-shadow: var(--shadow-xs);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.search-wrap:focus-within {
    border-color: var(--accent);
    color: var(--text-muted);
}

.search-wrap input {
    border: none;
    outline: none;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
    width: 210px;
}

.search-wrap input::placeholder { color: var(--text-faint); }

.search-kbd {
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-faint);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.4;
}

.content-body {
    padding: 24px 28px;
    flex: 1;
    min-width: 0;
}

/* ── Card ────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: clip;
}

/* ── Overview table ──────────────────────────────────────── */

table.overview {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.card--table {
    cursor: grab;
    user-select: none;
}
.card--table.is-dragging { cursor: grabbing; }

.table-scroll {
    max-height: calc(100vh - 64px - 48px - 41px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

.table-scroll::-webkit-scrollbar        { width: 8px; height: 12px; }
.table-scroll::-webkit-scrollbar-track  { background: transparent; }
.table-scroll::-webkit-scrollbar-track:horizontal { border-top: 1px solid var(--border); }
.table-scroll::-webkit-scrollbar-thumb  { background: #CBD5E1; border-radius: 99px; border: 2px solid #FFFFFF; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #98A2B3; }

table.overview thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface-subtle);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0 16px;
    height: 40px;
    vertical-align: middle;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.overview thead th.col-num { text-align: right; }

/* Vertical column dividers */
table.overview thead th:not(:last-child),
table.overview tbody td:not(:last-child) {
    border-right: 1px solid var(--border);
}

/* The sticky actions column draws its own left divider — avoid doubling it */
table.overview thead th:nth-last-child(2),
table.overview tbody td:nth-last-child(2) {
    border-right: none;
}

table.overview thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.12s ease;
}

table.overview thead th.sortable:hover { color: var(--text); }

table.overview thead th.sort-asc::after,
table.overview thead th.sort-desc::after {
    content: '';
    display: inline-block;
    margin-left: 6px;
    width: 0;
    height: 0;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

table.overview thead th.sort-asc::after { border-bottom: 4px solid var(--accent); }
table.overview thead th.sort-desc::after { border-top: 4px solid var(--accent); }

table.overview thead th:last-child,
table.overview tbody td:last-child {
    position: sticky;
    right: 0;
}

table.overview thead th:last-child {
    background: var(--surface-subtle);
    z-index: 6;
    border-left: 1px solid var(--border);
}

table.overview tbody td:last-child {
    background: var(--surface);
    border-left: 1px solid var(--border);
}

table.overview tbody tr:hover td:last-child { background: var(--surface-subtle); }

table.overview tbody td {
    padding: 0 16px;
    height: 40px;
    color: var(--text-secondary);
    vertical-align: middle;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    transition: background 0.08s ease;
}

table.overview tbody tr:last-child td { border-bottom: none; }

table.overview tbody tr:hover td { background: var(--surface-subtle); }

table.overview tbody td.cell-pk {
    color: var(--text);
    font-weight: 500;
}

/* Type-aware cell formatting */
table.overview tbody td.cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

table.overview tbody td.cell-date {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

table.overview tbody td.cell-code {
    font-family: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, 'Liberation Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.cell-null {
    color: var(--text-faint);
    font-weight: 400;
}

/* Status column: red box = has an error message, green box = clean */
table.overview th.col-status,
table.overview td.status-cell {
    width: 28px;
    min-width: 28px;
    padding: 0 8px;
    text-align: center;
}

.status-box {
    width: 5px;
    height: 20px;
    border-radius: 3px;
    margin: 0 auto;
}

.status-box.status-ok { background: var(--success); }

.status-box.status-error { background: var(--danger); }

.status-box.status-pending { background: var(--border-strong); }

.status-box.status-head { background: var(--text-muted); }

table.overview tbody td.row-actions {
    text-align: right;
    padding-right: 16px;
}

.btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
    white-space: nowrap;
}

.btn-edit:hover {
    color: var(--text);
    background: var(--surface-subtle);
    border-color: var(--border-strong);
}

/* ── Table footer / pagination ───────────────────────────── */

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    min-height: 40px;
    padding: 4px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.table-meta {
    font-size: 12.5px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.table-meta strong {
    font-weight: 600;
    color: var(--text-secondary);
}

.pager {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xs);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

a.pager-btn:hover {
    background: var(--surface-subtle);
    border-color: var(--border-strong);
    color: var(--text);
}

.pager-btn.is-current {
    color: #FFFFFF;
    background: var(--accent);
    border-color: var(--accent);
}

.pager-btn.is-disabled {
    color: var(--text-faint);
    background: var(--surface-subtle);
    box-shadow: none;
    cursor: default;
}

.pager-gap {
    color: var(--text-faint);
    font-size: 12px;
    padding: 0 4px;
    user-select: none;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--accent);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 8px 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.btn-secondary:hover {
    background: var(--surface-subtle);
    color: var(--text);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--danger);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 8px 14px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
}

.btn-block { width: 100%; }

.push-end { margin-left: auto; }

/* ── Edit form ───────────────────────────────────────────── */

.field-grid {
    display: flex;
    flex-direction: column;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Edit form: two-column definition layout — label left, value right */
.field-grid .field {
    position: relative;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    column-gap: 32px;
    row-gap: 6px;
    align-items: start;
    padding: 14px 24px;
}

/* Vertical divider between the label and value columns */
.field-grid .field::after {
    content: '';
    position: absolute;
    left: 280px; /* 24px padding + 240px label column + half the gap */
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
}

.field-grid .field + .field { border-top: 1px solid var(--border); }

.field-grid .field label {
    grid-column: 1;
    padding-top: 13px; /* aligns label with the first line inside the control */
    overflow-wrap: break-word;
    min-width: 0;
}

.field-grid .field textarea {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.field-grid .field .field-hint {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    margin-top: -2px;
}

.field label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field textarea {
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field input[type="text"]:focus,
.field input[type="password"]:focus,
.field textarea:focus {
    border-color: var(--accent);
}

.field textarea[readonly] {
    background: var(--surface-subtle);
    color: var(--text-muted);
    box-shadow: none;
}

.field textarea[readonly]:focus {
    border-color: var(--border-strong);
    box-shadow: none;
}

.field-hint {
    font-size: 11.5px;
    color: var(--text-faint);
}

.auto-grow-textarea {
    min-height: 45px;
    overflow: hidden;
    resize: vertical;
    line-height: 1.5;
    white-space: pre-wrap;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface-subtle);
}

/* ── Notices ─────────────────────────────────────────────── */

.notice {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 15px 16px;
    border-radius: var(--radius-lg);
    margin: 16px 28px -8px;
}

.notice .notice-content svg {
    color: var(--success-text);
    flex-shrink: 0;
}

.dismissible-notice {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.notice-content {
    align-items: center;
    display: inline-flex;
    gap: 8px;
}

.notice-close {
    align-items: center;
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 18px;
    font-weight: 400;
    justify-content: center;
    line-height: 1;
    opacity: 0.6;
    padding: 0 2px;
    transition: opacity 0.12s ease;
}

.notice-close:hover,
.notice-close:focus-visible {
    opacity: 1;
    outline: none;
}

/* ── Empty / placeholder states ──────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 96px 32px;
    gap: 6px;
    color: var(--text-faint);
    text-align: center;
}

.empty-state svg { margin-bottom: 10px; }

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
}

.empty-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text) !important;
}

.empty-text {
    font-size: 12.5px;
}

.empty-action { margin-top: 12px; }

/* ── Auth pages (login / errors) ─────────────────────────── */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    background:
        radial-gradient(1100px 480px at 50% -10%, rgba(16,24,40,0.05), transparent 60%),
        var(--bg);
}

.auth-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 48px 20px;
}

.auth-brand { margin-bottom: 20px; }

.brand-logo--lg {
    width: 44px;
    height: 44px;
    border-radius: 11px;
}

.auth-title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text);
    text-align: center;
}

.auth-subtitle {
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.auth-card {
    width: 100%;
    margin-top: 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 24px;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-card .field label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-secondary);
}

.auth-card .field input {
    width: 100%;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    outline: none;
    box-shadow: var(--shadow-xs);
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.auth-card .field input:focus {
    border-color: var(--accent);
}

.auth-error {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--danger-text);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

.auth-error svg { flex-shrink: 0; }

.auth-footnote {
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-faint);
    text-align: center;
}

.auth-card--message {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.auth-card--message .btn-primary { margin-top: 14px; }

.auth-message-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--danger-text);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    margin-bottom: 8px;
}

/* ── Menu button (mobile only) ───────────────────────────── */

.menu-btn {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 52px;
    height: 56px;
    z-index: 300;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16,24,40,0.5);
    z-index: 199;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.open { display: block; }

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 768px) {

    .menu-btn { display: flex; }

    .brand { padding-left: 52px; height: 64px; }

    #aside {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 200;
        width: 264px !important; /* override any saved desktop resize width */
        display: none;
        border-right: 1px solid rgba(255,255,255,0.08);
    }

    .sidebar-resizer { display: none; }

    #aside.open { display: flex; }

    body:has(#aside.open) .menu-btn {
        z-index: 201;
        margin-top: 4px;
    }

    #main { width: 100%; min-width: 0; }

    .content-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        height: auto;
        padding: 0;
    }

    .header-main {
        flex: none;
        width: 100%;
    }

    .content-header .header-row {
        display: flex;
        align-items: center;
        min-height: 56px;
        padding: 0 16px 0 56px;
        gap: 10px;
    }

    .header-row h1 { font-size: 15px; }

    .content-header .header-tools {
        width: 100%;
        padding: 0 16px 12px;
        flex-wrap: wrap;
        row-gap: 8px;
    }

    /* Edit-page actions become their own row below the title */
    .content-header .header-actions {
        width: 100%;
        padding: 0 16px 12px;
        justify-content: flex-end;
    }

    /* Search drops to its own full-width line; buttons share the first line */
    .header-tools .search-wrap { flex: 1 1 100%; min-width: 0; }

    .search-wrap input { width: 100%; }

    .search-kbd { display: none; }

    /* Filter and Columns split the first line 50:50, full width */
    .header-tools .filter-toggle,
    .header-tools .columns-popover {
        flex: 1 1 0;
        min-width: 0;
    }

    .filter-seg {
        flex: 1;
        justify-content: center;
        padding: 0 9px;
        font-size: 12px;
    }

    .columns-popover .tool-btn {
        width: 100%;
        justify-content: center;
        padding: 0 10px;
        font-size: 12.5px;
    }

    .content-body { padding: 12px; }

    .table-scroll {
        max-height: calc(100vh - 56px - 46px - 24px - 51px);
    }

    .table-footer { justify-content: center; }
    .table-meta { width: 100%; text-align: center; }
    .pager { flex-wrap: wrap; justify-content: center; }

    .field-grid { padding: 2px 0; }

    .field-grid .field {
        grid-template-columns: 1fr;
        row-gap: 6px;
        padding: 12px 16px;
    }

    .field-grid .field label { padding-top: 0; }

    .field-grid .field::after { display: none; }

    .field-grid .field textarea,
    .field-grid .field .field-hint {
        grid-column: 1;
        grid-row: auto;
    }

    .form-actions { padding: 12px 16px; }

    .notice { margin: 12px 12px -4px; }

    .btn-primary, .btn-secondary, .btn-danger { padding: 7px 12px; font-size: 12.5px; }

    .auth-shell { padding: 32px 16px; }
}

/* ── Small phones ────────────────────────────────────────── */

@media (max-width: 480px) {

    /* Each toolbar control gets its own full-width row */
    .header-tools .filter-toggle,
    .header-tools .columns-popover {
        flex: 1 1 100%;
    }

    .columns-panel {
        left: 0;
        right: 0;
        width: auto;
    }
}
