/* 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; }
}

/* ===== public page — spesa.simulalab.it =============================
   Sections: 01 tech matrix · 02 urgent cards · 03 priority checklist · 04 future.
   The check mark is a single accent (it encodes one boolean, "used here", not
   project identity); the cost column is a three-state tier that always carries
   its text label, so colour is never the only carrier. */

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* page shell */
.stack-page {
    position: relative; z-index: 1;
    width: 100%; max-width: 1440px;
    margin: 0 auto; padding: 0 0 48px;
}
.sec-first { margin-top: 0; }

.stack-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; margin-bottom: 42px; }
.stack-hero .portal-mark { flex: none; }
.stack-h1 { font-size: 30px; font-weight: 650; margin: 0; letter-spacing: -0.02em; }
.stack-hero-sub { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }

/* section frame */
.sec { margin-bottom: 54px; }
.sec-head { display: flex; justify-content: center; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.sec-num {
    font-size: 13px; font-weight: 700; color: var(--accent);
    font-variant-numeric: tabular-nums; letter-spacing: 0.06em;
    background: rgba(167,139,250,0.12); border: 1px solid rgba(167,139,250,0.22);
    border-radius: 7px; padding: 2px 8px; line-height: 1.4;
}
.sec-title { font-size: 21px; font-weight: 620; margin: 0; letter-spacing: -0.01em; }
.sec-sub { margin: 0 auto 18px; color: var(--muted); font-size: 14px; max-width: 68ch; line-height: 1.55; text-align: center; }
.sec-foot { margin: 12px 2px 0; font-size: 12.5px; color: var(--muted); text-align: center; }

/* stat strip */
.stack-stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0 18px; }
.stack-stat {
    flex: 1 1 130px;
    background: rgba(42,43,50,0.62);
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px; padding: 13px 16px; text-align: center;
}
.stack-stat b { display: block; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; }
.stack-stat span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.stack-stat.is-open b { color: var(--ok); }

/* ---- 01 matrix table ---- */
.stack-panel {
    background: rgba(42,43,50,0.62);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.42);
    overflow: hidden;
}
/* the table scrolls inside itself so the header/first column can stick */
.stack-scroll {
    max-height: 78vh; overflow: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: #4A4B57 transparent;
}
.stack-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.stack-scroll::-webkit-scrollbar-track { background: transparent; }
.stack-scroll::-webkit-scrollbar-thumb { background: #4A4B57; border-radius: 6px; border: 2px solid #2A2B32; }
.stack-scroll::-webkit-scrollbar-thumb:hover { background: #5C5D6B; }

/* fixed layout at EVERY width: columns are uniform and compact (percentages of
   the table width), never content-inflated. min-width keeps them readable; if
   the viewport is narrower than that (e.g. a strongly zoomed / hi-DPI display)
   the table scrolls horizontally rather than squeezing the columns to mush. */
/* min-width = the exact sum of the column widths below, so every column gets the
   room its header actually needs and the table simply scrolls horizontally. */
.stack-table { width: 100%; min-width: 2684px; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.stack-table th, .stack-table td { padding: 0; vertical-align: middle; text-align: center; }

/* Column widths via <col>: authoritative in fixed layout. (Widths on the header
   cells are ignored here because the colspan'd client-row is the first row.) */
.stack-table col.col-tech { width: 300px; }
.stack-table col.col-cost { width: 100px; }
.stack-table col.col-proj { width: 82px; }
.stack-table col.col-use  { width: 70px; }

/* header — solid and opaque so nothing shows through when the body scrolls */
.stack-table thead th {
    position: sticky; top: 0; z-index: 3;
    background: #2B2C37;
    border-bottom: 1px solid var(--border);
    padding: 10px 6px; font-weight: 600; font-size: 11.5px; color: var(--muted);
    text-align: center; white-space: normal;
}
.stack-table thead th.c-tech { z-index: 4; width: 16.5%; }
.stack-table thead th.c-proj { width: 3.55%; padding-left: 3px; padding-right: 3px; }
.stack-table thead th.c-proj .p-n {
    display: block; font-size: 12.5px; color: var(--accent); font-weight: 700;
    font-variant-numeric: tabular-nums; line-height: 1;
}
/* Process names: normal case (the base th uppercases everything, which is both
   wider and uglier here) and wrapping ONLY at spaces — never mid-word. */
.stack-table thead th.c-proj .p-t {
    display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
    margin-top: 6px; font-size: 10px; color: var(--text);
    font-weight: 550; line-height: 1.28;
    text-transform: none; letter-spacing: 0;
    overflow-wrap: normal; word-break: normal; hyphens: none;
}
.stack-table thead th.c-cost { width: 5%; }
.stack-table thead th.c-use { width: 3.2%; }

/* client grouping band — ONE continuous frosted orange-glass strip across the
   whole line above the column headers (glassmorphism). It scrolls; the
   column-header row below it is the one that sticks. */
.stack-table thead tr.client-row th {
    position: static;
    padding: 8px 3px 9px;
    text-align: center;
    /* wrap instead of spilling: a one-column client (es. FIDITALIA) must still
       sit centred inside its narrow cell */
    white-space: normal; overflow-wrap: anywhere; line-height: 1.25;
    font-size: 10px; font-weight: 700; letter-spacing: 0.01em;
    color: #FFF3E6;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.20), rgba(255,255,255,0) 48%),
        linear-gradient(180deg, rgba(251,146,60,0.56), rgba(234,88,12,0.37));
    -webkit-backdrop-filter: blur(13px) saturate(185%);
    backdrop-filter: blur(13px) saturate(185%);
    border-top: 1px solid rgba(255,214,176,0.44);
    border-bottom: 1px solid rgba(234,88,12,0.60);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.42), inset 0 -10px 18px -11px rgba(150,50,0,0.58);
    text-shadow: 0 1px 3px rgba(120,40,0,0.5);
}
.stack-table thead tr.client-row th.c-client { border-left: 1px solid rgba(255,255,255,0.18); }

/* Innovations group — rose "liquid glass", deliberately louder than the orange
   so the planned products read as a different class of thing. The Uso cap gets
   the same treatment so the last column reads as part of that family. */
.stack-table thead tr.client-row th.cl-innov,
.stack-table thead tr.client-row th.cl-tail {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0) 48%),
        linear-gradient(180deg, rgba(244,63,94,0.62), rgba(190,18,60,0.44));
    border-top-color: rgba(255,192,206,0.50);
    border-bottom-color: rgba(190,18,60,0.68);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.46), inset 0 -10px 18px -11px rgba(140,10,45,0.62);
    text-shadow: 0 1px 3px rgba(120,0,30,0.55);
    color: #FFEFF2;
}

