/* =====================================================================
   admin.css
   Operator console.

   Same restrained fintech direction as the checkout, but tuned for a
   different job. The checkout persuades one person to act once; this is
   a tool someone stares at all day looking for the one row that is
   wrong. So: denser type, tabular numerals everywhere, and colour used
   only where it means something.

   The environment band and the status badges are the only saturated
   colour on the page. If everything is coloured, nothing is.
   ===================================================================== */

:root {
    --ink:        #0f172a;
    --ink-soft:   #475569;
    --muted:      #64748b;
    --dim:        #94a3b8;
    --line:       #e2e8f0;
    --line-soft:  #f1f5f9;
    --surface:    #ffffff;
    --canvas:     #f8fafc;
    --raised:     #ffffff;

    --accent:     #4f46e5;
    --accent-ink: #ffffff;
    --accent-bg:  #eef2ff;

    --good:       #047857;
    --good-bg:    #ecfdf5;
    --warn:       #b45309;
    --warn-bg:    #fffbeb;
    --bad:        #b91c1c;
    --bad-bg:     #fef2f2;
    --progress:   #1d4ed8;
    --progress-bg:#eff6ff;

    --radius:     10px;
    --radius-sm:  7px;
    --shadow:     0 1px 2px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.05);

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    --side-w: 232px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink:        #e2e8f0;
        --ink-soft:   #cbd5e1;
        --muted:      #94a3b8;
        --dim:        #64748b;
        --line:       #1e293b;
        --line-soft:  #172033;
        --surface:    #0f172a;
        --canvas:     #020617;
        --raised:     #1e293b;
        --accent:     #818cf8;
        --accent-bg:  #1e1b4b;
        --good:       #34d399;
        --good-bg:    #052e26;
        --warn:       #fbbf24;
        --warn-bg:    #3b2503;
        --bad:        #f87171;
        --bad-bg:     #3f0d0d;
        --progress:   #93c5fd;
        --progress-bg:#0c2447;
        --shadow:     0 1px 2px rgba(0,0,0,.4);
    }
}

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

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    /* Every figure in every table lines up column-wise. */
    font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--mono); font-size: .92em; }

.dim { color: var(--dim); }

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

.skip {
    position: absolute; left: -9999px;
    background: var(--accent); color: #fff; padding: 10px 16px; z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

/* --- environment band ------------------------------------------------ */

/* The single most expensive admin mistake is believing you are on
   testnet when you are on mainnet. Stated on every page, unmissable,
   and impossible to dismiss. */
.envbar {
    background: repeating-linear-gradient(-45deg, #b45309, #b45309 12px, #92400e 12px, #92400e 24px);
    color: #fff;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    padding: 5px;
}

/* --- shell ------------------------------------------------------------ */

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

.side {
    flex: 0 0 var(--side-w);
    width: var(--side-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side__head {
    display: flex; align-items: center; gap: 9px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line);
}

.side__mark {
    width: 22px; height: 22px; border-radius: 6px;
    background: var(--accent);
    display: inline-block;
    position: relative;
}
.side__mark::after {
    content: ""; position: absolute; inset: 7px;
    border-radius: 2px; background: var(--accent-ink);
}

.side__title { font-weight: 650; letter-spacing: -.01em; }

.side__nav { flex: 1 1 auto; overflow-y: auto; padding: 12px 10px; }

.side__group {
    font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
    color: var(--dim);
    padding: 14px 8px 6px;
}

.side__link {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 13.5px;
    text-decoration: none;
}

.side__link:hover { background: var(--line-soft); text-decoration: none; }

.side__link.is-active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }

.side__count {
    background: var(--muted); color: #fff;
    font-size: 11px; font-weight: 700;
    min-width: 19px; text-align: center;
    padding: 1px 6px; border-radius: 999px;
}
.side__count--bad { background: var(--bad); }

.side__foot { border-top: 1px solid var(--line); padding: 12px; }

.side__user { margin-bottom: 8px; font-size: 12.5px; }
.side__user strong { display: block; }
.side__user span { color: var(--dim); font-size: 11px; letter-spacing: .06em; }

/* --- main ------------------------------------------------------------- */

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}

.topbar__title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; flex: 1 1 auto; }

