/* rodrg UI — design tokens, base, layout, components, views, responsive */

/* ---- tokens */
:root {
  --bg: #f5f6f8; --surface: #fff; --surface-2: #f0f3f7; --border: #d9dee6; --border-strong: #b9c2cf;
  --text: #1d2330; --text-muted: #5d6675; --primary: #1f5fbf; --primary-strong: #174a96; --primary-soft: #e8effa;
  --ok: #1b8a4a; --ok-soft: #e3f1e8; --warn: #9a6512; --warn-soft: #fbeccc; --bad: #c0392b; --bad-soft: #f8d7d3;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs: 15px; --fs-lg: 17px; --fs-xl: 20px; --fs-2xl: 26px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --r1: 6px; --r2: 10px; --control-h: 38px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- base */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font: var(--fs)/1.5 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--primary); }
a:hover { color: var(--primary-strong); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 var(--s3); }
h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--s3); }
code { font-family: var(--mono); font-size: 0.92em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
pre { font-family: var(--mono); font-size: var(--fs-xs); line-height: 1.45; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r1); padding: var(--s3); overflow: auto; max-height: 420px; margin: var(--s2) 0; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); margin: var(--s2) 0; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.is-this td { font-weight: 600; background: var(--primary-soft); }
details { margin: var(--s3) 0; }
summary { cursor: pointer; color: var(--primary); font-weight: 500; }
summary:hover { color: var(--primary-strong); }
button, input, select { font: inherit; color: inherit; }
/* one control height for text inputs, number inputs, selects and buttons */
input:not([type=checkbox]):not([type=radio]):not([type=file]), select {
  height: var(--control-h); line-height: 1.3; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--r1);
  background: var(--surface); min-width: 0; }
