/* HRTS Manage: flat, minimal, mobile first. No frameworks.
   UI rules: --background only, one button style, square badges,
   no card boxes, no row lines, no sub labels. */

:root {
  --background: #f4f2ec;
  --text: #22241f;
  --brand-colour-mid: #2e6e4e;
  --danger: #a93226;
  --warn: #8a6100;
  --line: #cfc9ba;
  --radius: 0.75em;
  --tap: 2.75rem;
}

* { box-sizing: border-box; }

a { color: var(--brand-colour-mid); text-decoration: none; }
a:visited { color: var(--brand-colour-mid); }
a:active { filter: brightness(0.9); }

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  padding-bottom: 4.5rem;
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus { left: 0.5rem; top: 0.5rem; background: var(--background); padding: 0.5rem; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--brand-colour-mid);
}
.topbar a { color: var(--background); }
.brand { font-weight: bold; text-decoration: none; font-size: 1.1rem; color: var(--brand-colour-mid); }
.railway-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; color: var(--background);}
.usermenu { display: flex; gap: 0.75rem; align-items: center; margin-left: auto; }
.usermenu form { margin: 0; }
.linklike {
  background: none; border: none; color: var(--brand-colour-mid);
  text-decoration: underline; font-size: 1rem; font-weight: bold;
  cursor: pointer; padding: 0.5rem;
}
.meta .linklike { padding: 0.25rem; }

/* Side nav: hidden on mobile, shown on desktop */
.sidenav { display: none; }
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--background);
  border-top: 1px solid var(--line);
}
.bottomnav a {
  flex: 1;
  text-align: center;
  padding: 0.9rem 0.25rem;
  min-height: var(--tap);
  text-decoration: none;
  color: var(--text);
  font-weight: bold;
}
.bottomnav a[aria-current="page"] { color: var(--brand-colour-mid); }

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1rem;
}

.footer {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
}
.footer span:first-child { font-weight: bold; }

/* Headings and text */
h1 { font-size: 1.6rem; margin: 0.25rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 2rem 0 0.75rem; }
h3 { font-size: 1.1rem; margin: 0 0 0.25rem; }
p { margin: 0.5rem 0; }

/* Messages */
.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.message {
  background: var(--background);
  border-left: 0.3rem solid var(--brand-colour-mid);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}
.message.error { border-color: var(--danger); }

/* Plain lists and rows */
.stack { display: grid; gap: 1.25rem; }
.stack-tight { display: grid; gap: 0.75rem; }
.card { margin-bottom: 1.25rem; }
.card h3 { margin: 0 0 0.25rem; font-size: 1.15rem; }
.rowline {
  display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap;
}
.bigtime { font-size: 1.6rem; font-weight: bold; font-variant-numeric: tabular-nums; }

/* Badges: square text labels, never colour alone */
.badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 0.1rem 0.5rem;
  border: 0.1rem solid var(--text);
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.cancelled { border-color: var(--danger); color: var(--danger); }
.badge.special, .badge.amended { border-color: var(--brand-colour-mid); color: var(--brand-colour-mid); }

/* Buttons: one style, 0.75em rounding */
.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.6rem 1.25rem;
  background: var(--brand-colour-mid);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: bold;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { filter: brightness(0.92); }
/* Secondary actions are plain links, not second button styles */
.actionlink {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-weight: bold;
  color: var(--brand-colour-mid);
}
.actions { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin: 1rem 0; }
.inline { display: inline; }
.actions.sticky {
  position: sticky;
  bottom: 4rem;
  background: var(--background);
  padding: 0.5rem 0;
}

/* Forms */
form.standard { display: grid; gap: 1.25rem;  }
.field label { display: block; font-weight: bold; margin-bottom: 0.25rem; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--tap);
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 0.12rem solid var(--line);
  border-radius: 0;
  background: var(--background);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 0.15rem solid var(--brand-colour-mid);
  outline-offset: 0.1rem;
}
.field .help { font-size: 0.9rem; }
.field-label { display: block; font-weight: bold; margin-bottom: 0.25rem; }
.preset-list { display: grid; gap: 0.5rem; }
.preset-option {
  border: 0.12rem solid var(--line);
  border-radius: 0;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}
