:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;
    --border-subtle: rgba(148, 163, 184, 0.12);
    --border: rgba(148, 163, 184, 0.22);
    --row: #0f1626;
    --rowhi: #18233b;
    --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
    --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --tl-height: 64px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    inset: 0;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
button { font-family: inherit; color: inherit; cursor: pointer; }
code {
    font-family: var(--mono);
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Header */
.header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.header h1 {
    font-family: var(--mono);
    font-size: 1.2rem;
    font-weight: 600;
    white-space: nowrap;
}
.upload-area { display: flex; align-items: center; gap: 12px; min-width: 0; }
.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: border-color .15s, color .15s;
}
.upload-btn:hover { border-color: var(--accent-cyan); color: var(--text-primary); }
.upload-btn-short { display: none; }
.file-info { color: var(--text-muted); font-family: var(--mono); font-size: 12px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.chip {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.chip b { color: var(--text-primary); font-family: var(--mono); font-weight: 600; }

/* Main scroll area */
.main-area { flex: 1; overflow: auto; position: relative; }
.content { padding: 18px 20px; max-width: 1500px; margin: 0 auto; }
.content h2 { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; }
.hint { color: var(--text-secondary); font-size: 12.5px; margin: 4px 0 14px; }

.empty-state {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 12px; color: var(--text-muted); text-align: center; padding: 20px;
}
.empty-state svg { width: 64px; height: 64px; color: var(--bg-tertiary); }
.empty-state p { font-size: 15px; }
.empty-state .hint { max-width: 520px; }

/* overview table */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td {
    padding: 8px 12px; border-bottom: 1px solid var(--border-subtle);
    text-align: left; white-space: nowrap;
}
table.grid thead th {
    position: sticky; top: 0; background: var(--bg-secondary);
    color: var(--text-muted); font-weight: 600; font-size: 11.5px;
    letter-spacing: .04em; text-transform: uppercase;
    cursor: pointer; user-select: none; z-index: 5;
}
table.grid thead th.n, table.grid td.n { text-align: right; }
table.grid thead th .ar { opacity: .4; margin-left: 4px; font-size: 10px; }
table.grid thead th[aria-sort] .ar { opacity: 1; color: var(--accent-cyan); }
table.grid tbody tr { cursor: pointer; background: var(--row); }
table.grid tbody tr:hover { background: var(--rowhi); }
table.grid tbody tr:focus-visible { outline: 2px solid var(--accent-cyan); outline-offset: -2px; }
table.grid tbody tr.all { background: #102132; }
table.grid tbody tr.all td:first-child { color: var(--accent-cyan); }
.pname { font-weight: 600; }
.cpucell { position: relative; min-width: 118px; }
.cpubar {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: var(--accent-cyan); opacity: .16; border-right: 2px solid var(--accent-cyan);
}
.cpuval { position: relative; font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* timeline footer */
.timeline {
    height: var(--tl-height);
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
}
.tl-all {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
    font-family: var(--mono);
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}
.tl-all:hover { border-color: var(--accent-cyan); color: var(--text-primary); }
.tl-all.active {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, .12);
}
.tl-track {
    position: relative;
    flex: 1;
    height: 40px;
    display: flex;
    align-items: flex-end;
    gap: 1px;
    cursor: crosshair;
    overflow: hidden;
}
.tl-bar {
    flex: 1 1 0;
    min-width: 1px;
    background: var(--accent-cyan);
    opacity: .38;
    transition: opacity .1s;
}
.tl-bar.sel { opacity: 1; background: var(--accent-amber); }
.tl-cursor {
    position: absolute; top: 0; bottom: 0; width: 2px;
    background: var(--accent-amber); pointer-events: none; display: none;
}
.tl-label {
    font-size: 12px; color: var(--text-secondary);
    white-space: nowrap; flex-shrink: 0; min-width: 240px; text-align: right;
}
.tl-label b { color: var(--accent-amber); }

/* modal */
.scrim { position: fixed; inset: 0; background: rgba(2, 6, 18, .62); z-index: 50; display: none; }
.scrim.open { display: block; }
.modal {
    position: fixed; inset: 3vh 2vw; z-index: 60;
    background: var(--bg-primary); border: 1px solid var(--border);
    border-radius: 12px; display: none; flex-direction: column;
    overflow: hidden; box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}
.modal.open { display: flex; }
.mhead {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.mhead .ttl { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.mhead .pid { color: var(--text-muted); font-family: var(--mono); font-size: 13px; }
.mhead .cmd {
    color: var(--text-muted); font-family: var(--mono); font-size: 11.5px;
    margin-top: 6px; max-width: 80ch; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.mchips { display: flex; gap: 7px; margin-top: 9px; flex-wrap: wrap; }
.close {
    margin-left: auto; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; flex: none;
}
.close:hover { background: var(--bg-tertiary); }
.close svg { width: 16px; height: 16px; stroke: var(--text-primary); }

.toolbar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.toolbar input {
    background: var(--bg-secondary); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: 8px; padding: 7px 11px;
    font-family: var(--mono); font-size: 12.5px; min-width: 230px;
}
.toolbar input:focus { outline: 2px solid var(--accent-cyan); outline-offset: 0; border-color: var(--accent-cyan); }
.btn { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; font-size: 12.5px; }
.btn:hover { background: var(--bg-tertiary); }
.crumbs {
    font-family: var(--mono); font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 120px;
}
.crumbs b { color: var(--text-primary); }
.matchinfo { font-size: 12px; color: var(--accent-cyan); font-family: var(--mono); }

.flamewrap { padding: 10px 18px; overflow: auto; max-height: 46vh; border-bottom: 1px solid var(--border); }
#flame { position: relative; width: 100%; }
.frame {
    position: absolute; height: 21px; border-radius: 2px; overflow: hidden;
    font-family: var(--mono); font-size: 11px; line-height: 21px; padding: 0 5px;
    color: #06121a; white-space: nowrap; cursor: pointer; border: 1px solid rgba(0, 0, 0, .25);
}
.frame:hover { filter: brightness(1.12); outline: 1px solid #fff; }
.frame.anc { background: var(--bg-tertiary) !important; color: var(--text-muted); border: 1px dashed var(--border); }
.frame.dim { opacity: .18; }
.frame.match { outline: 2px solid #fff; color: #000; z-index: 2; }
.flame-empty { color: var(--text-muted); font-size: 13px; padding: 24px 4px; }

.tabs { display: flex; gap: 4px; padding: 10px 18px 0; }
.tab {
    background: none; border: 1px solid transparent; border-bottom: none;
    border-radius: 8px 8px 0 0; padding: 8px 14px; color: var(--text-muted); font-size: 13px;
}
.tab[aria-selected="true"] { color: var(--text-primary); background: var(--bg-secondary); border-color: var(--border); }
.tablewrap { overflow: auto; flex: 1; padding: 0 18px 18px; }
table.cost { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.cost th, table.cost td { padding: 6px 10px; border-bottom: 1px solid var(--border-subtle); text-align: left; }
table.cost th {
    position: sticky; top: 0; background: var(--bg-primary); color: var(--text-muted);
    font-size: 11px; text-transform: uppercase; letter-spacing: .04em; z-index: 1;
}
table.cost td.sym {
    font-family: var(--mono); max-width: 62ch; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
table.cost td.sym:hover { color: var(--accent-cyan); }
table.cost td.barcell { width: 34%; }
.bar { position: relative; height: 14px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent-cyan); opacity: .8; }
.bar em {
    position: absolute; right: 6px; top: -1px; font-style: normal;
    font-family: var(--mono); font-size: 10.5px; color: var(--text-primary); line-height: 16px;
}

#tooltip {
    position: fixed; z-index: 100; pointer-events: none; display: none;
    background: #020617; border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; font-size: 12px; max-width: 520px; box-shadow: 0 8px 30px rgba(0, 0, 0, .6);
}
#tooltip .t-sym { font-family: var(--mono); color: var(--text-primary); word-break: break-all; }
#tooltip .t-meta { color: var(--text-muted); font-family: var(--mono); margin-top: 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 720px) {
    .upload-btn-text { display: none; }
    .upload-btn-short { display: inline; }
    .chips { width: 100%; margin-left: 0; }
    .tl-label { min-width: 0; }
}
