/* =========================================================================
   Sangam Travels — Trip Sheet System
   Design system layered over Bootstrap 5.3
   =========================================================================

   Palette is taken from the brand mark itself: gold #E0AF2A on black. Gold is
   the accent, not the interface — it marks the active section, focus, and the
   lead chart series, and never has to carry small text on a light background
   where it would fail contrast. Primary actions are near-black, which is both
   the other half of the logo and the most legible button there is.

   Colour otherwise means one of exactly three things: over/under a limit, the
   direction money moved, or trip status. Everything else is neutral, because
   this is a ledger and the numbers are the content.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens */

:root {
  /* brand */
  --st-brand:        #e0af2a;
  --st-brand-deep:   #8a6a12;   /* darkened for text on light: ~5.4:1 */
  --st-brand-soft:   #fdf6e4;

  /* surfaces */
  --st-bg:           #f2f4f7;
  --st-surface:      #ffffff;
  --st-surface-2:    #f8fafc;
  --st-surface-3:    #eef1f5;
  --st-border:       #e4e8ee;
  --st-border-2:     #cfd6e0;
  --st-grid:         #edf0f4;

  /* ink */
  --st-ink:          #10131a;
  --st-ink-2:        #414a58;
  --st-muted:        #6b7585;

  /* accent = interactive */
  --st-accent:       #8a6a12;
  --st-accent-bg:    #fbf4e2;

  /* semantic */
  --st-pos:          #067a53;
  --st-pos-bg:       #e9f8f1;
  --st-neg:          #c02626;
  --st-neg-bg:       #fdeded;
  --st-warn:         #a86a08;
  --st-warn-bg:      #fdf4e3;

  /* rail */
  --st-rail:         #12151c;
  --st-rail-2:       #1b202a;
  --st-rail-ink:     #9aa4b4;
  --st-rail-ink-2:   #e8ecf2;

  --st-radius:       12px;
  --st-radius-sm:    8px;
  --st-shadow:       0 1px 2px rgba(16, 19, 26, .04), 0 1px 3px rgba(16, 19, 26, .06);
  --st-shadow-lg:    0 10px 30px rgba(16, 19, 26, .12);

  --st-sidebar-w:    250px;
}

[data-bs-theme="dark"] {
  --st-brand:        #e8bb43;
  --st-brand-deep:   #e8bb43;
  --st-brand-soft:   #2a2113;

  --st-bg:           #0b0e13;
  --st-surface:      #141922;
  --st-surface-2:    #1a202b;
  --st-surface-3:    #212936;
  --st-border:       #262e3b;
  --st-border-2:     #38404f;
  --st-grid:         #222a36;

  --st-ink:          #e9eef6;
  --st-ink-2:        #b4bfcf;
  --st-muted:        #7f8b9c;

  --st-accent:       #e8bb43;
  --st-accent-bg:    #2a2113;

  --st-pos:          #46d39a;
  --st-pos-bg:       #0e2a20;
  --st-neg:          #f2777a;
  --st-neg-bg:       #2c1618;
  --st-warn:         #f0b543;
  --st-warn-bg:      #2b2112;

  --st-rail:         #0e1218;
  --st-rail-2:       #161c25;
  --st-rail-ink:     #8a95a6;
  --st-rail-ink-2:   #eef2f8;

  --st-shadow:       0 1px 2px rgba(0, 0, 0, .5);
  --st-shadow-lg:    0 12px 34px rgba(0, 0, 0, .55);
}

/* Hand the palette to Bootstrap so its own components inherit it. Bootstrap
   sets these under [data-bs-theme=dark] itself; we load after, so we win. */
:root, [data-bs-theme="dark"] {
  --bs-body-bg:          var(--st-bg);
  --bs-body-color:       var(--st-ink);
  --bs-border-color:     var(--st-border);
  --bs-secondary-color:  var(--st-muted);
  --bs-secondary-bg:     var(--st-surface-2);
  --bs-tertiary-bg:      var(--st-surface-2);
  --bs-emphasis-color:   var(--st-ink);
  --bs-link-color:       var(--st-accent);
  --bs-link-hover-color: var(--st-accent);
  --bs-code-color:       var(--st-accent);
  --bs-border-radius:    var(--st-radius-sm);
}

/* ------------------------------------------------------------------ base */

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

body {
  background: var(--st-bg);
  color: var(--st-ink);
  font-family: Inter, ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "cv08" 1, "tnum" 0;
}

