/* SimulaLab Audit — dark theme.
   Palette per user request: bg #202123, card #2A2B32, panel #343541,
   text #ECECF1 / muted #C5C5D2, accent #A78BFA. */

:root {
    --bg:        #202123;
    --card:      #2A2B32;
    --panel:     #343541;
    --panel-2:   #3E3F4A;
    --border:    #3A3B45;
    --text:      #ECECF1;
    --muted:     #C5C5D2;
    --accent:    #A78BFA;
    --accent-2:  #8B6FF0;
    --ok:        #4ADE80;
    --warn:      #FBBF24;
    --danger:    #F87171;
    --info:      #60A5FA;

    --radius:    10px;
    --radius-lg: 14px;
    --shadow:    0 1px 3px rgba(0,0,0,0.4);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

/* ===== top nav ===== */
.topnav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand .dot {
    width: 9px; height: 9px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--accent);
}
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a, .nav-links button.nav-btn {
    color: var(--muted);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 14px;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.nav-links a:hover, .nav-links button.nav-btn:hover { background: var(--panel); color: var(--text); }
.nav-links a.active { color: var(--text); background: var(--panel); }

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 180px;
    box-shadow: var(--shadow);
    padding: 6px;
}
.dropdown-menu a, .dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    color: var(--text);
    padding: 8px 12px;
    border-radius: 6px;
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--panel); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }

.user-chip {
    display: flex; gap: 8px; align-items: center;
    padding: 4px 10px 4px 4px;
    border-radius: 999px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 13px;
}
.user-chip img { width: 24px; height: 24px; border-radius: 50%; }

/* ===== main ===== */
main { padding: 24px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 18px; }
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}
.page-header .page-mark {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(167,139,250,0.25);
}
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; color: var(--text); }

/* ===== cards ===== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 16px;
}
.card .title { font-size: 13px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ===== stat grid ===== */
.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
/* cards inside grids get no extra bottom margin — gap handles spacing */
.grid > .card { margin-bottom: 0; }

/* ===== stats row (4 stats + reload block side by side) ===== */
.stats-row {
    display: flex;
    gap: 14px;
    align-items: stretch;
    margin-bottom: 16px;
}
.stats-row > .grid {
    flex: 1;
    margin-bottom: 0; /* stats-row handles outer spacing */
}

/* ===== reload card ===== */
.reload-card {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    margin-bottom: 0;
    flex-shrink: 0;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
}
.reload-card:hover { background: var(--panel); }
.reload-card:active { background: var(--panel-2); }
.reload-icon {
    width: 54px; height: 54px;
    color: var(--accent);
    display: block;
}
@keyframes reload-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.reload-card.spinning .reload-icon {
    animation: reload-spin 0.45s cubic-bezier(.4,0,.2,1);
}
.pin-btn {
    position: absolute;
    bottom: 10px; left: 10px;
    width: 28px; height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.pin-btn:hover { background: var(--panel-2); color: var(--text); }
.pin-btn.active {
    background: rgba(167,139,250,0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.stat .num { font-size: 28px; font-weight: 600; color: var(--text); }
.stat .num.pending { color: var(--muted); font-size: 18px; font-style: italic; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* ===== forms ===== */
form.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    align-items: end;
}
/* action buttons always on their own full-width row, never wrap */
form.filters .actions {
    grid-column: 1 / -1;
    flex-wrap: nowrap;
    justify-content: flex-start;
}
label {
    color: var(--muted);
    font-size: 12px;
    display: block;
    margin-bottom: 4px;
}
input, select, textarea {
    width: 100%;
    padding: 9px 10px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    /* force browser to render native chrome (dropdowns, date pickers) in dark */
    color-scheme: dark;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167,139,250,0.18);
}
/* date-picker calendar icon tint */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

button, .btn {
    display: inline-block;
    padding: 9px 14px;
    background: var(--accent);
    color: #1A1B25;
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
button:hover, .btn:hover { background: var(--accent-2); color: #ffffff; }
.btn.secondary {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--panel-2); }
.btn.danger { background: var(--danger); color: #1A1B25; }
.btn.danger:hover { background: #ef4444; color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }

/* ===== scrollbars ===== */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--panel-2); }
::-webkit-scrollbar-corner { background: var(--bg); }
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--bg); }

/* ===== tables ===== */
.table-wrap {
    overflow-x: auto;
    margin-left: -18px;
    margin-right: -18px;
    padding-left: 18px;
    padding-right: 18px;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: max-content;
}
th, td {
    border-bottom: 1px solid var(--border);
    padding: 9px 10px;
    vertical-align: middle;
    text-align: center;
}
th {
    background: var(--panel);
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    /* sticky disabled: overflow-x on .table-wrap breaks sticky vertical behaviour */
}
/* keep sort links centered within the now-centered header cells */
th .th-sort { justify-content: center; }
tr:hover td { background: rgba(167,139,250,0.04); }

.th-sort {
    color: var(--muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.th-sort:hover { color: var(--text); }
.th-sort.active { color: var(--accent); }
.th-sort .arrow { font-size: 9px; }

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--border);
    font-size: 11px;
    color: var(--text);
}
.pill.accent { background: rgba(167,139,250,0.18); border-color: var(--accent); color: var(--accent); }
.pill.ok     { background: rgba(74,222,128,0.13); border-color: var(--ok); color: var(--ok); }
.pill.warn   { background: rgba(251,191,36,0.13); border-color: var(--warn); color: var(--warn); }
.pill.danger { background: rgba(248,113,113,0.13); border-color: var(--danger); color: var(--danger); }

.muted { color: var(--muted); }
.danger { color: var(--danger); }
.ok { color: var(--ok); }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.right { text-align: right; }
.mono { font-family: ui-monospace, "JetBrains Mono", Menlo, Monaco, Consolas, monospace; font-size: 12px; }

pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 12px;
    border-radius: var(--radius);
    max-height: 500px;
    overflow: auto;
    font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
    font-size: 12px;
    color: var(--text);
}

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

