@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,500;0,600;0,700;1,600&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/*
 * Soul and Psyche — Admin Control Center
 * Unified @brand Design System (Derived from Academy Tokens)
 */

:root {
    /* Surfaces — Ivory Atelier */
    --surface-canvas: #F7F3E9;
    --surface-raised: #FFFDF7;
    --surface-sunken: #EFE9D9;
    --surface-overlay: rgba(255, 253, 247, 0.85);

    /* Ink / Typography */
    --ink-strong: #1C3A5B;
    --ink: #3D4C5C;
    --ink-muted: #5F6E7C;
    --ink-faint: #8A96A2;
    --ink-inverse: #FFFDF7;

    /* Brand Accents — Botanical Sage & Royal Gold */
    --brand: #2D5A43;
    --brand-strong: #1D4330;
    --brand-soft: rgba(45, 90, 67, 0.10);
    --brand-ink: #FFFDF7;

    --brand-gold: #C5A059;
    --brand-gold-hi: #E2C167;
    --brand-gold-deep: #8A6A12;
    --brand-gold-soft: rgba(197, 160, 89, 0.14);
    --brand-gold-glow: rgba(201, 162, 39, 0.28);

    --brand-sage: #2D5A43;
    --brand-sage-light: #3F7257;
    --brand-sage-glow: rgba(45, 90, 67, 0.22);
    --brand-navy: #1C3A5B;

    --gold-grad: linear-gradient(135deg, #E2C167 0%, #C9A227 46%, #8A6A12 100%);
    --sage-grad: linear-gradient(135deg, #3F7257 0%, #2D5A43 100%);

    /* Status */
    --success: #2D5A43;
    --success-soft: rgba(45, 90, 67, 0.12);
    --warning: #C5A059;
    --warning-soft: rgba(197, 160, 89, 0.14);
    --danger: #B14A44;
    --danger-soft: rgba(177, 74, 68, 0.12);
    --info: #1C3A5B;
    --info-soft: rgba(28, 58, 91, 0.10);

    /* Lines and depth */
    --line: rgba(28, 58, 91, 0.12);
    --line-strong: rgba(28, 58, 91, 0.22);
    --line-gold: rgba(201, 162, 39, 0.35);
    --shadow-sm: 0 1px 3px rgba(28, 58, 91, 0.06);
    --shadow: 0 6px 20px -4px rgba(28, 58, 91, 0.12), 0 2px 6px -2px rgba(28, 58, 91, 0.05);
    --shadow-lg: 0 20px 40px -12px rgba(28, 58, 91, 0.20), 0 0 0 1px rgba(28, 58, 91, 0.08);

    /* Typography families */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;

    /* Geometry */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-pill: 999px;
    --sidebar-width: 260px;
    --topbar-height: 68px;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="dark"] {
    /* Surfaces — Obsidian Observatory */
    --surface-canvas: #08182A;
    --surface-raised: #0C1B2C;
    --surface-sunken: #061220;
    --surface-overlay: rgba(12, 27, 44, 0.85);

    /* Ink / Typography */
    --ink-strong: #FFFDF7;
    --ink: #CBD5E1;
    --ink-muted: #7C8AA1;
    --ink-faint: #4B5563;
    --ink-inverse: #0C1B2C;

    /* Brand Accents */
    --brand: #8FA87C;
    --brand-strong: #B0C79E;
    --brand-soft: rgba(143, 168, 124, 0.15);
    --brand-ink: #0C1B2C;

    --brand-gold: #D9B449;
    --brand-gold-hi: #EFD79A;
    --brand-gold-deep: #A8811C;
    --brand-gold-soft: rgba(217, 180, 73, 0.15);
    --brand-gold-glow: rgba(217, 180, 73, 0.32);

    --brand-sage: #8FA87C;
    --brand-sage-light: #B0C79E;
    --brand-sage-glow: rgba(143, 168, 124, 0.26);
    --brand-navy: #1C3A5B;

    --gold-grad: linear-gradient(135deg, #EFD79A 0%, #D9B449 46%, #A8811C 100%);
    --sage-grad: linear-gradient(135deg, #B0C79E 0%, #8FA87C 100%);

    /* Status */
    --success: #8FA87C;
    --success-soft: rgba(143, 168, 124, 0.16);
    --warning: #D9B449;
    --warning-soft: rgba(217, 180, 73, 0.16);
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, 0.16);
    --info: #60A5FA;
    --info-soft: rgba(96, 165, 250, 0.16);

    /* Lines and depth */
    --line: rgba(242, 240, 230, 0.10);
    --line-strong: rgba(242, 240, 230, 0.18);
    --line-gold: rgba(217, 180, 73, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow: 0 6px 20px -4px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(242, 240, 230, 0.08);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(217, 180, 73, 0.18);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--surface-canvas);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

h1, h2, h3, h4 {
    color: var(--ink-strong);
    margin: 0;
    font-weight: 650;
    letter-spacing: -0.015em;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); }

/* ---------------------------------------------------------------- Shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface-raised);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    transition: transform 0.24s var(--ease);
}

.sidebar__brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
}

.sidebar__mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: var(--brand-ink);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.sidebar__name { font-weight: 650; color: var(--ink-strong); font-size: 14px; }
.sidebar__tag { font-size: 11px; color: var(--ink-faint); }

.sidebar__nav { padding: 14px 12px; overflow-y: auto; flex: 1; }

.nav__section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--ink-faint);
    padding: 14px 10px 6px;
    font-weight: 650;
}

.nav__link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 11px;
    border-radius: var(--radius-sm);
    color: var(--ink-muted);
    font-weight: 500;
    margin-bottom: 2px;
    transition: background-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}

.nav__link:hover {
    background: var(--surface-sunken);
    color: var(--ink-strong);
    transform: translateX(2px);
}

.nav__link--active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.nav__link svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav__badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
}

/* ---------------------------------------------------------------- Main */

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--surface-overlay);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar__title { font-size: 16px; font-weight: 650; color: var(--ink-strong); }
.topbar__spacer { flex: 1; }

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-raised);
    color: var(--ink-muted);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}

