:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-soft: #eef2ef;
  --surface-muted: #f9faf8;
  --text: #17201d;
  --muted: #5d6965;
  --line: #d8dfdc;
  --line-strong: #b9c4bf;
  --accent: #246b5b;
  --accent-dark: #164a3f;
  --accent-soft: #e3eeea;
  --warning: #8a5a14;
  --danger: #8f2f24;
  --shadow: 0 4px 8px rgba(20, 32, 28, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent-dark);
  font-weight: 600;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 107, 91, 0.22);
  outline-offset: 2px;
}

.site-header,
.site-footer,
.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(216, 223, 220, 0.82);
  background: rgba(246, 247, 245, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 48%, rgba(22, 74, 63, 0.22) 48%, rgba(22, 74, 63, 0.22) 52%, transparent 52%),
    linear-gradient(0deg, transparent 48%, rgba(22, 74, 63, 0.22) 48%, rgba(22, 74, 63, 0.22) 52%, transparent 52%),
    var(--surface);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-end;
}

.site-nav a,
.site-footer a {
  color: var(--accent-dark);
  font-size: 0.92rem;
  text-decoration: none;
}

.site-nav a:hover,
.site-footer a:hover,
.topic-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer {
  padding: 10px 0 28px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.shell {
  padding: 34px 0;
}

.workspace {
  display: grid;
  gap: 20px;
}

.intro {
  display: grid;
  gap: 10px;
  max-width: 920px;
}

.intro-copy {
  max-width: 700px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.intro-kicker {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.section-label,
.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 600;
}

.topic-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  justify-content: flex-end;
}

.topic-nav a {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.tool {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.notice {
  padding: 16px 18px;
  border: 1px solid rgba(138, 90, 20, 0.3);
  border-radius: 8px;
  color: #4e3309;
  background: #fff8e9;
  line-height: 1.5;
}

.inputs,
.results,
.schedule-panel,
.saved-panel {
  padding: 20px;
}

.results {
  position: sticky;
  top: 82px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.schedule-header {
  align-items: flex-end;
}

.schedule-controls {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.compact-field {
  display: grid;
  gap: 6px;
  min-width: 132px;
}

.compact-field span,
.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.compact-field select {
  min-height: 40px;
}

.ghost-button,
.primary-button,
.guide-cta a {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--accent-dark);
  background: var(--surface);
}

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

.primary-button,
.guide-cta a {
  min-height: 46px;
  border: 1px solid var(--accent-dark);
  color: #ffffff;
  background: var(--accent-dark);
}

.primary-button:hover,
.guide-cta a:hover {
  background: var(--accent);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button svg,
.state-icon svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  margin-bottom: 14px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 3px solid rgba(36, 107, 91, 0.16);
  border-color: var(--accent);
}

input:disabled {
  color: var(--accent-dark);
  background: var(--surface-soft);
  opacity: 1;
}

.hint,
.summary,
.footnote,
.analytics-note,
.error-list {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.error-list {
  color: var(--danger);
  font-weight: 600;
}

.error-list ul,
.info-card ul {
  margin: 0;
  padding-left: 20px;
}

.footnote {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.analytics-note {
  font-size: 0.84rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.status,
.subtle {
  color: var(--muted);
  font-size: 0.86rem;
}

.status {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
}

.status.warning {
  color: var(--warning);
  border-color: rgba(138, 90, 20, 0.34);
  background: #fff8e9;
  font-weight: 600;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  display: grid;
  gap: 10px;
  min-height: 108px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.metric.primary {
  grid-column: 1 / -1;
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.metric.savings {
  grid-column: 1 / -1;
  background: var(--accent-soft);
  border-color: rgba(36, 107, 91, 0.26);
}

.metric span {
  color: inherit;
  opacity: 0.74;
  font-size: 0.84rem;
  font-weight: 600;
}

.metric strong {
  overflow-wrap: anywhere;
  font-size: clamp(1.2rem, 3vw, 2rem);
  line-height: 1.1;
}

.schedule-panel {
  overflow: hidden;
}

.saved-list {
  display: grid;
  gap: 12px;
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.saved-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.saved-item p,
.empty-state {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.saved-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.state-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-muted);
  line-height: 1.45;
}

.state-card.compact {
  grid-template-columns: auto 1fr;
  align-items: start;
  padding: 12px;
}

.state-card strong {
  color: var(--text);
}

.state-card p {
  margin: 0;
}

.state-icon {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.state-error {
  border-color: rgba(143, 47, 36, 0.28);
  background: #fff4f2;
}

.state-error .state-icon,
.state-error > svg {
  color: var(--danger);
}

.loader {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.info-card {
  padding: 20px;
  box-shadow: none;
}

.info-card h2 {
  margin-bottom: 12px;
}

.info-card p,
.info-card li {
  color: var(--muted);
  line-height: 1.55;
}

.static-page {
  max-width: 900px;
}

.static-page h1 {
  margin-bottom: 20px;
}

.guide-list {
  display: grid;
  gap: 16px;
}

.guide-list article {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.guide-list article:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.guide-page h2 {
  margin-top: 22px;
}

.guide-page h2:first-child {
  margin-top: 0;
}

.guide-page h3 {
  margin: 16px 0 6px;
  font-size: 1rem;
}

.guide-cta {
  margin-top: 22px;
}

.admin-page h1 {
  max-width: 760px;
}

.admin-login {
  display: flex;
  align-items: end;
  gap: 14px;
  padding: 20px;
}

.admin-login .field {
  flex: 1;
}

.admin-content {
  display: grid;
  gap: 20px;
}

.admin-toolbar {
  margin-top: 0;
}

.admin-metrics .metric.primary {
  grid-column: auto;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-label strong {
  color: var(--text);
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

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

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 860px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav,
  .topic-nav {
    justify-content: flex-start;
  }

  .intro-kicker {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .tool {
    grid-template-columns: 1fr;
  }

  .results {
    position: static;
    order: -1;
  }

  .info-grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-header,
  .site-footer,
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .shell {
    padding: 20px 0;
  }

  h1 {
    font-size: 2.25rem;
  }

  .inputs,
  .results,
  .schedule-panel,
  .saved-panel {
    padding: 16px;
  }

  .form-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .schedule-header,
  .schedule-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .schedule-controls .ghost-button,
  .compact-field,
  .actions .ghost-button,
  .actions .primary-button {
    width: 100%;
  }

  .saved-item,
  .saved-actions,
  .admin-login {
    align-items: stretch;
    flex-direction: column;
  }

  .saved-actions .ghost-button,
  .admin-login .primary-button {
    width: 100%;
  }
}