select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235d6675' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
input[type=file] { font-size: var(--fs-sm); }
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input:invalid:not(:placeholder-shown) { border-color: var(--bad); }
input:read-only:not([type=file]) { background: var(--surface-2); color: var(--text-muted); }
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
small { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---- layout */
header.top { background: var(--surface); border-bottom: 1px solid var(--border); padding: var(--s3) var(--s5); display: flex; flex-wrap: wrap; align-items: center; gap: var(--s4) var(--s5); }
.brand { font-size: var(--fs-xl); font-weight: 700; color: var(--text); text-decoration: none; }
.brand small { font-weight: 400; margin-left: var(--s2); color: var(--text-muted); font-size: var(--fs-sm); }
nav#nav { display: flex; gap: var(--s1); }
nav#nav a { padding: 6px 14px; border-radius: var(--r1); text-decoration: none; color: var(--text); font-size: var(--fs-md); font-weight: 500; }
nav#nav a:hover { background: var(--surface-2); }
nav#nav a[aria-current="page"] { background: var(--primary); color: #fff; }
.hospital { margin-left: auto; display: flex; align-items: center; gap: var(--s2); min-width: 260px; }
.combo { position: relative; flex: 1; }
.combo input { width: 100%; font-size: var(--fs-sm); }
.menu { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r1); box-shadow: 0 6px 20px rgba(0,0,0,.08); max-height: 320px; overflow: auto; }
.menu li { padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: var(--fs-sm); }
.menu li .code { font-family: var(--mono); color: var(--text-muted); margin-right: 6px; }
.menu li.more { color: var(--text-muted); cursor: default; font-size: var(--fs-xs); border-top: 1px solid var(--border); border-radius: 0; margin-top: 2px; }
.menu li.active, .menu li:hover { background: var(--primary-soft); }
.chip { display: inline-flex; align-items: center; gap: var(--s2); background: var(--primary-soft); border: 1px solid #c5d6f1; border-radius: 20px; padding: 4px 6px 4px 12px; font-size: var(--fs-sm); max-width: 560px; }
.chip .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .meta { color: var(--text-muted); white-space: nowrap; font-size: var(--fs-xs); }
.chip button { border: 0; background: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 6px; border-radius: 50%; color: var(--text-muted); }
.chip button:hover { background: #fff; color: var(--bad); }
main { max-width: 1100px; margin: var(--s5) auto; padding: 0 var(--s4); }
footer { color: var(--text-muted); font-size: var(--fs-xs); text-align: center; padding: var(--s6) var(--s4); line-height: 1.6; }
footer p { margin: 0 0 var(--s1); }

/* ---- components */
.btn { display: inline-flex; align-items: center; justify-content: center; height: var(--control-h); border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--r1); padding: 0 16px; font-size: var(--fs-md); font-weight: 500; cursor: pointer; color: var(--text); text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-strong); }
.btn.small { height: 28px; padding: 0 10px; font-size: var(--fs-sm); }
.btn:disabled { opacity: .6; cursor: progress; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r2); padding: var(--s4) var(--s5); margin: 0 0 var(--s4); }
.card > h2:first-child { margin-top: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 var(--s4); min-width: 0; }
legend { font-size: var(--fs-md); font-weight: 600; color: var(--text-muted); padding: 0; margin-bottom: var(--s2); }
label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--text-muted); }
label > .caption { display: flex; align-items: center; gap: 4px; min-height: 20px; }
label > input, label > select { color: var(--text); font-size: var(--fs); }
label.check { flex-direction: row; align-items: center; gap: var(--s2); color: var(--text); font-size: var(--fs-md); min-height: var(--control-h); }
label.check input { width: 16px; height: 16px; margin: 0; }
.row { display: grid; gap: var(--s3) var(--s4); }
.row-dx { grid-template-columns: 1fr 2fr 2fr; }
.row-auto { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.row-auto > label:not(.check) { justify-content: flex-end; }
.infant-only { display: contents; }
.actions { display: flex; gap: var(--s2); align-items: center; margin-top: var(--s2); }
.result-title { font-size: var(--fs); font-weight: 400; margin: 0 0 var(--s3); display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); }
.result-title .tools { margin-left: auto; display: flex; gap: var(--s2); align-items: center; }
.result-title .tools .btn.small { font-weight: 400; }
.result-title code { font-size: var(--fs-2xl); font-weight: 700; background: none; padding: 0; color: var(--text); }
.result-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); margin: var(--s2) 0; }
.result-line code { font-size: var(--fs-xl); font-weight: 700; background: none; padding: 0; }
dl.facts { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: 0 0 var(--s3); font-size: var(--fs-sm); }
dl.facts > div { display: flex; flex-direction: column; gap: 1px; }
dl.facts dt { color: var(--text-muted); font-size: var(--fs-xs); }
dl.facts dd { margin: 0; }
dl.facts.money { background: var(--surface-2); border-radius: var(--r1); padding: var(--s2) var(--s3); }
dl.facts.money dd b { font-size: var(--fs); }
dl.facts.money.unconfirmed { background: var(--warn-soft); }
dl.facts.money.unconfirmed dd b { color: var(--warn); }
ul.notes { list-style: none; padding: 0; margin: 0 0 var(--s3); display: flex; flex-direction: column; gap: var(--s1); }
.note { font-size: var(--fs-sm); padding: 6px 10px; border-radius: var(--r1); border-left: 3px solid var(--border-strong); background: var(--surface-2); margin: 0 0 var(--s2); }
.note.fatal { border-color: var(--bad); background: var(--bad-soft); }
.note.warning { border-color: var(--warn); background: var(--warn-soft); }
.note.info { border-color: var(--primary); background: var(--primary-soft); }
.note b { margin-right: 4px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: var(--fs-xs); background: var(--surface-2); color: var(--text-muted); margin-right: 4px; vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
ul.codes { list-style: none; padding: 6px 10px; margin: var(--s2) 0; border: 1px solid var(--border); border-radius: var(--r1); background: #fafbfc; max-height: 280px; overflow: auto; font-size: var(--fs-sm); }
ul.codes li { display: flex; gap: var(--s3); padding: 2px 0; }
ul.codes li code, ul.codes li .c { min-width: 76px; font-weight: 600; background: none; padding: 0; }
ul.codes li a { text-decoration: none; color: inherit; display: flex; gap: var(--s3); width: 100%; } ul.codes li a:hover { color: var(--primary); }
.cond { font-family: var(--mono); font-size: var(--fs-xs); background: var(--surface-2); padding: 5px 8px; border-radius: var(--r1); display: inline-block; margin: 3px 0; }
/* decision trace */
.trace ol { list-style: none; padding: 0; margin: var(--s2) 0; font-size: var(--fs-sm); }
.trace li { padding: 4px 0 4px 22px; position: relative; border-left: 2px solid var(--border); margin-left: 6px; }
.trace li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.trace li.ok::before { background: var(--ok); } .trace li.ok { font-weight: 500; }
.trace li.drg { padding-left: 34px; } .trace li.drg::before { left: 6px; width: 8px; height: 8px; top: 12px; }
.trace li .cond { margin: 2px 0 0; display: block; white-space: normal; }
.trace li details { margin: 0; } .trace li details summary { font-weight: 400; font-size: var(--fs-sm); color: var(--text-muted); }
.trace li details p { margin: var(--s1) 0 0; font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.7; }
.trace .summary { font-size: var(--fs-sm); margin: var(--s2) 0; padding: var(--s2) var(--s3); background: var(--surface-2); border-radius: var(--r1); }
.trace .summary b { font-weight: 600; }
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--border); margin: var(--s4) 0 var(--s3); flex-wrap: wrap; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--text-muted); font-weight: 500; font-size: var(--fs-md); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); } .tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: end; margin-bottom: var(--s3); }
.toolbar label { min-width: 160px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); margin-top: var(--s3); font-size: var(--fs-sm); color: var(--text-muted); }
a.help { display: inline-block; width: 16px; height: 16px; line-height: 15px; text-align: center; border-radius: 50%; border: 1px solid var(--primary); color: var(--primary); font-size: 11px; font-weight: 600; text-decoration: none; vertical-align: middle; margin-left: 3px; }
a.help:hover { background: var(--primary); color: #fff; }
.hint { color: var(--text-muted); font-size: var(--fs-sm); margin: var(--s2) 0 var(--s3); }
.search { display: flex; gap: var(--s2); } .search input { flex: 1; font-size: var(--fs); }
.group { margin-bottom: var(--s4); } .group h3 { font-size: var(--fs-md); color: var(--text-muted); margin: 0 0 var(--s1); display: flex; align-items: center; gap: var(--s2); }
.group h3 .count { font-weight: 400; } .group h3 a { font-size: var(--fs-xs); font-weight: 400; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); } th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; } th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
tr.selected td { background: var(--primary-soft); }
.scroll { overflow-x: auto; margin: var(--s2) 0; border-radius: var(--r1);
  background: linear-gradient(90deg, var(--surface) 30%, rgba(255,255,255,0)) 0 0, linear-gradient(90deg, rgba(255,255,255,0), var(--surface) 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.16), rgba(0,0,0,0)) 0 0, radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.16), rgba(0,0,0,0)) 100% 0;
  background-repeat: no-repeat; background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%; background-attachment: local, local, scroll, scroll; }
