/* ==========================================================================
   AI Hub Web — Admin console, user portal, public pages
   Professional VFX-industry dark graphite theme
   ========================================================================== */

/* --- Design tokens (plan P2) --------------------------------------------
   Scale reference — use these variables instead of raw values:

   Backgrounds (darkest -> lightest):
     --crust      page chrome / deepest wells (auth backdrop, code wells)
     --mantle     sidebar / topbar
     --base       main page background
     --surface0   cards & panels          --panel-bg     analytics panels
     --surface1   raised controls/borders --surface2     strongest border
   Text (dimmest -> brightest):
     --overlay0 / --overlay1   de-emphasized labels, meta text
     --subtext0 / --subtext1   secondary body text
     --text                    primary text
   Accents:
     --blue   primary action      --green  success/ok
     --red    danger/error        --yellow warning
     --peach  secondary accent    --mauve  brand secondary (tier/plan)
     --teal   charts/gradients
     --<accent>-bright            hover states on filled buttons/links
     --tint-<accent>              translucent washes for badges/alerts
   Component tokens:
     --panel-bg/--panel-border    analytics panel surfaces
     --input-bg/--input-border    form fields
     --hairline / --row-line      structural separators / table row lines
     --hover-row                  table row + nav hover wash
   Spacing ladder: --space-xs 8 / sm 14 / md 18 / lg 22 / xl 30 (px).
   Type: --font-sans / --font-mono; sizes --text-xs 0.72rem -> --text-xl 1.45rem.
   Radius: --radius-sm 5 (controls) / --radius 8 (cards) / --radius-lg 12 (modals).
   Shadows: --shadow-1 card hover / --shadow-2 floating card / --shadow-3 modal.
   Ratchet: templates must not add new raw hex colors
   (tests/cloud/test_style_tokens.py).
   ------------------------------------------------------------------------- */
:root {
    /* Graphite background scale */
    --crust:    #070b10;
    --mantle:   #0b1118;
    --base:     #0f1722;
    --surface0: #172231;
    --surface1: #233041;
    --surface2: #334155;

    /* Text scale */
    --overlay0: #64748b;
    --overlay1: #8290a1;
    --subtext0: #aab4c0;
    --subtext1: #c1cad4;
    --text:     #dce3ea;

    /* Accents */
    --blue:     #5b8def;
    --green:    #37b27f;
    --red:      #e65f5c;
    --yellow:   #f2b84b;
    --peach:    #e08b4f;
    --mauve:    #8b7cf6;
    --teal:     #29a8ab;
    --blue-bright:  #9fc5fc;
    --red-bright:   #f5a0b6;

    /* Translucent accent washes (badges, alerts, glows) */
    --tint-blue:   rgba(137, 180, 250, 0.1);
    --tint-green:  rgba(166, 227, 161, 0.1);
    --tint-red:    rgba(243, 139, 168, 0.1);
    --tint-yellow: rgba(249, 226, 175, 0.1);
    --tint-mauve:  rgba(203, 166, 247, 0.1);
    --hover-row:   rgba(137, 180, 250, 0.04);

    /* Component surfaces */
    --panel-bg:     #121c28;
    --panel-border: #263446;
    --input-bg:     #101923;
    --input-border: #2c3a4b;
    --well-bg:      rgba(15, 23, 34, 0.55);
    --hairline:     rgba(69, 71, 90, 0.4);
    --row-line:     rgba(49, 50, 68, 0.6);

    /* Layout, type, depth */
    --sidebar-w: 214px;
    --radius-sm: 5px;
    --radius:    8px;
    --radius-lg: 12px;
    --transition: 0.15s ease;
    --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", "SF Mono", monospace;
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --text-xs: 0.72rem;
    --text-sm: 0.82rem;
    --text-md: 0.88rem;
    --text-lg: 1.05rem;
    --text-xl: 1.45rem;
    --space-xs:  8px;
    --space-sm:  14px;
    --space-md:  18px;
    --space-lg:  22px;
    --space-xl:  30px;
    --shadow-1: 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-3: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

html {
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-sans);
    background: var(--base);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-bright); text-decoration: none; }

ul, ol { list-style: none; }

