:root {
  color-scheme: light;
  --ink: #18233a;
  --muted: #63708a;
  --blue: #3157d5;
  --line: #dfe5f0;
  --surface: #ffffff;
  --page: #f4f6fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 85% 8%, #e3eafe 0, transparent 28rem), var(--page);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page {
  width: min(100% - 2rem, 880px);
  margin: 0 auto;
  padding: 3rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: 2rem;
  font-weight: 800;
  letter-spacing: .05em;
}

.brand-mark {
  display: grid;
  width: 2.5rem;
  aspect-ratio: 1;
  place-items: center;
  border-radius: .8rem;
  color: white;
  background: var(--blue);
}

.card {
  padding: clamp(1.5rem, 5vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  background: var(--surface);
  box-shadow: 0 1.5rem 4rem #24375c12;
}

.eyebrow {
  margin: 0 0 .6rem;
  color: var(--blue);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  max-width: 15ch;
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.3rem);
  line-height: 1.08;
  letter-spacing: -.04em;
}

.intro {
  max-width: 62ch;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
  margin: 2rem 0;
}

.slot {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fbfcff;
}

.slot strong, .slot span { display: block; }
.slot strong { font-size: 1.1rem; }
.slot span { margin-top: .2rem; color: var(--muted); font-size: .9rem; }