.icon-button:hover {
    color: var(--ink-strong);
    border-color: var(--line-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.icon-button svg { width: 17px; height: 17px; }

.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: var(--brand-ink);
    display: grid;
    place-items: center;
    font-weight: 650;
    font-size: 12px;
    flex-shrink: 0;
}

/* -------------------------------------------------------- User Dropdown */

.user-dropdown {
    position: relative;
    display: inline-block;
}

.user-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--radius-pill);
    background: var(--surface-raised);
    border: 1px solid var(--line);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    color: var(--ink-strong);
}

.user-dropdown__trigger:hover {
    border-color: var(--line-strong);
    background: var(--surface-sunken);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.user-dropdown__info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.2;
}

.user-dropdown__name {
    font-size: 13px;
    font-weight: 650;
    color: var(--ink-strong);
}

.user-dropdown__role {
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.user-dropdown__chevron {
    width: 14px;
    height: 14px;
    color: var(--ink-muted);
    transition: transform 0.2s var(--ease);
}

.user-dropdown.is-open .user-dropdown__chevron {
    transform: rotate(180deg);
}

.user-dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 240px;
    background: var(--surface-raised);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 12px 28px -4px rgba(28, 58, 91, 0.15);
    padding: 6px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease), visibility 0.18s;
}

.user-dropdown.is-open .user-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown__header {
    padding: 10px 12px 8px;
}

.user-dropdown__header-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-strong);
}

.user-dropdown__header-email {
    font-size: 12px;
    color: var(--ink-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown__header-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
}

.user-dropdown__divider {
    height: 1px;
    background: var(--line);
    margin: 6px 0;
}

.user-dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
    box-sizing: border-box;
    text-align: left;
}

