:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f6f7f5;
  --panel: #ffffff;
  --text: #172018;
  --muted: #697268;
  --line: #dfe4dd;
  --accent: #276749;
  --accent-strong: #1f513a;
  --warn: #9a5b13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
}

.topnav {
  display: flex;
  gap: 12px;
  margin-left: auto;
}

.topnav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.topnav a:hover {
  color: var(--accent);
}

.brand {
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.muted {
  color: var(--muted);
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto 56px;
}

.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.hero.compact {
  align-items: center;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.12;
  margin-bottom: 8px;
}

h2 {
  font-size: 18px;
  margin-bottom: 18px;
}

.hero p {
  color: var(--muted);
  max-width: 680px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 10px;
}

.stats div,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats div {
  min-width: 92px;
  padding: 16px;
}

.stats strong {
  display: block;
  font-size: 24px;
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

.stats small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.forecast-panel {
  grid-column: span 2;
}

.quick-links,
.summary-grid,
.analytics-grid {
  display: grid;
  gap: 20px;
}

.quick-links {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 20px;
}

.quick-card,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
}

.quick-card {
  color: var(--text);
  text-decoration: none;
}

.quick-card strong,
.quick-card span {
  display: block;
}

.quick-card span {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.quick-card:hover {
  border-color: #b8c9bd;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 20px;
}

.metric strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 6px;
}

.analytics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-panel canvas {
  width: 100%;
  height: auto;
  display: block;
}

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

.attention-panel {
  border-color: #d7b36a;
  background: #fffaf1;
}

.attention-list {
  display: grid;
  gap: 10px;
}

.attention-item {
  border-left: 4px solid #d7b36a;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
}

.attention-item strong,
.attention-item span {
  display: block;
}

.attention-item span {
  color: var(--muted);
  line-height: 1.4;
  margin-top: 3px;
}

.attention-item.danger {
  border-left-color: #b33a3a;
}

.attention-item.warning {
  border-left-color: #d7b36a;
}

.panel {
  padding: 20px;
}

.wide {
  margin-top: 20px;
}

form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.forecast-form {
  grid-template-columns: minmax(120px, 0.7fr) minmax(210px, 1fr);
}

form:first-of-type {
  border-top: 0;
}

.single-action {
  display: block;
  border-top: 0;
  padding-bottom: 14px;
}

.single-action button {
  width: 100%;
}

.danger-action {
  margin-top: 16px;
}

.danger-action button {
  color: #8f2f2f;
}

.reset-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 8px;
}

.filters {
  grid-template-columns: auto minmax(170px, 1fr) auto minmax(150px, 1fr) auto minmax(150px, 1fr) auto;
  border-top: 0;
  padding: 0;
}

label {
  color: var(--muted);
  font-size: 14px;
}

input[type="file"],
input[type="date"],
input[type="text"],
input[type="password"] {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--text);
}

input::placeholder {
  color: #758178;
  font-size: 13px;
}

.auth-panel {
  width: min(440px, 100%);
  margin: 70px auto;
}

.auth-form,
.inline-form {
  border-top: 0;
}

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

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

.inline-form {
  display: inline-grid;
  padding: 0;
}

button,
.button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: #e7ece6;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-weight: 650;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

button.primary {
  background: var(--accent);
  color: white;
}

button:not(:disabled):hover,
.button:hover {
  background: var(--accent-strong);
  color: white;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(246, 247, 245, 0.78);
  backdrop-filter: blur(4px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-box {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(23, 32, 24, 0.16);
  text-align: center;
}

.loading-box strong {
  display: block;
  font-size: 20px;
  margin-bottom: 8px;
}

.loading-box p {
  color: var(--muted);
  line-height: 1.45;
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border: 4px solid #dfe4dd;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.checkbox {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.last-run {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  font-weight: 650;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: #fff;
}

.notice.ok {
  border-color: #9bc7aa;
  color: #1f513a;
}

.notice.warn {
  border-color: #e1c48d;
  color: var(--warn);
}

.notice.error {
  border-color: #d9a0a0;
  color: #8f2f2f;
}

.panel-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin-bottom: 12px;
}

.form-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: -2px 0 10px;
}

.config-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.columns {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

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

.recommendation-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fbfcfb;
}

.recommendation-card.warning {
  border-color: #e1c48d;
  background: #fffaf1;
}

.recommendation-card.attention {
  border-color: #b8c9bd;
  background: #f8fbf8;
}

.recommendation-main {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.recommendation-main strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin: 8px 0 4px;
}

.recommendation-main span,
.recommendation-card p {
  color: var(--muted);
}

.eyebrow {
  display: block;
  color: var(--text) !important;
  font-weight: 750;
}

.recommendation-numbers {
  align-self: flex-start;
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.recommendation-numbers span {
  background: #f1f4f0;
  border-radius: 6px;
  padding: 8px 10px;
}

.inline-warning {
  border: 1px solid #e1c48d;
  border-radius: 6px;
  color: var(--warn);
  margin-bottom: 12px;
  padding: 10px 12px;
}

.accent-warning {
  border-color: #9bc7aa;
  color: var(--accent-strong);
  background: #f0f7f1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.detail-grid div {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid dd {
  font-size: 18px;
  font-weight: 750;
  margin: 4px 0 0;
}

.detail-grid small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
}

.subsection {
  margin-top: 14px;
}

.subsection h3 {
  font-size: 15px;
  margin: 0;
}

.compact-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-top: 10px;
}

.compact-grid dd {
  font-size: 16px;
}

.footnote {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin-top: 16px;
  padding-top: 12px;
}

.metrics-line {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}

td.nowrap,
th.nowrap {
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.compact-table {
  min-width: 560px;
}

.compact-table th,
.compact-table td {
  line-height: 1.25;
}

.row-danger td {
  background: #fff0f0;
  color: #8f2f2f;
  font-weight: 700;
}

.row-warning td {
  background: #fff8e8;
  color: var(--warn);
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f1f4f0;
  border-radius: 6px;
  padding: 14px;
}

summary {
  cursor: pointer;
  font-weight: 750;
}

.muted-panel {
  background: #fbfcfb;
}

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .forecast-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .hero,
  .grid,
  .quick-links,
  .analytics-grid,
  .admin-grid,
  .summary-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 14px 18px;
  }

  .topnav {
    width: 100%;
    margin-left: 0;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .forecast-panel {
    grid-column: auto;
  }

  .recommendation-main {
    display: grid;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
