/* ===========================================================================
   Lucia Medic · SPE Analyzer — clinical design system
   Palette: deep clinical navy, medical teal, warm neutral paper.
   Type: Source Serif 4 for headings (document feel), Inter for UI and data.
   =========================================================================== */
:root {
  --navy-900: #0b2740; --navy-800: #0f3557; --navy-700: #14456f; --navy-600: #1a5688;
  --teal-700: #0b7f73; --teal-600: #0e9f8f; --teal-100: #e4f4f2; --teal-50: #f1faf9;
  --paper: #ffffff; --paper-2: #f9fbfc; --bg: #eef2f6; --bg-2: #e6edf3;
  --ink: #12233a; --ink-2: #33475f; --muted: #64788f; --muted-2: #8497aa;
  --line: #dbe4ec; --line-2: #eaf0f5;
  --red: #b42318; --red-bg: #fef2f1; --amber: #b25e09; --amber-bg: #fff8ec; --green: #17705a; --green-bg: #ecf7f2;
  --trace-bg: #ffffff; --trace-line: #14456f; --trace-bound: #a9bacb; --trace-text: #4a5f76;
  --sh-1: 0 1px 2px rgba(11,39,64,.05);
  --sh-2: 0 1px 3px rgba(11,39,64,.06), 0 8px 24px -8px rgba(11,39,64,.10);
  --sh-3: 0 2px 6px rgba(11,39,64,.07), 0 20px 48px -16px rgba(11,39,64,.18);
  --r-sm: 8px; --r: 12px; --r-lg: 18px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
  margin: 0; color: var(--ink); font: 15px/1.55 var(--sans);
  background: var(--bg);
  min-height: 100vh;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1200px 420px at 50% -160px, rgba(14,159,143,.13), transparent 68%),
    linear-gradient(180deg, #f5f8fa 0%, var(--bg) 420px);
}
a { color: var(--navy-600); }
::selection { background: var(--teal-100); }