.user-dropdown__item:hover {
    background: var(--surface-sunken);
    color: var(--ink-strong);
}

.user-dropdown__item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--ink-muted);
    transition: color 0.12s var(--ease);
}

.user-dropdown__item:hover svg {
    color: var(--brand-gold);
}

.user-dropdown__item--danger {
    color: var(--danger);
}

.user-dropdown__item--danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.user-dropdown__item--danger svg {
    color: var(--danger);
}

.user-dropdown__item--danger:hover svg {
    color: var(--danger);
}

.content { padding: 24px; flex: 1; }

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.page-head__title { 
    font-family: var(--font-heading); 
    font-size: 24px; 
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink-strong);
}
.page-head__sub { color: var(--ink-muted); font-size: 13px; margin-top: 3px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Cards */

.card {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.card__head {
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
}

.card__title { 
    font-family: var(--font-sans);
    font-size: 14px; 
    font-weight: 650; 
    color: var(--ink-strong); 
}
.card__body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid--halves { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ---------------------------------------------------------------- Stats */

.stat {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 17px 18px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.stat:hover { transform: translateY(-5px); box-shadow: var(--shadow); }

.stat__top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }

.stat__icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: var(--brand-soft);
    color: var(--brand);
}

.stat__icon svg { width: 17px; height: 17px; }
.stat__icon--success { background: var(--success-soft); color: var(--success); }
.stat__icon--warning { background: var(--warning-soft); color: var(--warning); }
.stat__icon--danger { background: var(--danger-soft); color: var(--danger); }
.stat__icon--info { background: var(--info-soft); color: var(--info); }

.stat__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-faint);
    font-weight: 650;
}

.stat__value {
    font-size: 25px;
    font-weight: 700;
    color: var(--ink-strong);
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.stat__foot { font-size: 12px; color: var(--ink-muted); margin-top: 5px; }

/* ---------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; }

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 640px;
}

table.data th {
    text-align: left;
    padding: 11px 14px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-faint);
    font-weight: 650;
    border-bottom: 1px solid var(--line);
    background: var(--surface-sunken);
    white-space: nowrap;
}

table.data td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: middle;
}

table.data tbody tr { transition: background-color 0.12s var(--ease); }
table.data tbody tr:hover { background: var(--surface-sunken); }
table.data tbody tr:last-child td { border-bottom: none; }

.cell-strong { color: var(--ink-strong); font-weight: 600; }
.cell-muted { color: var(--ink-muted); font-size: 12px; }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------------------------------------------------------------- Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-neutral { background: var(--surface-sunken); color: var(--ink-muted); }

/* ---------------------------------------------------------------- Forms */

.field { margin-bottom: 16px; }

.field__label {
    display: block;
    font-size: 12px;
    font-weight: 650;
    color: var(--ink-strong);
    margin-bottom: 5px;
}

.field__hint { font-size: 12px; color: var(--ink-muted); margin-top: 5px; }
.field__error { font-size: 12px; color: var(--danger); margin-top: 5px; font-weight: 500; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-raised);
    color: var(--ink-strong);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.input::placeholder { color: var(--ink-faint); }
.textarea { min-height: 90px; resize: vertical; }

/*
 * Chrome paints its own background on autofilled fields and ignores the
 * background property, so a saved password renders as a white box on a dark
 * form. The inset shadow is the only thing that overrides it — there is no
 * supported way to set the colour directly.
 */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.select:-webkit-autofill,
.textarea:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--surface-raised) inset;
    box-shadow: 0 0 0 1000px var(--surface-raised) inset;
    -webkit-text-fill-color: var(--ink-strong);
    caret-color: var(--ink-strong);
    transition: background-color 9999s ease-in-out 0s;
}

