/* =====================================================================
   MycoLab — design system
   White ground, bordered cards, bold system-sans headings — the same
   typographic family as mycolink.ch, which loads no webfont.
   Hierarchy comes from weight and surface, colour is kept for state.
   No shadows, near-square corners, Mycolink brand palette.
   This file overrides Bootstrap 5: it is loaded AFTER bootstrap.
   ===================================================================== */

/* ── 1. Tokens ─────────────────────────────────────────────────────── */
/* Palette taken from the Mycolink brand (mycolink.ch):
   light #F7F3F3 · warm grey #CEC8C3 · dark #191009 · primary #D2996C     */
:root {
  /* Surfaces — mycolink.ch works on WHITE, with #F7F3F3 kept for
     secondary surfaces only (card footers, side rail, bands). Keeping
     white as the ground is what lets bordered cards read as objects. */
  --paper:          #ffffff;  /* page ground   */
  --paper-raised:   #ffffff;  /* cards, sheets */
  --paper-sunken:   #f7f3f3;  /* brand light   */
  --paper-deep:     #ece7e4;

  /* Ink — three clearly separated steps, not three shades of the same
     grey. Primary is near-black so headings carry real weight. */
  --ink:            #191009;  /* brand dark    */
  --ink-soft:       #5c534c;
  --ink-faint:      #8a807a;

  --rule:           #e4dfdb;
  --rule-soft:      #efebe8;
  --rule-strong:    #cec8c3;  /* brand secondary */

  /* Accent — brand primary. --accent and --accent-on are injected by the
     server (see getBase); every other shade derives from --accent, so a
     client changing the accent colour gets a coherent set for free.
     --accent-on is the text colour laid ON the accent: the server picks
     black or white from the accent's luminance, because a light tan like
     #d2996c cannot carry white text (2.2:1). */
  --accent:         #d2996c;
  --accent-on:      #191009;
  --accent-hover:   color-mix(in srgb, var(--accent) 84%, #000);
  --accent-ink:     color-mix(in srgb, var(--accent) 62%, #000);
  --accent-tint:    color-mix(in srgb, var(--accent) 16%, #fff);
  --accent-edge:    color-mix(in srgb, var(--accent) 42%, #fff);

  /* Earthy semantics */
  --moss:           #5c7a4a;
  --moss-tint:      #e8eede;
  --ochre:          #9a7124;
  --ochre-tint:     #f3ead4;
  --rust:           #a2452f;
  --rust-tint:      #f4e3dd;
  --slate:          #4a666c;
  --slate-tint:     #e2eaea;

  /* Colour of a live sensor value. Kept as its own token because it is
     not the brand primary (#d2996c) nor a state colour — change it here
     and every reading follows. */
  --value:          #4d6b3c;

  /* Shapes */
  --r:              3px;
  --rail:           248px;

  /* Fonts — the exact stack mycolink.ch runs on. Their Odoo theme loads
     no webfont: body and headings both use this system stack (Ubuntu is
     in it, which is what gives the rounded look on Linux). Matching the
     order matters — it is what makes the app read as the same family as
     the marketing site. Nothing is downloaded, so it works offline. */
  --font-ui:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Ubuntu, "Noto Sans", Arial, sans-serif;
  --font-display: var(--font-ui);
  --font-mono:    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "DejaVu Sans Mono", monospace;

  /* Bootstrap bridges */
  --bs-primary:          var(--accent);
  --bs-link-color:       var(--accent-ink);
  --bs-link-hover-color: var(--ink);
  --bs-body-color:       var(--ink);
  --bs-body-bg:          var(--paper);
  --bs-border-color:     var(--rule);
  --bs-border-radius:    var(--r);
  --bs-border-radius-sm: 2px;
  --bs-border-radius-lg: var(--r);
  --bs-font-sans-serif:  var(--font-ui);
}

/* ── 2. Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-ui);
  font-size: .9rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
  max-width: 100%;
}

/* Headings carry weight: the brand builds hierarchy on bold near-black
   type against small grey text, not on colour. */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--ink);
  line-height: 1.22;
}
h1, .h1 { font-size: clamp(1.8rem, 3.2vw, 2.35rem); font-weight: 700; }
h2, .h2 { font-size: 1.45rem; font-weight: 700; }
h3, .h3 { font-size: 1.3rem; }
h4, .h4 { font-size: 1.12rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: .92rem; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: .18em; }

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

code, kbd, samp, pre, .font-monospace {
  font-family: var(--font-mono);
  font-size: .85em;
}
code {
  color: var(--accent-ink);
  background: var(--paper-sunken);
  border: 1px solid var(--rule-soft);
  border-radius: 2px;
  padding: .05em .34em;
}

::selection { background: var(--accent-tint); color: var(--ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── 3. Editorial primitives ───────────────────────────────────────── */

/* Spaced small-caps micro-heading — replaces pill eyebrows.
   Sized and darkened so it works as a real signpost, not decoration. */
.overline {
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
}
.overline--accent { color: var(--accent-ink); }

/* Page header: rule underneath */
.page-head {
  border-bottom: 1px solid var(--rule-strong);
  padding-bottom: 1.1rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.page-head__title { margin: .25rem 0 0; }
.page-head__note {
  margin: .4rem 0 0;
  color: var(--ink-soft);
  font-size: .9rem;
}
.page-head__actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* Section heading: title, rule, then the action at the far right.
   Order matters — a button sitting between the title and the rule
   reads as a label, not as something you can click. */
.section-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.1rem;
}
.section-head::after {
  content: "";
  order: 2;
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.section-head .btn { order: 3; flex-shrink: 0; }
.section-head h2,
.section-head h3 { margin: 0; font-size: 1.25rem; }
.section-head .count {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--ink-soft);
}

/* Sheet: the .card replacement — no shadow, hairline border */
.sheet {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.sheet--flat { background: transparent; border: 0; }
.sheet__head {
  padding: .7rem 1.1rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: .6rem;
}
.sheet__body { padding: 1.1rem; }

/* Vertical hairline between meta cells */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
}
.meta-row > * {
  padding: 0 1.4rem;
  border-left: 1px solid var(--rule);
}
.meta-row > *:first-child { padding-left: 0; border-left: 0; }
.meta-cell__label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
}
.meta-cell__value {
  font-family: var(--font-mono);
  font-size: .88rem;
  color: var(--ink);
  display: block;
  margin-top: .1rem;
}

/* ── 4. App shell: notebook margin on the left ─────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.app-rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--paper-sunken);
  border-right: 1px solid var(--rule-strong);
  display: flex;
  flex-direction: column;
  padding: 1.6rem 0 1rem;
  z-index: 1040;
  overflow-y: auto;
}

.app-rail__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 0 1.5rem 1.3rem;
  margin-bottom: 1.1rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}
.app-rail__brand:hover { color: var(--ink); text-decoration: none; }
.app-rail__brand img { height: 30px; width: auto; flex-shrink: 0; }
.app-rail__wordmark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.15;
  min-width: 0;
  overflow-wrap: anywhere;
}

.app-rail__section {
  padding: 0 1.5rem;
  margin-bottom: .55rem;
}

.app-rail__nav { padding: 0 .85rem; margin-bottom: 1.6rem; }
.app-rail__link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .42rem .65rem;
  border-radius: 2px;
  color: var(--ink-soft);
  font-size: .88rem;
  border-left: 2px solid transparent;
  transition: color .12s, background-color .12s, border-color .12s;
}
.app-rail__link:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, .035);
  text-decoration: none;
}
.app-rail__link.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
  background: rgba(0, 0, 0, .04);
  font-weight: 600;
}
.app-rail__link i { font-size: .95rem; color: var(--ink-faint); }
.app-rail__link.is-active i { color: var(--accent); }

.app-rail__foot {
  margin-top: auto;
  padding: 1rem 1.5rem 0;
  border-top: 1px solid var(--rule);
}

/* Partner marks at the foot of the rail — visible on every app page,
   unlike the footer which sits below the fold on long pages. */
.rail-marks {
  display: flex;
  align-items: center;
  gap: .9rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px solid var(--rule);
}
.rail-marks img {
  height: 22px;
  width: auto;
  max-width: 100%;
  opacity: .8;
  transition: opacity .15s;
}
.rail-marks img:hover { opacity: 1; }

/* Project picker — in the margin, like a jar label */
.rail-picker { width: 100%; text-align: left; }
.rail-picker__btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: .42rem .6rem;
  font-size: .85rem;
  color: var(--ink);
  text-align: left;
}
.rail-picker__btn:hover { border-color: var(--rule-strong); }
.rail-picker__btn .bi-chevron-expand { margin-left: auto; color: var(--ink-faint); font-size: .75rem; }
.rail-picker__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Content */
.app-main {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: var(--rail);
  display: flex;
  flex-direction: column;
}
.app-column {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1240px;
  padding: 2.75rem 3rem 4rem;
}

/* Mobile bar */
.app-topbar {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  background: var(--paper-sunken);
  border-bottom: 1px solid var(--rule-strong);
  position: sticky;
  top: 0;
  z-index: 1035;
}
.app-topbar__burger {
  background: none;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink);
  padding: .2rem .5rem;
  font-size: 1.05rem;
  line-height: 1;
}
.app-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(36, 31, 26, .38);
  z-index: 1039;
}

