/* ==========================================================================
   Admin Panel — Sara777 light theme
   White surfaces, charcoal type, amber accent. Both colours are sampled from
   the logo. No external dependencies, no build step.
   ========================================================================== */

/* ----------------------------------- Tokens ----------------------------- */
:root {
    /* Straight from the logo: the amber disc and the charcoal wordmark. */
    --brand: #fab02b;
    --brand-600: #e89b14;
    --brand-700: #c87f08;
    --brand-soft: #fff6e6;
    --brand-line: #f7dca6;
    --brand-ring: rgba(250, 176, 43, .3);

    --ink: #282830;
    --ink-700: #3b3b47;
    --ink-900: #1b1b22;

    /* The one dark token every component reads. */
    --black: var(--ink);
    --white: #ffffff;

    /* Neutrals carry a trace of the logo's charcoal so greys sit with it. */
    --grey-25: #fcfcfd;
    --grey-50: #f7f7f9;
    --grey-100: #f0f0f3;
    --grey-150: #e7e7ec;
    --grey-200: #dcdce3;
    --grey-300: #c5c5ce;
    --grey-400: #a1a1ac;
    --grey-500: #76767f;
    --grey-600: #55555e;
    --grey-700: #3c3c45;
    --grey-800: #26262e;

    --bg: var(--grey-50);
    --surface: var(--white);
    --surface-alt: var(--grey-25);
    --border: var(--grey-150);
    --border-strong: var(--grey-200);

    --text: var(--black);
    --text-muted: var(--grey-600);
    --text-subtle: var(--grey-500);

    --radius-sm: 7px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;

    --shadow-xs: 0 1px 2px rgba(40, 40, 48, .05);
    --shadow-sm: 0 1px 3px rgba(40, 40, 48, .07), 0 1px 2px rgba(40, 40, 48, .04);
    --shadow-md: 0 4px 14px rgba(40, 40, 48, .09);
    --shadow-lg: 0 12px 40px rgba(40, 40, 48, .16);

    --sidebar-w: 256px;
    --topbar-h: 62px;

    --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI",
            Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SF Mono", ui-monospace, "JetBrains Mono", "Cascadia Mono",
            Consolas, "Liberation Mono", monospace;

    --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ----------------------------------- Reset ------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -.011em; }
p { margin: 0; }
a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

::selection { background: var(--brand); color: var(--ink); }

:focus-visible {
    outline: 2px solid var(--brand-700);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--grey-300) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--grey-300); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--grey-400); background-clip: content-box; }

/* =============================== LAYOUT ================================= */
.shell { display: flex; min-height: 100vh; }

/* ------------------------------- Sidebar -------------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 60;
    transition: transform .26s var(--ease);
}

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

/* The wordmark is the brand: it replaces a lettered square entirely. */
.sidebar__brand { flex-direction: column; align-items: flex-start; justify-content: center; gap: 3px; }
.sidebar__logo { height: 24px; width: auto; }
.sidebar__sub {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--grey-400);
    line-height: 1;
}

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

.nav__label {
    padding: 14px 10px 6px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--grey-400);
}
.nav__label:first-child { padding-top: 2px; }

.nav__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .13s var(--ease), color .13s var(--ease);
}
.nav__item:hover { background: var(--grey-100); color: var(--text); }

.nav__item.is-active {
    background: var(--ink);
    color: var(--white);
    font-weight: 550;
}
/* The amber icon is what marks the current page on the dark row. */
.nav__item.is-active .nav__icon { opacity: 1; color: var(--brand); }

.nav__icon { width: 17px; height: 17px; flex: 0 0 17px; opacity: .65; }
.nav__item:hover .nav__icon { opacity: .9; }

.nav__count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: var(--radius-full);
    background: var(--grey-100);
    color: var(--text-muted);
}
.nav__item.is-active .nav__count { background: rgba(255, 255, 255, .17); color: var(--white); }