/* --- Layout ------------------------------------------------------------ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar ----------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--mantle);
    border-right: 1px solid var(--surface1);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--hairline);
    position: relative;
}

/* subtle glow line under header */
.sidebar-header::after { display: none; }

.sidebar-logo {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0;
    line-height: 1.2;
}

.sidebar-subtitle {
    display: block;
    font-size: 0.72rem;
    color: var(--overlay0);
    letter-spacing: 0.04em;
    margin-top: 3px;
}

/* Sidebar brand (alternate class from original) */
.sidebar-brand {
    padding: 20px 22px 16px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 6px 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav li { margin: 1px 0; }

.sidebar-nav a,
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 18px;
    color: var(--subtext0);
    font-size: 0.84rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all var(--transition);
    position: relative;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav .nav-link:hover {
    background: var(--hover-row);
    color: var(--text);
}

.sidebar-nav a.active,
.sidebar-nav .nav-link.active {
    color: var(--blue);
    border-left-color: var(--blue);
    background: rgba(137, 180, 250, 0.07);
}

/* Glow behind active item */
.sidebar-nav a.active::before,
.sidebar-nav .nav-link.active::before { display: none; }

.sidebar-nav .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav .nav-link.active .nav-icon {
    opacity: 1;
}

.sidebar-section {
    padding: 12px 18px 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--overlay0);
}

.sidebar-footer {
    padding: 10px 18px;
    border-top: 1px solid var(--hairline);
}

.sidebar-footer .nav-link,
.sidebar-footer a {
    color: var(--overlay1);
    font-size: 0.82rem;
    padding: 6px 0;
    display: block;
    border-left: none;
}

.sidebar-footer a:hover { color: var(--red); }

.logout-link { color: var(--overlay1) !important; }
.logout-link:hover { color: var(--red) !important; }

/* --- Analytics shell --------------------------------------------------- */
.admin-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-width: 0;
}

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 2px;
}

.page-subtitle {
    color: var(--subtext0);
    max-width: 760px;
    margin-top: -8px;
}

.filter-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-bar.wide {
    max-width: 920px;
}

.filter-bar select,
.filter-bar input {
    min-height: 32px;
    min-width: 104px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    padding: 5px 9px;
    font: inherit;
}

.filter-bar input {
    width: 140px;
}

.btn {
    min-height: 32px;
    border: 1px solid var(--surface2);
    border-radius: var(--radius-sm);
    background: var(--surface0);
    color: var(--text);
    padding: 6px 12px;
    font: inherit;
    cursor: pointer;
}

.btn-primary {
    background: var(--blue);
    border-color: var(--blue);
    color: var(--crust);
    font-weight: 700;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
}