@media (max-width: 767.98px) {
  /* Once stacked, cells must not carry an orphan vertical rule */
  .meta-row > * {
    flex: 1 0 100%;
    padding: .35rem 0;
    border-left: 0;
  }
}

/* Bottom tab bar — mobile only. Thumb-reachable navigation to the main
   destinations; the rail becomes a drawer behind the "Menu" tab. */
.app-tabs {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  z-index: 1035;
  background: var(--paper-raised);
  border-top: 1px solid var(--rule-strong);
  padding-bottom: env(safe-area-inset-bottom, 0);  /* iPhone home indicator */
}
.app-tabs__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  padding: .5rem .25rem .45rem;
  background: none;
  border: 0;
  color: var(--ink-faint);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  min-width: 0;
}
.app-tabs__item i { font-size: 1.2rem; line-height: 1; }
.app-tabs__item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.app-tabs__item:hover { color: var(--ink-soft); text-decoration: none; }
.app-tabs__item.is-active { color: var(--accent-ink); }
.app-tabs__item.is-active i { color: var(--accent); }

@media (max-width: 991.98px) {
  .app-rail {
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
  }
  .app-rail.is-open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .app-topbar { display: flex; }
  .app-scrim.is-open { display: block; }
  /* Room for the tab bar so it never sits on top of the last row */
  .app-column { padding: 1.75rem 1.25rem 5.5rem; }

  .app-tabs { display: flex; }

  /* The consent banner is fixed at the bottom too — lift it above the bar
     rather than letting it hide the navigation. !important is needed here:
     the banner carries its position inline so it still works on the 404/500
     pages, which do not load this stylesheet. */
  #cookie-banner { bottom: calc(4.2rem + env(safe-area-inset-bottom, 0px)) !important; }

  .app-main .colophon { padding-bottom: 4.5rem; }
}