.nav__dot {
    margin-left: auto;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.nav__dot--off { background: var(--grey-300); box-shadow: none; }
.nav__item.is-active .nav__dot { box-shadow: none; }
.nav__item.is-active .nav__dot--off { background: var(--grey-500); }

.sidebar__foot {
    flex: 0 0 auto;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar__footlink {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-subtle);
}
.sidebar__footlink:hover { background: var(--grey-100); color: var(--text); }

/* ------------------------------- Main area ------------------------------ */
.main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar__title { font-size: 16px; font-weight: 600; letter-spacing: -.018em; }
.topbar__crumb { font-size: 12px; color: var(--text-subtle); }
.topbar__spacer { flex: 1 1 auto; }

.burger {
    display: none;
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: var(--radius-sm);
    place-items: center;
    cursor: pointer;
}

.content { padding: 24px; flex: 1 1 auto; }
.content--narrow { max-width: 860px; }

.page-head {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head__title { font-size: 21px; font-weight: 650; letter-spacing: -.022em; }
.page-head__desc { font-size: 13px; color: var(--text-muted); margin-top: 3px; max-width: 640px; }
.page-head__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(27, 27, 34, .45);
    z-index: 55;
}

/* ================================ CARDS ================================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: 18px; }

.card__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid var(--border);
}
.card__title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.card__desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.card__actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__foot {
    padding: 13px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    display: flex; align-items: center; gap: 10px;
}

/* ================================ GRID ================================== */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

/* ============================== STAT CARD =============================== */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 17px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .16s var(--ease), transform .16s var(--ease);
}
a.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--brand-line); }

.stat__top { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
.stat__icon {
    width: 29px; height: 29px;
    border-radius: 8px;
    background: var(--brand-soft);
    color: var(--brand-700);
    display: grid; place-items: center;
    flex: 0 0 29px;
}
.stat__icon svg { width: 15px; height: 15px; }
.stat__label { font-size: 12px; font-weight: 550; color: var(--text-muted); letter-spacing: -.005em; }
.stat__value { font-size: 27px; font-weight: 650; letter-spacing: -.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: 11.5px; color: var(--text-subtle); margin-top: 5px; }

/* =============================== BADGES ================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 550;
    line-height: 1.6;
    white-space: nowrap;
    border: 1px solid transparent;
}
.badge--solid { background: var(--black); color: var(--white); }
.badge--outline { background: var(--white); border-color: var(--border-strong); color: var(--text-muted); }
.badge--soft { background: var(--grey-100); color: var(--text-muted); }
.badge--on { background: var(--brand); color: var(--ink); }
.badge--off { background: var(--white); border-color: var(--border-strong); color: var(--text-subtle); }

.badge__dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.mono { font-family: var(--mono); font-size: 12.5px; }

/* =============================== BUTTONS ================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 550;
    letter-spacing: -.005em;
    cursor: pointer;
    white-space: nowrap;
    transition: background .14s var(--ease), border-color .14s var(--ease),
                color .14s var(--ease), box-shadow .14s var(--ease), opacity .14s var(--ease);
}
.btn svg { width: 15px; height: 15px; flex: 0 0 15px; }

/* Amber on charcoal type — the logo's own pairing, and the only loud thing
   on the page, so the main action is always obvious. */
.btn--primary { background: var(--brand); color: var(--ink); box-shadow: var(--shadow-xs); font-weight: 600; }
.btn--primary:hover { background: var(--brand-600); }
.btn--primary:active { background: var(--brand-700); color: var(--white); transform: translateY(.5px); }

.btn--dark { background: var(--ink); color: var(--white); box-shadow: var(--shadow-xs); }
.btn--dark:hover { background: var(--ink-700); }
.btn--dark:active { background: var(--ink-900); transform: translateY(.5px); }

.btn--secondary { background: var(--white); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--grey-50); border-color: var(--brand-line); }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--grey-100); color: var(--text); }

