/* EPCR: the look shared by every page. Colors live in the variables below, so a change here
   shows everywhere. Pages still add their own small rules for their own layout. */

:root {
  /* Brand and surfaces */
  --brand: #1f5fa8;
  --brand-dark: #174a85;
  --brand-soft: #e8f0fa;
  --navy: #0f2747;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --border: #dbe2ea;
  --border-strong: #c3ccd6;
  --text: #1c2733;
  --muted: #6b7785;
  /* Signals */
  --ok: #1e8a46;
  --ok-soft: #e4f4ea;
  --warn: #b7791f;
  --warn-soft: #fff4dc;
  --danger: #c62828;
  --danger-soft: #fde6e6;
  /* Service levels (the same everywhere: maps, run numbers, chips) */
  --level-car: #0f8b8d;
  --level-wc: #8b5a2b;
  --level-fr: #6b8e23;
  --level-bls: #1f6fd1;
  --level-als: #d62828;
  --level-micu: #d6338a;
  /* Shape */
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 32, 56, 0.06), 0 2px 8px rgba(16, 32, 56, 0.05);
  --shadow-lg: 0 10px 30px rgba(16, 32, 56, 0.16);
  --focus: 0 0 0 3px rgba(31, 95, 168, 0.28);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main.page { padding: 20px 24px 40px; }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 0.2em 0 0.7em; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 1em 0 0.5em; font-weight: 650; }
h3 { font-size: 1.05rem; margin: 1em 0 0.4em; font-weight: 650; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-dark); }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
small, .muted { color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
.icon { vertical-align: -0.2em; flex: none; }

/* ---------- Tables ---------- */
table {
  border-collapse: separate; border-spacing: 0; margin-bottom: 1.5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); color: var(--muted); font-size: 0.82em; font-weight: 650; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child > td { border-bottom: 0; }
tbody tr:hover > td, table > tr:hover > td { background: #fafbfd; }
/* Every table sits in a box that scrolls sideways if it must (the page itself never does) */
.table-scroll { max-width: 100%; overflow-x: auto; container-type: inline-size; }
/* ...and a table with headings turns into cards when its box is narrow: phones, a small window */
@container (max-width: 700px) {
  table.stack, table.stack > tbody, table.stack > tbody > tr, table.stack > tbody > tr > td { display: block; }
  table.stack { border: 0; box-shadow: none; background: none; overflow: visible; margin-bottom: 1rem; }
  table.stack > tbody > tr.th-row, table.stack > thead { display: none; }
  table.stack > tbody > tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 8px 14px; padding: 10px 12px;
                             margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
  table.stack > tbody > tr > td { border: 0; padding: 0; min-width: 0; background: none; }
  table.stack > tbody > tr > td[colspan] { grid-column: 1 / -1; }
  table.stack > tbody > tr > td:has(> .row-actions) { grid-column: 1 / -1; padding-top: 8px; border-top: 1px solid var(--border); }
  table.stack > tbody > tr > td:empty, table.stack > tbody > tr > td.blank { display: none; }
  table.stack > tbody > tr > td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; margin-bottom: 1px; font-size: 0.72em; font-weight: 650; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--muted);
  }
}
/* The dispatch board has many columns: its cards start at a laptop-window width */
@container (max-width: 1080px) {
  table.board-table.stack, table.board-table.stack > tbody, table.board-table.stack > tbody > tr, table.board-table.stack > tbody > tr > td { display: block; }
  table.board-table.stack { border: 0; box-shadow: none; background: none; overflow: visible; margin-bottom: 1rem; }
  table.board-table.stack > tbody > tr.th-row, table.board-table.stack > thead { display: none; }
  table.board-table.stack > tbody > tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 8px 14px; padding: 10px 12px;
                             margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
  table.board-table.stack > tbody > tr > td { border: 0; padding: 0; min-width: 0; background: none; }
  table.board-table.stack > tbody > tr > td[colspan] { grid-column: 1 / -1; }
  table.board-table.stack > tbody > tr > td:empty, table.board-table.stack > tbody > tr > td.blank { display: none; }
  table.board-table.stack > tbody > tr > td[data-label]:not([data-label=""])::before {
    content: attr(data-label); display: block; margin-bottom: 1px; font-size: 0.72em; font-weight: 650; text-transform: uppercase;
    letter-spacing: 0.03em; color: var(--muted);
  }
}

