:root {
  --bg: #0b1020;
  --bg2: #0f1629;
  --panel: #121a30;
  --panel2: #172040;
  --line: #243056;
  --line2: #2e3b68;
  --text: #e7ecf8;
  --muted: #8d99b8;
  --faint: #5d6a8c;
  --accent: #3b82f6;
  --accent2: #60a5fa;
  --accent-bg: rgba(59,130,246,.14);
  --good: #22c55e;
  --good-bg: rgba(34,197,94,.13);
  --warn: #f59e0b;
  --warn-bg: rgba(245,158,11,.12);
  --bad: #ef4444;
  --std: #38bdf8;
  --dc: #a78bfa;
  --vm: #34d399;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.55);
  --radius: 14px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f5fb;
  --bg2: #eaeef8;
  --panel: #ffffff;
  --panel2: #f6f8fd;
  --line: #e1e6f2;
  --line2: #cfd7ea;
  --text: #121a30;
  --muted: #5a6788;
  --faint: #8e99b5;
  --accent: #2563eb;
  --accent2: #1d4ed8;
  --accent-bg: rgba(37,99,235,.09);
  --good: #16a34a;
  --good-bg: rgba(22,163,74,.1);
  --warn: #b45309;
  --warn-bg: rgba(245,158,11,.13);
  --std: #0284c7;
  --dc: #7c3aed;
  --vm: #059669;
  --shadow: 0 10px 30px -16px rgba(20,30,70,.25);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(59,130,246,.12), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(167,139,250,.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .mono { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { font-size: 17px; font-weight: 700; }
.brand p { margin: 0; color: var(--muted); font-size: 12px; }
.logo { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; width: 26px; height: 26px; flex: none; }
.logo i:nth-child(1) { background: #f25022; } .logo i:nth-child(2) { background: #7fba00; }
.logo i:nth-child(3) { background: #00a4ef; } .logo i:nth-child(4) { background: #ffb900; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 8px 14px; font-weight: 600; font-size: 13px;
  background: var(--accent); color: #fff; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent2); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line2); }
.btn.ghost:hover { background: var(--panel2); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn.icon { width: 36px; justify-content: center; padding: 8px 0; }
.iconbtn {
  background: none; border: 1px solid transparent; border-radius: 8px; color: var(--muted);
  width: 30px; height: 30px; display: inline-grid; place-items: center; cursor: pointer; font-size: 15px;
}
.iconbtn:hover { background: var(--panel2); color: var(--text); border-color: var(--line); }
.iconbtn.del:hover { color: var(--bad); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 12px;
  padding: 6px; box-shadow: var(--shadow); z-index: 30;
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 8px;
  border: 0; background: none; cursor: pointer;
}
.menu button:hover { background: var(--panel2); }
.menu button.danger { color: var(--bad); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px; padding: 24px; max-width: 1640px; margin: 0 auto; align-items: start;
}
.inputs { min-width: 0; }
.results {
  position: sticky; top: 78px; max-height: calc(100vh - 96px); overflow: auto;
  min-width: 0; padding-right: 4px; scrollbar-width: thin;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 16px; overflow-x: auto;
}
.tab {
  flex: 1; border: 0; background: none; padding: 9px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent-bg); color: var(--accent2); }
:root[data-theme="light"] .tab.active { color: var(--accent); }

.section {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px;
}
.section > h2 { font-size: 15px; margin-bottom: 14px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.section-head h2 { font-size: 15px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }
.list { display: flex; flex-direction: column; gap: 10px; }
.empty {
  border: 1px dashed var(--line2); border-radius: 12px; padding: 16px; text-align: center;
  color: var(--faint); font-size: 13px;
}

/* ---------- Item rows ---------- */
.item {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  transition: border-color .15s;
}
.item:hover { border-color: var(--line2); }
.item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.item-top .name { flex: 1; font-weight: 600; }
.chip {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: var(--accent-bg); color: var(--accent2); white-space: nowrap;
}
:root[data-theme="light"] .chip { color: var(--accent); }
.chip.gray { background: var(--bg2); color: var(--muted); }
.chip.green { background: var(--good-bg); color: var(--good); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.fields.wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f > span { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.f.span2 { grid-column: span 2; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 10px; outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
input.name-input { background: transparent; border-color: transparent; font-weight: 600; padding: 5px 8px; }
input.name-input:hover { border-color: var(--line); }
input.name-input:focus { background: var(--bg2); }
.prefix { position: relative; }
.prefix::before {
  content: attr(data-p); position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.prefix input { padding-left: 24px; }
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.item-foot { margin-top: 8px; font-size: 12px; color: var(--muted); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.callout {
  background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; font-size: 13px;
}
.callout.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

/* SAL rows */
.sal-row {
  display: grid; grid-template-columns: minmax(0,1fr) 110px 100px 90px 30px; gap: 10px; align-items: center;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.sal-row .line-total { text-align: right; font-weight: 600; }
.sal-head { display: grid; grid-template-columns: minmax(0,1fr) 110px 100px 90px 30px; gap: 10px; padding: 0 12px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Results ---------- */
.res-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.res-head h2 { font-size: 18px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.seg button.on { background: var(--accent); color: #fff; }

.scenarios { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-bottom: 14px; }
.scn {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; overflow: hidden; box-shadow: var(--shadow);
}
.scn::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--c); }
.scn.best { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.scn .lbl { font-size: 12px; font-weight: 700; color: var(--c); text-transform: uppercase; letter-spacing: .05em; }
.scn .big { font-size: clamp(20px, 1.9vw, 28px); font-weight: 800; margin: 6px 0 2px; letter-spacing: -.02em; }
.scn .sub { color: var(--muted); font-size: 12px; }
.scn .ws { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; }
.scn .ws b { font-weight: 600; }
.scn-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; min-height: 30px; }
.badge-best {
  flex: none; font-size: 10.5px; font-weight: 700;
  background: var(--good-bg); color: var(--good); padding: 3px 8px; border-radius: 999px;
}
.bar { height: 6px; background: var(--bg2); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--c); border-radius: 99px; transition: width .35s ease; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card-head h3 { font-size: 14.5px; }
.muted { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; min-width: 130px; }
th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
td .best-cell { color: var(--good); font-weight: 700; }
td .small { display: block; color: var(--muted); font-size: 11px; }
tr.total td { font-weight: 700; border-bottom: 0; border-top: 2px solid var(--line2); }
.col-std { color: var(--std); } .col-dc { color: var(--dc); } .col-vm { color: var(--vm); }

.sum-table td:first-child { color: var(--muted); }
.sum-table td { padding: 7px 4px; }
.sum-table th { padding: 6px 4px; }
.sum-table tr.grand td { font-size: 15px; font-weight: 800; color: var(--text); border-top: 2px solid var(--line2); border-bottom: 0; }
.sum-table tr.sec td { color: var(--text); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat { background: var(--panel2); border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; }
.stat b { display: block; font-size: 19px; font-weight: 800; }
.stat span { color: var(--muted); font-size: 11.5px; }

.warn-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.wmsg {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 11px; font-size: 12.5px;
  background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.wmsg.info { background: var(--accent-bg); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.wmsg.good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.wmsg .ic { font-weight: 800; }

.foot { color: var(--faint); font-size: 11.5px; margin: 6px 2px 20px; }
.print-head { display: none; }

/* ---------- Dialog / toast ---------- */
dialog {
  border: 1px solid var(--line2); border-radius: 16px; background: var(--panel); color: var(--text);
  padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5,8,20,.55); backdrop-filter: blur(3px); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog h3 { font-size: 16px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.saved-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.saved-item .grow { flex: 1; min-width: 0; }
.saved-item small { color: var(--muted); display: block; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  transition: .25s; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Mobile totals bar ---------- */
.mbar { display: none; }
@media (max-width: 1100px) {
  .mbar {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 25;
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
    background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(10px);
    border: 1px solid var(--line2); border-radius: 14px; padding: 8px 10px; box-shadow: var(--shadow);
    text-decoration: none; color: var(--text); transition: opacity .2s, transform .2s;
  }
  .mbar.hide { opacity: 0; transform: translateY(20px); pointer-events: none; }
  .mbar div { min-width: 0; }
  .mbar small { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--c); }
  .mbar b { font-size: 15px; font-variant-numeric: tabular-nums; }
  body { padding-bottom: 70px; }
}
@media print { .mbar { display: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .results { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 640px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .brand p { display: none; }
  .layout { padding: 16px; gap: 16px; }
  .scenarios { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .f.span2 { grid-column: auto; }
  .sal-row { grid-template-columns: 1fr 1fr 30px; }
  .sal-row .line-total { grid-column: 1 / 3; text-align: left; }
  .sal-head { display: none; }
  #btnPrint { display: none; }
}

/* ---------- Print ---------- */
@media print {
  :root { --bg:#fff; --panel:#fff; --panel2:#fff; --text:#000; --muted:#444; --line:#ccc; --line2:#999; --shadow:none; color-scheme: light; }
  body { background: #fff; font-size: 11px; }
  .topbar, .inputs, .seg, .foot + *, #warnings { display: none !important; }
  .layout { display: block; padding: 0; }
  .results { position: static; max-height: none; overflow: visible; }
  .print-head { display: block; margin-bottom: 16px; }
  .print-head h1 { font-size: 20px; }
  .print-head .meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 20px; margin-top: 8px; }
  .card, .scn { break-inside: avoid; box-shadow: none; }
  .scenarios { grid-template-columns: repeat(3, 1fr); }
}

.btn-row { display: flex; gap: 6px; flex: none; }
input.name-input { background: var(--bg2); border-color: var(--line); }
dialog { width: min(520px, calc(100vw - 32px)); }
.fields.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 640px) { .fields.grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fields.grid4 .f.span2 { grid-column: 1 / -1; } }

/* ---------- Compact layout ---------- */
.layout { max-width: none; padding: 12px 14px; gap: 14px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.results { top: 64px; max-height: calc(100vh - 76px); }
.topbar { padding: 8px 14px; }
.tabs { margin-bottom: 10px; }
.tab { padding: 7px 10px; }
.section { padding: 12px; margin-bottom: 10px; }
.section-head { margin-bottom: 8px; align-items: center; }
.section-head .hint { font-size: 12px; }
.list { gap: 4px; }

/* Spreadsheet-style rows */
.r { display: grid; gap: 6px; align-items: center; padding: 3px 4px; border-radius: 8px; }
.r:not(.rh):hover { background: var(--panel2); }
.r.rh { padding: 0 4px 2px; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.r.rh span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r input, .r select { padding: 5px 8px; font-size: 13px; border-radius: 7px; height: 31px; }
.r input[type=number] { padding-right: 2px; }
.r .acts { display: flex; gap: 0; justify-content: flex-end; }
.r .iconbtn { width: 26px; height: 26px; font-size: 13px; }
.r .inh { font-size: 12px; padding-left: 4px; }
.r .rfoot { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); padding: 0 4px 2px; margin-top: -2px; }
.r .rfoot:empty { display: none; }
.r-cl   { grid-template-columns: minmax(120px, 1.2fr) minmax(150px, 1.4fr) minmax(130px, 1fr) 30px; }
.r-host { grid-template-columns: minmax(110px, 1.4fr) minmax(110px, 1.2fr) 58px 72px 100px minmax(110px, 1fr) 56px; }
.r-vm   { grid-template-columns: minmax(100px, 1.2fr) minmax(140px, 1.6fr) 98px 64px minmax(120px, 1fr) 56px; }

/* Denser results */
.res-head { margin-bottom: 10px; }
.scenarios { gap: 10px; margin-bottom: 10px; }
.scn { padding: 12px 14px; }
.scn .big { margin: 4px 0 0; }
.scn .ws { margin-top: 8px; padding-top: 8px; }
.card { padding: 12px 14px; margin-bottom: 10px; }
.card-head { margin-bottom: 6px; }
th, td { padding: 6px 6px; }
.warn-list { gap: 6px; margin-bottom: 10px; }
.wmsg { padding: 8px 10px; }

@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .r.rh { display: none; }
  .r-cl, .r-host, .r-vm { grid-template-columns: 1fr 1fr; padding: 8px; border: 1px solid var(--line); background: var(--panel2); }
  .r > input[data-f=name], .r > select[data-f=place] { grid-column: 1 / -1; }
  .r .acts { grid-column: 1 / -1; }
}

.btn.clr { color: var(--muted); }
.btn.clr:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.btn.danger-btn:hover { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
@media (max-width: 640px) { #btnResetAll { padding: 8px 10px; } }

/* ---------- One-screen results ---------- */
.results { overflow: auto; scrollbar-width: none; }
.results::-webkit-scrollbar { display: none; }
.res-head { align-items: flex-start; }
.envline { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; font-size: 12px; color: var(--muted); }
.envline b { color: var(--text); font-weight: 700; }
.scn .sub { font-size: 11.5px; }
.scn .bar { height: 4px; margin-top: 8px; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 10px; align-items: start; }
.res-grid .card { margin-bottom: 0; }
.res-grid table { font-size: 12px; }
.res-grid th, .res-grid td { padding: 5px 5px; }
.sum-table tr.grand td { font-size: 14px; }
.notes { margin-bottom: 10px; background: var(--accent-bg); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 10px; padding: 6px 10px; font-size: 12.5px; }
.notes.has-warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.notes summary { cursor: pointer; list-style: none; }
.notes summary::-webkit-details-marker { display: none; }
.notes summary b { color: var(--warn); }
.notes .warn-list { margin: 8px 0 2px; }
.foot { margin: 8px 2px 4px; }
@media print { .notes { display: none; } }
.scn-top { min-height: 0; }
.scn .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.sal-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.f > span .chip { text-transform: none; letter-spacing: 0; margin-left: 4px; }

/* Breakdown: cluster row + per-host sub rows */
.bd tr.grp td { border-bottom: 0; padding-top: 8px; }
.bd tr.sub td { font-size: 11.5px; padding-top: 3px; padding-bottom: 3px; border-bottom: 0; color: var(--muted); }
.bd tr.sub td:first-child { padding-left: 14px; color: var(--text); }
.bd tr.sub:last-of-type td, .bd tr.sub + tr.grp td { }
.bd tr.sub + tr.grp td { border-top: 1px solid var(--line); }
.bd td .small { white-space: normal; }
.res-grid .table-wrap { overflow-x: visible; }
.res-grid .bd th:first-child, .res-grid .bd td:first-child { min-width: 0; }

/* Desktop: each side scrolls on its own, the page itself doesn't */
@media (min-width: 1101px) {
  .inputs { position: sticky; top: 64px; max-height: calc(100vh - 76px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
  body { overflow: hidden; }
  .layout { height: calc(100vh - 57px); }
}
@media print { body { overflow: visible !important; } .layout { height: auto !important; } }
.res-grid { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
.bd tr.grp td { font-size: 12.5px; }
.bd td:first-child { white-space: normal; }
.results { scrollbar-width: thin; }
.results::-webkit-scrollbar { display: initial; width: 6px; }
.notes .warn-list { gap: 4px; margin: 6px 0 0; }
.notes .wmsg { padding: 5px 8px; font-size: 12px; }
.scn { padding: 10px 12px; }
.scn .big { font-size: clamp(20px, 1.7vw, 26px); }
.res-head h2 { font-size: 17px; }
@media (min-width: 1700px) { .res-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); } }
.sum-table td { padding: 5px 4px; }