/* ── 5. Readings (dashboard) ───────────────────────────────────────── */
/* Sensor cards — bordered white objects on the white ground, each with
   a grey footer, echoing the product cards on mycolink.ch. With a dozen
   sensors this is far quicker to scan than a flat list of hairlines. */
.readings {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.reading {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.reading__body { padding: .95rem 1rem .85rem; flex: 1; }
.reading__label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reading__figure {
  display: flex;
  align-items: baseline;
  gap: .35rem;
  min-width: 0;
}
.reading__value {
  font-family: var(--font-display);
  font-size: 2.35rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -.02em;
  transition: color .2s;
  color: var(--value);
}
/* No value: a discreet dash, not a rule across the block */
.reading__value.text-muted {
  color: var(--rule-strong) !important;
  font-size: 1.5rem;
  letter-spacing: 0;
}
.reading__unit {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink-soft);
}
/* ── Board plan ─────────────────────────────────────────────────────
   Readings laid over a picture of the board, each one where its sensor
   physically sits. Coordinates are percentages (see Sensor.pos_x/pos_y),
   so everything scales with the image. Sensors with no coordinates —
   remote probes, or ones not placed yet — go to the side column. */
.sensor-map {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.sensor-map__plan {
  position: relative;
  flex: 1 1 640px;
  /* Below this the plan scrolls rather than letting pinned cards collide */
  min-width: 640px;
  border: 1px solid var(--rule);
  border-radius: var(--r);
  background: var(--paper-sunken);
  overflow: hidden;
  /* Cards are sized in cqw, so they keep their proportion to the plan
     whatever width it is displayed at — a fixed px card looks tiny on a
     large screenshot and huge on a small schematic. */
  container-type: inline-size;
}
.sensor-map__plan > img { display: block; width: 100%; height: auto; }

.sensor-map__aside {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.sensor-map__aside .reading { width: 100%; }

/* Compact card pinned on the plan: label + value only, centred on its
   coordinate so the card marks the spot itself.
   --card-scale is the per-sensor adjustment (Sensor.card_scale), set
   inline on the element; everything below is derived from it, so one
   number resizes the box and its text together. */
.reading--pinned {
  --s: var(--card-scale, 1);
  position: absolute;
  transform: translate(-50%, -50%);
  width: 132px;                       /* fallback, overridden just below */
  padding: .4rem .55rem;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(25, 16, 9, .18);
}
.reading--pinned .reading__label { font-size: .62rem; margin-bottom: .1rem; letter-spacing: .07em; }
.reading--pinned .reading__value { font-size: 1.3rem; }
.reading--pinned .reading__value.text-muted { font-size: 1.05rem; }
.reading--pinned .reading__unit  { font-size: .78rem; }

@supports (container-type: inline-size) {
  /* --s scales the whole card, text included (corner handle).
     --w and --h stretch the box only (side and bottom handles), so making
     a card wider never blows up its type. */
  .reading--pinned {
    width: clamp(70px, calc(13cqw * var(--s) * var(--w, 1)), 560px);
    padding: clamp(2px, calc(.42cqw * var(--s)), 14px) clamp(3px, calc(.58cqw * var(--s)), 18px);
  }
  /* Height only becomes explicit once the bottom handle has been used;
     otherwise it follows the content. */
  .reading--pinned.has-h {
    height: clamp(24px, calc(7cqw * var(--s) * var(--h, 1)), 420px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
  }
  .reading--pinned .reading__label { font-size: clamp(7px, calc(.95cqw * var(--s)), 20px); }
  .reading--pinned .reading__value { font-size: clamp(11px, calc(2.05cqw * var(--s)), 46px); }
  .reading--pinned .reading__value.text-muted { font-size: clamp(9px, calc(1.6cqw * var(--s)), 34px); }
  .reading--pinned .reading__unit  { font-size: clamp(7px, calc(1.2cqw * var(--s)), 26px); }
}

/* Freshness stamp: hidden until hover so it costs no room on the plan,
   but still in the DOM for updateMetrics() to write into. */
.reading--pinned .reading__meta--tip {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  white-space: nowrap;
  background: var(--ink);
  color: var(--paper-raised);
  border: 0;
  border-radius: 2px;
  padding: .15rem .4rem;
  font-size: .68rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.reading--pinned:hover { z-index: 4; }
.reading--pinned:hover .reading__meta--tip { opacity: 1; }

@media (max-width: 991.98px) {
  .sensor-map__plan { min-width: 0; flex-basis: 100%; }
  .sensor-map__aside { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; }
  .sensor-map__aside .reading { width: auto; flex: 1 1 180px; }
}

/* Card footer strip carrying the freshness stamp */
.reading__meta {
  padding: .4rem 1rem;
  background: var(--paper-sunken);
  border-top: 1px solid var(--rule);
  font-size: .72rem;
  color: var(--ink-soft);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── System state banner ────────────────────────────────────────────
   Answers "is the rig working?" in one glance. Colour is the signal
   here: the whole plate changes with the state, so it is readable
   from across the room. setDeviceStatus() in dashboard.html sets the
   modifier class. */
.system-state {
  display: flex;
  align-items: flex-start;
  gap: .85rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-left: 5px solid var(--ink-faint);
  border-radius: var(--r);
  background: var(--paper-sunken);
}
.system-state--ok    { border-left-color: var(--moss);  background: var(--moss-tint); }
.system-state--run   { border-left-color: var(--ochre); background: var(--ochre-tint); }
.system-state--busy  { border-left-color: var(--slate); background: var(--slate-tint); }
.system-state--down  { border-left-color: var(--rust);  background: var(--rust-tint); }

.system-state__dot { font-size: .6rem !important; margin-top: .45rem; flex-shrink: 0; }
.system-state__body { flex: 1; min-width: 0; }
.system-state__headline {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}
.system-state__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem 1.5rem;
  margin-top: .45rem;
  font-size: .8rem;
  color: var(--ink-soft);
}
.system-state__meta b {
  font-weight: 700;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: .35rem;
}
.system-state__meta .val { font-family: var(--font-mono); color: var(--ink); }

/* Event journal — time column + bullet */
.journal { max-height: 380px; overflow-y: auto; }
.journal .list-group-item {
  background: transparent;
  border: 0;
  border-bottom: 1px dotted var(--rule) !important;
  border-radius: 0;
  padding: .5rem 1.1rem .5rem 1.9rem;
  position: relative;
  font-size: .82rem;
  color: var(--ink);
}
.journal .list-group-item::before {
  content: "";
  position: absolute;
  left: .95rem;
  top: 1.05rem;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-faint);
}
.journal .list-group-item-success::before { background: var(--moss); }
.journal .list-group-item-warning::before { background: var(--ochre); }
.journal .list-group-item-danger::before  { background: var(--rust); }
.journal .list-group-item:last-child { border-bottom: 0 !important; }
.journal .list-group-item strong {
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .02em;
}

/* ── 6. Ledgers (tables) ───────────────────────────────────────────── */
.ledger { width: 100%; margin: 0; border-collapse: collapse; }
.ledger thead th {
  font-family: var(--font-ui);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0 1rem .55rem 0;
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
  text-align: left;
  background: transparent;
}
.ledger tbody td {
  padding: .8rem 1rem .8rem 0;
  border-bottom: 1px dotted var(--rule);
  vertical-align: middle;
  color: var(--ink);
  background: transparent;
}
.ledger tbody tr:hover td { background: rgba(0, 0, 0, .022); }
.ledger tbody tr:last-child td { border-bottom: 1px solid var(--rule-strong); }
.ledger th:last-child, .ledger td:last-child { padding-right: 0; text-align: right; }
.ledger .ref {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--ink-faint);
}
.ledger .primary-cell {
  font-weight: 600;
  font-size: .95rem;
}

/* Actions as text links separated by a middle dot */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .78rem;
  white-space: nowrap;
}
.row-actions a, .row-actions button {
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 0;
  font-size: .78rem;
}
.row-actions a:hover { color: var(--ink); }
.row-actions a.is-destructive:hover { color: var(--rust); }
.row-actions .sep { color: var(--rule-strong); }

/* List entry — the index card that replaces the card grid */
.entries { border-top: 1px solid var(--rule-strong); }
.entry {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.25rem 1.25rem 1.1rem;
  border-bottom: 1px solid var(--rule);
  border-left: 3px solid transparent;
}
.entry:hover { background: rgba(0, 0, 0, .018); }
.entry.is-current {
  border-left-color: var(--accent);
  background: var(--paper-raised);
}
.entry__main { flex: 1 1 260px; min-width: 0; }
.entry__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 .2rem;
}
.entry__text { font-size: .85rem; color: var(--ink-soft); margin: .3rem 0 0; }
.entry__meta {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--ink-faint);
  margin-top: .45rem;
}
.entry__side {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Form sheet */
.form-page { max-width: 760px; margin-inline: auto; }
.form-sheet {
  max-width: 760px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--accent);
  border-radius: var(--r);
  padding: 1.75rem;
}
.form-sheet .form-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