/* ===== login ===== */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: radial-gradient(ellipse at top, rgba(167,139,250,0.12), transparent 60%), var(--bg);
}
.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px 32px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}
.login-card .tagline-hero {
    text-align: center;
    color: var(--accent);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 6px 0 32px;
}
.login-card .btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    background: #fff;
    color: #1F1F1F;
    font-weight: 500;
    border-radius: 10px;
    border: 0;
    font-size: 14px;
    cursor: pointer;
}
.login-card .btn-google:hover { background: #f3f4f6; }
.login-card .err {
    background: rgba(248,113,113,0.10);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
}
.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--muted);
}
.login-card .divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--muted);
    font-size: 12px;
}
.login-card .divider::before,
.login-card .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.login-card .footer {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 22px;
}

/* ===== health strip ===== */
.health-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}
.health-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.health-item .dot {
    width: 8px; height: 8px; border-radius: 50%;
}
.health-item .dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.health-item .dot.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.health-item .dot.danger { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.health-item .lbl { font-size: 12px; color: var(--muted); }
.health-item .val { font-size: 14px; color: var(--text); font-weight: 500; }

/* ===== unattended worker + task boards ===== */

/* two equal-width, equal-height cards side by side */
.board-grid {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
}
.board-card { display: flex; flex-direction: column; }
.board-card > div[id] {        /* the htmx-swapped board body */
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* counters: one line, glowing colored dots (like the brand dot) */
.worker-counts-strip {
    display: flex;
    align-items: center;
    gap: 22px;
    padding-bottom: 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.wc-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}
.wc-item b { font-weight: 700; font-size: 15px; color: var(--text); }
.wc-item .dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

/* glowing status dots — counters + in-table state cell */
.wc-item .dot.ok,       #workers-board td .dot.ok     { background: var(--ok);     box-shadow: 0 0 10px var(--ok); }
.wc-item .dot.warn,     #workers-board td .dot.warn   { background: var(--warn);   box-shadow: 0 0 10px var(--warn); }
.wc-item .dot.danger,   #workers-board td .dot.danger { background: var(--danger); box-shadow: 0 0 10px var(--danger); }
#workers-board td .dot {
    display: inline-block;
    width: 9px; height: 9px; border-radius: 50%;
    margin-right: 5px; vertical-align: middle;
}

/* pending-approval worker: pulsing violet dot + faint row tint */
.wc-item .dot.pending,
#workers-board td .dot.pending { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
@keyframes wpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.dot.pending { animation: wpulse 1.4s ease-in-out infinite; }
#workers-board tr.row-pending td { background: rgba(167, 139, 250, 0.07); }

/* rejected worker: muted gray marker — deliberately NOT the red offline dot */
.wc-item .dot.rejected,
#workers-board td .dot.rejected { background: var(--muted); box-shadow: none; }

/* approve / reject / revoke — same pill style as the Coda dispatching recall (✕) */
.board-scroll td.cell-actions { overflow: visible; text-align: center; }
.wact { margin: 0 2px; }
.btn-approve {
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    background: transparent;
    color: var(--ok);
    border: 1px solid var(--ok);
    border-radius: 6px;
    cursor: pointer;
}
.btn-approve:hover { background: var(--ok); color: #1A1B25; }
.btn-del {
    padding: 3px 8px;
    line-height: 1;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
.btn-del svg { width: 13px; height: 13px; display: block; }
.btn-del:hover { background: var(--danger); color: #1A1B25; }

/* scrollable body — header + 7 rows visible, rest scrolls (max 70 in data) */
.board-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 332px;          /* thead (~40px) + 7 rows (~292px) */
    margin-top: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.board-scroll::-webkit-scrollbar { width: 6px; }
.board-scroll::-webkit-scrollbar-track { background: transparent; }
.board-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.board-scroll::-webkit-scrollbar-thumb:hover { background: var(--panel-2); }

/* board tables: fit the card, fixed columns, sticky header, ellipsis overflow */
.board-scroll table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
}
.board-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}
.board-scroll th, .board-scroll td {
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.board-scroll .cell-name,
.board-scroll .cell-task { max-width: 0; }   /* let ellipsis kick in under table-layout:fixed */

/* recall (cancel) button for queued tasks */
.btn-recall {
    padding: 2px 9px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 6px;
    cursor: pointer;
}
.btn-recall:hover { background: var(--danger); color: #1A1B25; }
.btn-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.45;
    transition: opacity .12s ease, color .12s ease, background .12s ease;
}
.btn-retry svg { display: block; }
.btn-retry:hover {
    opacity: 1;
    color: var(--accent);
    background: rgba(167, 139, 250, 0.12);
}

/* ===== chart container ===== */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 340px; }

/* ===== admin: file manager (/settings/files) ===== */
.files-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.files-page h1 { margin: 0 0 2px; }

/* drop zone */
.dropzone {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(120% 140% at 50% -10%, rgba(167,139,250,0.08), transparent 60%),
        var(--card);
    min-height: 132px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .15s, background .15s, transform .05s;
    outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); }
.dropzone.drag {
    border-color: var(--accent);
    background: rgba(167,139,250,0.10);
}
.dz-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dz-icon { width: 30px; height: 30px; color: var(--accent); }
.dz-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dz-sub { font-size: 12px; color: var(--muted); }
.dz-busy { display: none; align-items: center; gap: 10px; color: var(--accent); font-weight: 600; font-size: 14px; }
.dropzone.uploading .dz-inner { display: none; }
.dropzone.uploading .dz-busy { display: flex; }

.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(167,139,250,0.3);
    border-top-color: var(--accent);
    animation: reload-spin .7s linear infinite;
    display: inline-block;
}