/* innovation columns: tinted end-to-end so they stand out from the live ones */
.stack-table thead th.c-proj.c-innov {
    background: linear-gradient(180deg, rgba(244,63,94,0.17), rgba(244,63,94,0.05)), #2B2C37;
}
.stack-table thead th.c-proj.c-innov .p-n { color: #FB7185; }
.stack-table tbody td.c-innov { background: rgba(244,63,94,0.055); }
.stack-table tbody td.c-innov .mark {
    background: rgba(244,63,94,0.20);
    border-color: rgba(244,63,94,0.44);
    color: #FFE1E7;
}
.stack-table tbody td.c-innov .mark:hover,
.stack-table tbody td.c-innov .mark:focus-visible {
    background: rgba(244,63,94,0.36); border-color: #F43F5E; color: #fff;
}
.stack-table tbody td.c-innov .mark:focus-visible { box-shadow: 0 0 0 3px rgba(244,63,94,0.32); }

/* export bar */
.stack-export {
    margin: 42px 0 12px; padding-top: 28px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
}
.export-btn {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 11px 20px; border-radius: 12px;
    background: linear-gradient(135deg, #8B6FF0, #6344D8); color: #fff;
    font-size: 14px; font-weight: 600;
    box-shadow: 0 8px 22px rgba(124,92,240,0.35);
    transition: filter .15s ease, transform .08s ease;
}
.export-btn:hover { filter: brightness(1.08); color: #fff; }
.export-btn:active { transform: scale(.98); }
.export-btn svg { width: 18px; height: 18px; }
.export-hint { font-size: 12.5px; color: var(--muted); }

/* body — all cells centred, tech name centred and bold as the row label */
.stack-table tbody th.c-tech {
    text-align: center; padding: 8px 8px;
    font-weight: 600; color: var(--text); line-height: 1.3; overflow-wrap: anywhere;
}
.stack-table tbody td { padding: 8px 6px; text-align: center; }
.stack-table tbody tr + tr th.c-tech,
.stack-table tbody tr + tr td { border-top: 1px solid rgba(255,255,255,0.045); }

/* the check mark (its own hover only — no row/column highlight) */
.mark {
    width: 28px; height: 28px; margin: 0 auto; padding: 0; display: flex;
    align-items: center; justify-content: center;
    background: rgba(167,139,250,0.18);
    border: 1px solid rgba(167,139,250,0.38);
    border-radius: 9px; color: #E4DBFF; cursor: help;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.mark svg { width: 17px; height: 17px; }
/* NOTE: no transform on hover — a scaled element inside the overflow:auto
   wrapper enlarges the scrollable area and visibly shifts the whole table. */
.mark:hover, .mark:focus-visible {
    background: rgba(167,139,250,0.42); border-color: var(--accent);
    color: #fff; outline: none;
    box-shadow: 0 0 0 3px rgba(167,139,250,0.22);
}
.mark:focus-visible { box-shadow: 0 0 0 3px rgba(167,139,250,0.30); }
.no-mark { color: #4A4B57; font-size: 15px; user-select: none; }

/* cost chip — colour + permanent text label */
.chip {
    display: inline-block; padding: 3px 7px; border-radius: 999px;
    font-size: 10px; font-weight: 600; white-space: nowrap; cursor: help;
    border: 1px solid transparent;
}
.chip.t-open { color: var(--ok);     background: rgba(74,222,128,0.11);  border-color: rgba(74,222,128,0.30); }
.chip.t-free { color: var(--warn);   background: rgba(251,191,36,0.11);  border-color: rgba(251,191,36,0.30); }
.chip.t-proprietary { color: var(--danger); background: rgba(248,113,113,0.11); border-color: rgba(248,113,113,0.30); }

/* usage pill — one hue, opacity rises with the count */
/* Usage pill — default violet, as before. Scoped to the table so the nav's
   ".pill accent" badge keeps its own colours. */
.stack-table .pill {
    display: inline-block; min-width: 32px; padding: 3px 7px; border-radius: 8px;
    font-size: 11.5px; font-weight: 650; color: #EDE6FF;
    font-variant-numeric: tabular-nums;
    background: rgba(139,111,240,0.16); border: 1px solid rgba(139,111,240,0.22);
}
.stack-table .pill[data-n="2"] { background: rgba(139,111,240,0.28); border-color: rgba(139,111,240,0.34); }
.stack-table .pill[data-n="3"] { background: rgba(139,111,240,0.44); border-color: rgba(139,111,240,0.50); }
.stack-table .pill[data-n="4"] { background: rgba(139,111,240,0.62); border-color: rgba(139,111,240,0.68); }
.stack-table .pill[data-n="5"] { background: rgba(139,111,240,0.80); border-color: rgba(167,139,250,0.85); color: #fff; }

/* Uso column — only the two header rows are rose; the cells below stay default */
.stack-table thead th.c-use {
    background: linear-gradient(180deg, rgba(244,63,94,0.17), rgba(244,63,94,0.05)), #2B2C37;
    color: #FB7185;
}

/* Costo — header and chip both centred */
.stack-table thead th.c-cost,
.stack-table tbody td.c-cost { text-align: center; }

/* ===== orange "liquid glass" — reusable frosted-orange surface ===== */
.glass-orange {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0.02) 46%),
        linear-gradient(135deg, rgba(251,146,60,0.58), rgba(234,88,12,0.40));
    -webkit-backdrop-filter: blur(14px) saturate(185%);
    backdrop-filter: blur(14px) saturate(185%);
    border: 1px solid rgba(255,196,140,0.48);
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.42),
        inset 0 -12px 20px -14px rgba(150,50,0,0.6),
        0 8px 24px -8px rgba(234,88,12,0.45);
    color: #FFF3E6;
}

/* ---- 02 shop (highlighted with orange liquid glass) ---- */
.shop-sec .sec-num {
    color: #FFD9A8;
    background: linear-gradient(135deg, rgba(251,146,60,0.30), rgba(234,88,12,0.16));
    border-color: rgba(251,146,60,0.42);
}

.shop-cart {
    display: flex; align-items: center; gap: 13px;
    padding: 12px 16px; border-radius: 14px; margin-bottom: 16px;
}
.cart-ico { display: inline-flex; }
.cart-ico svg { width: 23px; height: 23px; }
.cart-text { flex: 1; font-size: 13.5px; font-weight: 600; text-shadow: 0 1px 2px rgba(120,40,0,0.35); }
.cart-checkout {
    padding: 8px 16px; border-radius: 10px; font-size: 13px; font-weight: 700;
    color: #7A2E00; background: linear-gradient(180deg, #FFE9C6, #FFD79C);
    border: 1px solid rgba(255,255,255,0.65);
    box-shadow: 0 2px 8px rgba(120,50,0,0.28); cursor: pointer;
    transition: filter .15s ease, transform .08s ease, opacity .15s ease;
}
.cart-checkout:disabled { opacity: 0.5; cursor: not-allowed; }
.cart-checkout:not(:disabled):hover { filter: brightness(1.05); }
.cart-checkout:not(:disabled):active { transform: scale(.97); }
.shop-cart.has-items { animation: cartpulse .4s ease; }
.shop-cart.ordered { animation: cartpulse .5s ease; }
@keyframes cartpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.015); } }