h1, h2, h3, h4, h5 { color: var(--st-ink); letter-spacing: -0.014em; font-weight: 650; }

a { text-decoration: none; color: var(--st-accent); }
a:hover { text-decoration: underline; }

.text-muted { color: var(--st-muted) !important; }
.small, small { font-size: .8rem; }

::selection { background: var(--st-brand); color: #12151c; }

:focus-visible {
  outline: 2px solid var(--st-brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Numbers only line up if they are tabular — reading down a money column is
   the entire point of a ledger. */
.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
td, th, .stat-value, .sheet-grid strong, .trip-header dd { font-variant-numeric: tabular-nums; }

.icon-sprite { display: none; }
.ico { width: 1.05rem; height: 1.05rem; flex: 0 0 auto; }

/* ============================================================== app shell */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--st-sidebar-w);
  flex: 0 0 var(--st-sidebar-w);
  background: var(--st-rail);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1040;
}

.sidebar-brand {
  padding: 1.1rem 1.15rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
/* The wordmark is black on transparent, so on the dark rail it needs a plate. */
.sidebar-brand img {
  height: 2.5rem;
  width: auto;
  background: #fff;
  border-radius: 8px;
  padding: .3rem .5rem;
  display: block;
}
.sidebar-close {
  background: none; border: 0; color: var(--st-rail-ink);
  font-size: 1.6rem; line-height: 1; padding: 0 .25rem;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: .9rem .7rem; }

.nav-group { margin-bottom: 1.1rem; }
.nav-group-label {
  display: block;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #5c6675;
  padding: 0 .6rem;
  margin-bottom: .35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .6rem;
  border-radius: var(--st-radius-sm);
  color: var(--st-rail-ink);
  font-weight: 500;
  font-size: .855rem;
  position: relative;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: var(--st-rail-ink-2); text-decoration: none; }
.nav-item .ico { opacity: .75; }

/* Active section: gold marker on the rail — the one place gold does real work. */
.nav-item.active {
  background: rgba(224, 175, 42, .12);
  color: #fff;
  font-weight: 600;
}
.nav-item.active .ico { opacity: 1; color: var(--st-brand); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -.7rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.35rem;
  border-radius: 0 3px 3px 0;
  background: var(--st-brand);
}

.sidebar-foot {
  padding: .7rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.sidebar-scrim { display: none; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.4rem;
  background: color-mix(in srgb, var(--st-surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--st-border);
}
/* The topbar names where you are; the page's own h1 is the heading. Keeping it
   quieter than the h1 stops the two reading as a duplicated title. */
.topbar-title {
  font-size: .9rem;
  font-weight: 600;
  margin: 0;
  color: var(--st-ink-2);
  letter-spacing: -0.005em;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--st-border);
  color: var(--st-ink-2);
  border-radius: var(--st-radius-sm);
  width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.icon-btn:hover { background: var(--st-surface-2); color: var(--st-accent); border-color: var(--st-border-2); }

.user-chip {
  display: flex; align-items: center; gap: .55rem;
  background: transparent; border: 1px solid var(--st-border);
  border-radius: 999px; padding: .22rem .7rem .22rem .22rem;
  color: var(--st-ink);
}
.user-chip:hover { background: var(--st-surface-2); border-color: var(--st-border-2); }
.user-chip .avatar {
  width: 1.75rem; height: 1.75rem; border-radius: 50%;
  background: linear-gradient(140deg, var(--st-brand), #b8891a);
  color: #12151c; font-weight: 700; font-size: .78rem;
  display: grid; place-items: center;
}
.user-chip .who { display: flex; flex-direction: column; line-height: 1.15; text-align: left; }
.user-chip .who strong { font-size: .8rem; font-weight: 600; }
.user-chip .who small { font-size: .66rem; color: var(--st-muted); }
@media (max-width: 575px) { .user-chip .who { display: none; } }

.content { flex: 1; padding: 1.4rem; max-width: 1600px; width: 100%; }
@media (min-width: 1200px) { .content { padding: 1.6rem 1.9rem; } }

.app-foot {
  display: flex; justify-content: space-between;
  padding: 1rem 1.4rem 1.4rem;
  color: var(--st-muted);
  font-size: .75rem;
}

/* Sidebar collapses to an overlay below lg. */
@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--st-shadow-lg);
  }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-scrim {
    display: block; position: fixed; inset: 0;
    background: rgba(9, 12, 17, .5); z-index: 1035;
  }
  .content { padding: 1rem; }
}

/* ------------------------------------------------------------ page header */

.content > h1 {
  font-size: 1.3rem;
  font-weight: 680;
  margin-bottom: 1rem;
}
.content > h1.h4 { font-size: 1.3rem; }

.page-head { margin-bottom: 1.1rem; }
.page-head .lede { color: var(--st-muted); margin: .15rem 0 0; font-size: .875rem; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: var(--st-radius);
  box-shadow: var(--st-shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--st-border);
  color: var(--st-ink);
  font-size: .8rem;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  padding: .75rem 1rem;
}

.card-body { padding: 1rem; }
.card-footer { background: var(--st-surface-2); border-top: 1px solid var(--st-border); }

/* KPI tiles ------------------------------------------------------------- */

.stat-card { position: relative; overflow: hidden; transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease; }
.stat-card .card-body { padding: .95rem 1rem; }

a:hover > .stat-card {
  border-color: var(--st-border-2);
  box-shadow: var(--st-shadow-lg);
  transform: translateY(-2px);
}

.stat-label {
  font-size: .68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--st-muted);
  margin-bottom: .3rem;
}

/* The tile icon is absolutely positioned, so the label has to be kept out from
   under it — "Awaiting settlement" is long enough to collide. */
.stat-card .stat-label { padding-right: 2.5rem; }

.stat-card .stat-value {
  font-size: 1.7rem;
  font-weight: 680;
  line-height: 1.1;
  letter-spacing: -0.028em;
  color: var(--st-ink);
}

.stat-foot { font-size: .74rem; color: var(--st-muted); margin-top: .3rem; }

.stat-ico {
  position: absolute;
  top: .8rem; right: .9rem;
  width: 2rem; height: 2rem;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--st-surface-3);
  color: var(--st-muted);
}
.stat-ico .ico { width: 1.1rem; height: 1.1rem; }
.stat-card.is-alert .stat-ico { background: var(--st-neg-bg); color: var(--st-neg); }
.stat-card.is-warn  .stat-ico { background: var(--st-warn-bg); color: var(--st-warn); }
.stat-card.is-good  .stat-ico { background: var(--st-pos-bg); color: var(--st-pos); }
.stat-card.is-brand .stat-ico { background: var(--st-brand-soft); color: var(--st-brand-deep); }

