/* ---------------------------------------------------------------------------
   RIGCLEAR — the design system.

   Direct descendant of the RigClear.dc.html canvas: cool steel ground, dark
   slate sidebar, IBM Plex Sans for prose, IBM Plex Mono for numbers and
   micro-labels, Instrument Serif for page titles. Type and spacing run 1.2×
   the canvas (the canvas is a 1440px mock; this is an app people read all
   day) — scaled TOGETHER, per the KATHARINE lesson: a font bump on its own
   overflows every fixed-width column.

   The five status colours are the entire vocabulary:
     cleared  #147D64  green — qualified, compliant, ready to drive
     expiring #8A6A1B  amber — legal today, a clock is running out
     missing  #A8453A  red   — do not dispatch
     review   #2B5FAD  blue  — a human decision is staged
     neutral  #98A1AD  grey  — not applicable / nothing yet
   Nothing else in the product may claim these hues.

   Soft blue ground + dashed edge marks DEMO SCAFFOLDING only — machinery that
   is deleted before launch. The fabricated drivers are NOT marked: they stand
   in for real ones. See CLAUDE.md.
--------------------------------------------------------------------------- */

:root {
  --bg:        #F3F5F8;
  --paper:     #FFFFFF;
  --ink:       #151A21;
  --ink-2:     #37404C;
  --muted:     #5B6572;
  --muted-2:   #7C8694;
  --muted-3:   #98A1AD;
  --line:      rgba(21, 26, 33, .10);
  --line-soft: rgba(21, 26, 33, .06);
  --accent:    #2B5FAD;
  --accent-2:  #1D4480;

  --sidebar:      #121924;
  --sidebar-ink:  #E7EBF0;

  --cleared:     #147D64;  --cleared-bg:  rgba(20, 125, 100, .12);
  --expiring:    #8A6A1B;  --expiring-bg: rgba(138, 106, 27, .13);
  --missing:     #A8453A;  --missing-bg:  rgba(168, 69, 58, .12);
  --review:      #2B5FAD;  --review-bg:   rgba(43, 95, 173, .11);
  --neutral:     #98A1AD;  --neutral-bg:  rgba(152, 161, 173, .16);

  --row-red:   rgba(168, 69, 58, .045);
  --swatch:    #DDE3EA;

  --demo:      #EAF2FB;
  --demo-edge: #9DBEE4;
  --demo-ink:  #2B5FAD;

  --placeholder: #A9B4C0;

  --radius:    10px;
  --radius-lg: 13px;

  --sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --serif: 'Instrument Serif', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

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

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

.side {
  width: 272px; flex: none;
  background: var(--sidebar); color: var(--sidebar-ink);
  padding: 29px 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side__brand {
  padding: 0 29px 29px; display: flex; align-items: center; gap: 14.5px;
  color: inherit;
}
.side__brand:hover { color: #fff; }
.side__mark {
  width: 38px; height: 38px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font: 600 17px var(--mono); color: #fff;
}
.side__name { font: 600 19px var(--sans); white-space: nowrap; }

.side__nav { display: flex; flex-direction: column; gap: 2.5px; padding: 0 12px; }
.side__link {
  padding: 12px 17px; border-radius: 7px; color: rgba(231, 235, 240, .72);
  font: 400 18px var(--sans); display: flex; align-items: center; gap: 9.5px;
}
.side__link:hover { color: var(--sidebar-ink); background: rgba(255, 255, 255, .05); }
.side__link.is-on { background: rgba(255, 255, 255, .11); color: var(--sidebar-ink); font-weight: 500; }
.side__badge { font: 500 14.5px var(--mono); color: #E08A7A; }

.side__stat {
  margin: auto 12px 0; padding: 21.5px 17px 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.side__stat__label {
  font: 400 13px var(--mono); color: rgba(231, 235, 240, .45);
  letter-spacing: .06em; text-transform: uppercase; margin-bottom: 9.5px;
}
.side__stat__n { font: 500 26.5px var(--mono); }
.side__stat__n .dim { color: rgba(231, 235, 240, .4); }
.side__stat__sub { font: 400 15.5px var(--sans); color: rgba(231, 235, 240, .55); margin-top: 2.5px; }

.side__ws {
  margin: 19px 12px 0; padding: 14.5px 17px; border-radius: 8px;
  background: rgba(255, 255, 255, .06); display: block; color: inherit;
}
.side__ws:hover { background: rgba(255, 255, 255, .1); color: inherit; }
.side__ws__kind {
  font: 400 12.5px var(--mono); color: rgba(231, 235, 240, .45);
  letter-spacing: .05em; text-transform: uppercase;
}
.side__ws__name { font: 500 17px var(--sans); margin-top: 2.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side__ws__switch { font: 400 15px var(--sans); color: #7FA4D6; margin-top: 5px; }

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

.topbar {
  height: 77px; flex: none; border-bottom: 1px solid var(--line);
  background: var(--paper); display: flex; align-items: center; gap: 19px;
  padding: 0 36px; position: sticky; top: 0; z-index: 40;
}
.topbar__search { flex: 1; max-width: 480px; position: relative; }
.topbar__search .input { height: 46px; font-size: 17px; }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: 14.5px; }
.topbar__avatar {
  width: 41px; height: 41px; border-radius: 50%; background: #CBD4DE;
  display: flex; align-items: center; justify-content: center;
  font: 600 15px var(--sans); color: #4A5563; flex: none;
}

.content { flex: 1; padding: 36px; min-width: 0; max-width: 2000px; }

/* ------------------------------------------------------------ typography -- */

h1.pg, h2.pg { font: 400 37px/1.15 var(--serif); margin: 0; }
h2.pg--lg { font-size: 43px; }
.pg-sub { font: 400 17px var(--sans); color: var(--muted-2); }
.pg-lede { font: 400 18px/1.55 var(--sans); color: var(--muted); margin: 5px 0 24px; max-width: 76ch; text-wrap: pretty; }
.pg-head { display: flex; align-items: baseline; gap: 17px; margin-bottom: 5px; flex-wrap: wrap; }

.microhead {
  font: 600 14.5px var(--mono); letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted-2);
}
.microhead--red { color: var(--missing); }

.mono { font-family: var(--mono); font-size: .92em; }
.muted   { color: var(--muted); }
.muted-2 { color: var(--muted-3); }
.xs { font-size: 15.5px; }
.grow { flex: 1; min-width: 0; }

.t-cleared  { color: var(--cleared); }
.t-expiring { color: var(--expiring); }
.t-missing  { color: var(--missing); }
.t-review   { color: var(--review); }

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

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 23px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--alert { border-color: #D8A29A; }
.card--dark  { background: var(--sidebar); color: var(--sidebar-ink); border: none; padding: 29px; }

.cols { display: flex; gap: 29px; align-items: flex-start; }
.cols__side { width: 475px; flex: none; display: flex; flex-direction: column; gap: 20.5px; }
.cols__side--sm { width: 432px; }
.cols__main { flex: 1; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 20.5px; }

/* stat tiles */
.tiles { display: flex; gap: 20.5px; margin-bottom: 24px; }
.tile { flex: 1; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20.5px 23px; }
.tile__label { font: 400 13px var(--mono); color: var(--muted-2); letter-spacing: .05em; text-transform: uppercase; }
.tile__n { font: 500 30px var(--mono); margin-top: 7px; }
.tile__sub { font: 400 15.5px var(--sans); color: var(--muted-2); margin-top: 2.5px; }

/* ---------------------------------------------------------------- lists -- */
/* Flex-row tables, exactly the canvas's construction: a .lst of .lst__row,
   each a flex line of fixed-width cells + one .grow. Wide ones scroll inside
   .lst-wrap; the page never scrolls sideways. */

.lst-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow-x: auto; min-width: 0; }
.lst { min-width: 0; }
.lst__head {
  display: flex; align-items: center; padding: 13px 26.5px;
  border-bottom: 1px solid var(--line);
  font: 600 14.5px var(--mono); letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted-2); white-space: nowrap;
}
.lst__row {
  display: flex; align-items: center; padding: 17px 26.5px;
  border-bottom: 1px solid var(--line-soft); color: inherit;
}
.lst__row:last-child { border-bottom: none; }
a.lst__row:hover, .lst__row.is-click:hover { background: #F7F9FB; color: inherit; }
.lst__row.is-red { background: var(--row-red); }
.lst__row.is-red:hover { background: rgba(168, 69, 58, .08); }

.cell { flex: none; }
.c-note { font: 400 15.5px var(--sans); color: var(--muted-2); margin-top: 2.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-name { font: 500 18px var(--sans); }

.tbl__sort { color: inherit; display: inline-flex; align-items: center; gap: 5px; }
.tbl__sort:hover { color: var(--ink); }
.tbl__sort.is-on { color: var(--ink); }
.tbl__sort__arr { font-size: 11px; }

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

.pill {
  display: inline-block; font: 600 14.5px var(--mono); letter-spacing: .03em;
  padding: 5px 12px; border-radius: 5px; white-space: nowrap;
}
.pill--rig { font-size: 15px; padding: 6px 14.5px; }
.pill.is-cleared  { background: var(--cleared-bg);  color: var(--cleared); }
.pill.is-expiring { background: var(--expiring-bg); color: var(--expiring); }
.pill.is-missing  { background: var(--missing-bg);  color: var(--missing); }
.pill.is-review   { background: var(--review-bg);   color: var(--review); }
.pill.is-neutral  { background: var(--neutral-bg);  color: var(--muted); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.is-cleared  { background: var(--cleared); }
.dot.is-expiring { background: var(--expiring); }
.dot.is-missing  { background: var(--missing); }
.dot.is-review   { background: var(--review); }
.dot.is-neutral  { background: var(--muted-3); }

.dqmark { font: 500 17px var(--mono); width: 15px; flex: none; text-align: center; }

/* tag chip on an exception card */
.tag {
  flex: none; font: 600 13px var(--mono); letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 11px; border-radius: 5px; white-space: nowrap; position: relative; top: 1px;
}
.tag.is-missing  { background: var(--missing-bg);  color: var(--missing); }
.tag.is-expiring { background: var(--expiring-bg); color: var(--expiring); }
.tag.is-review   { background: var(--review-bg);   color: var(--review); }
.tag.is-cleared  { background: var(--cleared-bg);  color: var(--cleared); }
.tag.is-neutral  { background: var(--neutral-bg);  color: var(--muted); }

/* ---------------------------------------------------------------- meters -- */

.pace { display: block; position: relative; height: 7px; border-radius: 4px; background: var(--swatch); overflow: visible; }
.pace__fill { display: block; height: 100%; border-radius: 4px; }
.pace__tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--muted); }
.pace--dim .pace__fill { opacity: .35; }

.meter { display: inline-flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--swatch); width: 180px; }
.meter__seg.is-cleared  { background: var(--cleared); }
.meter__seg.is-expiring { background: var(--expiring); }
.meter__seg.is-missing  { background: var(--missing); }

.days { display: inline-flex; align-items: baseline; gap: 5px; }
.days__n { font: 500 20.5px var(--mono); }
.days__l { font: 400 14.5px var(--sans); color: var(--muted-3); }

/* ---------------------------------------------------------------- clocks -- */

.clocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20.5px; }
.clock { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 21.5px 23px; }
.clock__head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.clock__label { font: 600 14.5px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--muted-2); }
.clock__value { font: 500 19px var(--sans); overflow-wrap: break-word; }
.clock__note { font: 400 16px/1.5 var(--sans); color: var(--muted-2); margin-top: 7px; text-wrap: pretty; }
.clock--wide { grid-column: 1 / -1; }

/* the machine feed */
.feed { display: flex; flex-direction: column; gap: 18px; }
.feed__line { display: flex; gap: 15.5px; align-items: baseline; }
.feed__line .dot { width: 8px; height: 8px; position: relative; top: -1px; }
.feed__what { font: 500 17.5px var(--sans); }
.feed__detail { font: 400 15.5px var(--sans); color: var(--muted-2); margin-top: 1px; }
.feed__when { margin-left: auto; font: 400 14.5px var(--mono); color: var(--muted-3); white-space: nowrap; }

/* exception cards */
.exc { display: flex; gap: 19px; padding: 20.5px 26.5px; border-bottom: 1px solid var(--line-soft); align-items: flex-start; color: inherit; }
.exc:last-child { border-bottom: none; }
a.exc:hover { background: #F7F9FB; color: inherit; }
.exc__title { font: 500 18.5px var(--sans); }
.exc__why { font: 400 17px/1.55 var(--sans); color: var(--muted); margin-top: 5px; text-wrap: pretty; }
.exc__action { font: 500 17px var(--sans); color: var(--accent); white-space: nowrap; }
.exc__age { font: 400 15px var(--mono); color: var(--muted-3); margin-top: 5px; white-space: nowrap; text-align: right; }

/* RTD / checklist lines */
.ck { display: flex; align-items: baseline; gap: 12px; font: 400 17px var(--sans); }
.ck + .ck { margin-top: 9.5px; }
.ck__mark { font: 500 15.5px var(--mono); width: 14px; flex: none; }
.ck__when { margin-left: auto; font: 400 14.5px var(--mono); color: var(--muted-3); white-space: nowrap; }

/* DQ grid on the driver page */
.dq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px 33.5px; }
@media (max-width: 900px) { .dq-grid { grid-template-columns: 1fr; } }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8.5px;
  height: 46px; padding: 0 19px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(21, 26, 33, .14); background: var(--paper);
  font: 500 17px var(--sans); color: var(--ink); white-space: nowrap;
}
.btn:hover { border-color: rgba(21, 26, 33, .3); color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn--danger { background: var(--missing); border-color: var(--missing); color: #fff; }
.btn--danger:hover { opacity: .92; color: #fff; }
.btn--sm { height: 38px; padding: 0 14.5px; font-size: 15.5px; }
.btn--block { width: 100%; }

.input, select.input, textarea.input {
  width: 100%; height: 48px; padding: 0 15.5px; border-radius: 8px;
  border: 1px solid rgba(21, 26, 33, .14); background: var(--paper);
  font: 400 17.5px var(--sans); color: var(--ink);
}
textarea.input { height: auto; padding: 12px 15.5px; resize: vertical; }
.input:focus { outline: 2px solid rgba(43, 95, 173, .35); border-color: var(--accent); }

/* A placeholder is an EXAMPLE, never a value: pale, light and italic, three
   signals so it cannot be mistaken for something somebody typed. Every field
   carries its own label, so the low contrast costs nothing. */
.input::placeholder { color: var(--placeholder); font-style: italic; font-weight: 400; }
select.input:has(option[value=""]:checked) { color: var(--placeholder); font-style: italic; }

label.lbl { display: block; font: 500 15.5px var(--sans); color: var(--ink-2); margin: 0 0 6px; }
.field { margin-bottom: 17px; }

/* flash + notes */
.flash { border-radius: var(--radius); padding: 14.5px 19px; margin-bottom: 19px; font: 400 17px var(--sans); }
.flash--ok { background: var(--cleared-bg); color: var(--cleared); }
.flash--err { background: var(--missing-bg); color: var(--missing); }
.note--plain { background: #F2F4F7; border-radius: 8px; padding: 14.5px 17px; font: 400 16px/1.5 var(--sans); color: var(--muted); }

/* ------------------------------------------------------------------ demo -- */
/* Soft blue + dashed edge + the tag: three signals. DEMO SCAFFOLDING ONLY —
   gated on DEMO_MODE in PHP; setting DEMO_MODE=0 removes the markup itself. */

.demo-bar {
  background: var(--demo); border-bottom: 1px dashed var(--demo-edge);
  color: var(--demo-ink); font: 400 15.5px var(--sans);
  padding: 8.5px 36px; display: flex; align-items: center; gap: 12px;
}
.demo-tag {
  font: 600 12px var(--mono); letter-spacing: .05em; text-transform: uppercase;
  background: var(--demo-ink); color: #fff; border-radius: 4px; padding: 2.5px 7px; flex: none;
}
.demo-block {
  background: var(--demo); border: 1.5px dashed var(--demo-edge);
  border-radius: var(--radius); padding: 18px 20.5px; margin: 17px 0;
}
.demo-block__flag { display: flex; align-items: center; gap: 9.5px; margin-bottom: 9.5px; color: var(--demo-ink); font: 500 15.5px var(--sans); }
.btn--demo { border: 1.5px dashed var(--demo-edge); background: #fff; color: var(--demo-ink); }

/* ---------------------------------------------------------------- signin -- */

.signin { max-width: 744px; margin: 72px auto; padding: 0 24px; }
.persona {
  display: flex; align-items: center; gap: 18px; padding: 18px 20.5px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  color: inherit; margin-bottom: 12px;
}
.persona:hover { border-color: var(--accent); color: inherit; }
.persona__avatar {
  width: 50px; height: 50px; border-radius: 50%; background: #CBD4DE; flex: none;
  display: flex; align-items: center; justify-content: center; font: 600 17px var(--sans); color: #4A5563;
}

/* ------------------------------------------------------------- utilities -- */

.hr { border: none; border-top: 1px solid var(--line); margin: 21.5px 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.spread { display: flex; align-items: baseline; gap: 14.5px; }
.spread > :last-child { margin-left: auto; }
.rule-line { flex: 1; height: 1px; background: var(--line); align-self: center; }

@media (max-width: 1100px) {
  .cols { flex-direction: column; }
  .cols__side, .cols__side--sm { width: auto; }
  .tiles { flex-wrap: wrap; }
  .tile { min-width: 40%; }
}
@media (max-width: 860px) {
  .side { display: none; }           /* the demo is a desktop pitch; the data survives */
  .content { padding: 21.5px; }
}