.shop { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.shop-item {
    display: flex; gap: 14px; align-items: flex-start;
    background: rgba(42,43,50,0.62);
    backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px; padding: 16px 18px;
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.shop-item.in-cart {
    border-color: rgba(251,146,60,0.55);
    box-shadow: 0 0 0 1px rgba(251,146,60,0.30), 0 12px 28px -12px rgba(234,88,12,0.5);
}
.shop-media {
    flex: none; width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(251,146,60,0.24), rgba(234,88,12,0.12));
    border: 1px solid rgba(251,146,60,0.30); color: #FFC894;
}
.shop-media svg { width: 22px; height: 22px; }
.shop-main { flex: 1; min-width: 0; }
.shop-top { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.shop-title { font-size: 15px; font-weight: 620; color: var(--text); }
.shop-tag {
    font-size: 11px; font-weight: 600; color: var(--accent);
    background: rgba(167,139,250,0.12); border: 1px solid rgba(167,139,250,0.22);
    border-radius: 999px; padding: 2px 10px;
}
.shop-desc { margin: 6px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.shop-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; flex-wrap: wrap; }
.shop-avail { font-size: 11.5px; color: #C9A98A; font-weight: 500; }
.shop-avail::before { content: "◷ "; opacity: 0.85; }

.cart-btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 8px 15px; border-radius: 10px; cursor: pointer;
    font-size: 12.5px; font-weight: 700;
    transition: filter .15s ease, transform .08s ease;
}
.cart-btn:hover { filter: brightness(1.06); }
.cart-btn:active { transform: scale(.97); }
.cart-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(251,146,60,0.35); }
.cart-btn svg { width: 15px; height: 15px; margin-right: 7px; }
.cart-btn-add, .cart-btn-done { display: inline-flex; align-items: center; }
.cart-btn-done { display: none; }
.shop-item.in-cart .cart-btn-add { display: none; }
.shop-item.in-cart .cart-btn-done { display: inline-flex; }

/* ---- 03 priority tiers ---- */
.tiers { display: flex; flex-direction: column; gap: 10px; }
.tier {
    background: rgba(42,43,50,0.55);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.07);
    border-left: 3px solid var(--tone, var(--accent));
    border-radius: 14px; overflow: hidden;
}
.tone-p0    { --tone: #F87171; }
.tone-p0bis { --tone: #FB923C; }
.tone-p1    { --tone: #FBBF24; }
.tone-p2    { --tone: #4ADE80; }
.tone-p3    { --tone: #AEB0BE; }

.tier-sum {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; cursor: pointer; list-style: none; user-select: none;
}
.tier-sum::-webkit-details-marker { display: none; }
.tier-sum:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tier-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tone); flex: none; box-shadow: 0 0 10px -1px var(--tone); }
.tier-code {
    font-size: 12px; font-weight: 700; letter-spacing: 0.03em; color: var(--tone);
    min-width: 52px; flex: none;
}
.tier-title { font-size: 14.5px; font-weight: 600; color: var(--text); flex: 1; }
.tier-note { font-size: 12px; color: var(--muted); }
.tier-count {
    font-size: 12px; font-weight: 650; color: var(--muted);
    background: rgba(255,255,255,0.06); border: 1px solid var(--border);
    border-radius: 999px; padding: 1px 9px; font-variant-numeric: tabular-nums; flex: none;
}
.tier-chev { width: 18px; height: 18px; color: var(--muted); transition: transform .2s ease; flex: none; }
.tier[open] .tier-chev { transform: rotate(180deg); }

.tier-list { list-style: none; margin: 0; padding: 0 16px 8px; }
.need { display: flex; gap: 12px; padding: 13px 0; border-top: 1px solid rgba(255,255,255,0.06); }
.need-num {
    flex: none; width: 24px; height: 24px; margin-top: 1px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 650; color: var(--tone);
    background: rgba(167,139,250,0.13);
    border: 1px solid rgba(167,139,250,0.30);
    background: color-mix(in srgb, var(--tone) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--tone) 32%, transparent);
    border-radius: 7px; font-variant-numeric: tabular-nums;
}
.need-body2 { flex: 1; }
.need-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.need-name { font-size: 14px; font-weight: 600; color: var(--text); }
.need-team {
    font-size: 11px; font-weight: 550; color: var(--accent);
    background: rgba(167,139,250,0.10); border: 1px solid rgba(167,139,250,0.20);
    border-radius: 6px; padding: 1px 8px;
}
.need-text { margin: 5px 0 0; font-size: 13px; color: var(--muted); line-height: 1.55; }

/* ---- 04 future needs table ---- */
.fut-panel { overflow: hidden; }
.fut-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.fut-table thead th {
    text-align: left; padding: 11px 16px; font-size: 11.5px; font-weight: 600;
    color: var(--muted); background: #2B2C37; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 1;
}
.fut-h-hz { width: 120px; white-space: nowrap; }
.fut-h-voce { width: 26%; }
.fut-group th {
    text-align: left; padding: 9px 16px; font-size: 11px; font-weight: 700;
    letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent);
    background: rgba(167,139,250,0.09); border-top: 1px solid rgba(167,139,250,0.18);
    border-bottom: 1px solid rgba(167,139,250,0.14);
}
.fut-row td { padding: 11px 16px; vertical-align: top; border-top: 1px solid rgba(255,255,255,0.05); }
.fut-voce { font-weight: 600; color: var(--text); }
.fut-det { color: var(--muted); line-height: 1.5; }
.fut-hz { white-space: nowrap; }
.hz-badge {
    display: inline-block; font-size: 11px; font-weight: 600; white-space: nowrap;
    border-radius: 999px; padding: 2px 10px; border: 1px solid transparent;
}
.hz-near { color: var(--ok);   background: rgba(74,222,128,0.10);  border-color: rgba(74,222,128,0.28); }
.hz-far  { color: var(--info); background: rgba(96,165,250,0.10);  border-color: rgba(96,165,250,0.28); }

.stack-legal {
    margin-top: 10px; padding-top: 22px; border-top: 1px solid var(--border);
    font-size: 12px; color: #8B8B9A; line-height: 1.6;
}

/* tooltip */
.tt {
    position: fixed; z-index: 60; max-width: 320px;
    background: #1B1C22; border: 1px solid rgba(167,139,250,0.34);
    border-radius: 12px; padding: 11px 13px;
    box-shadow: 0 18px 44px rgba(0,0,0,0.6);
    opacity: 0; visibility: hidden; transform: translateY(4px);
    transition: opacity .13s ease, transform .13s ease, visibility .13s;
    pointer-events: none;
}
.tt.on { opacity: 1; visibility: visible; transform: translateY(0); }
.tt-kind {
    display: inline-block; font-size: 10.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--accent); background: rgba(167,139,250,0.14);
    border-radius: 5px; padding: 2px 6px; margin-bottom: 7px;
}
.tt-role { font-size: 13px; color: var(--text); line-height: 1.5; }

/* responsive */

/* Only on genuinely small screens (phones) drop the fixed layout and allow a
   horizontal scroll; every desktop width — including 125–150% display scaling,
   which lands the CSS viewport near 800–1000px — keeps all five columns on one
   screen with no horizontal scrollbar. */
@media (max-width: 720px) {
    .stack-scroll { max-height: none; }
    .stack-page { padding: 0 0 40px; }
    .stack-h1 { font-size: 24px; }
    .sec { margin-bottom: 42px; }
    .sec-title { font-size: 19px; }
    .stack-stat b { font-size: 21px; }
    .stack-table { font-size: 12.5px; }
    .tier-note { display: none; }
    .tier-code { min-width: 44px; }
    .tt { max-width: 260px; }
}