/* ------------------------------- top bar ------------------------------- */
header.top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.88); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
header.top::after { content: ""; display: block; height: 3px; background: linear-gradient(90deg, var(--navy-700), var(--teal-600) 55%, #7fd3c6); }
.top-inner { max-width: 1200px; margin: 0 auto; padding: 12px 28px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 13px; text-decoration: none; color: inherit; }
.brand .mark { display: grid; place-items: center; filter: drop-shadow(0 3px 8px rgba(15,76,129,.28)); }
.brand .mark svg { display: block; }
.brand-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 20px; letter-spacing: .1px; color: var(--navy-800); }
.brand-sub { font-size: 11.5px; letter-spacing: .35px; color: var(--muted); text-transform: none; }
.topnav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

/* stepper */
.steps { display: flex; gap: 2px; list-style: none; padding: 4px; margin: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; box-shadow: inset 0 1px 2px rgba(11,39,64,.05); }
.steps li { display: flex; align-items: center; gap: 8px; padding: 6px 15px 6px 6px; border-radius: 999px; color: var(--muted); font-size: 13px; font-weight: 500; white-space: nowrap; transition: background .18s ease, color .18s ease; }
.steps li .num { width: 21px; height: 21px; flex: 0 0 21px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 600; background: #d5dfe9; color: #5d7288; transition: background .18s, color .18s; }
.steps li.active { background: var(--navy-700); color: #fff; box-shadow: 0 2px 8px rgba(20,69,111,.30); }
.steps li.active .num { background: rgba(255,255,255,.22); color: #fff; }
.steps li.done { color: var(--teal-700); }
.steps li.done .num { background: var(--teal-600); color: #fff; font-size: 0; }
.steps li.done .num::after { content: "✓"; font-size: 12px; font-weight: 700; }
.steps li.reachable { cursor: pointer; }
.steps li.reachable:hover { background: #dde6ee; color: var(--navy-700); }
.actions { display: flex; gap: 8px; align-items: center; }

/* ------------------------------- buttons ------------------------------- */
button { font: inherit; font-weight: 500; padding: 9px 17px; border-radius: 10px; border: 1px solid var(--navy-700); background: var(--navy-700); color: #fff; cursor: pointer; transition: background .16s, box-shadow .16s, transform .06s, border-color .16s; }
button:hover { background: var(--navy-600); box-shadow: 0 4px 14px -4px rgba(20,69,111,.45); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--teal-600); outline-offset: 2px; }
button.primary { background: linear-gradient(135deg, var(--navy-700) 0%, var(--teal-700) 100%); border-color: transparent; box-shadow: 0 2px 10px -2px rgba(11,127,115,.45); }
button.primary:hover { background: linear-gradient(135deg, var(--navy-600) 0%, var(--teal-600) 100%); box-shadow: 0 6px 18px -4px rgba(11,127,115,.5); }
button.secondary { background: #fff; color: var(--navy-700); border-color: #c4d2e0; box-shadow: var(--sh-1); }
button.secondary:hover { background: var(--paper-2); border-color: var(--navy-600); box-shadow: var(--sh-1); }
button.ghost { background: transparent; color: var(--navy-700); border-color: transparent; }
button.ghost:hover { background: #e8eef4; box-shadow: none; }
button.lang { border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; font-size: 11.5px; font-weight: 600; letter-spacing: .8px; color: var(--muted); background: #fff; }
button.lang:hover { color: var(--navy-700); border-color: var(--navy-600); background: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ------------------------------- layout -------------------------------- */
main { max-width: 1200px; margin: 0 auto; padding: 30px 28px 80px; }
.panel { scroll-margin-top: 130px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 30px 34px; margin-bottom: 20px; box-shadow: var(--sh-2); }
.hidden { display: none !important; }
h1 { font-family: var(--serif); font-size: 32px; line-height: 1.18; margin: 0 0 10px; color: var(--navy-900); letter-spacing: -.3px; }
h2 { font-family: var(--serif); font-size: 22px; margin: 0 0 16px; color: var(--navy-800); letter-spacing: -.1px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
p { margin: 0 0 10px; }
.small { font-size: 13px; color: var(--muted); line-height: 1.5; }
.section-title { display: flex; align-items: center; gap: 11px; margin: 30px 0 16px; padding-bottom: 11px; border-bottom: 1px solid var(--line-2); font-size: 19px; }
.section-title:first-of-type { margin-top: 6px; }
.step-dot { width: 27px; height: 27px; flex: 0 0 27px; border-radius: 50%; display: grid; place-items: center; background: var(--teal-100); color: var(--teal-700); font-family: var(--sans); font-size: 13px; font-weight: 700; }

/* --------------------------------- hero -------------------------------- */
.hero { display: grid; grid-template-columns: 1.25fr .95fr; gap: 34px; align-items: center; padding: 6px 0 26px; border-bottom: 1px solid var(--line-2); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; color: var(--teal-700); margin: 0 0 8px; }
.lead { font-size: 16px; line-height: 1.62; color: var(--ink-2); max-width: 54ch; margin-bottom: 16px; }
.hero-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.hero-points li { position: relative; padding-left: 26px; font-size: 14px; color: var(--ink-2); }
.hero-points li::before { content: ""; position: absolute; left: 0; top: 3px; width: 17px; height: 17px; border-radius: 50%; background: var(--teal-100); }
.hero-points li::after { content: ""; position: absolute; left: 5.5px; top: 6.5px; width: 5px; height: 9px; border: solid var(--teal-700); border-width: 0 2px 2px 0; transform: rotate(43deg); }
.hero-art { background: linear-gradient(180deg, #fbfdfe, var(--paper-2)); border: 1px solid var(--line-2); border-radius: var(--r); padding: 14px 12px 6px; box-shadow: inset 0 1px 0 #fff; }
.hero-art svg { width: 100%; height: auto; display: block; }
.hero-zones line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; gap: 22px; } .hero-art { order: -1; } h1 { font-size: 26px; } }

/* --------------------------------- cards ------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(238px, 1fr)); gap: 14px; }
.card { position: relative; text-align: left; background: var(--paper); color: var(--ink); border: 1.5px solid var(--line); border-radius: var(--r); padding: 18px 18px 20px; display: flex; flex-direction: column; gap: 8px; font-weight: 400; box-shadow: none; transition: border-color .18s, box-shadow .18s, transform .18s, background .18s; }
.card:hover { border-color: #b3c5d6; box-shadow: var(--sh-2); transform: translateY(-2px); background: var(--paper); }
.card-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-2); color: var(--navy-700); transition: background .18s, color .18s; }
.card-ico svg { width: 21px; height: 21px; }
.card b { font-size: 15.5px; color: var(--navy-800); font-weight: 600; letter-spacing: -.1px; }
.card span:not(.card-ico) { font-size: 13px; color: var(--muted); line-height: 1.5; }
.card.selected { border-color: var(--teal-600); background: var(--teal-50); box-shadow: 0 0 0 3px rgba(14,159,143,.12); }
.card.selected .card-ico { background: var(--teal-600); color: #fff; }
.card.selected::after { content: "✓"; position: absolute; top: 14px; right: 15px; width: 20px; height: 20px; border-radius: 50%; background: var(--teal-600); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

/* ------------------------------ upload area ---------------------------- */
.drop { border: 1.5px dashed #b3c5d6; border-radius: var(--r); padding: 34px 24px; text-align: center; cursor: pointer; background: linear-gradient(180deg, #fcfdfe, var(--paper-2)); transition: border-color .18s, background .18s, box-shadow .18s; }
.drop:hover, .drop.over { border-color: var(--teal-600); background: var(--teal-50); box-shadow: 0 0 0 4px rgba(14,159,143,.10); }
.drop-ico { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: #fff; border: 1px solid var(--line); color: var(--navy-600); margin-bottom: 12px; box-shadow: var(--sh-1); }
.drop:hover .drop-ico, .drop.over .drop-ico { color: var(--teal-700); border-color: var(--teal-600); }
.drop-main { font-size: 15px; font-weight: 500; color: var(--ink); margin-bottom: 6px; }
.alt-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding: 14px 16px; background: var(--paper-2); border: 1px solid var(--line-2); border-radius: var(--r); }
.alt-label { font-size: 13.5px; color: var(--muted); }
.alt-row select { min-width: 300px; flex: 1 1 260px; }
.alt-sep { width: 1px; height: 24px; background: var(--line); }
@media (max-width: 620px) { .alt-sep { display: none; } .alt-row select { min-width: 0; } }

/* ------------------------------- controls ------------------------------ */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.toolbar:last-child { border-bottom: none; padding-bottom: 0; }
label { display: inline-flex; gap: 7px; align-items: center; font-size: 14px; color: var(--ink-2); }
input[type=number], input[type=url], input[type=text], select, textarea { font: inherit; padding: 8px 11px; border: 1px solid #c4d2e0; border-radius: var(--r-sm); background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover { border-color: #a9bccd; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal-600); box-shadow: 0 0 0 3px rgba(14,159,143,.15); }
textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--teal-600); }
details > summary { cursor: pointer; font-size: 13px; color: var(--navy-600); padding: 6px 0; }

/* ---------------------------- work surfaces ---------------------------- */
.workspace { overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: #dfe7ee; max-height: 70vh; box-shadow: inset 0 2px 8px rgba(11,39,64,.08); }
#img-canvas { display: block; cursor: crosshair; }
.chartwrap { border: 1px solid var(--line); border-radius: var(--r); background: var(--trace-bg); overflow: hidden; box-shadow: var(--sh-1); }
#trace-canvas { width: 100%; height: auto; display: block; cursor: ew-resize; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; margin-top: 10px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; gap: 24px; } }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 16px; margin: 10px 0 16px; }
@media (max-width: 620px) { .checks { grid-template-columns: 1fr; } }
.checks label { font-size: 13.5px; }
.lanes { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.lanes button { padding: 5px 13px; font-size: 13px; }
.ocr { max-height: 200px; overflow: auto; background: var(--paper-2); border: 1px solid var(--line-2); padding: 11px; font-size: 12px; white-space: pre-wrap; border-radius: var(--r-sm); font-family: var(--mono); }

/* -------------------------------- tables ------------------------------- */
table.fr, table.kv { border-collapse: collapse; width: 100%; font-size: 14px; }
table.fr thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .9px; color: var(--muted); font-weight: 600; background: var(--paper-2); border-bottom: 1px solid var(--line); }
table.fr th, table.fr td, table.kv th, table.kv td { border-bottom: 1px solid var(--line-2); padding: 9px 11px; text-align: left; vertical-align: top; }
table.fr tbody tr:hover { background: var(--teal-50); }
table.fr td:nth-child(n+2) { font-variant-numeric: tabular-nums; }
table.kv th { width: 34%; color: var(--muted); font-weight: 500; }
table.fr input { width: 6.5em; text-align: right; font-variant-numeric: tabular-nums; }
.flag-h, .flag-l, .flag-n { display: inline-block; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 5px; font-size: 12px; font-weight: 700; }
.flag-h { color: var(--red); background: var(--red-bg); } .flag-l { color: var(--amber); background: var(--amber-bg); } .flag-n { color: var(--green); background: var(--green-bg); }

/* -------------------------------- report ------------------------------- */
.report { background: var(--paper); padding: 4px 2px; }
.report header { border-bottom: 2px solid var(--navy-700); margin-bottom: 20px; padding-bottom: 12px; }
.report h1 { font-size: 25px; margin-bottom: 6px; }
.report .meta { color: var(--muted); font-size: 12.5px; letter-spacing: .1px; }
.report section { margin: 26px 0; page-break-inside: avoid; scroll-margin-top: 130px; }
.report h2 { display: flex; align-items: baseline; gap: 8px; font-size: 16.5px; color: var(--navy-700); border-bottom: 1px solid var(--line); padding-bottom: 7px; margin-bottom: 14px; }
.report h3 { text-transform: none; letter-spacing: -.1px; font-size: 15px; color: var(--navy-800); font-weight: 600; font-family: var(--serif); margin: 0 0 6px; }
.report .status { padding: 12px 16px; border-radius: var(--r-sm); background: var(--paper-2); border-left: 4px solid var(--muted-2); font-size: 15px; }
.report .status-restriction { background: var(--red-bg); border-left-color: var(--red); color: #7c1d16; }
.report .status-suspicious { background: var(--amber-bg); border-left-color: var(--amber); color: #7a4106; }
.report .status-none { background: var(--green-bg); border-left-color: var(--green); color: #0f5442; }
.report .note { background: var(--amber-bg); border-left: 3px solid var(--amber); padding: 9px 13px; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-size: 14px; }
.report .src { font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }
.report .findings { padding-left: 20px; }
.report .findings li { margin-bottom: 12px; padding-left: 10px; }
.report .sev-3 { border-left: 3px solid var(--red); } .report .sev-2 { border-left: 3px solid var(--amber); } .report .sev-1 { border-left: 3px solid var(--muted-2); } .report .sev-0 { border-left: 3px solid var(--green); }
.report pre { font-size: 11px; background: var(--paper-2); border: 1px solid var(--line-2); padding: 9px; overflow: auto; max-height: 220px; border-radius: var(--r-sm); font-family: var(--mono); }
.report details summary { font-size: 12px; }
.report .trace { margin: 10px 0 14px; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: #fff; }
.tracesvg { width: 100%; height: auto; display: block; }
.report .pattern { background: var(--paper-2); border: 1px solid var(--line-2); border-left: 3px solid var(--teal-600); border-radius: 0 var(--r-sm) var(--r-sm) 0; padding: 13px 16px; margin-bottom: 11px; }
.model-opinion { background: #f6f4fd; border: 1px solid #e3ddf7; border-left: 3px solid #6d4fc2; padding: 12px 16px; margin: 18px 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.model-opinion h2 { color: #4f3a91; border-bottom-color: #e3ddf7; }
.feedback { border-top: 1px dashed var(--line); margin-top: 28px; padding-top: 18px; }
.feedback h3 { font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--navy-800); font-weight: 600; }

/* -------------------------------- dialog ------------------------------- */
dialog { border: none; border-radius: var(--r-lg); max-width: 840px; width: 92%; padding: 0; box-shadow: var(--sh-3); color: var(--ink); }
dialog article { padding: 28px 32px; max-height: 82vh; overflow: auto; }
dialog h2 { font-size: 22px; }
dialog h3 { color: var(--navy-800); font-size: 13px; }
dialog ul { padding-left: 20px; } dialog li { margin-bottom: 6px; font-size: 14px; }
dialog::backdrop { background: rgba(11,39,64,.45); backdrop-filter: blur(3px); }

/* -------------------------------- footer ------------------------------- */
footer { border-top: 1px solid var(--line); background: rgba(255,255,255,.7); }
.foot-inner { max-width: 1200px; margin: 0 auto; padding: 18px 28px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }

/* ------------------------------ responsive ----------------------------- */
@media (max-width: 980px) {
  .top-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  .topnav { justify-content: space-between; }
  .steps li span:not(.num) { display: none; }
  .steps li.active span:not(.num) { display: inline; }
  main { padding: 22px 18px 60px; } .panel { padding: 22px 20px; border-radius: var(--r); }
}

/* --------------------------------- print ------------------------------- */
@media print {
  header.top, .toolbar, .feedback, footer, #panel-1, #panel-2, #panel-3, .model-opinion { display: none !important; }
  body { background: #fff; } main { max-width: none; padding: 0; }
  .panel { border: none; box-shadow: none; padding: 0; margin: 0; }
  .report details { display: none; }
  .report section { break-inside: avoid; }
}