.metric-card {
    min-height: 92px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    background: var(--panel-bg);
    padding: 13px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-card span,
.panel-kicker {
    color: var(--subtext0);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-card strong {
    font-size: 1.55rem;
    line-height: 1.1;
    color: var(--text);
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.metric-card small {
    color: var(--overlay1);
}

.analytics-grid {
    display: grid;
    gap: 14px;
}

.analytics-grid.two {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

.panel {
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    background: var(--panel-bg);
    padding: 14px;
    min-width: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
}

.panel-header h2 {
    font-size: 1rem;
    color: var(--text);
    letter-spacing: 0;
}

.chart-wrap {
    height: 312px;
    min-height: 240px;
    position: relative;
}

.chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.data-table.dense {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.data-table.dense th,
.data-table.dense td {
    border-bottom: 1px solid var(--surface1);
    padding: 8px 7px;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.data-table.dense th {
    color: var(--subtext0);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.72rem;
}

.empty-state.compact {
    padding: 22px;
    color: var(--subtext0);
    border: 1px dashed var(--surface2);
    border-radius: var(--radius);
    background: var(--input-bg);
}

.alert.error {
    border: 1px solid rgba(230, 95, 92, 0.4);
    background: rgba(230, 95, 92, 0.12);
    color: #ffb3b1;
    border-radius: var(--radius);
    padding: 10px 12px;
}

@media (max-width: 980px) {
    .admin-header {
        flex-direction: column;
    }
    .filter-bar {
        width: 100%;
        justify-content: flex-start;
    }
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .analytics-grid.two {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    :root { --sidebar-w: 0px; }
    .sidebar {
        display: none;
    }
    .layout {
        display: block;
    }
    .main {
        margin-left: 0;
    }
    .content {
        padding: 14px;
    }
    .metric-grid {
        grid-template-columns: 1fr;
    }
    .filter-bar select,
    .filter-bar input,
    .filter-bar .btn {
        width: 100%;
    }
    .chart-wrap {
        height: 260px;
    }
}

/* --- Main content area ------------------------------------------------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--base);
}

.content {
    flex: 1;
    padding: 18px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

/* --- Page titles ------------------------------------------------------- */
.page-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: var(--space-md);
    letter-spacing: -0.01em;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: var(--space-md);
}

.page-header h1,
.page-header h2 {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.page-header p {
    color: var(--subtext0);
    font-size: 0.88rem;
    margin-top: 4px;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--subtext1);
    margin: var(--space-lg) 0 var(--space-sm);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hairline);
}

/* --- Stat cards -------------------------------------------------------- */
.card-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: var(--space-md);
}

.stat-card {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 14px 16px;
    border-top: 3px solid var(--blue);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}

/* Color variants via nth-child for dashboard rows */
.card-row .stat-card:nth-child(3) { border-top-color: var(--teal); }
.card-row .stat-card:nth-child(4) { border-top-color: var(--peach); }
.card-row + .card-row .stat-card:nth-child(1) { border-top-color: var(--green); }
.card-row + .card-row .stat-card:nth-child(2) { border-top-color: var(--mauve); }
.card-row + .card-row .stat-card:nth-child(3) { border-top-color: var(--yellow); }
.card-row + .card-row .stat-card:nth-child(4) { border-top-color: var(--red); }

.stat-value {
    font-size: 1.55rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--overlay1);
    margin-top: 8px;
}

/* Status dot inside stat cards */
.status-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-online  { background: var(--green); box-shadow: 0 0 8px rgba(166, 227, 161, 0.5); }
.status-offline { background: var(--red); box-shadow: 0 0 8px rgba(243, 139, 168, 0.4); }

/* --- Generic cards (legacy compat) ------------------------------------- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: var(--space-lg);
}

.card {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid transparent;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
    border-color: var(--surface1);
    box-shadow: var(--shadow-1);
    transform: translateY(-1px);
}

.card-label {
    font-size: 0.76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--overlay1);
    margin-bottom: 8px;
}

.card-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.card-value.blue   { color: var(--blue); }
.card-value.green  { color: var(--green); }
.card-value.red    { color: var(--red); }
.card-value.yellow { color: var(--yellow); }
.card-value.peach  { color: var(--peach); }
.card-value.mauve  { color: var(--mauve); }

.card-footer {
    margin-top: 10px;
    font-size: 0.8rem;
    color: var(--subtext0);
}

/* --- Panels ------------------------------------------------------------ */
.panel {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: var(--space-md);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

/* --- Config sections --------------------------------------------------- */
.config-section {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
}

.config-section .section-title {
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--space-sm);
}

/* --- Tables ------------------------------------------------------------ */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table,
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table thead th,
thead th {
    text-align: left;
    padding: 8px 10px;
    font-weight: 600;
    font-size: 0.73rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--overlay1);
    border-bottom: 2px solid var(--surface1);
    white-space: nowrap;
    background: transparent;
}

.data-table tbody td,
tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--row-line);
    color: var(--subtext1);
    transition: background var(--transition);
}

.data-table tbody tr:hover,
tbody tr:hover {
    background: var(--hover-row);
}

/* No zebra striping -- clean horizontal lines only */
.data-table tbody tr:nth-child(even),
tbody tr:nth-child(even) {
    background: transparent;
}
.data-table tbody tr:nth-child(even):hover,
tbody tr:nth-child(even):hover {
    background: var(--hover-row);
}

.action-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Monospace cells */
td.mono, .mono {
    font-family: var(--font-mono);
    font-size: 0.82em;
    letter-spacing: -0.01em;
}

