:root {
  color-scheme: light;
  --canvas: #f4f1e8;
  --surface: #ffffff;
  --surface-muted: #ece8de;
  --ink: #16201f;
  --muted: #5c6764;
  --line: #cbd1cb;
  --accent: #125e5b;
  --accent-dark: #0a4543;
  --focus: #a75d13;
  --danger: #9d2c2c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--canvas); color: var(--ink); }
body { margin: 0; min-width: 320px; }
a { color: inherit; }
button, a { font: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  padding: 0.65rem 0.85rem;
  background: var(--ink);
  color: white;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  min-height: 4rem;
  padding: 0.75rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(244, 241, 232, 0.96);
}
.brand { font-family: Georgia, "Times New Roman", serif; font-weight: 700; text-decoration: none; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.85rem; flex-wrap: wrap; }
.text-link { color: var(--accent-dark); font-weight: 650; text-underline-offset: 0.2rem; }
.command {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  min-height: 2.6rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}
.command:hover { background: var(--accent-dark); }

.shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) 0 4rem; }
.loading { min-height: 55vh; display: grid; place-items: center; }
.spinner { width: 2rem; height: 2rem; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-heading { display: grid; gap: 0.4rem; margin-bottom: 2rem; }
.page-heading h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 6vw, 3.75rem); line-height: 1.05; }
.page-heading p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }

.notice { border-left: 4px solid var(--accent); background: var(--surface); padding: 1rem; margin-bottom: 1.5rem; }
.notice.error { border-left-color: var(--danger); }
.notice h1 { margin: 0 0 0.5rem; font-size: 1.35rem; }
.notice p { margin: 0.25rem 0; }
.notice-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: 1rem; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.6rem 0.95rem;
  border: 1px solid var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}
.button.primary { background: var(--accent); color: white; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--surface); margin-bottom: 2rem; }
.stat { min-width: 0; padding: 1rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat:nth-child(2n) { border-right: 0; }
.stat-value { display: block; font-size: 1.65rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.86rem; }

.dashboard-grid { display: grid; gap: 2rem; }
.panel { min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: 0.65rem; }
.panel-heading h2 { margin: 0; font-size: 1.1rem; }
.panel-heading a { color: var(--accent-dark); font-weight: 650; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; gap: 0.35rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.row-title { font-weight: 700; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: 0.85rem; }
.tag { display: inline-flex; width: fit-content; border: 1px solid var(--line); padding: 0.2rem 0.45rem; font-size: 0.76rem; font-weight: 700; }
.progress-track { height: 0.5rem; background: var(--surface-muted); overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--accent); }
.empty { color: var(--muted); padding: 1rem 0; margin: 0; }
.route-links { display: flex; flex-wrap: wrap; gap: 0.65rem 1rem; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.route-links a { color: var(--accent-dark); font-weight: 650; }

@media (min-width: 760px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat { border-bottom: 0; }
  .stat:nth-child(2n) { border-right: 1px solid var(--line); }
  .stat:last-child { border-right: 0; }
  .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { gap: 0.5rem; }
  .text-link { font-size: 0.86rem; }
  .shell { width: min(100% - 1.25rem, 1180px); }
  .row-top { align-items: flex-start; flex-direction: column; gap: 0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