.btn--danger { background: var(--white); color: var(--black); border-color: var(--grey-300); }
.btn--danger:hover { background: var(--black); color: var(--white); border-color: var(--black); }

.btn--sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 6px; }
.btn--sm svg { width: 13px; height: 13px; flex: 0 0 13px; }
.btn--lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn--block { width: 100%; }
.btn--icon { width: 32px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ================================ FORMS ================================= */
.field { margin-bottom: 17px; }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -.004em;
}
.label__req { color: var(--brand-700); font-weight: 700; }
.label__opt { font-weight: 400; color: var(--text-subtle); font-size: 11.5px; }

.input, .select, .textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 12px;
    background: var(--white);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.5;
    transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
    appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--grey-400); }

.input:hover, .select:hover, .textarea:hover { border-color: var(--grey-300); }

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

.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.textarea--code { font-family: var(--mono); font-size: 12px; min-height: 150px; }

.select {
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2355555e' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.input--invalid, .select--invalid, .textarea--invalid { border-color: var(--black); background: var(--grey-50); }

.help { font-size: 12px; color: var(--text-muted); margin-top: 6px; line-height: 1.5; }
.error { font-size: 12px; font-weight: 550; margin-top: 6px; display: flex; gap: 5px; align-items: flex-start; }
.error svg { width: 13px; height: 13px; margin-top: 2px; flex: 0 0 13px; }

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group .input { flex: 1 1 auto; }

/* Toggle switch */
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch__track {
    position: relative;
    width: 42px; height: 24px;
    flex: 0 0 42px;
    background: var(--grey-200);
    border-radius: var(--radius-full);
    transition: background .2s var(--ease);
}
.switch__track::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: var(--white);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform .2s var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand-700); outline-offset: 2px; }

.switch__text { font-size: 13.5px; font-weight: 500; }

/* A toggle laid out as a bordered row */
.switch-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-alt);
}
.switch-row__body { flex: 1 1 auto; min-width: 0; }
.switch-row__title { font-size: 13.5px; font-weight: 600; }
.switch-row__desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.switch-row.is-on { background: var(--white); border-color: var(--brand-line); }

/* A switch-row carrying action buttons needs to wrap on a phone, or the
   description is squeezed into a one-word-per-line column. */
@media (max-width: 640px) {
    .switch-row--actions { flex-wrap: wrap; }
    .switch-row--actions .switch-row__body { flex: 1 1 180px; }
    .switch-row--actions > form,
    .switch-row--actions > .btn { flex: 1 1 140px; }
    .switch-row--actions > form > .btn { width: 100%; }
}

/* File upload row (e.g. the Firebase service-account JSON) */
.upload {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 15px;
    border: 1px dashed var(--grey-300);
    border-radius: var(--radius);
    background: var(--surface-alt);
    margin-bottom: 10px;
    transition: border-color .14s var(--ease), background .14s var(--ease);
}
.upload:hover { border-color: var(--brand); background: var(--white); }
.upload--invalid { border-color: var(--black); border-style: solid; }
.upload.is-filled { border-style: solid; border-color: var(--brand); background: var(--brand-soft); }

.upload__icon {
    width: 32px; height: 32px;
    flex: 0 0 32px;
    border-radius: 8px;
    background: var(--grey-100);
    color: var(--text);
    display: grid; place-items: center;
}
.upload__icon svg { width: 16px; height: 16px; }
.upload.is-filled .upload__icon { background: var(--brand); color: var(--ink); }

.upload__body { flex: 1 1 auto; min-width: 0; }
.upload__title { font-size: 13.5px; font-weight: 600; }
.upload__meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.upload__meta strong { color: var(--text); font-weight: 600; }

/* The input is driven by the surrounding <label>, so keep it out of the flow. */
.upload__input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload label { cursor: pointer; }