/* --- Badges ------------------------------------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    padding: 3px 11px;
    border-radius: 999px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.badge::before {
    content: "";
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge.green,
.badge-ok,
.badge-success     { color: var(--green); background: var(--tint-green); }
.badge.green::before,
.badge-ok::before,
.badge-success::before { background: var(--green); }

.badge.yellow,
.badge-warn,
.badge-warning     { color: var(--yellow); background: var(--tint-yellow); }
.badge.yellow::before,
.badge-warn::before,
.badge-warning::before { background: var(--yellow); }

.badge.red,
.badge-off,
.badge-danger,
.badge-error       { color: var(--red); background: var(--tint-red); }
.badge.red::before,
.badge-off::before,
.badge-danger::before,
.badge-error::before { background: var(--red); }

.badge.blue,
.badge-info         { color: var(--blue); background: var(--tint-blue); }
.badge.blue::before,
.badge-info::before { background: var(--blue); }

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
}

.admin-table th {
    color: var(--subtext0);
    font-size: 11px;
    text-transform: uppercase;
    cursor: pointer;
}

.table-shell,
.empty-state {
    min-height: 44px;
}

.badge-tier {
    color: var(--mauve);
    background: var(--tint-mauve);
}
.badge-tier::before { background: var(--mauve); }

/* Dot indicators */
.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    vertical-align: middle;
}
.dot.green  { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red    { background: var(--red); }

/* --- Token bar --------------------------------------------------------- */
.token-bar-container {
    width: 100%;
    height: 6px;
    background: var(--surface1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.token-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.token-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--teal));
    border-radius: 3px;
    transition: width 0.4s ease;
}

.token-text {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--subtext0);
}

/* --- Forms ------------------------------------------------------------- */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--subtext1);
    margin-bottom: 6px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
    min-width: 160px;
}

.form-group-btn {
    display: flex;
    gap: 8px;
    padding-bottom: 18px;
}

.form-input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--crust);
    border: 1px solid var(--surface1);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--tint-blue), 0 0 12px rgba(137, 180, 250, 0.06);
}

input::placeholder,
textarea::placeholder {
    color: var(--overlay0);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: var(--font-sans);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237f849c'%3E%3Cpath d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* Inline form */
.inline-form {
    background: var(--surface0);
    border-radius: var(--radius);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--surface1);
}

/* Key display */
.key-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--crust);
    border: 1px solid var(--surface1);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin: 12px 0 8px;
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--green);
    word-break: break-all;
}

.key-display span { flex: 1; }

.key-warning {
    color: var(--yellow);
    font-size: 0.82rem;
    font-weight: 500;
}

/* --- Buttons ----------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 20px;
    font-size: 0.86rem;
    font-weight: 600;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--blue);
    color: var(--crust);
}
.btn-primary:hover {
    background: var(--blue-bright);
    box-shadow: 0 2px 12px rgba(137, 180, 250, 0.25);
}

.btn-danger {
    background: var(--red);
    color: var(--crust);
}
.btn-danger:hover {
    background: var(--red-bright);
    box-shadow: 0 2px 12px rgba(243, 139, 168, 0.2);
}

.btn-success {
    background: var(--green);
    color: var(--crust);
}

.btn-secondary,
.btn-ghost {
    background: transparent;
    color: var(--subtext0);
    border: 1px solid var(--surface1);
}

.btn-secondary:hover,
.btn-ghost:hover {
    background: var(--surface0);
    color: var(--text);
    border-color: var(--surface2);
}

.btn-secondary.active {
    background: var(--tint-blue);
    color: var(--blue);
    border-color: rgba(137, 180, 250, 0.3);
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* --- Filter bar -------------------------------------------------------- */
.filter-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.page-header.compact {
    margin-bottom: 14px;
}

.compact-stats {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.ops-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    gap: 12px;
}

.tight-panel {
    padding: 12px;
    margin-bottom: 12px;
}

.tight-panel .panel-header {
    margin-bottom: 10px;
}

.dense-table {
    font-size: 0.8rem;
}

.empty-state {
    color: var(--overlay1);
    text-align: center;
    padding: 18px;
}

/* --- Toggle switch ----------------------------------------------------- */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 40px; height: 22px;
    background: var(--surface1);
    border-radius: 11px;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: var(--text);
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle input:checked + .toggle-slider {
    background: var(--blue);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(18px);
    background: var(--crust);
}