/* Tag — replaces solid pill badges */
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--font-ui);
  font-size: .66rem !important;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .18rem .45rem;
  border-radius: 2px;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink-soft);
  line-height: 1.5;
}
.badge.rounded-pill { border-radius: 2px; }
.badge.bg-primary,
.tag--accent   { background: var(--accent-tint) !important; border-color: var(--accent-edge); color: var(--accent-ink) !important; }
.badge.bg-success,
.tag--ok       { background: var(--moss-tint) !important;  border-color: #c4d1b4; color: #3f5431 !important; }
.badge.bg-warning,
.tag--warn     { background: var(--ochre-tint) !important; border-color: #ddc78f; color: #7a5817 !important; }
.badge.bg-danger,
.tag--alert    { background: var(--rust-tint) !important;  border-color: #dcb3a7; color: #8a3823 !important; }
.badge.bg-info,
.tag--info     { background: var(--slate-tint) !important; border-color: #b3c6c8; color: #3a5257 !important; }
.badge.bg-secondary,
.badge.bg-dark,
.badge.bg-light,
.tag--mute     { background: var(--paper-sunken) !important; border-color: var(--rule-strong); color: var(--ink-soft) !important; }
.badge.text-dark { color: var(--ink-soft) !important; }
.badge.font-monospace { font-family: var(--font-mono); letter-spacing: .02em; text-transform: none; }

/* Status dot */
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  display: inline-block;
  flex-shrink: 0;
}
.dot--ok    { background: var(--moss); }
.dot--warn  { background: var(--ochre); }
.dot--alert { background: var(--rust); }

/* ── 7. Bootstrap overrides ────────────────────────────────────────── */

/* Leftover cards → sheets */
.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  box-shadow: none !important;
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--rule);
  padding: .7rem 1.1rem;
}
.card-footer { background: transparent; border-top: 1px solid var(--rule); }

/* Buttons — flat, near-square, no shadow */
.btn {
  --bs-btn-border-radius: var(--r);
  font-family: var(--font-ui);
  font-size: .82rem;
  font-weight: 500;
  letter-spacing: .01em;
  padding: .45rem .95rem;
  border-width: 1px;
  border-radius: var(--r);
  box-shadow: none !important;
  transition: background-color .12s, border-color .12s, color .12s;
}
.btn-sm { font-size: .8rem; padding: .35rem .8rem; font-weight: 600; }
.btn-lg { font-size: .92rem; padding: .55rem 1.2rem; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-on);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-on);
}
.btn-outline-primary {
  color: var(--accent-ink); border-color: var(--accent); background: transparent;
}
.btn-outline-primary:hover, .btn-outline-primary:active {
  background: var(--accent-tint); border-color: var(--accent); color: var(--accent-ink);
}