/* the two stacked blocks — fixed share of the viewport */
.files-block { height: 46vh; min-height: 240px; display: flex; flex-direction: column; margin-bottom: 0; }
.log-block   { height: 28vh; min-height: 170px; display: flex; flex-direction: column; margin-bottom: 0; }
.files-scroll, .log-scroll { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }

.file-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 8px;
    border-bottom: 1px solid var(--border);
}
.file-row:last-child { border-bottom: 0; }
.file-icon, .file-icon-badge {
    width: 42px; height: 42px;
    border-radius: 9px;
    background: rgba(167,139,250,0.12);
    border: 1px solid var(--border);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
}

/* editable icon cell (auto-extracted or admin-uploaded) */
.file-icon-cell { position: relative; flex: 0 0 auto; }
.file-icon-edit { display: block; width: 42px; height: 42px; cursor: pointer; }
.file-icon-img {
    width: 42px; height: 42px; object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 9px; display: block;
}
.file-icon-edit:hover .file-icon-badge,
.file-icon-edit:hover .file-icon-img { border-color: var(--accent); }
.icon-clear {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px; padding: 0;
    border-radius: 50%; border: 0;
    background: var(--danger); color: #1A1B25;
    font-size: 13px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.icon-clear:hover { background: #ef4444; color: #fff; }
.file-main {
    flex: 1; min-width: 0;
    display: grid;
    grid-template-columns: minmax(120px, 1.1fr) 84px minmax(150px, 1.9fr) auto auto;
    gap: 8px;
    align-items: center;
}
.file-main input { padding: 7px 9px; font-size: 13px; }
.f-title { font-weight: 600; }
.f-version {
    text-align: center;
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
}
.file-meta { font-size: 11px; color: var(--muted); white-space: nowrap; text-align: right; }
.save-btn { white-space: nowrap; }
.file-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }

/* icon buttons (download / delete) */
.icon-btn {
    width: 32px; height: 32px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s, color .12s, border-color .12s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.danger:hover { background: rgba(248,113,113,0.15); color: var(--danger); border-color: var(--danger); }
.del-form { display: inline-flex; margin: 0; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    transition: background .18s, border-color .18s;
}
.switch .slider::before {
    content: ""; position: absolute;
    height: 16px; width: 16px; left: 2px; top: 2px;
    background: var(--muted);
    border-radius: 50%;
    transition: transform .18s, background .18s;
}
.switch input:checked + .slider { background: rgba(167,139,250,0.30); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); background: var(--accent); }

.files-empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 13px; }