.topbar__env {
    font-size: 11px; font-weight: 700; letter-spacing: .08em;
    color: var(--muted);
    border: 1px solid var(--line); border-radius: 999px;
    padding: 3px 10px;
}

.burger { display: none; background: none; border: 0; cursor: pointer; padding: 6px; }
.burger span { display: block; width: 18px; height: 2px; background: var(--ink); margin: 3px 0; border-radius: 2px; }

.content { padding: 20px 24px 48px; max-width: 1500px; width: 100%; }

/* --- panels ------------------------------------------------------------ */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}

.panel--highlight { border-color: var(--accent); }

.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.panel__title { margin: 0 0 12px; font-size: 14.5px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
.panel__head .panel__title { margin: 0; }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* --- stats -------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
}

.stat__label { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.stat__value { display: block; font-size: 24px; font-weight: 620; letter-spacing: -.02em; line-height: 1.15; font-family: var(--mono); }
.stat__unit  { display: block; font-size: 12px; color: var(--dim); margin-top: 3px; }

/* --- tables -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }

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

.table th {
    text-align: left;
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }

.table tbody tr:hover { background: var(--line-soft); }

.table .num { text-align: right; font-family: var(--mono); white-space: nowrap; }

.table .truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.table .is-short { color: var(--bad); }
.table .is-held  { color: var(--warn); font-weight: 600; }

.table tr.is-dropped td { opacity: .55; text-decoration: line-through; }

.table tr.subrow td { border-bottom: 1px solid var(--line-soft); padding-top: 0; font-size: 12px; }
.table tr.subrow:hover { background: none; }

.row-actions { white-space: nowrap; text-align: right; }

.kv { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 12px 6px 0; white-space: nowrap; vertical-align: top; width: 1%; }
.kv td { padding: 6px 0; word-break: break-word; }

/* --- badges --------------------------------------------------------------- */

.badge {
    display: inline-block;
    font-size: 11px; font-weight: 650; letter-spacing: .02em;
    padding: 2px 8px; border-radius: 999px;
    white-space: nowrap;
}

.badge--good     { background: var(--good-bg);     color: var(--good); }
.badge--warn     { background: var(--warn-bg);     color: var(--warn); }
.badge--bad      { background: var(--bad-bg);      color: var(--bad); }
.badge--progress { background: var(--progress-bg); color: var(--progress); }
.badge--muted    { background: var(--line-soft);   color: var(--muted); }

/* --- notices ---------------------------------------------------------------- */

.notice {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 13.5px;
    line-height: 1.5;
}

.notice strong { display: block; margin-bottom: 2px; }
.notice a { text-decoration: underline; }

.notice--good { background: var(--good-bg); color: var(--good); }
.notice--warn { background: var(--warn-bg); color: var(--warn); }
.notice--bad  { background: var(--bad-bg);  color: var(--bad); }
.notice--info { background: var(--accent-bg); color: var(--accent); }

/* --- forms -------------------------------------------------------------------- */

.stack > * + * { margin-top: 14px; }

.field { display: block; }

.field__label {
    display: block;
    font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 5px;
}

.input {
    width: 100%;
    font: inherit;
    font-size: 13.5px;
    color: var(--ink);
    background: var(--raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 11px;
}

.input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-bg); }
.input[readonly], .input[disabled] { background: var(--line-soft); color: var(--muted); }

.input--tiny { width: 90px; }