.btn-secondary,
.btn-dark {
  background: var(--ink); border-color: var(--ink); color: var(--paper-raised);
}
.btn-secondary:hover, .btn-dark:hover {
  background: #3a332b; border-color: #3a332b; color: var(--paper-raised);
}
.btn-outline-secondary,
.btn-outline-dark,
.btn-light {
  color: var(--ink-soft); border-color: var(--rule-strong); background: var(--paper-raised);
}
.btn-outline-secondary:hover, .btn-outline-dark:hover, .btn-light:hover {
  background: var(--paper-sunken); border-color: var(--ink-faint); color: var(--ink);
}

.btn-success { background: var(--moss); border-color: var(--moss); color: var(--paper-raised); }
.btn-success:hover { background: #47603a; border-color: #47603a; color: var(--paper-raised); }
.btn-outline-success { color: #3f5431; border-color: #c4d1b4; background: transparent; }
.btn-outline-success:hover { background: var(--moss-tint); border-color: var(--moss); color: #3f5431; }

.btn-warning { background: var(--ochre); border-color: var(--ochre); color: var(--paper-raised); }
.btn-warning:hover { background: #7f5c1c; border-color: #7f5c1c; color: var(--paper-raised); }
.btn-outline-warning { color: #7a5817; border-color: #ddc78f; background: transparent; }
.btn-outline-warning:hover { background: var(--ochre-tint); border-color: var(--ochre); color: #7a5817; }

.btn-danger { background: var(--rust); border-color: var(--rust); color: var(--paper-raised); }
.btn-danger:hover { background: #843725; border-color: #843725; color: var(--paper-raised); }
.btn-outline-danger { color: #8a3823; border-color: #dcb3a7; background: transparent; }
.btn-outline-danger:hover { background: var(--rust-tint); border-color: var(--rust); color: #8a3823; }

.btn-outline-info { color: #3a5257; border-color: #b3c6c8; background: transparent; }
.btn-outline-info:hover { background: var(--slate-tint); border-color: var(--slate); color: #3a5257; }
.btn-info { background: var(--slate); border-color: var(--slate); color: var(--paper-raised); }

.btn-link { color: var(--accent-ink); text-decoration: none; }
.btn-link:hover { color: var(--ink); text-decoration: underline; }

.btn:disabled, .btn.disabled { opacity: .45; }

/* Fields — pencil-underlined rather than ringed in blue */
.form-control, .form-select {
  background-color: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: .87rem;
  padding: .42rem .65rem;
  box-shadow: none !important;
}
/* Checkboxes keep Bootstrap's box model — the padding above would
   squash them against their label. */
.form-check-input {
  background-color: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  width: 1em;
  height: 1em;
  margin-top: .25em;
  box-shadow: none !important;
}
.form-check { padding-left: 1.6em; }
.form-check .form-check-input { margin-left: -1.6em; }
.form-check-label { margin-left: .1em; }
.form-control:focus, .form-select:focus {
  background-color: var(--paper-raised);
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent) !important;
  color: var(--ink);
}
.form-control::placeholder { color: var(--ink-faint); }
.form-check-input:checked { background-color: var(--accent-ink); border-color: var(--accent-ink); }
.form-label, label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .3rem;
}
.form-text, .form-check-label { font-size: .78rem; color: var(--ink-faint); text-transform: none; letter-spacing: 0; font-weight: 400; }
.form-check-label { font-size: .87rem; color: var(--ink); }
.input-group-text {
  background: var(--paper-sunken);
  border-color: var(--rule-strong);
  color: var(--ink-soft);
  border-radius: 2px;
  font-size: .82rem;
}
textarea.form-control { line-height: 1.6; }

/* Leftover Bootstrap tables aligned with the ledger */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--ink);
  --bs-table-border-color: var(--rule);
  --bs-table-hover-bg: rgba(0, 0, 0, .022);
  margin-bottom: 0;
}
.table > :not(caption) > * > * { background: transparent; }
.table thead th {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--rule-strong);
}
.table-light, .table > thead.table-light th { background: transparent !important; }

/* Alerts — accent rule on the left, very pale ground */
.alert {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--ink-faint);
  border-radius: var(--r);
  background: var(--paper-raised);
  color: var(--ink);
  padding: .85rem 1.1rem;
  font-size: .87rem;
}
.alert h5, .alert h6 { font-size: 1.02rem; margin-bottom: .4rem; }
.alert-success { background: var(--moss-tint);  border-left-color: var(--moss); }
.alert-warning { background: var(--ochre-tint); border-left-color: var(--ochre); }
.alert-danger  { background: var(--rust-tint);  border-left-color: var(--rust); }
.alert-info    { background: var(--slate-tint); border-left-color: var(--slate); }
.alert-link { color: var(--accent-ink); font-weight: 600; }

/* Dropdowns */
.dropdown-menu {
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  box-shadow: 0 6px 20px rgba(36, 31, 26, .1);
  padding: .3rem;
  font-size: .86rem;
}
.dropdown-item { border-radius: 2px; color: var(--ink); padding: .35rem .6rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--paper-sunken); color: var(--ink); }
.dropdown-item.active, .dropdown-item:active { background: var(--accent-tint); color: var(--accent-ink); }
.dropdown-divider { border-color: var(--rule); }
.dropdown-item-text { font-size: .78rem; }

/* Modals */
.modal-content {
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  box-shadow: 0 18px 50px rgba(36, 31, 26, .22);
}
.modal-header, .modal-footer { border-color: var(--rule); padding: .9rem 1.25rem; }
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-body { padding: 1.25rem; }
.modal-backdrop.show { opacity: .4; background: #241f1a; }

/* Toasts */
.toast {
  background: var(--paper-raised);
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--ink-faint);
  border-radius: var(--r);
  box-shadow: 0 10px 28px rgba(36, 31, 26, .16);
  color: var(--ink);
  font-size: .84rem;
}
.toast.text-bg-success { background: var(--moss-tint)  !important; color: var(--ink) !important; border-left-color: var(--moss); }
.toast.text-bg-warning { background: var(--ochre-tint) !important; color: var(--ink) !important; border-left-color: var(--ochre); }
.toast.text-bg-danger  { background: var(--rust-tint)  !important; color: var(--ink) !important; border-left-color: var(--rust); }
.toast.text-bg-info    { background: var(--slate-tint) !important; color: var(--ink) !important; border-left-color: var(--slate); }
.toast .btn-close-white { filter: none; }

/* Tabs — underlined rather than hanging folders */
.nav-tabs {
  border-bottom: 1px solid var(--rule);
  gap: 1.25rem;
}
.nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: .35rem 0 .5rem;
  font-family: var(--font-ui);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: transparent;
}
.nav-tabs .nav-link:hover { color: var(--ink-soft); border-bottom-color: var(--rule-strong); }
.nav-tabs .nav-link.active {
  color: var(--ink);
  background: transparent;
  border-bottom-color: var(--accent);
}

pre {
  font-family: var(--font-mono);
  color: var(--ink);
}

/* Lists */
.list-group-item {
  background: transparent;
  border-color: var(--rule);
  color: var(--ink);
}

/* Misc realigned utilities */
.text-muted    { color: var(--ink-faint) !important; }
.text-primary  { color: var(--accent-ink) !important; }
.text-success  { color: var(--moss) !important; }
.text-warning  { color: var(--ochre) !important; }
.text-danger   { color: var(--rust) !important; }
.text-info     { color: var(--slate) !important; }
.text-secondary{ color: var(--ink-soft) !important; }
.bg-primary    { background-color: var(--accent) !important; color: var(--accent-on) !important; }
.bg-light      { background-color: var(--paper) !important; }
.border-primary{ border-color: var(--accent) !important; }
.border-secondary { border-color: var(--rule-strong) !important; }
.shadow-sm, .shadow { box-shadow: none !important; }
.rounded-pill  { border-radius: 2px !important; }
.spinner-border { border-width: .13em; color: var(--ochre); }

/* ── 8. Public showcase ────────────────────────────────────────────── */
.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
  padding: 1.1rem 0;
}
.masthead__inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.masthead__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
}
.masthead__brand:hover { color: var(--ink); text-decoration: none; }
.masthead__brand img { height: 30px; width: auto; }
.masthead__nav { display: flex; align-items: center; gap: 1.5rem; margin-left: auto; }
.masthead__nav a {
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.masthead__nav a:hover, .masthead__nav a.active { color: var(--ink); text-decoration: none; }

.hero {
  padding: 4.5rem 0 4rem;
  border-bottom: 1px solid var(--rule);
}
.hero__title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5.5vw, 3.4rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.03em;
  margin: .6rem 0 1.2rem;
}
.hero__lede {
  font-size: 1.1rem;
  line-height: 1.62;
  color: var(--ink-soft);
  max-width: 34ch;
}
.hero__plate {
  border: 1px solid var(--rule-strong);
  border-radius: var(--r);
  background: var(--paper-raised);
  padding: .5rem;
  aspect-ratio: 16 / 10;
}
.hero__plate img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 1px; }
.hero__plate--empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--ink-faint);
}
.plate-caption {
  font-size: .82rem;
  color: var(--ink-faint);
  margin-top: .55rem;
}