/* download log table */
.log-table { font-size: 13px; }
.log-table th { position: sticky; top: 0; z-index: 1; }
.log-table th, .log-table td { text-align: left; }
.log-table .log-email { color: var(--text); }
.log-table .log-file { color: var(--accent); font-weight: 500; }
.log-table tbody tr:hover td { background: rgba(167,139,250,0.05); }

/* ===== public download portal ===== */
.portal-body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    overflow-x: hidden;
}
.portal-bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.portal-bg .blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.55;
    mix-blend-mode: screen;
    will-change: transform;
}
.portal-bg .b1 {
    width: 520px; height: 520px; top: -140px; left: -120px;
    background: radial-gradient(circle, #7C5CF0, transparent 70%);
    animation: float1 18s ease-in-out infinite;
}
.portal-bg .b2 {
    width: 480px; height: 480px; bottom: -160px; right: -100px;
    background: radial-gradient(circle, #6344D8, transparent 70%);
    animation: float2 22s ease-in-out infinite;
}
.portal-bg .b3 {
    width: 360px; height: 360px; top: 40%; left: 55%;
    background: radial-gradient(circle, #A78BFA, transparent 70%);
    opacity: 0.32;
    animation: float3 26s ease-in-out infinite;
}
.portal-bg .grain {
    position: absolute; inset: 0;
    background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 3px 3px;
}
@keyframes float1 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%     { transform: translate(80px,60px) scale(1.12); }
}
@keyframes float2 {
    0%,100% { transform: translate(0,0) scale(1); }
    50%     { transform: translate(-70px,-50px) scale(1.08); }
}
@keyframes float3 {
    0%,100% { transform: translate(-50%,-50%) scale(1); }
    50%     { transform: translate(-60%,-40%) scale(1.18); }
}
@media (prefers-reduced-motion: reduce) {
    .portal-bg .blob { animation: none; }
}

.portal-stage {
    position: relative; z-index: 1;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 32px 20px;
}
.portal-stage.wide { align-items: flex-start; padding-top: 7vh; }

/* access card */
.portal-card {
    width: 100%; max-width: 380px;
    background: rgba(42,43,50,0.72);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 20px;
    padding: 38px 32px 34px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.45);
    text-align: center;
    animation: portal-rise .5s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes portal-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.portal-mark {
    width: 52px; height: 52px; margin: 0 auto 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #7C5CF0, #4527B8);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    box-shadow: 0 8px 22px rgba(124,92,240,0.45);
}
.portal-mark.sm { width: 38px; height: 38px; margin: 0; border-radius: 11px; }
.portal-mark svg { width: 24px; height: 24px; }
.portal-mark.sm svg { width: 18px; height: 18px; }

.portal-h1 {
    font-size: 22px; font-weight: 600; margin: 0 0 6px;
    color: var(--text); letter-spacing: -0.01em;
}
.portal-sub { font-size: 13.5px; color: var(--muted); margin: 0 0 22px; line-height: 1.5; text-wrap: balance; }
.portal-sub strong { color: var(--text); }

.portal-form { display: flex; flex-direction: column; gap: 12px; }
.portal-form input {
    width: 100%; padding: 12px 14px; font-size: 15px; text-align: center;
    background: rgba(20,21,26,0.6);
    border: 1px solid var(--border);
    border-radius: 11px;
}
.portal-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(167,139,250,0.20);
}
.portal-form button {
    width: 100%; padding: 12px; font-size: 15px; border-radius: 11px;
    background: linear-gradient(135deg, #8B6FF0, #6344D8); color: #fff;
}
.portal-form button:hover { filter: brightness(1.08); color: #fff; }
.otp-input { letter-spacing: 8px; font-family: ui-monospace, Menlo, monospace; font-size: 22px; }

.portal-err {
    background: rgba(248,113,113,0.10); border: 1px solid var(--danger);
    color: var(--danger); padding: 9px 12px; border-radius: 9px;
    font-size: 13px; margin-bottom: 14px;
}
.portal-note {
    background: rgba(167,139,250,0.08); border: 1px solid var(--border);
    color: var(--muted); padding: 9px 12px; border-radius: 9px;
    font-size: 12.5px; margin-bottom: 14px; line-height: 1.5; text-wrap: balance;
}
.linklike {
    background: none; border: 0; color: var(--accent); cursor: pointer;
    font-size: 13px; font-family: inherit; padding: 0; font-weight: 500;
}
/* keep the link-button transparent on hover (the global button:hover would
   otherwise paint it solid violet) */
.linklike:hover { color: var(--accent-2); text-decoration: underline; background: none; }
.portal-resend { margin: 16px 0 0; }
.portal-back { display: inline-block; margin-top: 8px; }

/* liability disclaimer (prototype / not Econocom) */
.portal-disclaimer {
    margin: 22px 0 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    line-height: 1.55;
    color: var(--muted);
    text-align: left;
}
.portal-disclaimer strong { color: var(--text); font-weight: 600; }
.portal-disclaimer.center { text-align: center; }
.portal-disclaimer.center p { margin: 0 0 9px; }
.portal-disclaimer.center p:last-child { margin-bottom: 0; }

/* code step: spam-folder notice */
.portal-divider { height: 1px; background: var(--border); margin: 24px 0 20px; }
.portal-spam { text-align: center; }
.portal-spam-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto 16px;
    image-rendering: -webkit-optimize-contrast;
}
.portal-spam-t1 { font-size: 13px; color: var(--text); margin: 0 0 12px; line-height: 1.5; text-wrap: balance; }
.portal-spam-t2 { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.5; text-wrap: balance; }
.portal-spam strong { color: var(--text); font-weight: 600; }

/* download list */
.portal-list { width: 100%; max-width: 760px; position: relative; z-index: 1; }
.portal-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.portal-head-l { display: flex; align-items: center; gap: 12px; }
.portal-head-r { display: flex; align-items: center; gap: 14px; }
.portal-who { font-size: 13px; color: var(--muted); }

.dl-grid { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.dl-item {
    display: flex; align-items: center; gap: 16px;
    background: rgba(42,43,50,0.66);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    padding: 16px 18px;
    transition: border-color .15s, transform .08s, background .15s;
}
.dl-item:hover { border-color: rgba(167,139,250,0.4); background: rgba(48,49,58,0.7); }
.dl-ext {
    flex: 0 0 auto; width: 50px; height: 50px; border-radius: 11px;
    background: rgba(167,139,250,0.14); border: 1px solid rgba(167,139,250,0.25);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; letter-spacing: .03em;
}
.dl-icon {
    flex: 0 0 auto; width: 50px; height: 50px; border-radius: 11px;
    object-fit: cover; border: 1px solid var(--border); display: block;
}
.dl-body { flex: 1; min-width: 0; }
.dl-title { font-size: 15px; font-weight: 600; color: var(--text); }
.dl-desc { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.dl-meta {
    display: flex; align-items: center; flex-wrap: wrap;
    margin-top: 6px;
    font-size: 12px; color: var(--muted);
    font-family: ui-monospace, Menlo, monospace;
}
.dl-meta span { display: inline-flex; align-items: center; }
.dl-meta span + span::before {
    content: "·"; margin: 0 8px; color: var(--border);
}
.dl-btn {
    flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #8B6FF0, #6344D8); color: #fff;
    transition: filter .15s, transform .08s;
}
.dl-btn:hover { filter: brightness(1.1); color: #fff; }
.dl-btn:active { transform: scale(.94); }
.dl-btn svg { width: 20px; height: 20px; }
.dl-empty {
    text-align: center; color: var(--muted); font-size: 14px;
    padding: 60px 20px;
}

/* responsive */
@media (max-width: 720px) {
    main { padding: 16px; }
    .topnav { padding: 10px 14px; }
    .nav-links a, .nav-links button.nav-btn { padding: 6px 10px; font-size: 13px; }
    .file-main { grid-template-columns: 1fr; }
    .file-main .file-meta { text-align: left; }
    .files-block, .log-block { height: auto; }
    .files-scroll { max-height: 50vh; }
}