.toggle-label {
    font-size: 0.88rem;
    color: var(--subtext1);
}

/* --- Login page -------------------------------------------------------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--crust);
    background-image:
        radial-gradient(ellipse 600px 400px at 30% 20%, var(--hover-row), transparent),
        radial-gradient(ellipse 500px 350px at 70% 80%, rgba(203, 166, 247, 0.03), transparent);
}

/* Also support .login-page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--crust);
}

.login-card {
    background: var(--surface0);
    border-radius: 12px;
    padding: 44px 38px 38px;
    width: 100%;
    max-width: 390px;
    box-shadow:
        var(--shadow-2),
        0 0 0 1px var(--hairline);
    position: relative;
    overflow: hidden;
}

/* Animated gradient border glow */
.login-card::before {
    content: "";
    position: absolute;
    top: -1px; left: -1px; right: -1px;
    height: 3px;
    background: linear-gradient(90deg, var(--blue), var(--mauve), var(--teal), var(--blue));
    background-size: 300% 100%;
    animation: loginGlow 6s linear infinite;
    border-radius: 12px 12px 0 0;
}

@keyframes loginGlow {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}

.login-title,
.login-card h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--blue);
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--overlay1);
    font-size: 0.85rem;
    margin-bottom: var(--space-lg);
}

.login-card .btn {
    width: 100%;
    margin-top: 8px;
    padding: 11px 20px;
}

.login-error {
    background: rgba(243, 139, 168, 0.08);
    color: var(--red);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
    border-left: 3px solid var(--red);
}

/* --- Log viewer -------------------------------------------------------- */
.log-viewer {
    background: var(--crust);
    border: 1px solid var(--row-line);
    border-radius: var(--radius);
    padding: 18px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    line-height: 1.75;
    color: var(--subtext0);
    overflow-x: auto;
    max-height: 560px;
    overflow-y: auto;
    white-space: pre;
}

.log-line {
    padding: 1px 0 1px 10px;
    border-left: 2px solid transparent;
    transition: background var(--transition);
}

.log-line:hover {
    background: rgba(137, 180, 250, 0.03);
}

.log-line.log-error,
.log-viewer .log-error {
    color: var(--red);
    border-left-color: var(--red);
}

.log-line.log-warn,
.log-line.log-warning,
.log-viewer .log-warning {
    color: var(--yellow);
    border-left-color: var(--yellow);
}

.log-line.log-info,
.log-viewer .log-info {
    color: var(--blue);
    border-left-color: var(--blue);
}

/* --- Modal ------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 17, 27, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--surface0);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow:
        var(--shadow-3),
        0 0 0 1px var(--hairline);
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    color: var(--overlay1);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all var(--transition);
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
    background: var(--surface1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: var(--space-md);
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
}

/* --- Cost calculator --------------------------------------------------- */
.calc-result {
    background: var(--crust);
    border: 1px solid var(--surface1);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.92rem;
    color: var(--subtext1);
}

.calc-result strong {
    color: var(--green);
    font-family: var(--font-mono);
}

.calc-sep {
    color: var(--surface2);
}

/* --- Utility classes --------------------------------------------------- */
.text-muted  { color: var(--overlay1); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue   { color: var(--blue); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

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

/* --- Scrollbar (Webkit) ------------------------------------------------ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface2); }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--surface1) transparent; }

/* --- Animations -------------------------------------------------------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease forwards; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.pulse { animation: pulse 2s ease-in-out infinite; }

/* --- Menu toggle (mobile) ---------------------------------------------- */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
}

/* --- Responsive -------------------------------------------------------- */
@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        width: 232px;
    }

    .sidebar.open { transform: translateX(0); }

    .main { margin-left: 0; }

    .card-row,
    .card-grid { grid-template-columns: 1fr 1fr; }

    .ops-grid { grid-template-columns: 1fr; }

    .content { padding: 18px; }

    .menu-toggle { display: block !important; }

    .form-row { flex-direction: column; }

    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .card-row,
    .card-grid { grid-template-columns: 1fr; }

    .login-card {
        margin: 0 16px;
        padding: 28px 22px;
    }
}