.upload__or {
    position: relative;
    text-align: center;
    margin: 4px 0 10px;
}
.upload__or::before {
    content: "";
    position: absolute;
    top: 50%; left: 0; right: 0;
    border-top: 1px solid var(--border);
}
.upload__or span {
    position: relative;
    padding: 0 10px;
    background: var(--surface);
    font-size: 11.5px;
    color: var(--text-subtle);
}

/* Checkbox */
.check { display: inline-flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
    width: 17px; height: 17px;
    flex: 0 0 17px;
    margin-top: 1px;
    border: 1.5px solid var(--grey-300);
    border-radius: 5px;
    background: var(--white);
    display: grid; place-items: center;
    transition: background .14s var(--ease), border-color .14s var(--ease);
}
.check__box svg { width: 11px; height: 11px; stroke: var(--ink); opacity: 0; transition: opacity .12s; }
.check input:checked + .check__box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .check__box svg { opacity: 1; }
.check input:focus-visible + .check__box { outline: 2px solid var(--brand-700); outline-offset: 2px; }
.check__text { font-size: 13px; }

/* ================================ TABLE ================================= */
.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-subtle);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--text); }

.table td { padding: 12px 14px; border-bottom: 1px solid var(--grey-100); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s var(--ease); }
.table tbody tr:hover { background: var(--grey-25); }

.table__num { font-variant-numeric: tabular-nums; }
.table__actions { text-align: right; white-space: nowrap; }
.table__check { width: 42px; padding-right: 0 !important; }

.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
    width: 33px; height: 33px;
    flex: 0 0 33px;
    border-radius: 50%;
    background: var(--grey-100);
    color: var(--text);
    display: grid; place-items: center;
    font-size: 11.5px;
    font-weight: 650;
    letter-spacing: -.01em;
}
.avatar--dark { background: var(--ink); color: var(--white); }
.avatar--lg { width: 52px; height: 52px; flex: 0 0 52px; font-size: 17px; }

.cell-user__name { font-weight: 550; line-height: 1.35; }
.cell-user__meta { font-size: 12px; color: var(--text-subtle); line-height: 1.35; }

/* --------------------------------------------------------------------------
   Card tables
   A table marked .table--cards (inside .table-wrap--cards) keeps its grid on a
   wide screen and stacks into one card per row on a narrow one, so nothing has
   to be scrolled sideways on a phone. Each <td> supplies its own heading
   through data-label; a td.cell-main becomes the card's title row.
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
    .table-wrap--cards { overflow-x: visible; }

    .table--cards thead { display: none; }

    .table--cards,
    .table--cards tbody,
    .table--cards tr,
    .table--cards td {
        display: block;
        width: 100%;
    }

    .table--cards tr {
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
    }
    .table--cards tr:last-child { border-bottom: 0; }
    .table--cards tbody tr:hover { background: transparent; }

    .table--cards td {
        display: flex;
        align-items: center;
        gap: 10px;
        min-height: 30px;
        padding: 4px 0;
        border: 0;
    }

    .table--cards td::before {
        content: attr(data-label);
        flex: 0 0 84px;
        font-size: 10.5px;
        font-weight: 600;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--text-subtle);
    }

    /* The title row spans the full width and carries no label. */
    .table--cards td.cell-main {
        display: block;
        padding: 0 0 8px;
    }
    .table--cards td.cell-main::before { display: none; }

    .table--cards .table__check { display: none; }

    .table--cards .table__actions {
        justify-content: flex-start;
        text-align: left;
        padding-top: 10px;
    }
    .table--cards .table__actions::before { display: none; }

    /* Desktop-only conveniences that would just add noise on a card. */
    .table--cards .hide-mobile { display: none; }

    /* Inputs inside a card cell take the space they are given. */
    .table--cards .input-group { flex: 1 1 auto; min-width: 0; }
}

