/* SR Extraction Toolkit */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #121620;
  --muted: #5d6676;
  --faint: #8a92a0;
  --accent: #0d7468;
  --accent-ink: #ffffff;
  --accent-soft: #e3f3f0;
  --accent-line: #a7d9d0;
  --warn-bg: #fff6e0;
  --warn-line: #f1d18a;
  --warn: #7a5200;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 288px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1015;
  --surface: #151920;
  --surface-2: #1b2029;
  --border: #262c37;
  --border-strong: #353d4a;
  --text: #e8ebf1;
  --muted: #a0a8b7;
  --faint: #737c8c;
  --accent: #3cc9b4;
  --accent-ink: #062520;
  --accent-soft: rgba(60, 201, 180, .12);
  --accent-line: rgba(60, 201, 180, .35);
  --warn-bg: rgba(245, 180, 60, .1);
  --warn-line: rgba(245, 180, 60, .35);
  --warn: #f3c46d;
  --danger: #ff8a7a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 20px 14px 14px;
}
.content { min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 8px 40px 40px; outline: none; }

.brand { display: flex; align-items: center; gap: 11px; color: var(--text); padding: 4px 8px 18px; }
.brand:hover { text-decoration: none; }
.brand .logo svg { width: 34px; height: 34px; }
.brand .logo rect { fill: var(--accent); stroke: none; }
.brand .logo path { stroke: var(--accent-ink); stroke-width: 2.6; }
.brand strong { display: block; font-size: 15px; letter-spacing: -0.01em; }
.brand em { display: block; font-style: normal; font-size: 12.5px; color: var(--muted); }

.nav-search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 10px; margin: 0 4px 14px; color: var(--faint); }
.nav-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.nav-search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text); font: inherit; padding: 9px 0; outline: none; }
kbd { font: 11px var(--mono); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }

#nav { flex: 1; }
.nav-group { margin-bottom: 14px; }
.nav-cat { font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 6px 10px 4px; }
.nav-link { display: block; color: var(--text); padding: 6px 10px; border-radius: 8px; font-size: 14px; line-height: 1.35; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-empty { color: var(--muted); padding: 0 10px; font-size: 14px; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.guides-link { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; color: var(--text); border: 1px dashed var(--border-strong); }
.guides-link:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.guides-link span { display: flex; flex-direction: column; font-weight: 600; font-size: 14px; line-height: 1.25; }
.guides-link small { font-weight: 400; color: var(--muted); font-size: 12px; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 40px 0; max-width: 1200px; width: 100%; margin: 0 auto; }
.topbar-spacer { flex: 1; }
.icon-btn.menu-btn { display: none; }
.dp-select { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dp-select select { width: auto; padding: 5px 26px 5px 10px; }

.scrim { display: none; }
.site-foot { max-width: 1120px; margin: 0 auto; padding: 0 40px 32px; width: 100%; }
.site-foot p { margin: 0; font-size: 12.5px; color: var(--faint); border-top: 1px solid var(--border); padding-top: 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; font: 600 14px var(--font); border-radius: 10px; padding: 9px 14px; border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.small svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .45; cursor: default; filter: none; }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- home ---------- */
.hero { padding: 36px 0 26px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 5px 11px; border-radius: 99px; }
.eyebrow svg { width: 15px; height: 15px; }
.hero h1 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 720; margin: 16px 0 12px; max-width: 760px; letter-spacing: -0.025em; }
.lede { color: var(--muted); font-size: 16.5px; max-width: 700px; margin: 0 0 24px; }
.hero-search { display: flex; align-items: center; gap: 12px; max-width: 640px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 0 16px; box-shadow: var(--shadow); color: var(--faint); }
.hero-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.hero-search svg { width: 20px; height: 20px; }
.hero-search input { flex: 1; border: 0; background: transparent; font: inherit; font-size: 16px; color: var(--text); padding: 15px 0; outline: none; }

.quick { margin: 8px 0 34px; }
.quick h2, .home-cat h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border); padding: 7px 13px; border-radius: 99px; transition: all .15s; }
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); text-decoration: none; }

.home-cat { margin-bottom: 30px; }
.cat-icon { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--surface); border: 1px solid var(--border); color: var(--accent); font-size: 13px; text-transform: none; letter-spacing: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.calc-card { position: relative; display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 44px 16px 18px; color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s; }
.calc-card:hover { text-decoration: none; border-color: var(--accent-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.calc-card h3 { font-size: 15.5px; font-weight: 650; margin-bottom: 5px; }
.calc-card p { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.calc-card .go { position: absolute; right: 14px; top: 16px; color: var(--faint); transition: transform .15s, color .15s; }
.calc-card:hover .go { color: var(--accent); transform: translateX(2px); }

/* ---------- calculator ---------- */
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 8px; padding: 22px 0 10px; }
.crumbs span { color: var(--faint); }
.calc-head h1 { font-size: clamp(24px, 2.8vw, 31px); font-weight: 720; letter-spacing: -0.02em; }
.calc-head p { color: var(--muted); margin: 8px 0 16px; max-width: 760px; font-size: 15.5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }

.calc-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; }
.results-panel { position: sticky; top: 16px; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide, .field.check { grid-column: 1 / -1; }
.field:has(select) { grid-column: 1 / -1; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.field .help { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.field.check label { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
.field.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }

input[type="text"], select, textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px;
  transition: border-color .15s, box-shadow .15s; font-variant-numeric: tabular-nums;
}
textarea { font-family: var(--mono); font-size: 13.5px; resize: vertical; }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a92a0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input[type="text"]:hover, select:hover, textarea:hover { border-color: var(--faint); }
input[type="text"]:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 15%, transparent); }
input::placeholder, textarea::placeholder { color: var(--faint); }

.groups { margin-top: 18px; }
.fields:empty + .groups { margin-top: 0; }
.group-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; margin-top: -8px; }
.group-table th { font-size: 12.5px; font-weight: 600; color: var(--muted); text-align: left; padding: 0 6px; white-space: nowrap; }
.group-table tbody th { color: var(--text); font-size: 13px; }
.group-table td { padding: 0 4px; }
.group-table td:last-child { width: 40px; }
.group-table input { padding: 8px 10px; }
.group-table .icon-btn { width: 32px; height: 32px; border-color: transparent; background: transparent; color: var(--faint); }
.group-table .icon-btn:hover { color: var(--danger); background: var(--surface-2); }

