:root {
  --bg: #f3f5f8; --card: #ffffff; --ink: #18212b; --muted: #6b7684; --line: #e1e6ec;
  --accent: #0b5cad; --accent-ink: #ffffff; --ok: #1d8a4a; --ok-bg: #e6f4ec; --err: #b42318; --err-bg: #fdecea;
  --warn-bg: #fff6db; --warn: #8a6100; --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
h1, h2 { margin: 0; }
h1 { font-size: 18px; letter-spacing: .2px; }
h2 { font-size: 14px; font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12.5px; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 14px 24px; background: #0f1b2a; color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand p { margin: 2px 0 0; color: #a9b6c6; font-size: 12.5px; }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--accent); font-weight: 700; font-size: 13px; }
.banner { margin-left: auto; background: var(--warn-bg); color: var(--warn); padding: 6px 12px; border-radius: 6px; font-size: 12.5px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 46px; flex-wrap: wrap; }

.controls { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; margin: 16px 24px 0; padding: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1 1 360px; }
.field label, .field .label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.row { display: flex; gap: 8px; }
select, input[type=number] { height: 36px; border: 1px solid #cdd5df; border-radius: 7px; padding: 0 10px; font: inherit; background: #fff; color: var(--ink); }
select { flex: 1; min-width: 0; }
input[type=number] { width: 96px; }
select:focus, input:focus, button:focus-visible { outline: 2px solid #8fb8e6; outline-offset: 1px; }

.btn { height: 36px; padding: 0 16px; border-radius: 7px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.btn.primary { background: var(--accent); color: var(--accent-ink); min-width: 140px; justify-content: center; }
.btn.primary:hover { background: #094d91; }
.btn.secondary { background: #fff; border-color: #cdd5df; color: var(--ink); }
.btn.secondary:hover { background: #f5f7fa; }
.btn.ghost { background: transparent; color: var(--accent); border-color: transparent; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; margin-left: auto; }
.btn:disabled { opacity: .6; cursor: progress; }

.segmented { display: inline-flex; border: 1px solid #cdd5df; border-radius: 7px; overflow: hidden; height: 36px; }
.segmented label { display: flex; cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--ink); font-weight: 500; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { padding: 0 14px; display: flex; align-items: center; border-right: 1px solid #cdd5df; font-weight: 500; }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: #e8f1fb; color: var(--accent); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid #8fb8e6; outline-offset: -2px; }

.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-line { margin: 8px 26px 0; min-height: 18px; font-size: 12.5px; color: var(--muted); }
.status-line.err { color: var(--err); }

.grid { display: grid; grid-template-columns: minmax(320px, 2fr) minmax(420px, 3fr); gap: 16px; margin: 10px 24px 0; }
@media (max-width: 1000px) { .grid { grid-template-columns: 1fr; } }

.viewer-card, .result-card { display: flex; flex-direction: column; min-height: 560px; }
.viewer { position: relative; flex: 1; min-height: 480px; background: linear-gradient(#fbfcfd, #e9eef3); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.viewer canvas { display: block; width: 100%; height: 100%; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; text-align: center; padding: 20px; }
.overlay.err { color: var(--err); }
.hint { margin: 0; padding: 6px 14px 10px; color: var(--muted); font-size: 12px; }

.tabs { display: inline-flex; gap: 4px; }
.tabs.sub { margin-left: auto; background: #eef2f6; border-radius: 7px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tabs button.active { background: #e8f1fb; color: var(--accent); }
.tabs.sub button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c3cbd5; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.run { background: #e0a100; }

.result-body { flex: 1; position: relative; min-height: 480px; display: flex; }
.result-body iframe { flex: 1; border: 0; width: 100%; min-height: 480px; background: #525659; }
.svg-wrap { flex: 1; display: flex; flex-direction: column; background: #fff; }
.svg-wrap img { flex: 1; width: 100%; min-height: 420px; max-height: 70vh; object-fit: contain; padding: 12px; }
.legend { display: flex; gap: 18px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 22px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 6px; }
.empty { margin: auto; color: var(--muted); padding: 30px; text-align: center; }
.error-box { margin: 24px; padding: 16px 18px; background: var(--err-bg); border: 1px solid #f5c2bd; border-radius: 8px; color: var(--err); align-self: flex-start; flex: 1; }
.error-box h3 { margin: 0 0 8px; font-size: 15px; }
.error-box pre { white-space: pre-wrap; word-break: break-word; margin: 0; color: #5c1a14; font-size: 12.5px; font-family: Consolas, monospace; max-height: 340px; overflow: auto; }
.error-box p { margin: 10px 0 0; color: #5c1a14; font-size: 12.5px; }
#pdfFullscreen { margin-left: 0; }
.result-card:fullscreen { background: #fff; border: 0; border-radius: 0; min-height: 0; height: 100vh; }
.result-card:fullscreen .links { display: none; }
.result-card:fullscreen .result-body, .result-card:fullscreen .result-body iframe { min-height: 0; flex: 1 1 auto; }
.links { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; min-height: 36px; align-items: center; }
.links a { color: var(--accent); text-decoration: none; font-weight: 600; }
.links a:hover { text-decoration: underline; }

.compare-card { margin: 16px 24px 0; }
.compare { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f7f9fb; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
td.num { font-variant-numeric: tabular-nums; }
td.rowh { color: var(--muted); font-weight: 600; width: 210px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.err { background: var(--err-bg); color: var(--err); }
.delta-ok { color: var(--ok); } .delta-bad { color: var(--err); font-weight: 600; }
td.errtxt { color: var(--err); white-space: pre-wrap; max-width: 520px; }
footer { margin: 18px 24px 24px; color: var(--muted); font-size: 12px; }