.input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--surface-raised) inset, 0 0 0 3px var(--brand-soft);
    box-shadow: 0 0 0 1000px var(--surface-raised) inset, 0 0 0 3px var(--brand-soft);
}

/* The native checkbox is white-on-white in dark mode without this. */
input[type="checkbox"], input[type="radio"] {
    accent-color: var(--brand);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.input--mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filters .field { margin-bottom: 0; min-width: 160px; flex: 1 1 160px; }

/* ---------------------------------------------------------------- Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    min-height: 38px;
    transition: all 0.15s var(--ease);
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) {
    background: var(--brand-strong);
    color: var(--brand-ink);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-ghost {
    background: var(--surface-raised);
    border-color: var(--line-strong);
    color: var(--ink);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); color: var(--ink-strong); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }

.btn-sm { padding: 5px 11px; font-size: 12px; min-height: 30px; }

/* ---------------------------------------------------------------- States */

.empty { text-align: center; padding: 48px 24px; }

.empty__mark {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    background: var(--surface-sunken);
    color: var(--ink-faint);
    display: grid;
    place-items: center;
    margin: 0 auto 14px;
}

.empty__mark svg { width: 25px; height: 25px; }
.empty__title { font-size: 15px; font-weight: 650; color: var(--ink-strong); margin-bottom: 5px; }
.empty__text { color: var(--ink-muted); font-size: 13px; max-width: 380px; margin: 0 auto; }

.skeleton {
    background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--line) 50%, var(--surface-sunken) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--radius-sm);
    height: 15px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    width: 15px;
    height: 15px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.is-loading { pointer-events: none; opacity: 0.6; }

/* ---------------------------------------------------------------- Pagination */

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 18px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}

.pagination__info { color: var(--ink-muted); font-size: 12px; }
.pagination__links { margin-left: auto; display: flex; gap: 4px; }

.pagination__links a,
.pagination__links span {
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 12px;
    font-weight: 600;
}

.pagination__links a:hover { background: var(--surface-sunken); color: var(--ink-strong); }
.pagination__links .is-current { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pagination__links .is-disabled { opacity: 0.4; }

/* ---------------------------------------------------------------- Login */

.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(1000px 520px at 12% -8%, var(--brand-soft), transparent 62%),
        var(--surface-canvas);
}

.auth__card {
    width: 100%;
    max-width: 396px;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px;
}

.auth__mark {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--brand), var(--brand-strong));
    color: var(--brand-ink);
    display: grid;
    place-items: center;
    font-weight: 700;
    margin-bottom: 18px;
}

.auth__title { font-size: 20px; margin-bottom: 5px; }
.auth__sub { color: var(--ink-muted); font-size: 13px; margin-bottom: 24px; }

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: currentColor; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: currentColor; }

.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-wrap .input {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--ink-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background-color 0.15s ease;
}

.password-toggle:hover {
    color: var(--brand-gold);
    background-color: var(--surface-sunken);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--brand-gold);
    outline-offset: 1px;
}

/* ---------------------------------------------------------------- Misc */