/* --- Topbar (legacy compat) -------------------------------------------- */
.topbar {
    height: 56px;
    background: var(--mantle);
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-actions a {
    color: var(--subtext0);
    font-size: 0.85rem;
    transition: color var(--transition);
}

.topbar-actions a:hover { color: var(--text); }

/* --- Ops Cockpit (plan M2) ---------------------------------------------- */
/* Progressive disclosure: lights + money above the fold, one attention
   feed, two compact cards below. White space is intentional. */

.cockpit-refresh {
    font-size: 0.75rem;
    color: var(--overlay1);
    font-family: var(--font-mono);
    white-space: nowrap;
}

.cockpit-lights {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.light-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.light-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.light-dot.g { background: var(--green); box-shadow: 0 0 8px rgba(166, 227, 161, 0.5); }
.light-dot.a { background: var(--yellow); box-shadow: 0 0 8px rgba(249, 226, 175, 0.5); }
.light-dot.r { background: var(--red); box-shadow: 0 0 8px rgba(243, 139, 168, 0.5); }
.light-dot.u { background: var(--overlay0); }

.light-body { min-width: 0; display: flex; flex-direction: column; }

.light-name {
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--subtext1);
}

.light-name:hover { color: var(--blue); }

.light-sub {
    font-size: 0.76rem;
    color: var(--overlay1);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cockpit-money {
    display: flex;
    align-items: flex-start;
    gap: 48px;
    background: var(--surface0);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 18px;
    position: relative;
}

.money-headline { display: flex; flex-direction: column; }

.money-headline .label {
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--overlay1);
}

.money-headline strong {
    font-size: 2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    margin-top: 2px;
}

.money-headline small {
    font-size: 0.75rem;
    color: var(--overlay1);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.details-link {
    font-size: 0.78rem;
    color: var(--overlay1);
    white-space: nowrap;
}

.details-link:hover { color: var(--blue); }

.money-link { position: absolute; top: 14px; right: 16px; }

.cockpit-attention { margin-bottom: 18px; }

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

.attention-feed li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 2px;
    border-bottom: 1px solid var(--row-line);
    font-size: 0.85rem;
}

.attention-feed li:last-child { border-bottom: none; }

.attention-empty { color: var(--overlay1); padding: 10px 2px; }

.sev-chip {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 8px;
    border-radius: 999px;
    flex-shrink: 0;
}

.sev-chip.crit { color: var(--red); background: var(--tint-red); }
.sev-chip.warn { color: var(--yellow); background: var(--tint-yellow); }
.sev-chip.info { color: var(--blue); background: var(--tint-blue); }

.attention-time {
    font-family: var(--font-mono);
    font-size: 0.73rem;
    color: var(--overlay0);
    white-space: nowrap;
    flex-shrink: 0;
}

.attention-text { color: var(--subtext1); min-width: 0; flex: 1; }

.attention-text small { color: var(--overlay1); }

.attention-link { font-size: 0.75rem; white-space: nowrap; }

.cockpit-queue-note {
    font-size: 0.76rem;
    color: var(--overlay1);
    font-family: var(--font-mono);
    margin-top: 8px;
}

@media (max-width: 980px) {
    .cockpit-lights { grid-template-columns: repeat(2, 1fr); }
    .cockpit-money { flex-wrap: wrap; gap: 24px; }
}

/* ==========================================================================
   Public pages & user portal shared components (plan P2)
   One card/badge/form language for /plans, /legal/*, auth screens,
   /app/checkout, /app/billing and the rest of the user portal. Templates
   reference these classes instead of page-local <style> blocks.
   ========================================================================== */

/* --- Auth shell extras -------------------------------------------------- */
.login-card.login-card-wide   { max-width: 1100px; }
.login-card.login-card-medium { max-width: 760px; }

.auth-footer {
    text-align: center;
    margin-top: var(--space-md);
    font-size: 0.85rem;
    color: var(--overlay1);
}

.auth-divider {
    text-align: center;
    color: var(--overlay1);
    font-size: 0.85rem;
    margin: 20px 0 12px;
}

.auth-actions { text-align: center; margin-top: 20px; }

.icon-inline { flex-shrink: 0; }

/* --- Notes & alerts ------------------------------------------------------ */
.alert-success {
    background: rgba(166, 227, 161, 0.08);
    border-left: 3px solid var(--green);
    color: var(--green);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.alert-warning {
    background: rgba(249, 226, 175, 0.08);
    border-left: 3px solid var(--yellow);
    border-radius: var(--radius-sm);
    padding: 14px var(--space-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.alert-warning .alert-text { color: var(--yellow); font-size: var(--text-md); }

.note-info {
    background: rgba(137, 180, 250, 0.08);
    border: 1px solid rgba(137, 180, 250, 0.22);
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: var(--space-md);
}

.note-info .note-title { color: var(--text); font-weight: 600; margin-bottom: 8px; }
.note-info .note-body  { color: var(--subtext0); font-size: var(--text-md); line-height: 1.55; margin: 0; }

.key-callout {
    background: rgba(166, 227, 161, 0.08);
    border: 1px solid rgba(166, 227, 161, 0.2);
    padding: var(--space-md);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.key-callout .key-title { color: var(--green); font-weight: 600; margin-bottom: 8px; }

/* --- Form extras --------------------------------------------------------- */
.form-consent { display: flex; gap: 8px; align-items: flex-start; }
.form-consent input[type="checkbox"] { margin-top: 3px; }
.form-consent label {
    font-size: 0.8rem;
    color: var(--overlay1);
    font-weight: 400;
    margin: 0;
    display: inline;
}

.form-hint { color: var(--overlay1); font-size: 0.75rem; margin: 6px 0 0; }

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

/* --- Plan / catalog cards (public /plans, /app/register) ----------------- */
.plans-grid,
.packs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-sm);
}

.plans-grid { margin-top: 10px; }

.plan-card {
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--well-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.plan-card:hover {
    border-color: var(--overlay0);
    transform: translateY(-2px);
    box-shadow: var(--shadow-1);
}

.plan-featured,
.plan-featured:hover { border-color: var(--mauve); }

.plan-card header h2 {
    color: var(--mauve);
    font-size: var(--text-lg);
    margin: 0 0 4px;
}

.plan-price {
    color: var(--yellow);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.plan-price span {
    color: var(--overlay1);
    font-size: 0.8rem;
    font-weight: 400;
}

.plan-card dl {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    margin: 0;
    font-size: var(--text-sm);
    flex: 1;
}

.plan-card dt { color: var(--overlay1); }
.plan-card dd { color: var(--text); margin: 0; font-weight: 600; text-align: right; }

.plans-section-title { color: var(--text); font-size: 1rem; margin: 24px 0 4px; }
.plans-muted { color: var(--overlay1); font-size: var(--text-sm); margin: 0 0 10px; }

.signup-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.95fr) minmax(360px, 1.35fr);
    gap: 24px;
    align-items: start;
}

.catalog-panel h2 { color: var(--text); font-size: 0.95rem; margin: 0 0 8px; }
.catalog-panel h2.catalog-gap { margin-top: 16px; }

.catalog-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.token-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.catalog-card {
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 10px;
    background: var(--well-bg);
    min-width: 0;
}

.catalog-card > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.catalog-card strong { color: var(--mauve); font-size: 0.94rem; }
.catalog-card span   { color: var(--yellow); font-weight: 600; white-space: nowrap; }

.catalog-card dl {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 8px;
    margin: 0;
    font-size: 0.78rem;
}

.catalog-card dt,
.catalog-muted { color: var(--overlay1); }
.catalog-card dd { color: var(--text); margin: 0; font-weight: 600; text-align: right; }
.catalog-card p  { color: var(--text); margin: 0 0 4px; font-size: var(--text-sm); }

@media (max-width: 900px) {
    .signup-grid { grid-template-columns: 1fr; }
    .catalog-list,
    .token-list { grid-template-columns: 1fr; }
}

/* --- Legal pages ---------------------------------------------------------- */
.legal-meta {
    text-align: center;
    color: var(--overlay1);
    font-size: 0.8rem;
    margin-bottom: var(--space-md);
}

.legal-section h2 {
    color: var(--mauve);
    font-size: 1rem;
    margin: 20px 0 8px;
}

.legal-section p {
    color: var(--subtext1);
    font-size: 0.9rem;
    line-height: 1.7;
    margin: 0 0 10px;
}

/* --- Checkout ------------------------------------------------------------- */
.checkout-card { max-width: 560px; }

.checkout-tier { color: var(--mauve); margin-top: 0; }

.checkout-price {
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 700;
    margin: 4px 0 16px;
    font-variant-numeric: tabular-nums;
}

.checkout-price span { color: var(--overlay1); font-size: 0.85rem; font-weight: 400; }

.checkout-note { color: var(--overlay1); font-size: 0.9rem; }

/* --- Billing portal -------------------------------------------------------- */
.billing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-md);
}

.billing-h2 { color: var(--mauve); font-size: 0.95rem; margin: 0 0 12px; }

.billing-dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 18px;
    margin: 0;
    font-size: var(--text-md);
}