.preset-option:has(input:checked) {
  border-color: var(--brand-colour-mid);
  outline: 0.15rem solid var(--brand-colour-mid);
  outline-offset: 0.1rem;
}
.errorlist { color: var(--danger); margin: 0.25rem 0; padding-left: 1.25rem; }
.checkrow { display: flex; gap: 0.6rem; align-items: center; min-height: var(--tap); }
.checkrow input { width: 1.4rem; height: 1.4rem; accent-color: var(--brand-colour-mid); }
.filters { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.filters label { font-weight: bold; display: grid; gap: 0.25rem; }
.filters select, .filters input { min-height: var(--tap); font-size: 1rem; }

/* Tables: spaced plain rows, no outer border, no row lines */
.tablewrap { overflow-x: auto; }
table.grid { border-collapse: separate; border-spacing: 0 1rem; width: 100%; }
table.grid th, table.grid td {
  text-align: left;
  padding: 0 0.75rem 0 0;
  vertical-align: top;
}
table.grid th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* Today's running: time, service, action */
.today-list { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 2rem; }
.today-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  align-items: baseline;
}
.today-time { font-size: 1.75rem; font-weight: bold; font-variant-numeric: tabular-nums; }
.today-main { display: grid; gap: 0.15rem; }
.today-headline { display: flex; flex-wrap: wrap; gap: 0.35rem 0.6rem; align-items: baseline; }
.today-head { font-size: 1.25rem; font-weight: bold; }
.today-action {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: center;
}
.today-action .btn { width: 100%; }
.today-single { grid-template-columns: 1fr; }

/* Timetable rows: plain list, times tabular */
.movements { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.movement {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  align-items: baseline;
}
.movement .st { font-weight: bold; font-size: 1.1rem; }
.movement .times { text-align: right; font-variant-numeric: tabular-nums; font-weight: bold; }
.movement .meta { grid-column: 1 / -1; }

/* Running days: one compact toggle grid instead of seven stacked rows */
.daygrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.25rem; max-width: 34rem; }
.day input { position: absolute; opacity: 0; }
.day span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  border: 0.12rem solid var(--line);
  border-radius: 0;
  font-weight: bold;
  cursor: pointer;
}
.day input:checked + span {
  background: var(--brand-colour-mid);
  border-color: var(--brand-colour-mid);
  color: #fff;
}
.day input:focus-visible + span {
  outline: 0.15rem solid var(--brand-colour-mid);
  outline-offset: 0.1rem;
}

/* Movement editor: one stop after another, grouped fields */
.movements-edit {  gap: 2rem; }
.move-edit { list-style: none; }
.move-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}
.move-head .remove { font-weight: normal; }
.move-trio { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.timepair { display: flex; gap: 0.5rem; }
.timepair .field:first-child { flex: 1 1 auto; min-width: 0; }
.timepair .field:last-child { flex: 0 0 7rem; }
.card-errors { color: var(--danger); margin-bottom: 0.5rem; }

/* Warnings */
.warnings { list-style: none; margin: 0 0 1rem; padding: 0; }
.warnings li {
  background: var(--background);
  border-left: 0.3rem solid var(--warn);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

:focus-visible { outline: 0.15rem solid var(--brand-colour-mid); outline-offset: 0.1rem; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .today-row { grid-template-columns: 6rem 1fr auto; align-items: center; gap: 0.25rem 1rem; }
  .today-action { grid-column: auto; justify-content: flex-end; text-align: right; }
  .today-action .btn { width: auto; }
  .sidenav {
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem 1rem;
    background: var(--background);
  }
  .sidenav a {
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: var(--text);
    font-weight: bold;
  }
  .sidenav a[aria-current="page"] { color: var(--brand-colour-mid); }
  .actions.sticky { bottom: 0; }
}