.sidebar__toggle { display: none; }
.scrim { display: none; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--wrap { flex-wrap: wrap; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.masked {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.1em;
    color: var(--ink-faint);
}

/* ---------------------------------------------------------------- Tabs */

.tabs {
    display: flex;
    gap: 3px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    overflow-x: auto;
    /* The scrollbar under a tab strip is noise; the overflow still scrolls. */
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    border: none;
    background: none;
    color: var(--ink-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.tab:hover { color: var(--ink-strong); }

.tab[aria-selected="true"] {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.tab__count {
    background: var(--surface-sunken);
    color: var(--ink-faint);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
}

.tab[aria-selected="true"] .tab__count { background: var(--brand-soft); color: var(--brand); }

.tab-panel[hidden] { display: none; }

/* ---------------------------------------------------------------- Dialog */

/*
 * The house dialog, used for every notification and confirmation. Browser
 * alert() and confirm() are never used — they cannot be styled, they block
 * the whole browser, and they cannot show a pending state.
 *
 * Namespaced `snp-dialog`, not `swal`. It used to share the class name
 * `.swal-overlay` with the SweetAlert library, which two pages loaded from a
 * CDN. That library's own rule sets `pointer-events: none` on `.swal-overlay`,
 * so our dialog rendered but every click went straight through it — the OK
 * button did nothing and the page underneath got the click instead.
 */
.snp-dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.18s var(--ease);
}

.snp-dialog-overlay.is-open { opacity: 1; }

.snp-dialog {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 26px;
    width: 100%;
    max-width: 384px;
    text-align: center;
    transform: scale(0.94) translateY(8px);
    transition: transform 0.18s var(--ease);
}

.snp-dialog-overlay.is-open .snp-dialog { transform: scale(1) translateY(0); }

.snp-dialog__mark {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 15px;
}

.snp-dialog__mark svg { width: 24px; height: 24px; }
.snp-dialog__mark--success { background: var(--success-soft); color: var(--success); }
.snp-dialog__mark--danger  { background: var(--danger-soft);  color: var(--danger); }
.snp-dialog__mark--warning { background: var(--warning-soft); color: var(--warning); }
.snp-dialog__mark--info    { background: var(--info-soft);    color: var(--info); }

.snp-dialog__title { font-size: 16px; font-weight: 650; color: var(--ink-strong); margin-bottom: 6px; }
.snp-dialog__text { color: var(--ink-muted); font-size: 13px; margin-bottom: 20px; }
.snp-dialog__actions { display: flex; gap: 8px; justify-content: center; }
.snp-dialog__actions .btn { flex: 1; max-width: 160px; }

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.is-open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar__toggle { display: grid; }

    .scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 35;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s var(--ease);
    }

    .scrim.is-open { opacity: 1; pointer-events: auto; }
}

@media (max-width: 640px) {
    .content { padding: 16px; }
    .topbar { padding: 0 16px; }
    .grid--halves { grid-template-columns: 1fr; }
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head__actions { margin-left: 0; }
    .modal-overlay { padding: 16px 12px; }
    .modal-card {
        padding: 20px 16px;
        max-height: calc(100dvh - 32px);
        border-radius: var(--radius-md);
    }
}

/* ---------------------------------------------------------------- Brand Utilities */

.btn-gold {
    background: var(--gold-grad);
    color: #1C3A5B !important;
    font-weight: 700;
    border: none;
    box-shadow: 0 2px 8px var(--brand-gold-glow);
}
.btn-gold:hover:not(:disabled) {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--brand-gold-glow);
}

.btn-sage {
    background: var(--sage-grad);
    color: #FFFDF7 !important;
    font-weight: 600;
    border: none;
}
.btn-sage:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.badge-gold {
    background: var(--brand-gold-soft);
    color: var(--brand-gold-deep);
    border: 1px solid var(--line-gold);
}
:root[data-theme="dark"] .badge-gold {
    color: var(--brand-gold-hi);
}

.badge-sage {
    background: var(--brand-soft);
    color: var(--brand);
}

/* ---------------------------------------------------------------- Log Viewer */

.log-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 12px;
}

.log-table th {
    padding: 10px 14px;
    background: var(--surface-sunken);
    color: var(--ink-faint);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.08em;
    font-weight: 650;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

.log-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: top;
    line-height: 1.5;
}

.log-table tr:hover td {
    background: var(--surface-sunken);
}

.log-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.log-badge--emergency,
.log-badge--alert,
.log-badge--critical,
.log-badge--error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(177, 74, 68, 0.3);
}

.log-badge--warning {
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid rgba(197, 160, 89, 0.3);
}

.log-badge--notice,
.log-badge--info {
    background: var(--info-soft);
    color: var(--info);
}

.log-badge--debug {
    background: var(--surface-sunken);
    color: var(--ink-faint);
}

