:root {
  --bg: #f6f7fb; --panel: #ffffff; --panel2: #f1f4f9; --border: #dfe3ec;
  --text: #1e293b; --muted: #64748b; --accent: #0284c7; --accent2: #7c3aed;
  --ok: #059669; --redir: #b45309; --warn: #ea580c; --err: #dc2626;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, sans-serif; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; } .pad { padding: 24px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand img { width: 22px; height: 22px; }
.file-info { flex: 1; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.icon { padding: 2px 10px; font-size: 18px; line-height: 1.2; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.landing { max-width: 720px; width: 100%; margin: 8vh auto; padding: 0 20px; }
.dropzone { border: 2px dashed var(--border); border-radius: 16px; padding: 56px 24px; text-align: center; background: var(--panel); transition: .15s; }
.dropzone.over { border-color: var(--accent); background: var(--panel2); }
.dropzone h1 { margin: 8px 0; font-size: 22px; }
.dz-icon { font-size: 40px; color: var(--accent); }
.error { margin-top: 18px; border: 1px solid var(--err); background: #fef2f2; border-radius: 12px; padding: 14px 18px; }
.error h3 { margin: 0 0 6px; color: var(--err); }
.error ul { margin: 6px 0 0; padding-left: 20px; }
.error code { font-family: var(--mono); background: #0000000d; padding: 1px 5px; border-radius: 4px; }
.drag-overlay { position: fixed; inset: 0; background: #f6f7fbdd; display: flex; align-items: center; justify-content: center; font-size: 24px; border: 3px dashed var(--accent); z-index: 50; pointer-events: none; }

.app { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 14px 18px; gap: 12px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
.stat .bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 6px; background: var(--panel2); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search { flex: 1; min-width: 240px; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 7px 10px; font: inherit; }
.search:focus { outline: none; border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip .n { opacity: .7; margin-left: 4px; }
.check { color: var(--muted); font-size: 13px; display: flex; gap: 4px; align-items: center; cursor: pointer; }

.split { flex: 1; min-height: 0; display: flex; gap: 12px; }
.table-wrap { flex: 1; min-width: 0; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th { position: sticky; top: 0; background: var(--panel2); text-align: left; padding: 7px 8px; font-weight: 600; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap; border-bottom: 1px solid var(--border); }
thead th.asc::after { content: " \25B2"; font-size: 9px; } thead th.desc::after { content: " \25BC"; font-size: 9px; }
td { padding: 5px 8px; border-bottom: 1px solid #eef1f6; white-space: nowrap; }
td.grow { max-width: 0; width: 40%; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
td.dom { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.num { text-align: right; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel2); }
tbody tr.sel { background: #e0f2fe; }
tbody tr.failed td { color: var(--err); }
.st { font-weight: 700; font-family: var(--mono); }
.s2 { color: var(--ok); } .s3 { color: var(--redir); } .s4 { color: var(--warn); } .s5, .s0 { color: var(--err); }
.wf-col { width: 22%; min-width: 160px; }
.wf { position: relative; height: 10px; background: #e8ecf3; border-radius: 3px; }
.wf span { position: absolute; top: 0; height: 100%; border-radius: 3px; min-width: 2px; }

.detail { width: 48%; min-width: 380px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); min-height: 0; }
.detail-head { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.detail-title { flex: 1; font-family: var(--mono); font-size: 12px; word-break: break-all; }
.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: 0; color: var(--muted); padding: 8px 10px; font: inherit; font-size: 13px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.detail-body { flex: 1; overflow: auto; padding: 12px; }
.sec { margin-bottom: 16px; }
.sec h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.sec h4 .sp { flex: 1; }
.kv { width: 100%; font-family: var(--mono); font-size: 12px; }
.kv td { white-space: normal; word-break: break-all; vertical-align: top; padding: 3px 6px; }
.kv td:first-child { color: var(--accent2); width: 30%; word-break: normal; overflow-wrap: anywhere; }
.code { font-family: var(--mono); font-size: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px; white-space: pre-wrap; word-break: break-all; margin: 0; max-height: 70vh; overflow: auto; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 11px; padding: 2px 8px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.badge { font-size: 10px; background: var(--panel2); color: var(--muted); padding: 1px 6px; border-radius: 4px; text-transform: none; letter-spacing: 0; }

/* syntax highlighting */
.j-k { color: #0369a1; } .j-s { color: #15803d; } .j-n { color: #c2410c; } .j-b { color: #7c3aed; } .j-null { color: #64748b; }
.j-tog { cursor: pointer; color: var(--muted); user-select: none; display: inline-block; width: 1em; }
.j-tog:hover { color: var(--accent); }
.j-coll > .j-inner { display: none; } .j-coll > .j-ell { display: inline !important; }
.j-ell { display: none; color: var(--muted); cursor: pointer; }
.h-tag { color: #be185d; } .h-attr { color: #0369a1; } .h-val { color: #15803d; } .h-com { color: #94a3b8; font-style: italic; }

.timing-row { display: grid; grid-template-columns: 90px 1fr 70px; gap: 8px; align-items: center; font-size: 12px; margin: 4px 0; }
.timing-row .tb { position: relative; height: 10px; background: #e8ecf3; border-radius: 3px; }
.timing-row .tb span { position: absolute; height: 100%; border-radius: 3px; min-width: 2px; }

@media (max-width: 900px) {
  .split { flex-direction: column; }
  .detail { width: 100%; min-width: 0; max-height: 70vh; }
  .wf-col, td.wfc { display: none; }
}
