:root {
  color-scheme: dark;
  --paper: #0e1821;
  --surface: #15222e;
  --raised: #1b2a38;
  --side: #09121a;
  --ink: #e7edf3;
  --muted: #9aabbb;
  --line: #273746;
  --field: #3a4c5e;
  --road: #4a90e2;
  --button: #2563b0;
  --button-hover: #1d5294;
  --brand: #d4202c;
  --green: #4fb387;
  --red: #f07167;

  --sans: "Fira Sans", system-ui, sans-serif;
  --condensed: "Fira Sans Condensed", "Fira Sans", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Panel base size 12px: every rem below scales with it (small texts come out at about 10px). */
html { font-size: 12px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--road); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

h1, h2 { font-family: var(--condensed); font-weight: 700; line-height: 1.1; margin: 0; }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); }
h2 { font-size: 1.35rem; }
p { margin: 0; }

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

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: inherit;
  text-decoration: none;
  font: 700 1.45rem/1 var(--condensed);
  letter-spacing: -0.02em;
}

.lede { margin-top: .6rem; color: var(--muted); font-size: 1.1rem; max-width: 42rem; }
.small { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); }

/* Buttons and forms */

.button {
  display: inline-block;
  padding: .6rem 1.1rem;
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 500 1rem/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.button--primary { background: var(--button); border-color: var(--button); color: #fff; }
.button--primary:hover { background: var(--button-hover); border-color: var(--button-hover); }
.button--block { display: block; width: 100%; }
.button--small { padding: .3rem .75rem; font-size: .9rem; border-width: 1px; border-color: var(--field); background: var(--raised); }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--road);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

label { display: grid; gap: .3rem; font-weight: 500; font-size: .95rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="datetime-local"], input[type="week"], input:not([type]), select, textarea {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--field);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.3 var(--sans);
}
input:focus, select:focus { border-color: var(--road); outline: 2px solid rgba(74, 144, 226, .3); outline-offset: 0; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--road); }

.stack { display: grid; gap: 1rem; margin-top: 1.75rem; }

.form-grid { display: grid; gap: 1rem; max-width: 28rem; }
.form-grid--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 46rem; }
.form-grid--wide .form-actions, .form-grid--wide fieldset, .form-grid--wide .check { grid-column: 1 / -1; }
fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}
legend { padding: 0 .4rem; font-weight: 500; }

.notice { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1.5rem; border-left: 4px solid; }
.notice--ok { background: rgba(79, 179, 135, .12); border-color: var(--green); }
.notice--error { background: rgba(240, 113, 103, .12); border-color: var(--red); }

/* Guest pages: login, setup link, messages */

.guest {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.5rem;
  padding: 2rem 1rem;
}
.guest-card {
  width: min(26rem, 100%);
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--button);
  border-radius: 10px;
}
.is-staff .guest-card { border-top-color: var(--brand); }
.guest-langs { display: flex; flex-wrap: wrap; gap: .25rem .8rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .85rem; }
.guest-langs a { color: var(--muted); text-decoration: none; }
.guest-langs a[aria-current] { color: var(--ink); font-weight: 500; }

/* Signed-in shell: sidebar, top bar, page */

