:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #647067;
  --line: #d8ded8;
  --panel: #ffffff;
  --page: #eef2ef;
  --accent: #1f7a5a;
  --accent-strong: #145a42;
  --warn: #a54628;
  --soft: #e1eee7;
  --shadow: 0 18px 55px rgba(23, 32, 27, 0.11);
  --nav-width: 244px;
  --nav-collapsed: 76px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(238, 242, 239, 0.9), rgba(238, 242, 239, 0.94)),
    url("https://images.unsplash.com/photo-1560518883-ce09059eeffa?auto=format&fit=crop&w=1800&q=80");
  background-size: cover;
  background-position: center;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

a {
  color: inherit;
}

button,
input {
  font: inherit;
}

.dashboard-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto 1fr;
  width: var(--nav-width);
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 8px 0 28px rgba(23, 32, 27, 0.08);
}

.nav-brand {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
  min-height: 50px;
  margin-bottom: 14px;
}

.nav-brand a,
.nav-links a {
  display: flex;
  align-items: center;
  min-width: 0;
  border-radius: 8px;
  text-decoration: none;
}

.nav-brand a {
  gap: 10px;
}

.brand-mark,
.nav-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  font-weight: 900;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: #ffffff;
  background: var(--accent-strong);
  font-size: 0.82rem;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.nav-label strong,
.nav-label small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-label small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.nav-toggle {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
}

.nav-toggle span {
  width: 14px;
  height: 14px;
  border-top: 3px solid var(--accent-strong);
  border-left: 3px solid var(--accent-strong);
  transform: rotate(-45deg);
}

.nav-links {
  display: grid;
  align-content: start;
  gap: 8px;
}

.nav-links a {
  gap: 10px;
  min-height: 44px;
  padding: 0 10px;
  color: var(--muted);
  font-weight: 850;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--accent-strong);
  background: var(--soft);
}

.nav-icon {
  width: 28px;
  height: 28px;
  background: rgba(31, 122, 90, 0.12);
  font-size: 0.86rem;
}

body.nav-collapsed .dashboard-nav {
  width: var(--nav-collapsed);
}

body.nav-collapsed .nav-brand {
  grid-template-columns: 1fr;
}

body.nav-collapsed .nav-toggle {
  order: -1;
}

body.nav-collapsed .nav-toggle span {
  transform: rotate(135deg);
}

body.nav-collapsed .nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  clip: rect(0 0 0 0);
  overflow: hidden;
  white-space: nowrap;
}

body.nav-collapsed .nav-brand a,
body.nav-collapsed .nav-links a {
  justify-content: center;
}

.shell {
  width: min(1420px, calc(100% - var(--nav-width) - 32px));
  margin: 0 auto 0 var(--nav-width);
  padding: 30px 0;
  transition: margin-left 180ms ease;
}

body.nav-collapsed .shell {
  width: min(1420px, calc(100% - var(--nav-collapsed) - 32px));
  margin-left: var(--nav-collapsed);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.08rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(145px, 1fr));
  gap: 10px;
  width: min(610px, 100%);
}

.summary-strip div,
.formula-box {
  padding: 14px 16px;
  border: 1px solid rgba(216, 222, 216, 0.85);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(23, 32, 27, 0.08);
  backdrop-filter: blur(14px);
}

.summary-strip span,
.formula-box span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-strip strong,
.formula-box strong {
  font-size: 1.2rem;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.main-stack {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.controls,
.panel {
  border: 1px solid rgba(216, 222, 216, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.controls {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.control-head,
.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.ghost-button {
  min-width: 72px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: var(--soft);
  cursor: pointer;
  font-weight: 800;
}

#useSolverBtn {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #ffffff;
  background: var(--accent-strong);
  cursor: pointer;
  font-weight: 850;
}

label {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

input[type="text"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fbfdfb;
}

input:focus {
  outline: 3px solid rgba(31, 122, 90, 0.18);
  border-color: var(--accent);
}

.input-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.input-pair span {
  color: var(--ink);
  font-size: 0.9rem;
}

fieldset {
  margin: 18px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.radio-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  margin: 10px 0;
  color: var(--ink);
  font-weight: 700;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  padding: 18px 18px 0;
}

.panel-head p {
  max-width: 780px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.solver-panel {
  overflow: visible;
}

.solver-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 0 18px 18px;
}

.solver-card,
.ratio-control {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfb;
}

.solver-card label:last-child,
.ratio-control {
  margin-bottom: 0;
}

.ratio-control {
  grid-column: 1 / -1;
}

.solver-results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: #f7faf7;
}

.solver-results div {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.solver-results div:last-child {
  border-right: 0;
}

.solver-results span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.solver-results strong {
  font-size: 1.45rem;
}

.solver-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

.solver-actions span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 850px;
}

th,
td {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  background: #f7faf7;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  font-variant-numeric: tabular-nums;
}

tr.highlight {
  background: #edf7f1;
}

.good {
  color: var(--accent-strong);
  font-weight: 850;
}

.bad {
  color: var(--warn);
  font-weight: 850;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--accent-strong);
  background: var(--soft);
  font-size: 0.78rem;
  font-weight: 850;
}

.pill.bad {
  color: var(--warn);
  background: #f7e5df;
}

@media (max-width: 980px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
    display: grid;
  }

  .controls {
    position: static;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .solver-grid,
  .solver-results {
    grid-template-columns: 1fr;
  }

  .solver-results div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .solver-results div:last-child {
    border-bottom: 0;
  }

  .solver-actions {
    display: grid;
  }
}

@media (max-width: 620px) {
  .dashboard-nav {
    right: 0;
    bottom: auto;
    width: 100%;
    height: 68px;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr;
    gap: 10px;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-brand {
    margin-bottom: 0;
  }

  .nav-toggle {
    display: none;
  }

  .nav-links {
    display: flex;
    justify-content: end;
    overflow-x: auto;
  }

  .nav-links a {
    flex: 0 0 auto;
  }

  body.nav-collapsed .dashboard-nav {
    width: 100%;
  }

  body.nav-collapsed .nav-label {
    position: static;
    width: auto;
    height: auto;
    clip: auto;
    overflow: hidden;
  }

  .shell {
    width: min(100% - 20px, 1420px);
    margin: 68px auto 0;
    padding: 16px 0;
  }

  body.nav-collapsed .shell {
    margin: 68px auto 0;
  }

  .panel-head,
  .control-head {
    display: grid;
  }

  .formula-box {
    width: 100%;
  }
}
