:root {
  color-scheme: light;
  --paper: #f5f7f5;
  --white: #fff;
  --ink: #173028;
  --muted: #53665e;
  --green: #245c49;
  --line: #d7e1da;
  --mint: #e7f2eb;
  --warn: #8e3724;
  font: 16px/1.48 "Segoe UI", "Helvetica Neue", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); }
a { color: var(--green); text-underline-offset: .22em; }
button, select, input { font: inherit; }
button, select, summary { cursor: pointer; }
:focus-visible { outline: 3px solid #9a5f2c; outline-offset: 3px; }
.shell { max-width: 1440px; padding: 0 clamp(16px, 3.5vw, 48px); margin: 0 auto; }
.top { color: var(--white); background: #193b30; border-bottom: 4px solid #c7d9be; }
.top-inner { display: flex; justify-content: space-between; align-items: center; min-height: 68px; gap: 20px; }
.brand { display: inline-flex; gap: 13px; align-items: center; font-weight: 750; letter-spacing: .14em; color: inherit; text-decoration: none; }
.brand span { border-left: 1px solid #779789; padding-left: 13px; font-size: .92rem; font-weight: 500; letter-spacing: .025em; color: #e1ece5; }
nav { display: flex; align-items: center; gap: clamp(8px, 2vw, 26px); flex-wrap: wrap; }
nav a, .link-button { color: #e1ece5; text-decoration: none; background: none; border: 0; padding: 7px 0; font-size: .9rem; }
nav a:hover, nav a[aria-current], .link-button:hover { color: white; text-decoration: underline; }
main { padding-top: 37px !important; padding-bottom: 50px !important; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.95rem, 3.7vw, 3rem); line-height: 1.1; letter-spacing: -.038em; font-weight: 690; }
h2 { font-size: 1.03rem; font-weight: 700; }
.hint { color: var(--muted); font-size: .9rem; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 27px; flex-wrap: wrap; }
.page-head .hint { margin-top: 9px; }
.head-actions, .picker { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
label { display: grid; gap: 5px; font-size: .875rem; font-weight: 600; }
input, select { background: white; color: var(--ink); border: 1px solid #9cb1a5; min-height: 42px; border-radius: 6px; padding: 7px 10px; max-width: 100%; }
input::placeholder { color: #6a7c73; }
.button, .primary, .secondary { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; min-height: 42px; border-radius: 6px; padding: 7px 15px; font-size: .92rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.primary { background: var(--green); border-color: var(--green); color: white; }
.primary:hover { background: #183e31; }
.secondary { background: var(--white); border-color: #9cb1a5; color: var(--ink); }
.secondary:hover { background: var(--mint); }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; background: var(--white); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.metrics.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metrics section { display: grid; align-content: start; gap: 4px; padding: 17px clamp(13px, 2vw, 24px); border-right: 1px solid var(--line); }
.metrics section:last-child { border-right: 0; }
.metrics h2 { font-size: .9rem; color: var(--muted); }
.metrics strong { font-size: clamp(1.15rem, 2.45vw, 2.25rem); letter-spacing: -.04em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metrics small { color: var(--muted); font-size: .82rem; }
.metrics .highlight { background: var(--mint); }
.panel { background: white; border: 1px solid var(--line); border-radius: 9px; min-width: 0; }
.section-head { padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.section-head span { font-size: .85rem; color: var(--muted); text-align: right; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(0, 1fr); gap: 18px; }
.monthly-list, .results { margin-top: 20px; }
.chart { padding: 18px; display: grid; gap: 12px; }
.chart-row { display: grid; grid-template-columns: minmax(63px, 19%) minmax(30px, 1fr) max-content; align-items: center; gap: 9px; font-size: .9rem; }
.chart-row strong { text-align: right; min-width: 88px; font-variant-numeric: tabular-nums; }
meter { width: 100%; height: 16px; accent-color: var(--green); }
meter::-webkit-meter-bar { background: #eaf0eb; border: 0; border-radius: 3px; }
meter::-webkit-meter-optimum-value { background: #40765d; border-radius: 3px; }
meter.loss::-webkit-meter-optimum-value { background: var(--warn); }
meter::-moz-meter-bar { background: #40765d; }
meter.loss::-moz-meter-bar { background: var(--warn); }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .91rem; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
th:first-child, .text-col { text-align: left; }
.text-col { white-space: normal; min-width: 120px; }
thead th { background: #f5f8f6; color: var(--muted); font-size: .83rem; }
.result-table th, .result-table td { padding-inline: 15px; }
.result-table tbody tr:hover { background: #f7faf8; }
.negative { color: var(--warn); font-weight: 650; }
.entry-table th, .entry-table td { padding: 7px 5px; }
.entry-table th { white-space: normal; }
.entry-table th:first-child { padding-left: 14px; min-width: 94px; }
.entry-table th:last-child, .entry-table td:last-child { padding-right: 14px; }
.entry-table input.amount { width: 100%; min-width: 76px; }
.amount { text-align: right; font-variant-numeric: tabular-nums; }
.entry-table .note-input { width: 145px; }
.table-foot { padding: 12px 16px; display: flex; align-items: end; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.table-foot .hint { padding-bottom: 9px; }
.paired { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
summary { padding: 14px 18px; font-weight: 700; }
summary strong { float: right; font-size: .86rem; font-weight: 600; color: var(--muted); }
details[open] summary { border-bottom: 1px solid var(--line); }
.cost-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 15px 18px; }
.cost-grid label { align-content: end; }
.archive-costs { list-style: none; padding: 10px 18px; margin: 0; display: grid; gap: 5px 25px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.archive-costs li { display: flex; justify-content: space-between; gap: 7px; color: var(--muted); }
.actions { display: flex; justify-content: end; margin-top: 16px; gap: 8px; flex-wrap: wrap; }
.message { padding: 12px 14px; color: #184834; background: var(--mint); border: 1px solid #b2cabc; border-radius: 6px; margin-bottom: 16px; }
.message.error { color: var(--warn); background: #fff1eb; border-color: #ecc3ae; }
.empty { padding: 22px 18px; color: var(--muted); }
.gate { max-width: 498px; padding-top: clamp(32px, 11vh, 132px) !important; }
.gate-panel { padding: clamp(19px, 5vw, 32px); }
.gate-panel h1 { font-size: 1.9rem; margin-bottom: 24px; }
.stack { display: grid; gap: 15px; }
.stack .primary { justify-self: start; min-width: 132px; }
@media (max-width: 780px) {
  .overview-grid, .paired { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metrics:not(.three) section:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .metrics:not(.three) section:nth-child(2) { border-right: 0; }
}
@media (max-width: 510px) {
  main { padding-top: 25px !important; }
  .top-inner { align-items: start; flex-direction: column; justify-content: center; padding-top: 12px; padding-bottom: 8px; gap: 2px; min-height: 0; }
  nav { column-gap: 13px; }
  nav a, .link-button { font-size: .86rem; }
  .metrics.three { grid-template-columns: 1fr; }
  .metrics.three section { grid-template-columns: 1fr auto; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .metrics.three section:last-child { border-bottom: 0; }
  .archive-costs { grid-template-columns: 1fr; }
  .section-head { padding-inline: 13px; }
}