.shell { display: grid; grid-template-columns: 15.5rem minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.shell.side-closed { grid-template-columns: 0 minmax(0, 1fr); }

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden auto;
  padding: 1.5rem 1.1rem;
  background: var(--side);
  color: #fff;
  border-right: 1px solid var(--line);
  border-top: 5px solid var(--button);
}
.side-closed .side { visibility: hidden; padding-inline: 0; border-right: 0; }
.is-staff .side { border-top-color: var(--brand); }
.side-org { margin: 1rem 0 1.5rem; padding-left: .5rem; color: rgba(255, 255, 255, .7); font-size: .95rem; white-space: nowrap; }
.side-org--staff { color: var(--brand); font-weight: 500; }
.side-nav { display: grid; gap: .15rem; }
.side-nav a { padding: .55rem .6rem; border-radius: 6px; color: rgba(255, 255, 255, .85); text-decoration: none; white-space: nowrap; }
.side-nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.side-nav a[aria-current] { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.side-scrim { display: none; }

.frame { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.page-map .frame { height: 100vh; }

.topnav {
  position: sticky;
  top: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: .5rem;
  height: 3.6rem;
  flex: none;
  padding: 0 1rem 0 .75rem;
  background: var(--side);
  border-bottom: 1px solid var(--line);
}
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  height: 2.5rem;
  padding: 0 .65rem;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.icon-btn:hover, .menu[open] > summary { background: rgba(255, 255, 255, .08); }
.caret { opacity: .7; }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.lang-code { text-transform: uppercase; font-size: .8rem; font-weight: 600; letter-spacing: .05em; }
.account-btn { display: flex; align-items: center; gap: .6rem; padding: .3rem .55rem .3rem .3rem; border-radius: 8px; cursor: pointer; }
.avatar {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--button);
  color: #fff;
  font-weight: 600;
  flex: none;
}
.is-staff .avatar { background: var(--brand); color: #fff; }
.account-name { display: grid; line-height: 1.2; text-align: left; }
.account-name strong { font-weight: 500; font-size: .95rem; }
.account-name small { color: var(--muted); font-size: .8rem; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + .45rem);
  z-index: 950;
  display: grid;
  min-width: 13rem;
  padding: .35rem;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
}
.menu-pop form { margin: 0; display: grid; }
.menu-pop a, .menu-pop button {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .55rem .75rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: rgba(255, 255, 255, .07); }
.menu-pop [aria-current] { color: var(--brand); font-weight: 500; }
.menu-pop--langs .lang-code { width: 1.6rem; color: var(--muted); }

.main { padding: clamp(1.5rem, 4vw, 3rem); max-width: 72rem; width: 100%; }
.main--full { flex: 1; position: relative; min-height: 0; max-width: none; padding: 0; }
.main > h1 + .lede { margin-bottom: 2rem; }
.crumb { margin-bottom: .5rem; font-size: .95rem; }

.panel-block { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.panel-block > h2 { margin-bottom: 1.1rem; }
.block-actions { margin-top: 1.5rem; }
.empty { margin: 1.5rem 0; color: var(--muted); }
.soon { margin-top: 2.5rem; max-width: 40rem; color: var(--muted); }

/* Team on the overview */

.team { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.team li { display: grid; padding: 1.1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.team-count { font: 700 2.4rem/1 var(--condensed); color: var(--road); }
.team-role { margin-top: .35rem; font-weight: 500; }
.team-desc { color: var(--muted); font-size: .9rem; }
.team--four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.team--users { margin: 1.5rem 0 2rem; }
@media (max-width: 1100px) { .team--four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Lists */

.table-wrap { overflow-x: auto; margin-top: 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.list { width: 100%; border-collapse: collapse; }
.list th, .list td { padding: .75rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.list tbody tr:last-child td { border-bottom: 0; }
.list th { font-size: .85rem; font-weight: 500; color: var(--muted); background: var(--raised); }
.list .sub { display: block; color: var(--muted); font-size: .9rem; }
.you { color: var(--muted); font-weight: 400; }
.actions-cell { text-align: right; white-space: nowrap; }

.status { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .85rem; white-space: nowrap; }
.status--on { background: rgba(79, 179, 135, .15); color: var(--green); }
.status--wait { background: rgba(167, 139, 250, .15); color: #a78bfa; }
.status--off { background: rgba(154, 171, 187, .12); color: var(--muted); }
.status--bad { background: rgba(240, 113, 103, .14); color: var(--red); }
.status--info { background: rgba(77, 148, 255, .14); color: var(--road); }

.row-edit summary { list-style: none; display: inline-block; }
.row-edit summary::-webkit-details-marker { display: none; }
.row-edit[open] summary { background: var(--paper); }
.team-count { color: var(--road); }
.row-edit-body {
  display: grid;
  gap: 1rem;
  margin-top: .75rem;
  padding: 1rem;
  text-align: left;
  white-space: normal;
  background: var(--paper);
  border-radius: 8px;
  min-width: 18rem;
}

/* One-time setup link */

.linkbox {
  margin: 0 0 2rem;
  padding: 1.25rem;
  background: rgba(212, 32, 44, .08);
  border: 1px solid rgba(212, 32, 44, .35);
  border-left: 5px solid var(--brand);
  border-radius: 8px;
}
.linkbox h2 { font-size: 1.2rem; }
.linkbox p { margin-top: .35rem; color: var(--muted); }
.linkrow { display: flex; gap: .5rem; margin-top: .9rem; }
.linkrow input { font-family: ui-monospace, monospace; font-size: .9rem; }

.crumbs { margin: 0 0 .4rem; font-size: .9rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.block-actions--top { margin: 0 0 1.5rem; }
.block-actions .button + .button { margin-left: .5rem; }
.list a { color: inherit; }
.list tfoot th, .list tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; color: var(--ink); background: none; font-size: inherit; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem 1.5rem; max-width: 46rem; margin: 1.5rem 0 0; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: .1rem 0 0; white-space: pre-line; }
.facts-wide { grid-column: 1 / -1; }
.trip-map { height: 380px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.history { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.history ul { margin: .35rem 0 0; padding-left: 1.2rem; color: var(--muted); }
.correct { display: grid; gap: 1.25rem; max-width: 52rem; }
.correct-block { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.correct-block--new { border-style: dashed; }
.correct-block label { display: grid; gap: .3rem; }
.correct-block .span-all { grid-column: 1 / -1; }
.correct-block .check { display: flex; }
.counts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.correct input[type="datetime-local"], .correct input[type="number"], .correct textarea, .export-form input[type="week"], .review-forms textarea { width: 100%; }
.sheet-state { margin: 0 0 1.5rem; display: grid; gap: .4rem; }
.sheet-state p { margin: 0; }
.sheet-note { margin: .25rem 0 0; padding: .6rem .9rem; border-left: 3px solid var(--red); background: var(--surface); white-space: pre-line; }
.review-forms { display: grid; grid-template-columns: auto minmax(0, 28rem); gap: 2rem; align-items: start; }
.export-form { display: grid; grid-template-columns: repeat(3, minmax(0, 12rem)) auto; gap: 1rem; align-items: end; }
.export-form .form-actions { margin: 0; }
.small { font-size: .85rem; }

@media (max-width: 860px) {
  .correct-block, .facts, .review-forms, .export-form { grid-template-columns: minmax(0, 1fr); }
  .team.team--four { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .shell, .shell.side-closed { grid-template-columns: minmax(0, 1fr); }
  .side, .side-closed .side {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 1000; width: 16rem;
    visibility: visible; padding-inline: 1.1rem; transform: translateX(-100%); transition: transform .2s ease;
  }
  .shell.side-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .5); }
  .shell.side-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 999; background: rgba(0, 0, 0, .5); }
  .account-name { display: none; }
  .team { grid-template-columns: minmax(0, 1fr); }
  .form-grid--wide, fieldset { grid-template-columns: minmax(0, 1fr); }
  .linkrow { flex-direction: column; }
}

@media (max-width: 640px) {
  .table-wrap { overflow: visible; }
  .list thead { display: none; }
  .list, .list tbody, .list tr, .list td { display: block; }
  .list tr { padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
  .list tbody tr:last-child { border-bottom: 0; }
  .list td { padding: .15rem 0; border: 0; }
  .list td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  .list td[data-label]:empty { display: none; }
  .list tfoot, .list tfoot tr, .list tfoot th, .list tfoot td { display: block; border: 0; padding: .15rem 0; }
  .list tfoot tr { padding: .8rem 1rem; border-top: 1px solid var(--line); }
  .list tfoot td:empty { display: none; }
  .list tfoot td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; font-weight: 400; }
  .actions-cell { text-align: left; margin-top: .4rem; }
  .row-edit-body { min-width: 0; }
}

/* shifts week navigation */
.week-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* Roles of a user: checkboxes, one per role */
.roles-field { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1.25rem; }
.roles-field legend, .roles-field .small { grid-column: 1 / -1; }
.roles-field .small { margin: 0; }
.form-grid--wide .roles-field .check { grid-column: auto; }

.trip-stop { display: grid; place-items: center; border-radius: 50%; border: 2px solid #fff; background: #9aabbb; color: #0e1821; font: 700 .8rem/1 var(--sans); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.trip-stop--load { background: #d4202c; }
.trip-stop--unload { background: #4fb387; }

/* Home: figures on the left, live feed on the right */
.main--wide { max-width: 104rem; }
.home { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: clamp(1.5rem, 3vw, 3rem); align-items: start; }
.home-main > h1 + .lede { margin-bottom: 2rem; }
.feed { position: sticky; top: 1.5rem; display: flex; flex-direction: column; max-height: calc(100vh - 7rem); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.feed-head { padding: 1.1rem 1.2rem .9rem; border-bottom: 1px solid var(--line); }
.feed-head h2 { font-size: 1.15rem; }
.feed-lede { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; }
.feed-body { overflow-y: auto; overscroll-behavior: contain; padding: .4rem 0; scrollbar-width: thin; scrollbar-color: var(--field) transparent; }
.feed-list { list-style: none; margin: 0; padding: 0; }
.feed-item > a, .feed-item > div { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .2rem .75rem; align-items: start; padding: .6rem 1.2rem; color: inherit; text-decoration: none; }
.feed-item > a:hover { background: rgba(255, 255, 255, .04); }
.feed-icon { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 6px; background: rgba(74, 144, 226, .14); color: var(--road); }
.feed-item--stop .feed-icon { background: rgba(79, 179, 135, .15); color: var(--green); }
.feed-item--break .feed-icon { background: rgba(154, 171, 187, .14); color: var(--muted); }
.feed-item--review .feed-icon, .feed-alert .feed-icon { background: rgba(232, 163, 61, .16); color: #e8a33d; }
.feed-item--week .feed-icon { background: rgba(167, 139, 250, .15); color: #a78bfa; }
.feed-text { padding-top: .25rem; font-size: .95rem; line-height: 1.35; overflow-wrap: anywhere; }
.feed-text strong { font-weight: 500; }
.feed-item time { padding-top: .3rem; color: var(--muted); font-size: .8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed-empty { margin: 0; padding: 1rem 1.2rem; color: var(--muted); }
.feed-alert { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .75rem; align-items: center; margin: .4rem .8rem .5rem; padding: .6rem .7rem; border: 1px solid rgba(232, 163, 61, .45); border-radius: 8px; background: rgba(232, 163, 61, .08); color: var(--ink); text-decoration: none; font-size: .95rem; }
.feed-alert:hover { background: rgba(232, 163, 61, .14); }
.feed-alert-go { color: #e8a33d; font-weight: 500; white-space: nowrap; }
@media (max-width: 1180px) {
  .home { grid-template-columns: minmax(0, 1fr); }
  .feed { position: static; max-height: 32rem; }
}