.empty { padding: 56px 24px; text-align: center; }
.empty__icon {
    width: 44px; height: 44px;
    margin: 0 auto 14px;
    border-radius: 12px;
    background: var(--grey-100);
    color: var(--grey-500);
    display: grid; place-items: center;
}
.empty__icon svg { width: 21px; height: 21px; }
.empty__title { font-size: 14.5px; font-weight: 600; }
.empty__text { font-size: 13px; color: var(--text-muted); margin-top: 5px; }

/* ============================== PAGINATION ============================== */
.pagination { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pagination__item,
.pagination span[aria-current], .pagination span[aria-disabled] {
    min-width: 32px; height: 32px;
    padding: 0 9px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--white);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}
.pagination__item:hover { background: var(--grey-50); color: var(--text); border-color: var(--brand-line); }
.pagination__item.is-active, .pagination span[aria-current] { background: var(--black); border-color: var(--black); color: var(--white); font-weight: 600; }
.pagination span[aria-disabled] { opacity: .4; }
.pagination__info { font-size: 12.5px; color: var(--text-subtle); }

/* ================================ ALERTS ================================ */
.alert {
    display: flex;
    gap: 11px;
    padding: 13px 15px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--white);
    font-size: 13.5px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-xs);
}
.alert__icon { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }
.alert__body { flex: 1 1 auto; min-width: 0; }
.alert__title { font-weight: 600; margin-bottom: 2px; }
.alert__close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--grey-400); padding: 0 2px; }
.alert__close:hover { color: var(--text); }

.alert--success { border-left: 3px solid var(--brand); background: var(--brand-soft); border-color: var(--brand-line); }
.alert--error { background: var(--black); color: var(--white); border-color: var(--black); }
.alert--error .alert__close { color: rgba(255, 255, 255, .6); }
.alert--error .alert__close:hover { color: var(--white); }
.alert--info { background: var(--grey-50); }
.alert--warning { border-left: 3px solid var(--brand-700); background: var(--grey-50); }

/* ============================== FILTER BAR ============================== */
.filters {
    display: flex;
    gap: 9px;
    align-items: center;
    flex-wrap: wrap;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.filters .input, .filters .select { height: 34px; min-height: 34px; font-size: 13px; }
.filters__search { position: relative; flex: 1 1 240px; max-width: 340px; }
.filters__search .input { padding-left: 33px; }
.filters__search svg {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    color: var(--grey-400);
    pointer-events: none;
}
.filters__spacer { flex: 1 1 auto; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    background: var(--white);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}
.chip:hover { border-color: var(--brand-line); color: var(--text); }
.chip.is-active { background: var(--black); border-color: var(--black); color: var(--white); font-weight: 550; }
.chip__count { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }

/* ============================== DROPDOWN ================================ */
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 200px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 5px;
    z-index: 70;
    display: none;
}
.dropdown.is-open .dropdown__menu { display: block; }
.dropdown__menu--left { right: auto; left: 0; }

.dropdown__head { padding: 9px 11px 7px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.dropdown__name { font-size: 13px; font-weight: 600; }
.dropdown__mail { font-size: 11.5px; color: var(--text-subtle); word-break: break-all; }

.dropdown__item {
    display: flex; align-items: center; gap: 9px;
    width: 100%;
    padding: 7px 11px;
    border: 0;
    border-radius: 6px;
    background: none;
    text-align: left;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}
.dropdown__item:hover { background: var(--grey-100); color: var(--text); }
.dropdown__item svg { width: 15px; height: 15px; flex: 0 0 15px; opacity: .7; }
.dropdown__sep { height: 1px; background: var(--border); margin: 4px 0; }

.user-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 4px 9px 4px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--white);
    cursor: pointer;
}
.user-chip:hover { border-color: var(--border-strong); }
.user-chip__name { font-size: 13px; font-weight: 550; }
.user-chip svg { width: 13px; height: 13px; color: var(--grey-400); }

