:root {
  --ink: #17212b;
  --muted: #5b6b7c;
  --line: #d9e1e8;
  --bg: #f2f5f8;
  --panel: #ffffff;
  --accent: #12557a;
  --accent-soft: #e6f0f6;
  --danger: #b3261e;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

.site-header {
  background: var(--accent);
  color: #fff;
  padding: 1.5rem 1.25rem;
}
.site-header h1 { margin: 0; font-size: 1.6rem; }
.tagline { margin: 0.35rem 0 0; color: #cfe3ee; font-size: 0.95rem; }

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.25rem;
  display: grid;
  gap: 1.25rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
}
.panel h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}
.panel-head h2 { margin: 0; }

.hint { margin: 0.25rem 0 0.9rem; color: var(--muted); font-size: 0.87rem; }

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

.field { display: flex; flex-direction: column; }
.field label,
.inline-label {
  font-weight: 600;
  font-size: 0.87rem;
  margin-bottom: 0.3rem;
  color: var(--muted);
}
.inline-label { margin: 0 0.15rem 0 0.5rem; }

input[type="number"], select {
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid #b9c6d1;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}
input[type="number"]:focus, select:focus, .btn:focus {
  outline: 3px solid #9ec9e2;
  outline-offset: 1px;
}

.error {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--danger);
  min-height: 1.1em;
}
.error.block { min-height: 0; }
.error.block.visible { margin-bottom: 0.75rem; }

.derived {
  margin: 1.1rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}
.derived > div {
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}
.derived dt { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.derived dd {
  margin: 0.15rem 0 0;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.btn {
  font: inherit;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: #0e4361; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-remove {
  background: #fff;
  color: var(--danger);
  border-color: #d7b3b0;
  padding: 0.45rem 0.7rem;
}
.btn-remove:hover:not(:disabled) { background: #fbeceb; }

.scenario-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.scenario-row { display: flex; gap: 0.4rem; }
.scenario-row input { flex: 1 1 auto; }

.table-scroll { overflow-x: auto; }
.table-scroll.tall { max-height: 420px; overflow-y: auto; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); }
th[scope="row"], .compare-table th:first-child { text-align: left; }

.compare-table th[scope="col"] {
  background: var(--accent-soft);
  border-bottom: 2px solid #bcd6e5;
  white-space: nowrap;
}
.compare-table tr.headline td, .compare-table tr.headline th {
  font-weight: 700;
  font-size: 1.05rem;
  background: #f7fbfd;
}
.compare-table td, .compare-table th[scope="col"] { min-width: 120px; }
.table-note { text-align: left; color: var(--muted); font-size: 0.83rem; }

.schedule-table thead th {
  position: sticky;
  top: 0;
  background: var(--accent-soft);
  border-bottom: 2px solid #bcd6e5;
  z-index: 1;
}
.schedule-table td.period { text-align: left; color: var(--muted); }
.schedule-table tbody tr:nth-child(even) { background: #fafcfd; }

.schedule-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem; }

.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.5rem 1.25rem 2rem;
  color: var(--muted);
  font-size: 0.83rem;
}

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