/* --------------------------------------------------------------- tables */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--st-ink);
  margin-bottom: 0;
  border-color: var(--st-border);
}

.table > thead th {
  background: var(--st-surface-2);
  border-bottom: 1px solid var(--st-border) !important;
  color: var(--st-muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: .6rem .75rem;
}
.table > thead th.num { text-align: right; }

.table > tbody > tr > td {
  border-color: var(--st-border);
  padding: .58rem .75rem;
  vertical-align: middle;
}
.table > tbody > tr:last-child > td { border-bottom: 0; }
.table-hover > tbody > tr { transition: background .1s ease; }
.table-hover > tbody > tr:hover > * { background: var(--st-surface-2); }

.table tfoot td {
  background: var(--st-surface-2);
  border-top: 2px solid var(--st-border-2) !important;
  font-weight: 650;
}

.table-sm-tight td, .table-sm-tight th { font-size: .82rem; }

/* Registration numbers and names are the identifying cell in every table here;
   breaking "TN-63-AB-1212" across two lines makes it unreadable at a glance. */
.table > tbody > tr > td.fw-semibold { white-space: nowrap; }

.table-danger, .table > :not(caption) > * > .table-danger {
  --bs-table-bg: var(--st-neg-bg);
  color: var(--st-ink);
}

/* A blank table should explain itself rather than just being empty. */
.table td.text-center.text-muted { color: var(--st-muted) !important; font-size: .85rem; padding: 2rem 1rem !important; }

/* Cards that are pure table get no double padding. */
.card > .table-responsive { border-radius: 0 0 var(--st-radius) var(--st-radius); overflow: hidden; }

/* --------------------------------------------------------- semantic ink */

.over-limit  { color: var(--st-neg) !important; font-weight: 650; }
.under-limit { color: var(--st-pos) !important; }
.text-danger  { color: var(--st-neg) !important; }
.text-success { color: var(--st-pos) !important; }
.text-warning { color: var(--st-warn) !important; }

/* --------------------------------------------------------- status pills */

.pill {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1px solid transparent;
  line-height: 1.4;
  white-space: nowrap;
}
.pill-open    { background: var(--st-pos-bg);    color: var(--st-pos);        border-color: color-mix(in srgb, var(--st-pos) 30%, transparent); }
.pill-closed  { background: var(--st-warn-bg);   color: var(--st-warn);       border-color: color-mix(in srgb, var(--st-warn) 30%, transparent); }
.pill-settled { background: var(--st-surface-3); color: var(--st-muted);      border-color: var(--st-border-2); }
.pill-neutral { background: var(--st-surface-3); color: var(--st-ink-2);      border-color: var(--st-border-2); }
.pill-alert   { background: var(--st-neg-bg);    color: var(--st-neg);        border-color: color-mix(in srgb, var(--st-neg) 30%, transparent); }
.pill-brand   { background: var(--st-brand-soft); color: var(--st-brand-deep); border-color: color-mix(in srgb, var(--st-brand) 45%, transparent); }

.badge.bg-light { background: var(--st-surface-3) !important; color: var(--st-ink-2) !important; }

/* ----------------------------------------------------------------- tabs */

.nav-tabs { border-bottom: 1px solid var(--st-border); gap: .1rem; }
.nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--st-muted);
  font-weight: 550;
  font-size: .875rem;
  padding: .55rem .9rem;
  transition: color .12s ease, border-color .12s ease;
}
.nav-tabs .nav-link:hover { color: var(--st-ink); background: transparent; border-bottom-color: var(--st-border-2); text-decoration: none; }
.nav-tabs .nav-link.active {
  background: transparent;
  color: var(--st-ink);
  border-bottom-color: var(--st-brand);
  font-weight: 650;
}

