/* style.css */
:root {
  color-scheme: dark;
  --bg: #0b111a;
  --bg-2: #101927;
  --surface: #141f2e;
  --surface-strong: #1a293b;
  --line: #2b3c51;
  --text: #eff5fb;
  --muted: #9aabba;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --green: #51d69a;
  --yellow: #f9c74f;
  --red: #ff6b6b;
  --shadow: 0 18px 44px rgba(0, 0, 0, .22);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #edf3f8;
  --bg-2: #e3edf6;
  --surface: #ffffff;
  --surface-strong: #f7fafc;
  --line: #d5e0ea;
  --text: #142231;
  --muted: #66778a;
  --accent: #0384c5;
  --accent-strong: #0571a9;
  --green: #078a55;
  --yellow: #a96800;
  --red: #d93f4a;
  --shadow: 0 15px 38px rgba(31, 55, 77, .10);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #edf3f8;
    --bg-2: #e3edf6;
    --surface: #ffffff;
    --surface-strong: #f7fafc;
    --line: #d5e0ea;
    --text: #142231;
    --muted: #66778a;
    --accent: #0384c5;
    --accent-strong: #0571a9;
    --green: #078a55;
    --yellow: #a96800;
    --red: #d93f4a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background:
    radial-gradient(circle at 85% -10%, color-mix(in srgb, var(--accent) 19%, transparent), transparent 31rem),
    linear-gradient(150deg, var(--bg), var(--bg-2));
}

button, select, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 18px 15px 32px;
}

.topbar,
.card-heading,
.section-heading,
.gauge-label,
.combo-top,
.status-strip,
.reference-grid,
footer {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 14px;
  margin: 3px 2px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 65%, var(--line));
  border-radius: 13px;
  color: #061019;
  background: linear-gradient(145deg, #82dfff, var(--accent));
  box-shadow: 0 7px 20px color-mix(in srgb, var(--accent) 20%, transparent);
  font-weight: 900;
  letter-spacing: -.08em;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.15rem, 3.8vw, 1.55rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.65rem, 5vw, 2.55rem); letter-spacing: -.05em; line-height: 1.02; }
h3 { font-size: 1.05rem; letter-spacing: -.02em; }
.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .105em;
  text-transform: uppercase;
}
.eyebrow.accent { color: var(--accent); }

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface);
  font-size: 1.25rem;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 28px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  min-height: 44px;
  flex: 1 0 max-content;
  padding: 0 15px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-size: .87rem;
  font-weight: 750;
}
.tab.active {
  color: #07121c;
  background: var(--accent);
  box-shadow: 0 5px 16px color-mix(in srgb, var(--accent) 27%, transparent);
}

.panel-view { display: none; }
.panel-view.active { display: block; }

.hero-copy {
  max-width: 670px;
  margin: 0 3px 22px;
}
.hero-copy > p:last-child,
.section-heading p:not(.eyebrow) {
  max-width: 650px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.status-strip {
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}
.status-strip div {
  min-width: 50%;
  flex: 1;
  padding: 12px 14px;
  border-right: 1px solid var(--line);
}
.status-strip div:last-child { border-right: 0; }
.status-strip span,
.metric span,
.reference-grid span,
.combo-top span,
dl dt {
  display: block;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.status-strip b { display: block; margin-top: 3px; font-size: .88rem; }

.calculator-grid {
  display: grid;
  gap: 15px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--surface) 96%, white 4%), var(--surface));
  box-shadow: var(--shadow);
}

.setup-card, .target-card, .results-card { padding: 18px; }

.card-heading { justify-content: space-between; gap: 12px; margin-bottom: 17px; }

.field-grid {
  display: grid;
  gap: 13px;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 750;
}

select, input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: var(--bg);
  padding: 0 12px;
  font-weight: 700;
}
select:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.input-unit { position: relative; }
.input-unit input { padding-right: 46px; }
.input-unit span {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
}

.quick-targets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-top: 16px;
}
.quick-targets button,
.load-combo {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-strong);
  font-size: .76rem;
  font-weight: 800;
}
.quick-targets button:hover,
.load-combo:hover { border-color: var(--accent); color: var(--accent); }