.log-trace-chip {
    font-size: 11px;
    padding: 2px 6px;
    background: var(--brand-soft);
    color: var(--brand);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.log-trace-chip:hover {
    background: var(--brand);
    color: var(--brand-ink);
}

.log-message {
    word-break: break-word;
    white-space: pre-wrap;
    max-height: 120px;
    overflow-y: auto;
}

/* ---------------------------------------------------------------- Modal & Dialogs */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 27, 44, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s var(--ease);
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.modal-card::-webkit-scrollbar {
    width: 6px;
}

.modal-card::-webkit-scrollbar-track {
    background: transparent;
}

.modal-card::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 999px;
}

.modal-card::-webkit-scrollbar-thumb:hover {
    background: var(--ink-faint);
}

.modal-card--md {
    max-width: 540px;
}

.modal-card--lg {
    max-width: 680px;
}

.modal-overlay.is-open .modal-card {
    transform: scale(1) translateY(0);
}

.modal-card__header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 22px;
    position: relative;
}

.modal-card__icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--brand-soft);
    color: var(--brand);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.modal-card__title {
    font-size: 17px;
    font-weight: 700;
    color: var(--ink-strong);
    margin: 0 0 4px 0;
}

.modal-card__sub {
    font-size: 13px;
    color: var(--ink-muted);
    margin: 0;
    line-height: 1.4;
}

.modal-card__close {
    position: absolute;
    top: -6px;
    right: -6px;
    background: transparent;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--ink-faint);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}

.modal-card__close:hover {
    color: var(--ink-strong);
    background: var(--surface-sunken);
}

.modal-card__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------------- Slug Editor */

.slug-group {
    display: flex;
    align-items: stretch;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.slug-group:focus-within {
    border-color: var(--brand-gold);
    box-shadow: 0 0 0 3px var(--brand-gold-soft);
}

.slug-prefix {
    background: var(--surface-sunken);
    color: var(--ink-muted);
    padding: 9px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    border-right: 1px solid var(--line);
    display: flex;
    align-items: center;
    user-select: none;
    white-space: nowrap;
}

.slug-input {
    flex: 1;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 9px 12px !important;
    font-family: var(--font-mono) !important;
    font-size: 13px !important;
    color: var(--ink-strong) !important;
}

.slug-input:disabled {
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.02) !important;
    cursor: not-allowed;
}

.slug-btn {
    background: transparent;
    border: none;
    border-left: 1px solid var(--line);
    padding: 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.slug-btn:hover {
    background: var(--brand-soft);
}

/* ---------------------------------------------------------------- Quill Rich Text Editor */

.ql-toolbar.ql-snow {
    border: 1px solid var(--line) !important;
    border-top-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-sm);
    background: var(--surface-sunken) !important;
    padding: 10px 14px !important;
    font-family: var(--font-sans) !important;
}

.ql-container.ql-snow {
    border: 1px solid var(--line) !important;
    border-top: none !important;
    border-bottom-left-radius: var(--radius-sm);
    border-bottom-right-radius: var(--radius-sm);
    background: var(--surface-raised) !important;
    font-family: var(--font-sans) !important;
    font-size: 14px !important;
    line-height: 1.65 !important;
    color: var(--ink) !important;
}

.ql-editor {
    min-height: 320px;
    padding: 16px !important;
    color: var(--ink-strong);
}

.ql-editor.ql-blank::before {
    color: var(--ink-faint) !important;
    font-style: normal !important;
}

.ql-snow .ql-stroke {
    stroke: var(--ink-muted) !important;
}

.ql-snow .ql-fill {
    fill: var(--ink-muted) !important;
}

.ql-snow .ql-picker {
    color: var(--ink) !important;
}

.ql-snow .ql-picker-options {
    background-color: var(--surface-raised) !important;
    border: 1px solid var(--line) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 6px !important;
}