/* ------------------------------------------------- trip sheet masthead */

.trip-header dt {
  font-size: .66rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--st-muted);
  margin-bottom: .1rem;
}
.trip-header dd {
  font-size: 1rem;
  font-weight: 650;
  margin-bottom: 0;
  color: var(--st-ink);
}
.trip-header > div { border-left: 1px solid var(--st-border); padding-left: .9rem; }
.trip-header > div:first-child { border-left: 0; }

@media (max-width: 767px) {
  .trip-header > div { border-left: 0; padding-left: 0; margin-bottom: .75rem; }
}

.locked-banner { border-left: 3px solid var(--st-muted) !important; }

/* ---------------------------------------------------------------- forms */

.form-label { font-weight: 600; color: var(--st-ink-2); font-size: .82rem; margin-bottom: .28rem; }
.form-label.small { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--st-muted); font-weight: 650; }
.form-text { font-size: .76rem; color: var(--st-muted); }

.form-control, .form-select {
  background: var(--st-surface);
  border-color: var(--st-border-2);
  color: var(--st-ink);
  border-radius: var(--st-radius-sm);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus {
  border-color: var(--st-brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-brand) 22%, transparent);
}
.form-control::placeholder { color: var(--st-muted); opacity: .65; }
.form-check-input:checked { background-color: var(--st-ink); border-color: var(--st-ink); }
.form-check-input:focus { border-color: var(--st-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--st-brand) 22%, transparent); }

/* -------------------------------------------------------------- buttons */

.btn { border-radius: var(--st-radius-sm); font-weight: 560; transition: background .12s ease, border-color .12s ease, transform .06s ease; }
.btn:active { transform: translateY(1px); }
.btn-sm { font-size: .8rem; padding: .3rem .65rem; }

/* Primary = near-black: the other half of the logo, and the clearest button
   there is. Gold is reserved for state, where it does not have to carry text. */