textarea.input { resize: vertical; font-family: var(--sans); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.filters .input { width: auto; min-width: 150px; flex: 0 1 auto; }
.filters .input[type="search"] { flex: 1 1 260px; }

.inline { display: inline-flex; gap: 6px; align-items: center; }

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

.choices { border: 0; padding: 0; margin: 0; }
.choices legend { padding: 0; }

.choice { display: flex; gap: 9px; align-items: flex-start; padding: 7px 0; font-size: 13.5px; cursor: pointer; }
.choice input { margin-top: 3px; flex: 0 0 auto; }
.choice strong { display: block; font-weight: 600; }
.choice .dim { display: block; font-size: 12.5px; }

.setting { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.setting__help { font-size: 12.5px; color: var(--muted); padding-top: 22px; }
.setting__help code { display: block; margin-bottom: 3px; }

/* --- buttons --------------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-size: 13px; font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--raised);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { background: var(--line-soft); text-decoration: none; }

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

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

.btn--quiet { color: var(--ink-soft); }

.btn--tiny { padding: 4px 9px; font-size: 12px; }

.btn--block { width: 100%; }

/* --- tabs, pager, misc ------------------------------------------------------------- */

.tabs { display: flex; gap: 4px; }
.tabs--wrap { flex-wrap: wrap; }

.tab {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600;
    color: var(--muted);
    text-decoration: none;
}
.tab:hover { background: var(--line-soft); text-decoration: none; }
.tab.is-active { background: var(--accent-bg); color: var(--accent); }

.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; }
.pager__pos { font-size: 12.5px; color: var(--muted); }

.empty { color: var(--muted); font-size: 13.5px; padding: 22px 0; text-align: center; }

.footnote { margin-top: 14px; font-size: 12px; color: var(--dim); line-height: 1.55; }

.meter { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.meter__fill { height: 100%; background: var(--accent); border-radius: 999px; }
.meter__fill--warn { background: var(--warn); }

.selectable { user-select: all; background: var(--line-soft); padding: 3px 7px; border-radius: 5px; word-break: break-all; }
.secret { color: var(--bad); }

/* --- timeline ------------------------------------------------------------------------ */

.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }

.timeline li {
    position: relative;
    padding: 0 0 14px 18px;
    border-left: 2px solid var(--line);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }

.timeline li::before {
    content: ""; position: absolute; left: -5px; top: 5px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--accent);
}

.timeline__meta   { display: block; font-size: 12px; color: var(--dim); margin-top: 3px; }
.timeline__reason { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* --- alerts ---------------------------------------------------------------------------- */

.alerts { list-style: none; margin: 0; padding: 0; }

.alert { border: 1px solid var(--line); border-left-width: 3px; border-radius: var(--radius-sm); padding: 13px 15px; margin-bottom: 10px; }

.alert--critical { border-left-color: var(--bad);  background: var(--bad-bg); }
.alert--warning  { border-left-color: var(--warn); background: var(--warn-bg); }
.alert--info     { border-left-color: var(--accent); background: var(--accent-bg); }

.alert__head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 5px; }

.alert__sev { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; }
.alert--critical .alert__sev { color: var(--bad); }
.alert--warning  .alert__sev { color: var(--warn); }
.alert--info     .alert__sev { color: var(--accent); }

.alert__title { font-size: 14px; }
.alert__cat   { font-size: 11px; color: var(--muted); border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px; }
.alert__count { font-size: 11.5px; color: var(--muted); font-weight: 600; }

.alert__body { margin: 0 0 9px; font-size: 13px; line-height: 1.55; }

.alert__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; }

/* --- login ------------------------------------------------------------------------------- */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }

.login { width: 100%; max-width: 360px; }

.login__brand { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 18px; font-weight: 650; }

.login__card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px 24px;
}

.login__title { margin: 0 0 4px; font-size: 18px; font-weight: 650; }

.login__env { margin: 0 0 16px; font-size: 12px; color: var(--warn); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.login__card .field + .field { margin-top: 13px; }
.login__card .btn { margin-top: 18px; }

/* --- responsive ---------------------------------------------------------------------------- */

@media (max-width: 900px) {
    .side {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform .18s ease;
        box-shadow: var(--shadow);
    }

    .side.is-open { transform: translateX(0); }

    .burger { display: block; }

    .content { padding: 16px 14px 40px; }

    .table-wrap { margin: 0 -20px; padding: 0 20px; }

    .setting { grid-template-columns: 1fr; gap: 6px; }
    .setting__help { padding-top: 0; }

    .backdrop {
        position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35;
    }
}

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

@media print {
    .side, .topbar, .btn, .filters, .pager { display: none !important; }
    .panel { box-shadow: none; border-color: #ccc; }
    body { background: #fff; }
}