/* Notice entries — replace the coloured-icon feature cards */
.notice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  column-gap: 2.5rem;
  border-top: 1px solid var(--rule-strong);
}
.notice {
  padding: 1.5rem .2rem 1.6rem;
  border-bottom: 1px solid var(--rule);
}
.notice__num {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--accent-ink);
  letter-spacing: .1em;
}
.notice__title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: .5rem 0 .45rem;
}
.notice__text { font-size: .85rem; color: var(--ink-soft); margin: 0; line-height: 1.65; }

.band { padding: 4rem 0; }
.band--sunken { background: var(--paper-sunken); border-block: 1px solid var(--rule); }

.prose { font-size: 1rem; line-height: 1.75; color: var(--ink); max-width: 68ch; }
.prose h2, .prose h3 { margin-top: 2rem; }

/* Footer */
.colophon {
  background: var(--paper-sunken);
  border-top: 1px solid var(--rule-strong);
  color: var(--ink-soft);
  padding: 3rem 0 1.75rem;
  font-size: .84rem;
}
.colophon a { color: var(--ink-soft); }
.colophon a:hover { color: var(--ink); }
.colophon__brand {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}
.colophon__head {
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: .8rem;
}
.colophon__rule { border-top: 1px solid var(--rule); margin: 2.5rem 0 1.25rem; }

/* Inside the app shell the footer aligns with the content column */
.app-main .colophon { margin-top: auto; }
.app-main .colophon > .container {
  max-width: 1240px;
  margin-left: 0;
  padding-left: 3rem;
  padding-right: 3rem;
}
@media (max-width: 991.98px) {
  .app-main .colophon > .container { padding-left: 1.25rem; padding-right: 1.25rem; }
}

/* ── 9. Flash messages ─────────────────────────────────────────────── */
.flash-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1080;
  width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}
.flash-stack .alert { pointer-events: auto; margin-bottom: .5rem; box-shadow: 0 10px 28px rgba(36, 31, 26, .14); }

/* ── 10. Print ────────────────────────────────────────────────────── */
@media print {
  .app-rail, .app-topbar, .flash-stack, .row-actions { display: none !important; }
  .app-main { margin-left: 0; }
  body { background: #fff; }
}