.btn-dark {
  background: var(--st-ink);
  border-color: var(--st-ink);
  color: #fff;
}
.btn-dark:hover, .btn-dark:focus {
  background: #262d3a;
  border-color: #262d3a;
  color: #fff;
}
[data-bs-theme="dark"] .btn-dark { background: var(--st-brand); border-color: var(--st-brand); color: #14171d; }
[data-bs-theme="dark"] .btn-dark:hover { background: #f0c65c; border-color: #f0c65c; color: #14171d; }

.btn-outline-secondary { border-color: var(--st-border-2); color: var(--st-ink-2); background: var(--st-surface); }
.btn-outline-secondary:hover,
.btn-outline-secondary.active { background: var(--st-surface-2); border-color: var(--st-muted); color: var(--st-ink); }

/* Closing a trip is consequential and one-way — amber, not Bootstrap yellow. */
.btn-warning { background: var(--st-warn); border-color: var(--st-warn); color: #fff; }
.btn-warning:hover, .btn-warning:focus {
  background: color-mix(in srgb, var(--st-warn) 84%, #000);
  border-color: color-mix(in srgb, var(--st-warn) 84%, #000);
  color: #fff;
}

.btn-outline-danger { border-color: color-mix(in srgb, var(--st-neg) 42%, transparent); color: var(--st-neg); }
.btn-outline-danger:hover { background: var(--st-neg); border-color: var(--st-neg); color: #fff; }

.btn-link { color: var(--st-muted); }

/* --------------------------------------------------------------- alerts */

.alert { border-radius: var(--st-radius); border-width: 1px; font-size: .87rem; padding: .7rem .95rem; }
.alert-success { background: var(--st-pos-bg);    border-color: color-mix(in srgb, var(--st-pos) 25%, transparent);   color: var(--st-pos); }
.alert-danger  { background: var(--st-neg-bg);    border-color: color-mix(in srgb, var(--st-neg) 25%, transparent);   color: var(--st-neg); }
.alert-warning { background: var(--st-warn-bg);   border-color: color-mix(in srgb, var(--st-warn) 25%, transparent);  color: var(--st-warn); }
.alert-info    { background: var(--st-brand-soft); border-color: color-mix(in srgb, var(--st-brand) 35%, transparent); color: var(--st-brand-deep); }
.alert-secondary { background: var(--st-surface-2); border-color: var(--st-border); color: var(--st-ink-2); }
.alert .alert-link { color: inherit; text-decoration: underline; font-weight: 650; }

/* --------------------------------------------------- misc bootstrap bits */

.dropdown-menu {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: var(--st-radius);
  box-shadow: var(--st-shadow-lg);
  font-size: .87rem;
  padding: .3rem;
}
.dropdown-item { color: var(--st-ink-2); border-radius: 6px; padding: .4rem .6rem; }
.dropdown-item:hover { background: var(--st-surface-2); color: var(--st-ink); }
.dropdown-divider { border-color: var(--st-border); margin: .3rem 0; }

.list-group-item { background: var(--st-surface); border-color: var(--st-border); color: var(--st-ink); }

code {
  background: var(--st-surface-3);
  border: 1px solid var(--st-border);
  border-radius: 4px;
  padding: .05rem .3rem;
  font-size: .82em;
  color: var(--st-ink-2);
}

hr { border-color: var(--st-border); opacity: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--st-border-2); border-radius: 10px; border: 2px solid var(--st-bg); }
::-webkit-scrollbar-thumb:hover { background: var(--st-muted); }
.sidebar ::-webkit-scrollbar-thumb { background: #2c3542; border-color: var(--st-rail); }

/* ================================================================ login */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 2rem 1rem; }
.login-shell { max-width: 24rem; width: 100%; }

.login-logo { height: 4.4rem; width: auto; }
[data-bs-theme="dark"] .login-logo {
  background: #fff; border-radius: 12px; padding: .65rem .85rem; box-sizing: content-box;
}

/* Password field with an in-field reveal. Typing a password blind on a phone in
   a bus depot is how people get locked out. */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 4.2rem; }
.pw-toggle {
  position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--st-muted);
  font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  padding: .25rem .45rem; border-radius: 5px;
}
.pw-toggle:hover { color: var(--st-accent); background: var(--st-accent-bg); }

/* ================================================= driver mobile view === */

/* Entered one-handed on a moving bus by someone who would rather not be filling
   in a form: every target is thumb-sized and the primary action is the biggest
   thing on the screen. */

.m-shell { max-width: 34rem; margin: 0 auto; padding: 1rem; }

.m-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .6rem;
  padding: .65rem .9rem;
  background: var(--st-rail);
  color: var(--st-rail-ink-2);
}
.m-topbar img { height: 1.9rem; background: #fff; border-radius: 6px; padding: .18rem .3rem; }
.m-topbar .who { margin-left: auto; font-size: .78rem; color: var(--st-rail-ink); min-width: 0; }
.m-topbar .m-btn {
  background: rgba(255, 255, 255, .1); border: 0; color: #fff;
  border-radius: 7px; padding: .3rem .6rem; font-size: .8rem; font-weight: 600;
}

.m-hero {
  background: linear-gradient(150deg, var(--st-rail) 0%, var(--st-rail-2) 100%);
  color: #fff;
  border-radius: var(--st-radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.m-hero .reg { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.m-hero .route { color: #aab3c0; font-size: .9rem; }
/* minmax(0, 1fr), not 1fr: a bare 1fr track will not shrink below its content's
   min-width, so a long figure pushes the whole row off a narrow phone screen. */
.m-hero .m-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .9rem; }
.m-hero .m-stats > div {
  background: rgba(255, 255, 255, .07); border-radius: 8px;
  padding: .5rem .35rem; text-align: center; min-width: 0;
}
.m-hero .m-stats span {
  display: block; font-size: .58rem; text-transform: uppercase;
  letter-spacing: .06em; color: #96a0ae; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.m-hero .m-stats strong {
  font-size: .9rem; font-variant-numeric: tabular-nums;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-hero .m-cash { margin-top: .9rem; padding-top: .9rem; border-top: 1px solid rgba(255, 255, 255, .12); text-align: center; }
.m-hero .m-cash span { font-size: .62rem; text-transform: uppercase; letter-spacing: .07em; color: #96a0ae; }
.m-hero .m-cash strong { display: block; font-size: 1.65rem; font-weight: 700; }

.m-action {
  display: flex; align-items: center; gap: .85rem;
  padding: 1rem 1.1rem; margin-bottom: .75rem;
  font-size: 1.02rem; font-weight: 600; text-align: left;
  border-radius: var(--st-radius);
  border: 1px solid var(--st-border);
  background: var(--st-surface);
  color: var(--st-ink);
  box-shadow: var(--st-shadow);
}
.m-action:hover { border-color: var(--st-border-2); color: var(--st-ink); text-decoration: none; }
.m-action .m-icon {
  width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem;
  border-radius: 10px; display: grid; place-items: center; font-size: 1.2rem;
}
.m-action .m-chev { margin-left: auto; color: var(--st-muted); font-size: 1.3rem; }

.m-fuel    .m-icon { background: var(--st-brand-soft); }
.m-expense .m-icon { background: var(--st-neg-bg); }
.m-booking .m-icon { background: var(--st-pos-bg); }
.m-check   .m-icon { background: var(--st-surface-3); }

.m-action.btn-primary, .m-action.btn-danger, .m-action.btn-success, .m-action.btn-secondary {
  justify-content: center; color: #fff; border: 0; font-size: 1.05rem; padding: .95rem;
}
.m-action.btn-primary   { background: var(--st-ink); }
.m-action.btn-danger    { background: var(--st-neg); }
.m-action.btn-success   { background: var(--st-pos); }
.m-action.btn-secondary { background: var(--st-ink-2); }

.m-form .form-control, .m-form .form-select { font-size: 1.02rem; padding: .7rem .8rem; min-height: 3rem; }
.m-form .form-control-lg { font-size: 1.5rem; font-weight: 680; text-align: right; }
.m-form label { font-weight: 600; margin-bottom: .3rem; }

/* ====================================================== full trip sheet === */

.sheet {
  background: var(--st-surface);
  border: 1px solid var(--st-border);
  border-radius: var(--st-radius);
  box-shadow: var(--st-shadow);
  padding: 1.75rem;
  max-width: 62rem;
  margin: 0 auto;
}

.sheet-masthead {
  display: flex; align-items: center; gap: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--st-ink);
  margin-bottom: 1.35rem;
}
.sheet-logo { height: 3.4rem; width: auto; }
[data-bs-theme="dark"] .sheet-logo {
  background: #fff; border-radius: 8px; padding: .35rem .5rem; box-sizing: content-box;
}
.sheet-title { flex: 1; }
/* Serif here deliberately: it echoes the printed wordmark and reads as a
   document rather than a screen. */
.sheet-title h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem; font-weight: 700; margin: 0;
  letter-spacing: .1em; text-transform: uppercase;
}
.sheet-title p { margin: 0; color: var(--st-muted); font-size: .8rem; letter-spacing: .04em; }
.sheet-meta { text-align: right; display: grid; gap: .3rem; }
.sheet-meta span { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .07em; color: var(--st-muted); }
.sheet-meta strong { font-size: .95rem; font-variant-numeric: tabular-nums; }

.sheet-block { margin-bottom: 1.5rem; break-inside: avoid; }
.sheet-block h3 {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--st-ink-2);
  border-bottom: 1px solid var(--st-border-2);
  padding-bottom: .3rem; margin-bottom: .75rem;
}

.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .85rem 1.25rem; }
.sheet-grid > div { border-left: 2px solid var(--st-border); padding-left: .65rem; }
.sheet-grid span { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .07em; color: var(--st-muted); margin-bottom: .1rem; }
.sheet-grid strong { font-size: 1rem; font-weight: 650; }

.sheet-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.sheet-table th, .sheet-table td { border: 1px solid var(--st-border); padding: .38rem .55rem; text-align: left; }
.sheet-table th {
  background: var(--st-surface-2);
  font-size: .66rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--st-muted); white-space: nowrap;
}
.sheet-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sheet-table tfoot td { background: var(--st-surface-2); font-weight: 650; }
.sheet-table tr.strong td { font-weight: 700; border-top: 2px solid var(--st-border-2); }
.sheet-table td.empty { text-align: center; color: var(--st-muted); padding: 1rem; }

.sheet-split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 767px) { .sheet-split { grid-template-columns: 1fr; } }

.sheet-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .4rem .9rem; }
.sheet-check { display: flex; align-items: center; gap: .5rem; font-size: .83rem; }
.sheet-check .box {
  width: 1.05rem; height: 1.05rem; flex: 0 0 1.05rem;
  border: 1px solid var(--st-border-2); border-radius: 3px;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
  color: var(--st-pos);
}
.sheet-check .lbl { flex: 1; }
.sheet-check .dt { color: var(--st-muted); font-size: .73rem; }

.sheet-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; }
.sheet-sign > div { border-top: 1px solid var(--st-ink); padding-top: .5rem; }
.sheet-sign span { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .07em; color: var(--st-muted); }
.sheet-sign strong { display: block; font-size: 1rem; min-height: 1.4rem; }
.sheet-sign small { color: var(--st-muted); font-size: .73rem; }