.microcopy {
  margin-top: 16px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.5;
}

.results-card { overflow: hidden; }
.results-heading { align-items: start; }
.verdict {
  max-width: 140px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: .7rem;
  font-weight: 850;
  text-align: center;
}
.verdict.good { border-color: color-mix(in srgb, var(--green) 50%, var(--line)); color: var(--green); }
.verdict.warning { border-color: color-mix(in srgb, var(--yellow) 55%, var(--line)); color: var(--yellow); }
.verdict.danger { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); color: var(--red); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.metric {
  min-height: 104px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
}
.metric.primary {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 20%, var(--surface)), var(--surface-strong));
}
.metric strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--text);
  font-size: clamp(1.2rem, 5vw, 1.65rem);
  letter-spacing: -.06em;
}
.metric small { color: var(--muted); font-size: .68rem; }

.gauge-group { margin-top: 21px; }
.gauge-row + .gauge-row { margin-top: 14px; }
.gauge-label { justify-content: space-between; margin-bottom: 6px; color: var(--muted); font-size: .78rem; }
.gauge-label b { color: var(--text); }
.gauge {
  height: 9px;
  overflow: hidden;
  border-radius: 20px;
  background: var(--bg);
}
.gauge i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  transition: width .25s ease;
}
.gauge.turbo i { background: linear-gradient(90deg, var(--green), #85e6ba); }
.at-limit .gauge i { background: linear-gradient(90deg, var(--yellow), var(--red)); }

.advisory {
  margin-top: 19px;
  padding: 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 11px 11px 0;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}
.advisory strong { font-size: .86rem; }
.advisory p { margin-top: 5px; color: var(--muted); font-size: .8rem; line-height: 1.45; }

.section-heading {
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 3px 2px 20px;
}
.compact-filter { width: min(165px, 42vw); flex: 0 0 auto; }

.library-stack { display: grid; gap: 15px; }
.table-card { padding: 17px 0 4px; overflow: hidden; }
.table-card h3 { padding: 0 17px 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th, td { padding: 11px 14px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: color-mix(in srgb, var(--surface-strong) 78%, transparent); font-size: .65rem; letter-spacing: .06em; text-transform: uppercase; }
td { color: var(--text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .71rem; }

.combo-grid {
  display: grid;
  gap: 12px;
}
.combo-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.combo-top { justify-content: space-between; }
.combo-top b { color: var(--accent); font-size: .82rem; }
.combo-output { display: flex; align-items: baseline; gap: 7px; margin: 14px 0; }
.combo-output strong { font-size: 1.75rem; letter-spacing: -.065em; }
.combo-output span { color: var(--muted); font-size: .75rem; }
dl { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 8px; margin: 0 0 15px; }
dl div { min-width: 0; }
dl dt { margin-bottom: 3px; font-size: .61rem; }
dl dd { margin: 0; font-size: .78rem; font-weight: 750; overflow-wrap: anywhere; }
.load-combo { width: 100%; background: transparent; }

.notes-card { margin-top: 16px; padding: 18px; }
.notes-card h3 { margin-bottom: 14px; }
.reference-grid {
  display: grid;
  align-items: stretch;
  grid-template-columns: 1fr;
  gap: 7px;
}
.reference-grid div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.reference-grid b { display: block; margin-top: 4px; font-size: .78rem; }

footer {
  justify-content: space-between;
  gap: 15px;
  margin: 29px 2px 0;
  color: var(--muted);
  font-size: .69rem;
}

@media (min-width: 620px) {
  .app-shell { padding: 26px 24px 40px; }
  .status-strip div { min-width: 25%; }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
  .target-fields { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .combo-grid { grid-template-columns: repeat(2, 1fr); }
  .reference-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
  .calculator-grid {
    grid-template-columns: minmax(280px, .88fr) minmax(270px, .8fr) minmax(350px, 1.1fr);
    align-items: start;
  }
  .setup-card, .target-card { min-height: 424px; }
  .field-grid { grid-template-columns: 1fr; }
  .target-fields { grid-template-columns: 1fr; }
  .quick-targets { grid-template-columns: repeat(2, 1fr); }
  .combo-grid { grid-template-columns: repeat(3, 1fr); }
}