/* results */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 28px 10px; color: var(--muted); }
.empty p { margin: 12px 0 0; max-width: 300px; font-size: 14px; }
.empty-ring { width: 46px; height: 46px; border-radius: 50%; border: 2px dashed var(--border-strong); }
.primary-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.big-result { text-align: left; font: inherit; color: inherit; cursor: copy; display: flex; flex-direction: column; gap: 2px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 12px; padding: 14px 16px; transition: transform .1s; }
.big-result:hover { transform: translateY(-1px); }
.big-result:active { transform: scale(.99); }
.br-label { font-size: 12.5px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.br-value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; word-break: break-all; }
.br-value .unit { font-size: 18px; font-weight: 600; margin-left: 2px; color: var(--muted); }
.br-ci { font-size: 13.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.br-note { font-size: 12.5px; color: var(--muted); }
.sec-results { margin: 14px 0 0; border-top: 1px solid var(--border); }
.sr-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 9px 2px; border-bottom: 1px solid var(--border); cursor: copy; }
.sr-row:hover { background: var(--surface-2); }
.sr-row dt { font-size: 14px; color: var(--muted); }
.sr-row dt small { display: block; font-size: 12px; color: var(--faint); }
.sr-row dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.res-table { margin-top: 16px; }
.rt-cap { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.res-table table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.res-table th, .res-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.res-table th { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.callout { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 11px 13px; border-radius: 10px; font-size: 13.5px; line-height: 1.45; }
.callout.warn { background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); }
.callout svg { margin-top: 1px; }
.note { font-size: 13.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.5; }
.tip { font-size: 12px; color: var(--faint); margin: 14px 0 0; }

.method { margin-top: 18px; }
.method summary { cursor: pointer; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
.method summary::-webkit-details-marker { display: none; }
.method summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.method[open] summary::before { transform: rotate(45deg); }
.formula { margin-top: 14px; font-family: var(--mono); font-size: 13.5px; line-height: 1.9; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.refs { margin: 14px 0 0; padding-left: 20px; font-size: 13.5px; color: var(--muted); }
.refs li { margin-bottom: 6px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- guides & login (shared) ---------- */
.page { max-width: 880px; margin: 0 auto; padding: 32px 28px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.page-head .brand { padding: 0; }
.prose h1 { font-size: 32px; font-weight: 720; margin: 6px 0 10px; }
.prose h2 { font-size: 21px; margin: 34px 0 10px; padding-top: 6px; }
.prose h3 { font-size: 17px; margin: 22px 0 8px; }
.prose p, .prose li { color: var(--text); }
.prose .lede { font-size: 16.5px; }
.prose table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14.5px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.prose th, .prose td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.prose th { background: var(--surface-2); font-size: 13px; color: var(--muted); }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin: 16px 0; box-shadow: var(--shadow); }
.box.tip-box { background: var(--accent-soft); border-color: var(--accent-line); }
.box.warn-box { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.box > :first-child { margin-top: 0; } .box > :last-child { margin-bottom: 0; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 8px; }
.guide-list { display: grid; gap: 12px; margin-top: 20px; }
.guide-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; color: var(--text); }
.guide-card:hover { text-decoration: none; border-color: var(--accent-line); box-shadow: var(--shadow); }
.guide-card h3 { font-size: 17px; margin-bottom: 4px; }
.guide-card p { margin: 0; color: var(--muted); font-size: 14px; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin-right: 6px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow); }
.login-card .brand { padding: 0 0 22px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; }
.login-card p { color: var(--muted); margin: 0 0 20px; font-size: 14.5px; }
.login-card input[type="password"] { width: 100%; font: inherit; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 11px 12px; }
.login-card input[type="password"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { width: 100%; justify-content: center; margin-top: 14px; padding: 11px; }
.login-card .error { color: var(--danger); font-size: 14px; margin: 10px 0 0; }
.login-card .back { display: block; text-align: center; margin-top: 18px; font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .calc-grid { grid-template-columns: 1fr; }
  .results-panel { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: min(320px, 86vw); transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
  .icon-btn.menu-btn { display: inline-grid; }
  main, .topbar, .site-foot { padding-left: 18px; padding-right: 18px; }
  .fields { grid-template-columns: 1fr; }
  .hero { padding-top: 18px; }
}
@media print {
  .sidebar, .topbar, .toolbar, .tip, #copy-note, .site-foot { display: none !important; }
  .layout { display: block; }
  .panel { box-shadow: none; }
}