.sheet-note { font-size: .74rem; color: var(--st-muted); margin: .5rem 0 0; }

.sheet-foot {
  border-top: 1px solid var(--st-border);
  padding-top: .6rem; margin-top: 1.3rem;
  font-size: .71rem; color: var(--st-muted); text-align: center;
}

/* ============================================================== print === */

/* A settled trip sheet gets printed and filed. It should come out looking like
   the document it replaced — no navigation, no buttons, no colour. */

@media print {
  .sidebar, .topbar, .app-foot, .nav-tabs, .btn, form,
  .alert-dismissible .btn-close, .icon-btn, .no-print, .sidebar-scrim { display: none !important; }

  .app { display: block; }
  .content { padding: 0 !important; max-width: none; }

  /* Hiding every form would leave the "add a row" panels as empty shells, so
     drop the whole card when a form is all it holds. Inline delete buttons in
     table rows are forms too — already gone above, and their table survives
     because the form is not its card-body. */
  .card:has(> .card-body > form) { display: none !important; }

  body { background: #fff; color: #000; font-size: 10.5pt; }

  .sheet { border: 0; padding: 0; max-width: none; background: #fff; color: #000; box-shadow: none; }
  .sheet-logo { background: none !important; padding: 0 !important; }
  .sheet-masthead { border-bottom: 2px solid #000; }
  .sheet-block h3 { color: #000; border-bottom-color: #000; }
  .sheet-grid > div { border-left-color: #666; }
  .sheet-grid span, .sheet-meta span, .sheet-sign span, .sheet-check .dt,
  .sheet-note, .sheet-foot { color: #333; }
  .sheet-table th, .sheet-table td { border-color: #666; }
  .sheet-table th, .sheet-table tfoot td { background: #eee !important; color: #000; }
  .sheet-check .box { border-color: #000; color: #000; }
  .sheet-sign > div { border-top-color: #000; }
  .sheet-foot { border-top-color: #666; }
  .sheet-block { page-break-inside: avoid; }

  .card { border: 1px solid #999; border-radius: 0; break-inside: avoid; margin-bottom: .6rem; box-shadow: none; }
  .card-header { background: #eee !important; color: #000; border-bottom: 1px solid #999; }
  .table > thead th { background: #eee !important; color: #000; }
  .table, .table td, .table th { border-color: #999 !important; }

  .over-limit  { color: #000 !important; font-weight: 700; text-decoration: underline; }
  .under-limit { color: #000 !important; }
  .pill { border: 1px solid #000 !important; color: #000 !important; background: none !important; }

  a[href]::after { content: ""; }
}