.ql-snow .ql-picker-item:hover,
.ql-snow .ql-picker-item.ql-selected {
    color: var(--brand-gold) !important;
}

.ql-snow button:hover .ql-stroke,
.ql-snow button.ql-active .ql-stroke {
    stroke: var(--brand-gold) !important;
}

.ql-snow button:hover .ql-fill,
.ql-snow button.ql-active .ql-fill {
    fill: var(--brand-gold) !important;
}

/* ==========================================================================
   System Health & Operations Dashboard
   ========================================================================== */

.health-indicator-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    transition: all 0.15s ease;
}

.health-indicator-btn:hover {
    border-color: var(--line-strong);
    background: var(--surface-raised);
    transform: translateY(-1px);
}

.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.health-dot--healthy {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--success-soft);
}

.health-dot--warning {
    background: var(--warning);
    box-shadow: 0 0 0 2px var(--warning-soft);
    animation: healthPulse 2s infinite ease-in-out;
}

.health-dot--danger {
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--danger-soft);
    animation: healthPulseFast 1s infinite ease-in-out;
}

@keyframes healthPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.2); }
}

@keyframes healthPulseFast {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.3); }
}

.health-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.health-header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.health-countdown {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.health-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.health-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--line-strong);
}

.health-card--healthy {
    border-top: 3px solid var(--success);
}

.health-card--degraded {
    border-top: 3px solid var(--warning);
    background: linear-gradient(180deg, var(--warning-soft) 0%, var(--surface) 35%);
}

.health-card--down {
    border-top: 3px solid var(--danger);
    background: linear-gradient(180deg, var(--danger-soft) 0%, var(--surface) 35%);
}

.health-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.health-card__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.health-card__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--surface-sunken);
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-strong);
}

.health-card__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-strong);
}

.health-card__sub {
    font-size: 12px;
    color: var(--ink-muted);
}

.health-card__badge {
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.health-card__badge--healthy {
    background: var(--success-soft);
    color: var(--success);
}

.health-card__badge--degraded {
    background: var(--warning-soft);
    color: var(--warning);
}

.health-card__badge--down {
    background: var(--danger-soft);
    color: var(--danger);
}

.health-card__badge--unknown {
    background: var(--surface-sunken);
    color: var(--ink-muted);
}

.health-card__metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 14px 0;
    padding: 12px;
    background: var(--surface-sunken);
    border-radius: var(--radius-md);
}

.health-card__metric-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.health-card__metric-label {
    font-size: 11px;
    color: var(--ink-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.health-card__metric-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink-strong);
    font-variant-numeric: tabular-nums;
}

.health-card__error {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 12px;
    line-height: 1.4;
    word-break: break-word;
    border: 1px solid rgba(225, 29, 72, 0.2);
}

.health-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--ink-faint);
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
}

/* Tabs */
.health-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
    overflow-x: auto;
}

.health-tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.health-tab-btn:hover {
    color: var(--ink-strong);
}

.health-tab-btn--active {
    color: var(--brand-gold);
    border-bottom-color: var(--brand-gold);
}

.health-tab-panel {
    display: none;
}

.health-tab-panel--active {
    display: block;
}

/* Timeline */
.health-timeline {
    position: relative;
    padding-left: 28px;
}

.health-timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--line);
}

.health-timeline__item {
    position: relative;
    margin-bottom: 20px;
}

.health-timeline__item:last-child {
    margin-bottom: 0;
}

.health-timeline__dot {
    position: absolute;
    left: -28px;
    top: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--ink-muted);
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-timeline__dot--danger {
    border-color: var(--danger);
    background: var(--danger-soft);
}

.health-timeline__dot--warning {
    border-color: var(--warning);
    background: var(--warning-soft);
}

.health-timeline__dot--success {
    border-color: var(--success);
    background: var(--success-soft);
}

.health-timeline__content {
    background: var(--surface-sunken);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
}