.billing-dl dt { color: var(--overlay1); }
.billing-dl dd { color: var(--text); margin: 0; font-weight: 600; }

.billing-muted { color: var(--overlay1); font-size: 0.8rem; margin: 8px 0 0; }

.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface1);
    color: var(--text);
}

.status-active,
.status-trial { color: var(--green); }
.status-past_due,
.status-pending_payment { color: var(--yellow); }
.status-cancelled,
.status-suspended { color: var(--red); }
.status-checkout_expired { color: var(--overlay1); }

.status-note { font-size: 0.85rem; margin-top: 12px; }
.status-note.ok     { color: var(--green); }
.status-note.warn   { color: var(--yellow); }
.status-note.danger { color: var(--red); }
.status-note.muted  { color: var(--overlay1); }

.packs-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.pack-tile {
    border: 1px solid var(--surface2);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--well-bg);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pack-tile strong { color: var(--mauve); font-size: 0.9rem; }
.pack-tile span   { color: var(--text); font-size: var(--text-sm); }

/* --- Portal dashboard ------------------------------------------------------ */
.summary-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.35fr);
    gap: 16px;
    margin-bottom: var(--space-md);
}

.detail-list { display: grid; gap: 12px; }

.detail-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--hairline);
}

.detail-row:last-child { border-bottom: none; padding-bottom: 0; }

