/* ===========================================================================
   Dunaway Fleet - shared shell

   The layout rule that drives everything here: the page never scrolls. The
   header and the rail are fixed, and the content region owns its own scroll.
   Tables scroll inside their own pane with a sticky head. That is the fix for
   the sizing problems in the SharePoint build, where six screens shared one
   scroll container and one fixed 1200px column.
   =========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,700&family=DM+Mono:wght@400;500&display=swap");

:root {
  --navy: #002554;
  --navy-deep: #001a3d;
  --navy-line: #17406f;
  --teal: #00857d;
  --teal-deep: #046f68;
  --teal-wash: #e4f2f0;

  --ink: #101820;
  --muted: #5b6875;
  --faint: #8a95a3;
  --line: #dde3ea;
  --line-soft: #eaeff4;
  --canvas: #f4f6f9;
  --surface: #ffffff;

  --red: #a8342c;
  --red-wash: #fbe7e5;
  --amber: #b5701a;
  --amber-wash: #fdf1de;
  --green: #1d6b45;
  --green-wash: #e4f2ea;

  --rail: 232px;
  --rail-narrow: 76px;
  --header: 56px;
  --measure: 1640px;

  --r-sm: 5px;
  --r-md: 8px;
  --r-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 8px 24px rgba(0, 37, 84, .06);

  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --- shell ---------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  grid-template-rows: var(--header) 1fr;
  grid-template-areas: "brand header" "rail main";
  height: 100dvh;
}

.brandbox {
  grid-area: brand;
  background: var(--navy-deep);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--navy-line);
}

.brandbox .mark {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 5px;
  background: var(--teal);
  display: grid; place-items: center;
  color: #fff;
}

.brandbox b { font-weight: 700; letter-spacing: .01em; font-size: 18px; }
.brandbox span { color: #12a396; font-weight: 400; }

.topbar {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.005em;
}

.topbar .crumb {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
}

.topbar .spacer { margin-left: auto; }

.rail {
  grid-area: rail;
  background: var(--navy);
  padding: 12px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rail .group {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #6f8fb5;
  padding: 14px 12px 6px;
}

.rail a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: #c3d3e5;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.rail a:hover { background: #073464; color: #fff; }
.rail a[aria-current="page"] { background: var(--teal); color: #fff; }
.rail a svg { flex: none; opacity: .9; }
.rail .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(255, 255, 255, .14);
  border-radius: 9px;
  padding: 1px 7px;
}
.rail a[aria-current="page"] .count { background: rgba(0, 0, 0, .22); }

.rail .foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--navy-line);
  color: #8fa8c4;
  font-size: 12px;
}
.rail .foot .who { color: #dce7f3; font-weight: 500; display: block; }
.rail .foot a { padding: 6px 0; font-size: 12px; color: #8fa8c4; }

main {
  grid-area: main;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 12px;
}

.pad {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 22px 24px 64px;
}

/* --- type ----------------------------------------------------------------- */

h2 { font-size: 19px; margin: 0 0 3px; letter-spacing: -.01em; }
h3 { font-size: 14px; margin: 0 0 10px; letter-spacing: -.005em; }
.lede { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--faint);
  margin: 0 0 8px;
}

.mono { font-family: var(--mono); }

/* The fleet's own vernacular: a truck is always a stamped number. */
.plate {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .02em;
  background: var(--navy);
  color: #fff;
  border-radius: 3px;
  padding: 2px 7px;
  white-space: nowrap;
}
.plate.ghost { background: none; color: var(--navy); border: 1px solid var(--line); }

/* --- surfaces ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
}
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--r-md);
  padding: 13px 15px;
}
.kpi .n { font-family: var(--mono); font-size: 25px; font-weight: 500; letter-spacing: -.02em; }
.kpi .l { font-size: 12px; color: var(--muted); margin-top: 1px; }
.kpi.bad { border-left-color: var(--red); } .kpi.bad .n { color: var(--red); }
.kpi.watch { border-left-color: var(--amber); } .kpi.watch .n { color: var(--amber); }
.kpi.good { border-left-color: var(--green); }
.kpi.info { border-left-color: var(--teal); }

/* --- the fleet ribbon: 43 trucks, one glance ------------------------------ */

.ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ribbon button {
  font-family: var(--mono);
  font-size: 11.5px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 7px 0;
  width: 46px;
  cursor: pointer;
  background: var(--green-wash);
  color: var(--green);
  transition: transform .12s ease;
}
.ribbon button.watch { background: var(--amber-wash); color: var(--amber); }
.ribbon button.bad { background: var(--red-wash); color: var(--red); }
.ribbon button.stale { box-shadow: inset 0 -3px 0 var(--navy); }
.ribbon button:hover { transform: translateY(-2px); border-color: currentColor; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; }

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

.pane {
  max-height: 62vh;
  overflow: auto;
  border-top: 1px solid var(--line);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: #fbfcfe; cursor: pointer; }
td.num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.table-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  flex-wrap: wrap;
}
.table-head h3 { margin: 0; }

/* --- controls ------------------------------------------------------------- */

label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 5px;
}

input, select, textarea, .fake-input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: -1px;
  border-color: var(--teal);
}
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }

.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-deep); border-color: var(--teal-deep); }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red-wash); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }

.search { max-width: 260px; }
select.compact, input.compact { width: auto; min-width: 130px; padding: 7px 10px; font-size: 13px; }

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

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 99px;
  padding: 3px 10px;
  white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { background: var(--green-wash); color: var(--green); }
.pill.watch { background: var(--amber-wash); color: var(--amber); }
.pill.bad { background: var(--red-wash); color: var(--red); }
.pill.flat { background: var(--line-soft); color: var(--muted); }
.pill.teal { background: var(--teal-wash); color: var(--teal-deep); }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* --- drawer --------------------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(6, 20, 38, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
  z-index: 40;
}
.scrim.on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(440px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform .18s ease;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.drawer.on { transform: none; }
.drawer header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.drawer header h3 { margin: 0; font-size: 15px; }
.drawer .body { padding: 16px 18px 40px; overflow-y: auto; flex: 1; }
.drawer .close {
  margin-left: auto;
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
}

.kv { display: grid; grid-template-columns: 108px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }

/* --- toast ---------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all .18s ease;
  z-index: 70;
  max-width: min(520px, 92vw);
  box-shadow: var(--shadow);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

.banner {
  border-radius: var(--r-md);
  padding: 11px 15px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.banner.info { background: var(--teal-wash); border-color: #b9ddd9; color: #0b544f; }
.banner.warn { background: var(--amber-wash); border-color: #f0d8ad; color: #7d4c0f; }

.skeleton {
  background: linear-gradient(90deg, #eef2f6 25%, #f7f9fb 50%, #eef2f6 75%);
  background-size: 400% 100%;
  animation: sweep 1.3s ease infinite;
  border-radius: var(--r-sm);
  height: 13px;
}
@keyframes sweep { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* --- responsive ----------------------------------------------------------- */

@media (max-width: 1180px) {
  .grid.split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  :root { --rail: var(--rail-narrow); }
  .rail a span, .rail .group, .rail .foot .who { display: none; }
  .rail a { justify-content: center; padding: 11px 0; }
  .rail .count { margin: 0; position: absolute; }
  .grid.k2, .grid.k3 { grid-template-columns: minmax(0, 1fr); }
  .pad { padding: 16px 14px 60px; }
}

@media (max-width: 640px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header) 1fr auto;
    grid-template-areas: "header" "main" "rail";
  }
  .brandbox { display: none; }
  .rail {
    flex-direction: row;
    padding: 6px;
    gap: 2px;
    border-top: 1px solid var(--navy-line);
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .rail a { flex: 1; flex-direction: column; gap: 3px; font-size: 10px; padding: 7px 0; }
  .rail a span { display: block; font-size: 10px; }
  .rail .group, .rail .foot { display: none; }
  .pane { max-height: none; }
}
