:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1d2330; --muted: #677085; --line: #e2e5ec;
  --accent: #2f5fd0; --accent-soft: #e8eefc; --ok: #1f8a4c; --warn: #b7791f; --bad: #c53030;
  --b1: #9fb3c8; --b2: #6fa8dc; --b3: #4a90a4; --b4: #e0a33b; --b5: #d9734e; --b6: #b04a7a;
  --d1: #a9c3e0; --d2: #5f93cf; --d3: #3361a8; --d4: #1c3a70;
  --easy: #7cb7a0; --avg: #e0a33b; --diff: #c95f5f;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --surface: #1b2029; --text: #e6e9ef; --muted: #9aa3b5; --line: #2c3340;
    --accent: #7aa2ff; --accent-soft: #232d45; --ok: #5cc98a; --warn: #e3b55b; --bad: #ff7b7b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3 { font-size: 15px; margin: 0 0 12px; }
h4 { font-size: 14px; margin: 18px 0 8px; }
.sub, .hint, .muted, small { color: var(--muted); }
.hint { font-size: 13px; }
code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
pre { background: var(--bg); padding: 10px; border-radius: 6px; overflow-x: auto; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top .sub { margin: 2px 0 0; font-size: 13px; }
.top-actions { display: flex; gap: 8px; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
footer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 30px; }

button { font: inherit; font-size: 14px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); }
button.small { font-size: 13px; padding: 4px 10px; margin-top: 8px; }
button:disabled { opacity: .45; cursor: default; }
select, input, textarea { font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }
textarea { width: 100%; min-height: 180px; margin: 8px 0; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.inputs { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 24px; }
.input-col { min-width: 0; }
.step { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; }
.opt { font-weight: 400; font-size: 12px; color: var(--muted); }
.drop { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 14px; text-align: center; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; margin-top: 10px; }
details button { margin-right: 6px; }
.status { font-size: 13px; margin: 8px 0 0; }
.status.ok { color: var(--ok); } .status.error { color: var(--bad); } .status.warn { color: var(--warn); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.target-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 6px; }
.target-row label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.target-row input { width: 100%; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; overflow-x: auto; }
.tab { background: none; color: var(--muted); border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 14px; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.kpi.muted .kpi-val { color: var(--muted); }
.kpi-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi-val { font-size: 28px; font-weight: 650; line-height: 1.2; }
.kpi-val small { font-size: 14px; font-weight: 400; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 80px; align-items: center; gap: 10px; font-size: 13px; }
.bar-track { position: relative; height: 18px; background: var(--bg); border-radius: 4px; }
.bar-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); min-width: 2px; }
.bar-target { position: absolute; top: -3px; bottom: -3px; width: 3px; background: var(--text); border-radius: 2px; transform: translateX(-1px); }
.bar-val { text-align: right; }
.b1 { background: var(--b1); } .b2 { background: var(--b2); } .b3 { background: var(--b3); }
.b4 { background: var(--b4); } .b5 { background: var(--b5); } .b6 { background: var(--b6); }
.d1 { background: var(--d1); } .d2 { background: var(--d2); } .d3 { background: var(--d3); } .d4 { background: var(--d4); }
.band-easy { background: var(--easy); } .band-average { background: var(--avg); } .band-difficult { background: var(--diff); }
.findings { margin: 0; padding-left: 18px; } .findings li { margin-bottom: 6px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
thead th { background: var(--bg); font-weight: 600; white-space: nowrap; }
.matrix td { text-align: center; min-width: 54px; }
.matrix td.has { background: color-mix(in srgb, var(--accent) calc(var(--a) * 60% + 10%), transparent); font-weight: 600; }
.matrix td.tot, .matrix .foot td { font-weight: 600; }
.matrix .foot th, .matrix .foot td { background: var(--bg); }
.matrix td.nums { text-align: left; color: var(--muted); min-width: 120px; }
.items td.stem { min-width: 280px; max-width: 460px; }
.opts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.items select, .items input { font-size: 12px; padding: 3px 4px; max-width: 170px; }
.items .changed { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--surface)); }
.cue { color: var(--muted); font-style: italic; }
.conf { font-size: 11px; padding: 2px 7px; border-radius: 10px; }
.conf-high { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.conf-medium { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.conf-low { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
td.neg { color: var(--bad); font-weight: 600; }
.dist span { margin-right: 4px; } .dist .key { font-weight: 700; color: var(--ok); }
.dist .key::after { content: '✓'; }
.act { font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.act-retain { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.act-revise { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.act-check, .act-revise\ or { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.qitem .stem { margin: 6px 0; } .qitem ul { margin: 0; padding-left: 18px; color: var(--warn); }
.group { border-top: 1px solid var(--line); padding: 6px 0; }
.group summary { color: var(--text); }
.glist { margin: 6px 0 4px; padding-left: 28px; font-size: 13px; }
.glist li { margin-bottom: 4px; }
.tag { display: inline-block; font-size: 11px; background: var(--bg); color: var(--muted); border-radius: 8px; padding: 1px 7px; margin-left: 5px; }
.explain ul { padding-left: 20px; }
.empty { color: var(--muted); }

@media (max-width: 900px) {
  .inputs, .grid2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 120px 1fr 70px; }
}
@media print {
  .top-actions, .inputs, .tabs, details, footer, button { display: none !important; }
  body { background: #fff; }
  .panel { display: block !important; page-break-before: always; }
  .panel:first-of-type { page-break-before: auto; }
  .card, .kpi { break-inside: avoid; }
}

/* Analysis parameters tab */
.params h3 { font-size: 16px; }
.params section.card { scroll-margin-top: 12px; }
.params ol, .params ul { padding-left: 20px; }
.params li { margin-bottom: 5px; }
.params table th { width: 190px; }
.params .cuetable th { width: 150px; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.session { border-left: 4px solid var(--accent); }
.toc { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; align-items: center; }
.toc a { color: var(--accent); text-decoration: none; }
.toc a:hover { text-decoration: underline; }
.chip { display: inline-block; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin: 2px 0; }
.cuegrp { margin-bottom: 6px; }
.w { display: inline-block; font-size: 11px; font-weight: 600; border-radius: 8px; padding: 1px 7px; }
.w3 { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.w2 { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.w1 { background: var(--bg); color: var(--muted); }
.formula { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--bg); padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; display: inline-block; }
.formula-inline { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid3 table th, .grid3 table td { width: auto; }
.refs li { font-size: 13px; }
@media (max-width: 900px) { .grid3 { grid-template-columns: 1fr; } .kv { grid-template-columns: 1fr; } }

.privacy { flex-basis: 100%; margin: 4px 0 0; font-size: 13px; color: var(--text); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); border-radius: 8px; padding: 7px 12px; }
@media print { .privacy { display: none; } }

/* Table of specifications */
.tos-setup { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-bottom: 4px; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.button-like { display: inline-block; font-size: 14px; padding: 7px 14px; border-radius: 7px; border: 1px solid var(--accent); color: var(--accent); cursor: pointer; }
.matrix.tos th, .matrix.tos td { text-align: center; }
.matrix.tos td.comp { text-align: left; min-width: 240px; max-width: 360px; }
.matrix.tos td.plan { color: var(--muted); }
.matrix.tos td.match { background: color-mix(in srgb, var(--ok) 16%, transparent); font-weight: 600; }
.matrix.tos td.diff { background: color-mix(in srgb, var(--warn) 20%, transparent); font-weight: 600; }
.matrix.tos td.over { background: color-mix(in srgb, var(--bad) 14%, transparent); font-weight: 600; }
.matrix.tos tr.ua td { font-style: italic; }
.matrix.tos thead th { text-align: center; }
.small { font-size: 12px; }
.flag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 8px; white-space: nowrap; margin: 1px 0; }
.flag.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.flag.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.flag.bad { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.flag.info { background: var(--bg); color: var(--muted); }
.findings li.f-bad { color: var(--bad); }
@media (max-width: 900px) { .tos-setup { grid-template-columns: 1fr; } }
@media print { #tab-tos > .card:first-child { display: none; } }
.matrix.tos tbody td:first-child { white-space: nowrap; }

/* Validation */
.howto { padding-left: 20px; font-size: 14px; } .howto li { margin-bottom: 5px; }
.rating-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.rating-head h3 { margin: 0 auto 0 0; align-self: center; }
.progress { font-size: 13px; color: var(--muted); align-self: center; }
.rating tr.done td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.defs table th { width: 140px; }
table.agree th, table.agree td { text-align: center; }
table.agree tbody th { text-align: left; }
table.agree tbody tr { cursor: pointer; }
table.agree tbody tr:hover, table.agree tr.sel { background: var(--accent-soft); }
.matrix.conf td.on { background: color-mix(in srgb, var(--ok) 25%, transparent); font-weight: 600; }
.matrix.conf td.near { background: color-mix(in srgb, var(--warn) 25%, transparent); font-weight: 600; }
.matrix.conf td.off { background: color-mix(in srgb, var(--bad) 22%, transparent); font-weight: 600; }
.rec select.undecided { border-color: var(--bad); }
.rec input { width: 180px; font-size: 12px; }
.rec tr.st-disagree td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.rec tr.st-adjacent td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.chk { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; margin-right: auto; }
@media print { #tab-validation .rating, #tab-validation > .card:first-child { display: none; } }
.rec td.lbl { white-space: nowrap; }

/* Review items */
.review tr.excluded td { opacity: .45; }
.review tr.excluded td:first-child { opacity: 1; }
.review tr.excluded .stem { text-decoration: line-through; }
.review tr.suspect td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.review input.inc { width: 18px; height: 18px; cursor: pointer; }
.kpis.compact .kpi-val { font-size: 22px; }
.scope { margin: 0 0 12px; }
@media print { #tab-review { display: none !important; } }
