:root {
  --navy: #0f2942;
  --navy-soft: #16375a;
  --ink: #1c232b;
  --muted: #5c6672;
  --line: #d7dce2;
  --line-strong: #b8c0ca;
  --paper: #f5f6f8;
  --white: #ffffff;
  --accent: #9a3b1e;
  --accent-soft: #f4e7e1;
  --good: #1f6b45;
  --bad: #8c2f2f;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(15, 41, 66, 0.06), 0 4px 14px rgba(15, 41, 66, 0.05);
  --serif: Georgia, "Liberation Serif", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", "Liberation Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin: 0;
}

p {
  margin: 0 0 0.75rem;
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: #eef1f5;
  padding: 0.08em 0.32em;
  border-radius: 3px;
}

.shell {
  width: min(1180px, calc(100% - 2.5rem));
  margin-inline: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Masthead */

.masthead {
  background:
    radial-gradient(1100px 340px at 15% -40%, rgba(154, 59, 30, 0.32), transparent 62%),
    linear-gradient(160deg, #0f2942 0%, #16375a 100%);
  color: #eaf0f6;
  padding: 2.6rem 0 2.4rem;
  border-bottom: 3px solid var(--accent);
}

.eyebrow {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #c9a48f;
}

.masthead h1 {
  color: #ffffff;
  font-size: clamp(1.75rem, 3.4vw, 2.5rem);
  line-height: 1.15;
}

.lede {
  margin: 0.85rem 0 0;
  max-width: 62ch;
  color: #c6d3e0;
  font-size: 0.98rem;
}

/* Panels */

main.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
  padding: 2rem 0 3rem;
}

.panel {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem 1.5rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 1.2rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 70ch;
}

/* Fields */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}

.field-wide {
  grid-column: 1 / -1;
}

.field input[type="number"] {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.field input[type="number"]:focus,
.field input[type="range"]:focus,
.editor input:focus,
.button:focus-visible {
  outline: 2px solid var(--navy-soft);
  outline-offset: 2px;
}

.field output {
  float: right;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0;
  text-transform: none;
}

input[type="range"] {
  width: 100%;
  margin: 0.35rem 0 0;
  accent-color: var(--navy);
}

/* Tables */

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
  min-width: 640px;
}

thead th {
  background: #eef1f5;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

tbody td,
tfoot td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: 1px solid var(--line);
}

tbody tr:hover {
  background: #fbfbfc;
}

tfoot td {
  background: #f3f5f8;
  font-weight: 600;
  border-bottom: none;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.editor input {
  width: 100%;
  min-width: 4.5rem;
  padding: 0.38rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font: inherit;
  font-size: 0.87rem;
  background: var(--white);
  color: var(--ink);
}

.editor .name-input {
  min-width: 11rem;
}

.editor td.cost-readout {
  color: var(--muted);
  white-space: nowrap;
}

.row-remove {
  border: 1px solid transparent;
  background: none;
  color: var(--bad);
  font: inherit;
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  border-radius: 3px;
}

.row-remove:hover {
  background: #fbeeee;
  border-color: #e6c9c9;
}

/* Buttons */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

.toolbar-end {
  justify-content: flex-end;
}

.preset-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.preset-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.15rem;
}

.button {
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius);
  border: 1px solid var(--navy);
  background: var(--navy);
  color: #ffffff;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button:hover {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
}

.button-quiet {
  background: var(--white);
  color: var(--navy);
  border-color: var(--line-strong);
}

.button-quiet:hover {
  background: #eef1f5;
  border-color: var(--navy-soft);
}

.button:disabled {
  opacity: 0.55;
  cursor: progress;
}

/* Summary */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.stat {
  border: 1px solid var(--line);
  border-top: 3px solid var(--navy);
  border-radius: var(--radius);
  padding: 0.7rem 0.8rem;
  background: #fcfcfd;
}

.stat.is-accent {
  border-top-color: var(--accent);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  display: block;
  font-family: var(--serif);
  font-size: 1.45rem;
  color: var(--navy);
  line-height: 1.25;
}

.stat-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Status */

.status {
  display: inline-block;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-full {
  background: #e8f3ed;
  color: var(--good);
  border-color: #cbe3d7;
}

.status-part {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: #e6cfc5;
}

.status-none {
  background: #eef0f3;
  color: #4b5563;
  border-color: #dde1e7;
}

/* Notes */

.notes {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem 0.75rem 1.9rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 3px 3px 0;
  font-size: 0.85rem;
  color: #6a3320;
}

.notes li + li {
  margin-top: 0.3rem;
}

.alert {
  border: 1px solid #e2bcbc;
  border-left: 4px solid var(--bad);
  background: #fbf0f0;
  color: #7a2626;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.alert ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}

/* Charts */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 1.25rem;
}

.chart-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem;
  background: #fcfcfd;
}

.chart-card figcaption {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.canvas-wrap {
  position: relative;
  height: 300px;
}

.chart-note {
  margin: 0.7rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Method */

.method-body {
  max-width: 78ch;
}

.method-body p {
  font-size: 0.92rem;
  color: #333b45;
}

.method-body pre {
  background: #f2f4f7;
  border: 1px solid var(--line);
  border-left: 3px solid var(--navy);
  border-radius: 3px;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  line-height: 1.6;
  color: #26313d;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--line);
  background: #eceff3;
  padding: 1.4rem 0 1.8rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0 0 0.35rem;
}

.site-footer cite {
  font-style: italic;
  color: #48525e;
}

@media (max-width: 720px) {
  table {
    min-width: 100%;
  }

  thead th {
    white-space: normal;
  }

  .col-rank,
  .col-priority,
  .col-power,
  .col-cost,
  .col-share,
  .col-ratio,
  .col-full,
  .editor .cost-readout {
    display: none;
  }

  tbody td,
  tfoot td,
  thead th {
    padding: 0.45rem 0.4rem;
  }

  .editor .name-input {
    min-width: 5rem;
  }

  .editor input {
    min-width: 2.6rem;
  }

  .row-remove {
    font-size: 0.7rem;
    padding: 0.2rem 0.25rem;
  }

  .status {
    white-space: normal;
    font-size: 0.64rem;
    letter-spacing: 0.02em;
  }

  .results {
    font-size: 0.8rem;
  }
}

@media (max-width: 640px) {
  .shell {
    width: calc(100% - 1.5rem);
  }

  .masthead {
    padding: 1.8rem 0 1.7rem;
  }

  .panel {
    padding: 1.1rem 1rem 1.2rem;
  }

  .summary {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .canvas-wrap {
    height: 240px;
  }
}

@media print {
  body {
    background: #ffffff;
    font-size: 11pt;
  }

  .masthead {
    background: #ffffff;
    color: #000000;
    border-bottom: 2px solid #000000;
    padding: 0 0 1rem;
  }

  .masthead h1,
  .eyebrow,
  .lede {
    color: #000000;
  }

  .panel {
    border: none;
    box-shadow: none;
    padding: 0;
    break-inside: avoid;
  }

  .toolbar,
  .preset-group,
  .row-remove,
  #add-appliance,
  .site-footer {
    display: none !important;
  }

  .canvas-wrap {
    height: 240px;
  }

  main.shell {
    gap: 1.2rem;
    padding: 1rem 0;
  }
}