.note {
  margin: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

@media (max-width: 600px) {
  .page { padding: 1.5rem 0; }
  .slots { grid-template-columns: 1fr; }
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 2rem, 1180px);
  margin: 0 auto;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line);
}
.site-header .brand { margin: 0; color: var(--ink); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 1rem; }
.nav a, .nav-button, .text-link { color: var(--blue); font-weight: 700; text-decoration: none; }
.nav form { margin: 0; }
.nav-button, .text-danger { border: 0; padding: 0; background: transparent; cursor: pointer; font: inherit; }
.nav-user { color: var(--muted); font-size: .9rem; }
.container { width: min(100% - 2rem, 1180px); min-height: calc(100vh - 9rem); margin: 0 auto; padding: 2rem 0 4rem; }
.site-footer { padding: 1.5rem 1rem; color: var(--muted); text-align: center; font-size: .9rem; }
.hero { max-width: 720px; margin: 1.5rem 0 2rem; }
.hero h1, .panel h1 { margin: 0; font-size: clamp(2rem, 6vw, 3.1rem); line-height: 1.1; letter-spacing: -.04em; }
.hero .muted { max-width: 65ch; }
.public-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr); align-items: start; gap: 1.25rem; }
.panel { padding: clamp(1.2rem, 3vw, 2rem); border: 1px solid var(--line); border-radius: 1.25rem; background: var(--surface); box-shadow: 0 1rem 3rem #24375c0a; }
.panel.narrow { width: min(100%, 560px); margin: 2rem auto; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-heading h2, .panel h2 { margin: 0; font-size: 1.45rem; }
.section-heading .eyebrow { margin-bottom: .2rem; }
.muted { color: var(--muted); }
.section-heading .muted { margin: .2rem 0 0; }
.slot-list, .my-slots { display: grid; gap: .7rem; }
.slot-row, .my-slot { display: grid; grid-template-columns: 1fr; gap: .8rem; padding: 1rem; border: 1px solid var(--line); border-radius: .95rem; background: #fcfdff; }
.slot-row > div:first-child, .my-slot > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: .75rem; }
.slot-row > div:first-child span, .my-slot > div:first-child span { color: var(--muted); white-space: nowrap; }
.slot-register { display: grid; grid-template-columns: 1fr 1fr auto; gap: .5rem; }
input, select { width: 100%; min-width: 0; padding: .72rem .8rem; border: 1px solid #cfd7e6; border-radius: .65rem; color: var(--ink); background: white; font: inherit; }
input:focus, select:focus { outline: 3px solid #3157d530; border-color: var(--blue); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 2.7rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: .65rem; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.button.primary { color: white; background: var(--blue); }
.button.secondary { color: var(--ink); border-color: var(--line); background: white; }
.button.danger { color: white; background: #b42336; }
.stack { display: grid; gap: 1rem; margin: 1.25rem 0; }
.stack label { display: grid; gap: .4rem; font-weight: 700; }
.expedition-key { display: flex; flex-wrap: wrap; gap: .7rem 1.25rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.expedition-key b { color: var(--ink); }
.notice { padding: .8rem 1rem; border-radius: .7rem; }
.notice.success { color: #17613d; background: #e8f6ee; }
.notice.error { color: #8b1d2d; background: #fff0f1; }
.empty { padding: 1rem; border: 1px dashed var(--line); border-radius: .8rem; color: var(--muted); }
.subheading { margin: 1.5rem 0 .75rem; font-size: 1rem; }
.my-slot { grid-template-columns: 1fr auto auto; align-items: center; }
.badge { display: inline-flex; width: fit-content; padding: .25rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 750; }
.badge.available { color: #17613d; background: #e8f6ee; }
.badge.assigned { color: #264bb4; background: #eaf0ff; }
.badge.cancelled { color: #7b8496; background: #eff1f5; }
.text-danger { color: #b42336; font-weight: 700; }
.eyebrow { color: var(--blue); }

@media (max-width: 840px) {
  .public-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .site-header { width: min(100% - 1.25rem, 1180px); }
  .container { width: min(100% - 1.25rem, 1180px); padding-top: 1.2rem; }
  .nav { gap: .65rem; }
  .nav-user { display: none; }
  .slot-register { grid-template-columns: 1fr 1fr; }
  .slot-register .button { grid-column: 1 / -1; }
  .my-slot { grid-template-columns: 1fr auto; }
  .my-slot form { grid-column: 1 / -1; }
}

.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.25rem; margin: .5rem 0 1.5rem; }
.page-heading h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.7rem); line-height: 1.1; letter-spacing: -.04em; }
.page-heading .eyebrow { margin: 0 0 .25rem; }
.admin-links, .report-tabs { display: flex; flex-wrap: wrap; gap: .6rem; }
.admin-links a, .report-tabs a { padding: .55rem .8rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--blue); background: white; font-weight: 700; text-decoration: none; }
.report-tabs { margin-bottom: 1rem; }
.report-tabs a.active { color: white; border-color: var(--blue); background: var(--blue); }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; }
.filters label { display: grid; gap: .3rem; min-width: 140px; color: var(--muted); font-size: .85rem; font-weight: 700; }
.filter-panel { margin-bottom: 1rem; }
.admin-slot-list { display: grid; gap: 1rem; }
.admin-slot .section-heading { align-items: center; }
.admin-slot .section-heading h2 { margin-bottom: .4rem; }
.small { font-size: .82rem; }
.roster { display: grid; gap: .55rem; }
.driver-row { display: grid; grid-template-columns: minmax(150px, 1fr) auto minmax(200px, auto); align-items: center; gap: .75rem; padding: .8rem; border: 1px solid var(--line); border-radius: .75rem; }
.driver-row > div:first-child { display: grid; min-width: 0; }
.driver-row > div:first-child span { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.driver-actions, .actions, .action-row { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.driver-actions form, .actions form { margin: 0; }
.small-button { min-height: 2.2rem; padding: .4rem .65rem; font-size: .85rem; }
.move-form { display: flex; gap: .35rem; }
.move-form select { width: auto; max-width: 170px; padding: .4rem; font-size: .84rem; }
.add-driver { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.add-driver summary { color: var(--blue); font-weight: 750; cursor: pointer; }
.add-driver .slot-register { margin-top: .8rem; }
.master-form { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: .8rem; margin-top: 1rem; }
.master-form > label { display: grid; gap: .35rem; font-weight: 700; }
.master-form fieldset { display: flex; flex-wrap: wrap; gap: .75rem; grid-column: 1 / -1; border: 1px solid var(--line); border-radius: .7rem; }
.master-form legend { padding: 0 .4rem; color: var(--muted); font-size: .9rem; }
.check { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-size: .88rem; }
.check input { width: auto; }
.table-panel { margin-top: 1rem; }
.table-panel h2, .chart-panel h2 { margin: 0 0 1rem; font-size: 1.25rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem .65rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.inline-edit { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; min-width: 280px; }
.inline-edit input[name=name] { max-width: 180px; padding: .45rem; }
.inline-edit select { width: auto; padding: .45rem; }
.checks { display: flex; gap: .5rem; }
.actions { min-width: 140px; }
.message-cell { max-width: 300px; overflow-wrap: anywhere; }
.report-filter { margin-bottom: 1rem; }
.chart-panel { margin-bottom: 1rem; }
.chart-panel svg { display: block; width: 100%; height: auto; max-height: 720px; overflow: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .8rem; color: var(--muted); font-size: .85rem; }
.qr-panel { margin: 1rem auto; text-align: center; }
.qr-panel img { display: block; width: min(320px, 100%); height: auto; margin: 0 auto; padding: .5rem; border: 1px solid var(--line); border-radius: .75rem; background: white; }
.qr-panel p { color: var(--muted); }

@media (max-width: 820px) {
  .driver-row { grid-template-columns: 1fr auto; }
  .driver-actions { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
  .page-heading { display: grid; }
  .admin-links { gap: .4rem; }
  .admin-links a { font-size: .83rem; }
  .driver-row { grid-template-columns: 1fr; }
  .driver-actions { align-items: flex-start; }
  .master-form { grid-template-columns: 1fr; }
  .master-form fieldset { grid-column: auto; }
}
