/* ── Design tokens ────────────────────────────────────────────────────────── */
:root {
  --bg:          #16181a;
  --surface:     #1f2124;
  --surface-2:   #282c30;
  --border:      #363a3e;
  --text:        #e4e6e8;
  --text-muted:  #8a8e92;
  --accent:      #e8660a;
  --accent-dim:  #a04408;
  --road-bg:     #1e2832;
  --road-border: #2e4060;
  --rest-bg:     #191c1f;
  --font:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:        "SF Mono", "Fira Mono", Consolas, monospace;
  --radius:      6px;
  --shadow:      0 2px 8px rgba(0,0,0,.4);
}

/* ── Reset & base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

h1, h2 { font-weight: 600; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

a { color: var(--accent); }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1.5rem;
}
.header-inner { max-width: 1100px; margin: 0 auto; }
.site-header h1 { font-size: 1.5rem; color: var(--accent); }
.header-sub { font-size: .85rem; color: var(--text-muted); margin-top: .15rem; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.2rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* ── Controls ────────────────────────────────────────────────────────────── */
.controls-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.1rem 1.4rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.control-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

input[type="date"],
input[type="time"],
input[type="number"],
select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: .95rem;
  padding: .35rem .55rem;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="number"], select { width: 100%; }

.w-short { width: 5rem !important; }

.inline-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.hint {
  font-size: .75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ── Advanced panel ──────────────────────────────────────────────────────── */
.advanced-panel {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: .8rem;
}

.advanced-panel summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  user-select: none;
}
.advanced-panel summary:hover { color: var(--text); }

.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem 1.4rem;
  margin-top: .9rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Per-stop rest grid in advanced panel */
.adv-full-width { grid-column: 1 / -1; }

.stop-rests-grid {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: start;
  gap: .35rem 1rem;
  align-items: center;
  margin-top: .4rem;
}

.stop-rests-grid span {
  font-size: .88rem;
  color: var(--text);
  white-space: nowrap;
}

/* ── Model annotation strip ──────────────────────────────────────────────── */
.model-annotation {
  margin-top: .9rem;
  font-size: .78rem;
  font-family: var(--mono);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: .55rem;
}

/* ── Checkpoint cards ────────────────────────────────────────────────────── */
.checkpoints-section h2 { margin-bottom: .7rem; }

.cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  min-width: 130px;
  flex: 1 1 130px;
  max-width: 200px;
  box-shadow: var(--shadow);
}

.card--finish {
  border-color: var(--accent-dim);
  background: #1e1812;
}

.card-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .2rem;
}
.card--finish .card-name { color: var(--accent); }

.card-eta {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .02em;
}

.card-sub {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

/* ── Schedule table ──────────────────────────────────────────────────────── */
.schedule-section h2 { margin-bottom: .1rem; }

.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .75rem;
}

.schedule-header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.btn-export {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: .3rem .65rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-export:hover {
  border-color: var(--accent);
  color: var(--text);
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: .88rem;
  white-space: nowrap;
}

thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}
thead th:first-child { width: 2.5rem; }

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: .45rem .75rem;
  vertical-align: middle;
}

td.num {
  font-family: var(--mono);
  text-align: right;
}

/* ETA column — always mono */
tbody td:nth-child(7),
tbody td:nth-child(8),
tbody td:nth-child(9) {
  font-family: var(--mono);
}

/* Road crossing rows */
.row-road {
  background: var(--road-bg);
}
.row-road td:nth-child(2) {
  color: var(--accent);
  font-weight: 600;
}

/* Rest rows */
.row-rest {
  background: var(--rest-bg);
}
.row-rest td {
  color: var(--text-muted);
  font-size: .8rem;
  font-style: italic;
  padding: .25rem .75rem .25rem 2.5rem;
}

/* Hover */
tbody tr:not(.row-rest):hover {
  background: var(--surface-2);
}
.row-road:hover { background: #243040; }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 14px; }
  main { padding: 1rem .75rem 2rem; gap: 1.4rem; }
  .site-header { padding: .9rem 1rem; }
  .controls-grid { grid-template-columns: 1fr 1fr; }
  .cards-row { gap: .5rem; }
  .card { min-width: 100px; max-width: 160px; padding: .6rem .75rem; }
  .card-eta { font-size: 1.25rem; }
  .schedule-header { flex-direction: column; align-items: flex-start; }
}