/* ================================ MODAL ================================= */
.modal {
    position: fixed; inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.is-open { display: flex; }
.modal__overlay { position: absolute; inset: 0; background: rgba(27, 27, 34, .5); }
.modal__panel {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modal-in .18s var(--ease);
}
.modal__panel--wide { max-width: 640px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.modal__head { padding: 18px 20px 0; }
.modal__title { font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.modal__body { padding: 12px 20px 18px; font-size: 13.5px; color: var(--text-muted); line-height: 1.6; }
.modal__foot { padding: 14px 20px; background: var(--surface-alt); border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; }

/* ============================== DATA LIST =============================== */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); }
.dl > dt {
    padding: 11px 0;
    font-size: 12.5px;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--grey-100);
}
.dl > dd {
    margin: 0;
    padding: 11px 0;
    font-size: 13.5px;
    border-bottom: 1px solid var(--grey-100);
    word-break: break-word;
}
.dl > dt:last-of-type, .dl > dd:last-of-type { border-bottom: 0; }

/* =============================== CHART ================================== */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 150px; padding-top: 10px; }
.chart__col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 7px; height: 100%; min-width: 0; }
.chart__bar {
    width: 100%;
    max-width: 34px;
    min-height: 3px;
    background: linear-gradient(180deg, var(--brand), var(--brand-600));
    border-radius: 4px 4px 2px 2px;
    transition: opacity .14s var(--ease);
}
.chart__col:hover .chart__bar { opacity: .72; }
.chart__bar--empty { background: var(--grey-150); }
.chart__x { font-size: 10.5px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.chart__v { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* =============================== HEALTH ================================= */
.health { display: flex; flex-direction: column; }
.health__row {
    display: flex; align-items: center; gap: 11px;
    padding: 11px 0;
    border-bottom: 1px solid var(--grey-100);
}
.health__row:last-child { border-bottom: 0; }
.health__label { font-size: 13px; flex: 1 1 auto; }
.health__sub { font-size: 11.5px; color: var(--text-subtle); }

/* ============================= MISC HELPERS ============================= */
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--tight { gap: 6px; }

.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.tiny { font-size: 11.5px; }
.small { font-size: 12.5px; }
.bold { font-weight: 600; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; } .mb-4 { margin-bottom: 24px; }

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

.code-block {
    font-family: var(--mono);
    font-size: 12px;
    background: var(--grey-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    overflow-x: auto;
    white-space: pre;
    line-height: 1.6;
    color: var(--grey-800);
}

.kv {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--mono); font-size: 12px;
    background: var(--grey-100);
    border-radius: 5px;
    padding: 2px 7px;
}

.copy-field {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border: 1px dashed var(--brand-line);
    border-radius: var(--radius-sm);
    background: var(--brand-soft);
}
.copy-field__value { flex: 1 1 auto; font-family: var(--mono); font-size: 14px; font-weight: 600; letter-spacing: .04em; }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(760px 420px at 50% -8%, var(--brand-soft), transparent 72%),
        var(--grey-50);
}
.login-card {
    width: 100%;
    max-width: 396px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 30px 28px 26px;
    border-top: 3px solid var(--brand);
}
.login-logo { height: 34px; width: auto; margin: 0 auto 18px; }
.login-title { font-size: 17px; font-weight: 650; text-align: center; letter-spacing: -.02em; }
.login-sub { font-size: 13px; color: var(--text-muted); text-align: center; margin: 5px 0 22px; }
.login-foot { text-align: center; font-size: 12px; color: var(--text-subtle); margin-top: 20px; }

/* =============================== RESPONSIVE ============================= */
@media (max-width: 1100px) {
    .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
    .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .backdrop { display: block; }
    .main { margin-left: 0; }
    .burger { display: grid; }
    .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
    .content { padding: 18px 14px; }
    .topbar { padding: 0 14px; }
    .dl { grid-template-columns: minmax(0, 1fr); }
    .dl > dt { padding-bottom: 0; border-bottom: 0; }
    .dl > dd { padding-top: 3px; }
}

@media (max-width: 560px) {
    .grid--4, .grid--stats { grid-template-columns: minmax(0, 1fr); }
    .page-head__actions { margin-left: 0; width: 100%; }
    .topbar__crumb { display: none; }

    /* The name wraps to two lines and pushes the topbar out of shape, and the
       avatar already identifies who is signed in. */
    .user-chip__name { display: none; }
    .user-chip { padding: 4px 6px 4px 4px; }
}

@media print {
    .sidebar, .topbar, .page-head__actions, .filters, .pagination { display: none !important; }
    .main { margin-left: 0; }
    .card { box-shadow: none; border-color: #ccc; }
}

/* ================================ CHAT ================================== */
/* Two panes that fill what is left of the window, so only the message list
   scrolls and the composer stays put. */
.content--chat { display: flex; flex-direction: column; min-height: 0; }

.chat {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    flex: 1 1 auto;
    min-height: 0;
    height: calc(100vh - var(--topbar-h) - 150px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat__threads {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--surface-alt);
}

.chat__search { position: relative; padding: 12px; border-bottom: 1px solid var(--border); }
.chat__search .input { padding-left: 33px; height: 34px; min-height: 34px; }
.chat__search svg {
    position: absolute; left: 23px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    color: var(--grey-400);
    pointer-events: none;
}

.chat__list { flex: 1 1 auto; overflow-y: auto; }
.chat__hint { padding: 22px 16px; font-size: 12.5px; color: var(--text-subtle); line-height: 1.6; }

.chat__thread {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 13px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.chat__thread:hover { background: var(--white); }
.chat__thread.is-active { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }

.chat__thread-body { flex: 1 1 auto; min-width: 0; }
.chat__thread-top { display: flex; align-items: baseline; gap: 8px; }
.chat__thread-name { flex: 1 1 auto; font-size: 13px; font-weight: 600; color: var(--text); }
.chat__thread-time { font-size: 10.5px; color: var(--text-subtle); white-space: nowrap; }
.chat__thread-last {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat__unread {
    flex: 0 0 auto;
    min-width: 19px; height: 19px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    background: var(--brand);
    color: var(--ink);
    font-size: 11px;
    font-weight: 700;
    display: grid; place-items: center;
}

/* -------------------------------- Pane ---------------------------------- */
.chat__pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat__empty { margin: auto; text-align: center; padding: 30px; }
.chat__conversation { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
/* display:flex would otherwise beat the hidden attribute on its own. */
.chat__conversation[hidden] { display: none; }

.chat__header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.chat__name { display: block; font-size: 14px; font-weight: 600; }
.chat__meta { display: block; font-size: 12px; color: var(--text-subtle); font-family: var(--mono); }

.chat__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    background: var(--grey-25);
}

.chat__bubble {
    align-self: flex-start;
    max-width: min(560px, 78%);
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: 14px 14px 14px 4px;
    background: var(--white);
    box-shadow: var(--shadow-xs);
}
/* The admin's own replies, in the brand amber on the right. */
.chat__bubble--mine {
    align-self: flex-end;
    background: var(--brand-soft);
    border-color: var(--brand-line);
    border-radius: 14px 14px 4px 14px;
}

.chat__text { font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat__time { font-size: 10.5px; color: var(--text-subtle); margin-top: 4px; }

.chat__composer {
    display: flex;
    align-items: flex-end;
    gap: 9px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    flex: 0 0 auto;
}
.chat__composer .textarea { min-height: 40px; max-height: 140px; resize: none; }

@media (max-width: 880px) {
    .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 120px); }
    /* Only one pane fits on a phone: the list until a thread is open. */
    .chat__threads { display: none; }
    .chat:has(.chat__conversation[hidden]) .chat__threads { display: flex; }
    .chat:has(.chat__conversation[hidden]) .chat__pane { display: none; }
}