.detail-label {
    color: var(--overlay1);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.detail-value {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

.detail-grid {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    font-size: 0.9rem;
}

.quota-list { display: grid; gap: 14px; }

.quota-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 6px;
}

.quota-name  { color: var(--subtext1); font-weight: 600; }

.quota-count {
    color: var(--overlay1);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

.quota-track {
    height: 7px;
    border-radius: 999px;
    background: rgba(108, 112, 134, 0.25);
    overflow: hidden;
}

.quota-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--blue));
}

.muted-note { color: var(--overlay0); font-size: var(--text-sm); margin-top: 12px; }

.setup-list {
    color: var(--subtext0);
    font-size: var(--text-md);
    padding-left: 20px;
    line-height: 2;
    list-style: decimal;
}

/* CSS bar chart (portal usage page) */
.bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 0 4px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.bar-track { flex: 1; display: flex; align-items: flex-end; width: 100%; }

.bar-fill {
    width: 100%;
    min-height: 2px;
    background: linear-gradient(180deg, var(--blue), var(--teal));
    border-radius: 3px 3px 0 0;
    transition: height 0.3s;
}

.bar-label {
    font-size: 0.65rem;
    color: var(--overlay0);
    margin-top: 4px;
    white-space: nowrap;
}

/* --- Small utilities (spacing on tokens) ----------------------------------- */
.mt-md { margin-top: var(--space-md); }
.mb-md { margin-bottom: var(--space-md); }
.ml-xs { margin-left: var(--space-xs); }
.text-center { text-align: center; }

.empty-cell {
    text-align: center;
    color: var(--overlay0);
    padding: 24px;
}

@media (max-width: 900px) {
    .summary-grid { grid-template-columns: 1fr; }
    .detail-row { align-items: flex-start; flex-direction: column; gap: 4px; }
    .detail-value { text-align: left; }
}