.scroll table { margin: 0; } .scroll th { background: transparent; } table.wide { min-width: 720px; }
td.ref { color: var(--text-muted); font-style: italic; }
table.wide td:nth-child(2) { min-width: 220px; } table.wide .cond { white-space: normal; min-width: 200px; }
.links a { margin-right: var(--s4); }

/* ---- grupare */
#serie summary { font-size: var(--fs-lg); font-weight: 600; color: var(--text); }
#serie[open] summary { margin-bottom: var(--s3); }
#form-lot { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s4); align-items: center; margin: var(--s3) 0; }
#lot-rezultat table { font-size: var(--fs-sm); } #lot-rezultat tr.err td { background: var(--bad-soft); } #lot-rezultat tr.unc td { background: var(--warn-soft); }
#lot-rezultat .breakdown { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--s3) var(--s4); }
#lot-rezultat .breakdown h4 { margin: 0 0 var(--s1); font-size: var(--fs-sm); color: var(--text-muted); }
#lot-rezultat .rows { max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r1); } #lot-rezultat .rows table { margin: 0; } #lot-rezultat .rows th { position: sticky; top: 0; }
#lot-rezultat td.edits { color: var(--text-muted); font-size: var(--fs-xs); max-width: 360px; }
.unc-list { list-style: none; padding: 0; margin: 0; } .unc-list li { margin: 2px 0; }