.health-timeline__time {
    font-size: 11px;
    color: var(--ink-muted);
    margin-bottom: 4px;
}

.health-timeline__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-strong);
}

/* Charts Wrapper */
.health-chart-wrapper {
    position: relative;
    height: 280px;
    width: 100%;
}

/* ==========================================================================
   Settings 2-Column Responsive Grid Layout
   ========================================================================== */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: stretch;
}

@media (max-width: 960px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

.settings-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    margin-bottom: 0;
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
    box-shadow: var(--shadow-xs);
}

.settings-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.settings-card .card__body {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.settings-card form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.settings-card .field {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-bottom: 0;
}

.settings-card .field__label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 650;
    color: var(--ink-strong);
}

.settings-card .field__input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-card .field__input-wrap .input,
.settings-card .field__input-wrap .select,
.settings-card .field__input-wrap .textarea {
    flex: 1;
    min-width: 0;
}

/*
 * Title, control and description read top-down in every card; only the
 * setting key sinks to the bottom.
 *
 * The control used to carry `margin-top: auto`. Cards in a row stretch to the
 * tallest one, so any card whose neighbour had a longer description had its
 * control pushed down to meet the bottom edge — a gap under the title on one
 * card, the dropdown floating near the floor on the next.
 */
.settings-card .field__meta {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.settings-card .field__meta > :last-child {
    margin-top: auto !important;
    padding-top: 6px;
}

.settings-card--full {
    grid-column: 1 / -1;
}




/* ------------------------------------------------------------------
 * Settings — App versions: one card per app and platform.
 * ------------------------------------------------------------------ */
.appver-note {
    margin: 0 0 20px;
    padding: 12px 16px;
    border: 1px solid var(--warning);
    border-radius: 12px;
    background: var(--warning-soft);
    font-size: 13px;
    line-height: 1.5;
}

.appver-heading {
    margin: 28px 0 12px;
    font-size: 17px;
    font-weight: 600;
}

.appver-heading:first-of-type { margin-top: 8px; }

.appver-card .card__body { display: flex; flex-direction: column; }

.appver-card form { display: flex; flex-direction: column; gap: 14px; height: 100%; }

.appver-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.appver-card__title { margin: 0; font-size: 16px; font-weight: 600; }

.appver-badge { font-size: 11px; padding: 3px 8px; white-space: nowrap; }

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

.appver-field .field__label { margin: 0; }

.appver-card__actions { margin-top: auto; display: flex; justify-content: flex-end; }

/* ------------------------------------------------------------------
 * Settings — sectioned side navigation.
 *
 * Fifteen groups in one horizontal strip overflowed the screen and mixed
 * service credentials with business rules. A vertical list, grouped under
 * headings, holds any number of groups and says what kind each one is.
 * ------------------------------------------------------------------ */
.settings-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.settings-nav {
    position: sticky;
    top: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-nav__section { display: flex; flex-direction: column; gap: 2px; }

.settings-nav__heading {
    margin: 0 0 6px;
    padding: 0 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.settings-nav__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--ink-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.settings-nav__item:hover { background: var(--surface-sunken); color: var(--ink-strong); }

.settings-nav__item:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.settings-nav__item[aria-selected="true"] {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.settings-nav__item[aria-selected="true"] .tab__count { background: var(--brand-soft); color: var(--brand); }

/* Narrow screens: the list sits above the content and scrolls sideways,
   one section after another, rather than squeezing the forms. */
@media (max-width: 900px) {
    .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }

    .settings-nav {
        position: static;
        flex-direction: row;
        gap: 16px;
        overflow-x: auto;
        padding-bottom: 6px;
    }

    .settings-nav__section { flex-direction: row; align-items: center; flex-shrink: 0; }

    .settings-nav__heading { margin: 0 4px 0 0; padding: 0; }

    .settings-nav__item { width: auto; white-space: nowrap; }
}