/* ---------- Forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), select, textarea {
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 7px 10px; background: var(--surface);
  min-height: 36px; max-width: 100%; transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; vertical-align: -0.15em; }
input[type=file] { font-size: 0.9em; }
input::placeholder, textarea::placeholder { color: #9aa5b1; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
button:hover, .button:hover { background: var(--surface-2); border-color: #aeb9c5; }
button[type=submit], .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button[type=submit]:hover, .button.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
/* A button on each row of a list (Inactivate, Remove...) stays quiet so the list doesn't turn into a wall of blue;
   class="primary" keeps one blue. Low specificity, so .danger below still wins. */
:where(td) button[type=submit]:where(:not(.primary)) { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
:where(td) button[type=submit]:where(:not(.primary)):hover { background: var(--surface-2); border-color: #aeb9c5; color: var(--text); }
/* A submit button that isn't the page's main action (Search, Export...) */
button.secondary, .button.secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
button.secondary:hover, .button.secondary:hover { background: var(--surface-2); border-color: #aeb9c5; color: var(--text); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.danger, .button.danger { background: var(--surface); border-color: #e2a8a8; color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }

/* ---------- Cards, badges, messages ---------- */
.card, section.card, form.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 6px; margin-left: 4px;
  background: var(--danger); color: #fff; font-size: 0.72em; font-weight: 700; border-radius: 999px; line-height: 1; vertical-align: 0.1em;
}
.flash { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.flash.ok { background: var(--ok-soft); border-color: #b8dfc5; color: #175c31; }
.flash.error { background: var(--danger-soft); border-color: #efb7b7; color: #8e1d1d; }
.flash.link { background: #fff7ed; border-color: #fdba74; } .flash.link a { color: #9a3412; font-weight: 700; }
.flash.note { background: var(--warn-soft); border-color: #f0cf8a; color: #7a4b00; }
details > summary { cursor: pointer; }

/* A row of controls above a list (search, add, export...): <div class="toolbar"> ... <span class="spacer"></span> ... </div>.
   On a phone it wraps, and a search box takes the full width. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 14px; }
.toolbar form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.toolbar .spacer { flex: 1; }
.toolbar .search { display: flex; gap: 6px; flex: 1 1 18rem; max-width: 30rem; }
.toolbar .search input[type=search], .toolbar .search input[type=text] { flex: 1; min-width: 0; }
.button.ghost, button.ghost { background: none; border-color: transparent; color: var(--brand); }
.button.ghost:hover, button.ghost:hover { background: var(--brand-soft); border-color: transparent; color: var(--brand-dark); }
/* A row's own actions (Edit, Inactivate...) side by side at the end of the row */
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }

/* A shift still on after its set end time (nobody ended it) */
.past-end { display: inline-block; padding: 0 8px; border-radius: 999px; background: var(--warn-soft); color: #7a4b00; border: 1px solid #f0cf8a;
            font-size: 0.8em; font-weight: 650; white-space: nowrap; }

/* Service-level chips: <span class="level-chip bls">BLS</span> */
.level-chip { display: inline-block; padding: 1px 9px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 0.8em; }
.level-chip.car { background: var(--level-car); } .level-chip.wc { background: var(--level-wc); } .level-chip.fr { background: var(--level-fr); }
.level-chip.bls { background: var(--level-bls); } .level-chip.als { background: var(--level-als); }
.level-chip.micu { background: var(--level-micu); }

/* Priority: a soft pill with a dot, so it never looks like a service level. <span class="pri-chip" style="--c: ...">Critical</span> */
.pri-chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 0.78em; font-weight: 700;
            color: var(--c); background: color-mix(in srgb, var(--c) 11%, #fff); border: 1px solid color-mix(in srgb, var(--c) 40%, #fff); white-space: nowrap; }
.pri-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
/* Trip type with its icon */
.trip-type { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.trip-type .icon { color: var(--brand); }
/* Kind of place (LOCATION_TYPE_STYLE): a colored tag, and a colored edge on a stop */
.place-tag { display: inline-block; font-size: 0.7em; font-weight: 800; color: #fff; border-radius: 5px; padding: 1px 6px;
             letter-spacing: 0.03em; text-transform: uppercase; vertical-align: 1px; white-space: nowrap; line-height: 1.5; }
.place-edge { border-left: 4px solid var(--pc, #c9d3de); padding-left: 9px; }
/* Trip type picture (_trip_glyph.html): the leg this run drives bold, the others faint */
.trip-glyph { color: var(--brand); vertical-align: middle; overflow: visible; flex: none; }
.trip-glyph .on { stroke-width: 3.2; }
.trip-glyph .off { stroke-width: 1.7; opacity: 0.28; }
.trip-glyph .wait { stroke-width: 1.6; fill: none; }  /* the clock between the arrows: always full blue */


/* Pick one, as pills (New Dispatch: service level and priority in their colors, trip type with its icon) */
.pick { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 13px; border-radius: 999px; cursor: pointer;
        border: 2px solid var(--c, var(--border-strong)); color: var(--c, var(--text)); background: var(--surface); font-weight: 700; user-select: none; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.pick:hover { background: color-mix(in srgb, var(--c, var(--brand)) 9%, #fff); }
.pick:has(input:checked) { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); color: #fff; }
.pick:has(input:checked) .icon { color: #fff; }
.pick:has(input:focus-visible) { box-shadow: var(--focus); }
.pick:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

/* ---------- The header ---------- */
nav.topnav {
  position: sticky; top: 0; z-index: 1500; display: flex; align-items: center; gap: 8px; padding: 9px 16px;
  background: linear-gradient(100deg, #0d2342 0%, #133763 55%, #1a4a80 100%); color: #fff;
  border-bottom: 3px solid #3d8bff; box-shadow: 0 4px 14px rgba(10, 25, 50, 0.28);
}
nav.topnav a { color: #fff; text-decoration: none; white-space: nowrap; border-radius: 999px; padding: 6px 12px;
               display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 0.88em; }
nav.topnav a:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }
nav.topnav .brand { padding: 4px 10px 4px 4px; color: #fff; font-weight: 800; letter-spacing: 0.04em; font-size: 1em; margin-right: 6px; }
nav.topnav .brand img { width: auto; height: 26px; display: block; }  /* the white DW mark (static/brand) */
nav.topnav .shortcuts { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0; flex-wrap: wrap; }
/* Shortcuts: clear pills on the dark bar; the page you're on is the white one */
nav.topnav .shortcut { background: rgba(255, 255, 255, 0.13); border: 1px solid rgba(255, 255, 255, 0.28);
                       box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08); }
nav.topnav .shortcut .icon { color: #9cc8ff; }
nav.topnav .shortcut:hover { background: rgba(255, 255, 255, 0.24); border-color: rgba(255, 255, 255, 0.45); }
nav.topnav .shortcut.current { background: #fff; color: var(--navy); border-color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
nav.topnav .shortcut.current .icon { color: var(--brand); }
nav.topnav .right { display: flex; gap: 4px; align-items: center; margin-left: auto; }
/* The menu button and the shortcuts' names only show on phones (see below); wide screens show the round icons */
nav.topnav .nav-menu, nav.topnav .shortcut.menu-only, nav.topnav .sc-label { display: none; }
/* Icons only: every header button is a round icon; its name shows on hover (data-tip) */
nav.topnav .shortcut, nav.topnav .icon-btn, nav.topnav .view-switch, nav.topnav .profile { position: relative; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 9px; }
nav.topnav .shortcut .badge, nav.topnav .icon-btn .badge { position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; font-size: 0.7em; line-height: 18px; text-align: center; }
nav.topnav .profile { padding: 0 4px; }
nav.topnav [data-tip]:hover::after, nav.topnav [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 10;
  background: #0b1a2e; color: #fff; font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); pointer-events: none; }
nav.topnav .right [data-tip]:hover::after { left: auto; right: 0; transform: none; }
nav.topnav .search-open, nav.topnav .time-clock button { position: relative; }
/* The header's search icon and the search window */
nav.topnav .time-clock { margin: 0; }
nav.topnav .time-clock button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 0; min-width: 40px; height: 40px; padding: 0 10px; border-radius: 999px;
                                 font-weight: 800; font-size: 0.9em; background: #2f855a; border: 0; color: #fff; white-space: nowrap; }
nav.topnav .time-clock.in button { background: #b3261e; }
nav.topnav .time-clock b { font-variant-numeric: tabular-nums; background: rgba(0,0,0,0.2); border-radius: 6px; padding: 0 6px; }
@media (max-width: 700px) { nav.topnav .time-clock span { display: none; } }
nav.topnav .view-switch { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; font-weight: 700;
                         font-size: 0.88em; background: rgba(255,255,255,0.14); color: #fff; text-decoration: none; white-space: nowrap; }
nav.topnav .view-switch:hover { background: rgba(255,255,255,0.24); }
nav.topnav .view-switch.on-shift { background: #2f855a; }
@media (max-width: 700px) { nav.topnav .view-switch span { display: none; } }
nav.topnav .search-open { min-height: 40px; height: 40px; width: 40px; padding: 0; border-radius: 999px; background: rgba(255,255,255,0.13);
                          border: 1px solid rgba(255,255,255,0.28); color: #fff; margin-left: 6px; }
nav.topnav .search-open:hover { background: rgba(255,255,255,0.24); color: #fff; }
.search-dialog { z-index: 3000; width: min(640px, 94vw); max-height: 80vh; padding: 0; border: 0; border-radius: 16px; box-shadow: var(--shadow-lg);
                 margin-top: 10vh; overflow: hidden; color: var(--text); }
.search-dialog::backdrop { background: rgba(10, 22, 38, 0.45); backdrop-filter: blur(2px); }
.search-dialog form { display: flex; flex-direction: column; max-height: 80vh; }
.search-top { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--muted); }
.search-top input[type=search] { flex: 1; border: 0 !important; box-shadow: none !important; font-size: 1.15em; padding: 6px 0 !important; min-height: 0 !important; }
.search-close { min-height: 0; padding: 2px 8px; font-size: 0.75em; color: var(--muted); }
.search-kinds { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.search-kinds .label { font-size: 0.78em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-right: 2px; }
.search-kinds button { min-height: 0; padding: 4px 12px; border-radius: 999px; font-size: 0.88em; font-weight: 600; background: var(--surface); }
.search-kinds button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.search-list { overflow-y: auto; padding: 6px; min-height: 60px; flex: 1; }
.search-list .group { font-size: 0.75em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); padding: 8px 10px 2px; }
.search-list a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.search-list a strong { display: block; font-weight: 600; }
.search-list a small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-list a:hover, .search-list a.on { background: var(--brand-soft); }
.search-list .none { padding: 14px 10px; color: var(--muted); }
.search-foot { display: flex; justify-content: space-between; gap: 10px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 0.78em; color: var(--muted); }
kbd { border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: inherit; font-size: 0.95em; background: var(--surface); }
nav.topnav .profile { padding: 3px 12px 3px 3px; }
nav.topnav .badge { margin-left: 2px; }
.avatar { border-radius: 50%; object-fit: cover; display: inline-block; vertical-align: middle; flex: none; }
.avatar.initials { background: var(--brand); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
nav.topnav .avatar.initials { background: #2f6fbf; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }

/* ---------- Phones and small tablets ---------- */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  main.page { padding: 14px 12px 32px; }
  h1 { font-size: 1.3rem; }
  nav.topnav { padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); gap: 2px; }
  nav.topnav .brand span { display: none; }
  /* The shortcuts fold into a menu under the bar, each with its name */
  nav.topnav .nav-menu { display: inline-flex; position: relative; min-height: 40px; height: 40px; width: 40px; padding: 0; border-radius: 10px;
                         background: rgba(255,255,255,0.13); border: 1px solid rgba(255,255,255,0.28); color: #fff; }
  nav.topnav .nav-menu:hover, nav.topnav.menu-open .nav-menu { background: rgba(255,255,255,0.26); }
  nav.topnav .nav-menu .badge { position: absolute; top: -4px; right: -4px; margin: 0; }
  nav.topnav .shortcuts { display: none; position: absolute; top: 100%; left: 8px; right: 8px; flex-direction: column; flex-wrap: nowrap; gap: 2px;
                          padding: 6px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
                          max-height: calc(100vh - 90px); overflow-y: auto; margin-top: 6px; }
  nav.topnav.menu-open .shortcuts { display: flex; align-items: stretch; }
  nav.topnav .shortcuts .shortcut, nav.topnav .shortcuts .shortcut.menu-only { display: flex; justify-content: flex-start; gap: 12px; height: auto; min-height: 46px;
                          padding: 8px 12px; border-radius: 10px; background: none; border: 0; box-shadow: none; color: var(--text); font-size: 1em; }
  nav.topnav .shortcuts .shortcut .icon { color: var(--brand); }
  nav.topnav .shortcuts .shortcut:hover { background: var(--surface-2); }
  nav.topnav .shortcuts .shortcut.current { background: var(--brand-soft); color: var(--brand-dark); box-shadow: none; }
  nav.topnav .shortcuts .shortcut.menu-only { border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; margin-top: 4px; }
  nav.topnav .shortcuts .shortcut.menu-only + .shortcut.menu-only { border-top: 0; margin-top: 0; }
  nav.topnav .shortcuts .sc-label { display: inline; font-weight: 600; }
  nav.topnav .shortcuts .shortcut .badge { position: static; margin-left: auto; }
  nav.topnav .shortcuts [data-tip]:hover::after { display: none; }
  nav.topnav .icon-btn.logout { display: none; }
  nav.topnav .profile .name, nav.topnav .logout-text { display: none; }
  .search-dialog { margin-top: 4vh; }
  .search-foot span:last-child { display: none; }
  dialog table { display: block; overflow-x: auto; max-width: 100%; }
  button, .button { min-height: 42px; }
  input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]), select { min-height: 42px; }
  /* 16px text in a box: iPhones zoom the whole page in on a smaller one when you tap it */
  input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 16px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }
  .toolbar .search { flex-basis: 100%; max-width: none; }
  .row-actions { justify-content: flex-start; }
}

/* Touch screens: small text links (Edit, Find, a run number...) get a finger-sized tap area without moving anything */
@media (pointer: coarse) {
  main td a, main .find, main .row-actions a { display: inline-block; padding-block: 9px; margin-block: -9px; }
}

/* Narrow phones: smaller round buttons so the shortcuts, clock, messages, notices and profile all fit */
@media (max-width: 430px) {
  nav.topnav .brand { padding: 2px; margin-right: 2px; }
  nav.topnav .brand img { width: auto; height: 21px; }
  nav.topnav .shortcuts { gap: 3px; }
  nav.topnav .right { gap: 0; }
  nav.topnav .shortcut, nav.topnav .icon-btn, nav.topnav .view-switch { min-width: 34px; height: 34px; padding: 0 6px; }
  nav.topnav .profile { padding: 0 2px; }
  nav.topnav .time-clock button { min-width: 34px; height: 34px; padding: 0 7px; gap: 4px; }
  nav.topnav .time-clock b { font-size: 0.85em; padding: 0 4px; }
}

/* ---------- Big screens (a TV on the wall) ---------- */
@media (min-width: 1900px) {
  body { font-size: 16.5px; }
}

/* ---------- Printing ---------- */
@media print {
  body { background: #fff; }
  nav.topnav { display: none; }
  main.page { padding: 0; }
  table, .card { box-shadow: none; }
}

/* A patient's name that opens their file (app/ui.py patient_link) */
a.patient-link { color: inherit; text-decoration: underline; text-decoration-color: rgba(31, 95, 168, 0.45); text-underline-offset: 3px; }
a.patient-link:hover { color: var(--brand); text-decoration-color: currentColor; }

/* Loaded miles next to the map's distance (static/js/loaded_miles.js) */
.loaded-miles { padding: 8px 12px; border-radius: 10px; background: #eef4fb; border: 1px solid #c9dbf0; line-height: 1.6; }
.loaded-miles.ok { background: #e6f4ea; border-color: #b7dfc2; }
.loaded-miles.warn { background: #fff3dc; border-color: #e0b44c; color: #6b4400; }
.loaded-miles.bad { background: #fde7e5; border-color: #f0b4b4; color: #a40000; }