/* ---- ghid */
.ghid { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: var(--s4); align-items: start; }
.toc { position: sticky; top: var(--s3); display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }
.toc a { padding: 7px 10px; border-radius: var(--r1); color: var(--text); text-decoration: none; display: flex; gap: var(--s2); align-items: baseline; }
.toc a:hover { background: var(--surface-2); } .toc a.active { background: var(--primary); color: #fff; }
.toc .n { color: var(--text-muted); min-width: 16px; } .toc a.active .n, .toc a.active .min { color: #dfe8f7; }
.toc .min { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); }
article.card { max-width: 78ch; font-size: var(--fs); line-height: 1.6; padding: var(--s5) var(--s6); }
article h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s4); }
article h2 { font-size: var(--fs-xl); margin: var(--s6) 0 var(--s3); scroll-margin-top: var(--s4); }
article h3 { font-size: var(--fs-lg); margin: var(--s5) 0 var(--s2); scroll-margin-top: var(--s4); }
article p { margin: 0 0 var(--s3); } article ul, article ol { margin: 0 0 var(--s3); padding-left: 22px; } article li { margin: 3px 0; }
article a.anchor { color: var(--border); text-decoration: none; font-weight: 400; margin-left: 6px; } article h2:hover a.anchor, article h3:hover a.anchor { color: var(--primary); }
article figure { margin: var(--s4) 0; text-align: center; } article figure img { max-width: 100%; height: auto; } article figcaption { color: var(--text-muted); font-size: var(--fs-xs); margin-top: var(--s1); }
article table { margin: var(--s3) 0 var(--s4); }
article pre { max-height: none; }
article .note { margin: var(--s3) 0; }
article .formula { font-size: var(--fs-lg); font-weight: 500; text-align: center; background: var(--surface-2); border-radius: var(--r2); padding: var(--s3) var(--s4); margin: var(--s3) 0 var(--s4); line-height: 1.7; font-variant-numeric: tabular-nums; }
article .formula small { display: block; font-weight: 400; font-size: var(--fs-sm); margin-top: 2px; }
.exemplu { border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: var(--r2); margin: var(--s4) 0; padding: var(--s3) var(--s4); background: #fbfcfe; font-size: var(--fs-sm); }
.exemplu .eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--primary); font-weight: 600; }
.exemplu .ex-title { font-weight: 600; margin: 2px 0 var(--s2); font-size: var(--fs-md); color: var(--text); }
.exemplu .ex-inputs { color: var(--text-muted); margin-bottom: var(--s2); } .exemplu .ex-inputs b { color: var(--text); font-weight: 600; }
.exemplu .ex-inputs .desc { color: var(--text-muted); }
.exemplu dl.facts { margin-bottom: var(--s2); } .exemplu details { margin: var(--s2) 0; } .exemplu table { font-size: var(--fs-xs); }
.exemplu .ex-actions { margin-top: var(--s2); display: flex; gap: var(--s4); flex-wrap: wrap; font-size: var(--fs-sm); }
.exemplu .ex-actions a { cursor: pointer; }
.valoare { margin: var(--s3) 0; font-size: var(--fs-sm); }
.valoare table { margin: 0; } .valoare table.wide { min-width: 600px; } .valoare td:nth-child(2) { min-width: 240px; }
.pager-ghid { display: flex; justify-content: space-between; margin-top: var(--s6); padding-top: var(--s3); border-top: 1px solid var(--border); font-size: var(--fs-md); gap: var(--s3); }

/* ---- responsive */
@media (max-width: 900px) {
  .row-dx { grid-template-columns: 1fr; }
  .ghid { grid-template-columns: 1fr; }
  .toc { position: static; flex-direction: row; flex-wrap: wrap; } .toc a { padding: 5px 8px; } .toc .min { display: none; }
  header.top { padding: var(--s3) var(--s4); } .hospital { margin-left: 0; width: 100%; }
  article.card { padding: var(--s4); }
}
@media (max-width: 600px) {
  .row-auto { grid-template-columns: 1fr; }
  .search { flex-direction: column; }
  main { padding: 0 var(--s3); } .card { padding: var(--s3) var(--s4); }
  table { font-size: var(--fs-xs); } th, td { padding: 5px 6px; }
  .chip { max-width: 100%; }
  .result-title .tools { margin-left: 0; flex-basis: 100%; }
}
@media print {
  header.top nav, .hospital, .actions, .tools, a.help, #form-lot, .pager, .pager-ghid, .toc, .ex-actions, details.trace summary + * { display: none !important; }
  header.top, .card, article.card { border: 0; box-shadow: none; padding: 0; }
  body { background: #fff; font-size: 12px; } main { max-width: none; margin: 0; padding: 0; }
  .ghid { display: block; } article.card { max-width: none; }
  pre, ul.codes, .rows { max-height: none !important; overflow: visible !important; }
  a { color: inherit; text-decoration: none; }
  footer { text-align: left; }
}
