/* Resource Manager — "Blueprint Instrument" aesthetic.
   A technical drafting / precision-instrument identity: ink-and-paper surfaces,
   hairline blueprint grids, monospace readouts, a single high-vis amber accent.
   Self-hosted variable fonts (GDPR-safe, no external CDN at runtime). */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800; font-style: normal; font-display: swap;
}

:root {
  --bg: oklch(0.984 0.003 250);         /* clean cool white */
  --surface: oklch(0.998 0.002 250);    /* sheet (cards, bars) */
  --surface-2: oklch(0.955 0.005 250);
  --border: oklch(0.895 0.008 250);     /* cool grey rule */
  --border-strong: oklch(0.80 0.012 250);
  --fg: oklch(0.24 0.02 255);           /* slate ink */
  --fg-muted: oklch(0.48 0.018 255);
  --fg-faint: oklch(0.64 0.015 255);
  --accent: oklch(0.515 0.135 248);     /* Serviva blue (#0066a8) */
  --accent-fg: oklch(0.99 0.01 248);    /* white on blue */
  /* Company logo blue — the single source for brand tints on surfaces. */
  --brand: #0064a8;
  /* Graduated brand header: topbar darkest, statsbar a fainter wash,
     then the plain canvas. */
  --topbar-bg: color-mix(in oklch, var(--brand) 11%, var(--surface));
  --topbar-active: color-mix(in oklch, var(--brand) 20%, var(--surface));
  --statsbar-bg: color-mix(in oklch, var(--brand) 4%, var(--surface));
  --now: oklch(0.60 0.22 25);
  --grid-line: oklch(0.52 0.10 248 / 0.09);  /* blueprint atmosphere */
  --past-overlay: oklch(0.95 0.003 250 / 0.55);
  --shadow-sm: 0 1px 2px oklch(0.30 0.02 255 / 0.09);
  --shadow-md: 0 12px 36px oklch(0.25 0.03 255 / 0.15), 0 0 0 1px var(--border-strong);
  --danger: oklch(0.55 0.20 25);
  --success: oklch(0.55 0.13 150);
  /* Sequential heat ramp for the stats heatmaps — accent hue, light→dark,
     step 4 = --accent. Validated for monotone lightness, step gaps, and
     light-end contrast on this mode's surface. */
  --heat-0: var(--surface-2);
  --heat-1: oklch(0.765 0.095 248);
  --heat-2: oklch(0.69 0.11 248);
  --heat-3: oklch(0.60 0.125 248);
  --heat-4: oklch(0.515 0.135 248);
  --radius: 3px;
  --radius-lg: 4px;
  --tick: 12px;            /* DO NOT CHANGE — JS TICK_PX depends on this */
  --time-col: 64px;
  --tool-expanded: 108px;
  /* Floor for an expanded tool's total width so the head row (counts + bell +
     login + chevron) fits even with a single licence. */
  --tool-expanded-min: 188px;
  --header-h: 60px;
  --tool-head-h: 74px;
  --lic-head-h: 36px;
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html.dark {
  --bg: oklch(0.175 0.014 255);         /* slate console at night */
  --surface: oklch(0.215 0.016 255);
  --surface-2: oklch(0.262 0.018 255);
  --border: oklch(0.35 0.020 255);
  --border-strong: oklch(0.50 0.025 255);
  --fg: oklch(0.93 0.008 250);
  --fg-muted: oklch(0.74 0.016 245);
  --fg-faint: oklch(0.62 0.016 248);
  --accent: oklch(0.685 0.130 248);     /* lifted Serviva blue for dark */
  --accent-fg: oklch(0.15 0.02 248);
  /* Deeper brand wash at night — reads as navy slate, not pastel. */
  --topbar-bg: color-mix(in oklch, var(--brand) 24%, var(--surface));
  --topbar-active: color-mix(in oklch, var(--brand) 38%, var(--surface));
  --statsbar-bg: color-mix(in oklch, var(--brand) 11%, var(--surface));
  --now: oklch(0.66 0.21 28);
  --grid-line: oklch(0.70 0.10 248 / 0.08);
  --past-overlay: oklch(0.12 0.012 255 / 0.55);
  --danger: oklch(0.68 0.19 25);        /* lifted for legibility on dark */
  --success: oklch(0.66 0.14 150);
  /* Dark heat steps are selected for the dark surface, not a flipped ramp. */
  --heat-1: oklch(0.43 0.08 248);
  --heat-2: oklch(0.515 0.10 248);
  --heat-3: oklch(0.60 0.115 248);
  --heat-4: oklch(0.685 0.130 248);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.40);
  --shadow-md: 0 14px 44px oklch(0 0 0 / 0.55), 0 0 0 1px var(--border-strong);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;   /* raised from 13px for readability (older users) */
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }

/* ─── App shell ──────────────────────────────────────────────────────────── */
.app {
  display: grid;
  /* auto, not a fixed 60px: the topbar wraps to extra rows on narrow screens */
  grid-template-rows: auto 1fr;
  height: 100vh;
  overflow: hidden;
}
.app-content {
  overflow: auto;
}
.app-content.day {
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ─── Top bar ────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  /* Wrap instead of clipping: on screens too narrow for one row the controls
     flow onto extra rows and stay reachable (the shell row is auto-sized). */
  flex-wrap: wrap;
  gap: 16px;
  padding: 0 16px;
  border-bottom: 1px solid color-mix(in oklch, var(--brand) 14%, var(--border));
  background: var(--topbar-bg);
  min-height: var(--header-h);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  font-weight: 600; font-size: 13px;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.brand-logo {
  display: inline-grid; place-items: center;
  height: 28px; min-width: 28px; padding: 0 8px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.04em;
}
.brand-sub {
  color: var(--fg-faint); font-weight: 400; font-size: 11.5px;
  border-left: 1px solid var(--border-strong); padding-left: 10px;
}
.tb-center { display: flex; align-items: center; gap: 8px; }
.tb-date {
  font-size: 14px; color: var(--fg);
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: var(--radius);
  white-space: nowrap;
}
.tb-date .mono { color: var(--fg-muted); font-size: 11.5px; }
.tb-sep { flex: 1; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--fg);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.tb-btn:hover { background: var(--topbar-active); border-color: var(--border-strong); }
.tb-btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tb-btn.on { color: var(--success); border-color: color-mix(in oklch, var(--success), transparent 55%); }
.tb-btn.blocked { color: var(--fg-muted); }
.tb-icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}
.tb-icon-btn:hover { background: var(--topbar-active); color: var(--fg); border-color: var(--border); }
.kbd {
  font-family: var(--font-mono); font-size: 10.5px;
  padding: 1px 4px; border-radius: 3px;
  border: 1px solid var(--border-strong); background: var(--bg);
  color: var(--fg-muted);
}
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 11px 3px 3px;
  border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface);
  font-size: 13px;
  /* It's a button (opens the change-password modal). */
  font-family: inherit; color: var(--fg); cursor: pointer;
}
.user-chip:hover { background: var(--topbar-active); border-color: var(--border-strong); }
.user-chip .avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  color: white; font-size: 11px; font-weight: 600;
  background: var(--accent);
}
.tb-nav { display: flex; align-items: center; gap: 4px; }
.tb-nav a {
  padding: 8px 12px; border-radius: var(--radius);
  font-size: 13.5px; color: var(--fg-muted);
}
.tb-nav a:hover { background: var(--topbar-active); color: var(--fg); text-decoration: none; }
.tb-nav a.active {
  background: var(--topbar-active);
  color: color-mix(in oklch, var(--brand) 55%, var(--fg));
  font-weight: 500;
}
.signout-form { display: inline; }
.signout-btn {
  background: transparent; border: 0; color: var(--fg-faint);
  cursor: pointer; font-size: 13.5px; padding: 8px 10px; border-radius: var(--radius);
}
.signout-btn:hover { color: var(--fg); background: var(--topbar-active); }
[role="separator"] { width: 1px; height: 18px; background: var(--border); display: inline-block; }

/* ─── Stats bar ──────────────────────────────────────────────────────────── */
.statsbar {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; row-gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--statsbar-bg);
  font-size: 13px;
  color: var(--fg-muted);
}
.statpill { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.open { background: oklch(0.65 0.15 145); }
.dot.busy { background: oklch(0.65 0.15 30); }
.dot.mine { background: var(--accent); }
.statbar-sep { flex: 1; }

/* ─── Narrow screens (phones) ────────────────────────────────────────────── */
/* The topbar/statsbar already wrap; this trims redundant text so the topbar
   settles at ~2 rows instead of 4 on a 390px phone. */
@media (max-width: 720px) {
  .topbar { padding: 8px 12px; gap: 8px; row-gap: 6px; }
  .brand { gap: 8px; }
  .brand-sub,
  .topbar [role="separator"],
  .notify-label,
  .user-chip > span { display: none; }
  .user-chip { padding: 0; border: 0; background: transparent; }
  .tb-btn { padding: 8px 10px; }
  .tb-nav a { padding: 8px 9px; }
  .statsbar { gap: 10px; padding: 6px 12px; }
  .admin-page { padding: 16px 12px; }
}

/* ─── Grid layout (day view) ─────────────────────────────────────────────── */
.grid-wrap {
  position: relative;
  overflow: auto;
  background: var(--bg);
}
.grid {
  position: relative;
  display: grid;
  grid-template-columns: var(--time-col) 1fr;
  width: 100%;
}

/* Time column (left rail) */
.time-col {
  position: sticky; left: 0; z-index: 4;
  background: var(--bg);
  border-right: 1px solid var(--border);
}
.time-col-head {
  position: sticky; top: 0; z-index: 5;
  height: calc(var(--tool-head-h) + var(--lic-head-h));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.time-row {
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 8px 0 4px;
  color: var(--fg-muted);
  font-size: 11.5px; font-family: var(--font-mono);
}
.time-row.is-night { color: var(--fg-faint); font-size: 10.5px; }

/* Tool columns container */
.cols {
  position: relative;
  display: grid;
  min-width: 0;
}
.tool-col {
  position: relative;
  display: grid;
  grid-template-rows: var(--tool-head-h) var(--lic-head-h) 1fr;
  /* One explicit column clamped to the tool's own track. Without this the
     implicit column is auto-sized to the head's min-content width, so a
     narrow (single-licence) tool's head/strip overflow the column and get
     painted over by the next tool's sticky head — hiding the chevron, the
     login link and the between-tools border. */
  grid-template-columns: minmax(0, 1fr);
  /* Strong rule between tools so columns are easy to follow down the page. */
  border-right: 2px solid var(--border-strong);
  min-width: 0;
  width: 100%;
}
.tool-col:last-child { border-right: 0; }

.tool-head {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px 5px;
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
  user-select: none;
}
.tool-head:hover { background: var(--surface-2); }
.tool-head.expanded { background: var(--bg); cursor: default; }
.tool-head-row {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.tool-swatch {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--tool-color); flex-shrink: 0;
  border: 1px solid color-mix(in oklch, var(--tool-color), black 18%);
}
.tool-name {
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0; flex: 1;
}
.tool-sub { color: var(--fg-muted); font-size: 11.5px; }
.tool-counts { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-muted); white-space: nowrap; }
.tool-counts b { color: var(--fg); font-weight: 600; }
.tool-name-mini {
  font-weight: 600; font-size: 12.5px; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--fg);
  margin-top: 1px;
}

.bell-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 4px; border: 1px solid transparent;
  background: transparent; color: var(--fg-faint);
  cursor: pointer;
  flex-shrink: 0;
}
.bell-btn:hover { background: var(--surface-2); color: var(--fg-muted); border-color: var(--border); }
.bell-btn.on { color: oklch(0.62 0.18 60); background: oklch(0.95 0.06 80 / 0.6); border-color: oklch(0.85 0.10 70); }
html.dark .bell-btn.on { background: oklch(0.30 0.08 60); border-color: oklch(0.45 0.10 60); color: oklch(0.85 0.16 75); }

/* ─── Queue bell + count badge ──────────────────────────────────────────── */
/* Overrides the fixed-size .bell-btn on tool heads; also used standalone on
   licence heads (.lic-queue-bell). Count sits inline after the icon. */
.queue-bell {
  display: inline-flex; align-items: center; gap: 3px;
  width: auto; height: 24px; padding: 0 5px;
  border-radius: 4px; border: 1px solid transparent;
  background: transparent; color: var(--fg-faint); cursor: pointer;
  flex-shrink: 0;
}
/* Tool-head bell matches the login button's size (29px, 16px icon). Two-class
   selector beats .queue-bell's height:24px. */
.bell-btn.queue-bell { height: 29px; }
/* Per-licence bells ~20% larger than the .queue-bell default (24px → 29px). */
.queue-bell.lic-queue-bell { height: 29px; }
.queue-bell:hover { background: var(--surface-2); color: var(--fg-muted); border-color: var(--border); }
.queue-bell.on { color: oklch(0.62 0.18 60); background: oklch(0.95 0.06 80 / 0.6); border-color: oklch(0.85 0.10 70); }
html.dark .queue-bell.on { background: oklch(0.30 0.08 60); border-color: oklch(0.45 0.10 60); color: oklch(0.85 0.16 75); }
.queue-bell .q-count {
  font-size: 11px; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--accent); color: #fff;
}

/* ─── Transparent queue popover ─────────────────────────────────────────── */
.queue-popover {
  position: absolute; z-index: 50; width: 232px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 10px; font-size: 13px;
}
.queue-popover[hidden] { display: none; }
.qp-head {
  font-weight: 600; font-size: 12.5px; margin-bottom: 6px; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qp-list {
  list-style: none; margin: 0 0 8px; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
  max-height: 220px; overflow-y: auto;
}
.qp-list li { display: flex; align-items: center; gap: 7px; padding: 3px 5px; border-radius: 4px; }
.qp-list li.is-first { background: oklch(0.95 0.06 80 / 0.6); }
html.dark .qp-list li.is-first { background: oklch(0.30 0.08 60); }
.qp-list li.is-you .qp-name { color: var(--accent); font-weight: 600; }
.qp-pos { font-family: var(--font-mono); font-size: 11px; color: var(--fg-faint); min-width: 14px; text-align: right; }
.qp-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qp-any { color: var(--fg-faint); }
.qp-empty { color: var(--fg-faint); font-style: italic; padding: 4px 5px; }
.qp-status { font-size: 12px; color: var(--fg-faint); margin-bottom: 8px; }
.qp-toggle { width: 100%; justify-content: center; }

.exp-btn {
  width: 29px; height: 29px; display: grid; place-items: center;
  border-radius: 3px; color: var(--fg-faint);
  background: transparent; border: 0; cursor: pointer;
  flex-shrink: 0;
}
.exp-btn:hover { background: var(--surface-2); color: var(--fg); }

/* License sub-header strip */
.lic-strip {
  position: sticky;
  top: var(--tool-head-h);
  z-index: 3;
  display: grid;
  grid-template-columns: var(--lic-tracks);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.lic-head {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg);
  padding: 5px 4px;
  /* Solid rule continuing into the column below so each licence's lane is
     easy to trace (was a faint dashed line). */
  border-right: 1px solid var(--border-strong);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in oklch, var(--tool-color), transparent 90%);
  border-top: 2px solid var(--tool-color);
}
/* Status (free/busy/mine) is shown by the dot only; the header bar stays the
   tool colour so all licences of a tool look uniform. */
.lic-head:last-child { border-right: 0; }
/* Collapsed placeholder spans the whole strip; no inner rule needed. */
.lic-head.row-collapsed { border-right: 0; }
.lic-head .lic-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: oklch(0.70 0.12 145);
  flex-shrink: 0;
}
.lic-head.busy .lic-dot { background: oklch(0.65 0.18 30); }
.lic-head.mine .lic-dot { background: var(--accent); }

/* Tool body */
.tool-body {
  position: relative;
  display: grid;
  grid-template-columns: var(--lic-tracks);
}
.tool-col.collapsed .tool-body { display: block; }
.lic-col {
  position: relative;
  /* Clear vertical lane separator (aligned with the .lic-head rule above). */
  border-right: 1px solid var(--border-strong);
  min-width: 0;
  cursor: crosshair;
}
.lic-col:last-child { border-right: 0; }

/* Slot backgrounds (15-min and hour gridlines) */
.slot-bg {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--tick) - 1px),
      var(--border) calc(var(--tick) - 1px),
      var(--border) var(--tick)
    );
  background-size: 100% calc(var(--tick) * 4);
  pointer-events: none;
}
.slot-bg-hour {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--tick) * 4 - 1px),
      color-mix(in oklch, var(--border-strong), transparent 30%) calc(var(--tick) * 4 - 1px),
      color-mix(in oklch, var(--border-strong), transparent 30%) calc(var(--tick) * 4)
    );
  pointer-events: none;
}

/* Now line */
.now-line {
  position: absolute; left: 0; right: 0;
  height: 0;
  border-top: 1.5px solid var(--now);
  z-index: 5;
  pointer-events: none;
}
.now-line::before {
  content: "";
  position: absolute; left: -3px; top: -4px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--now);
  box-shadow: 0 0 0 2px oklch(0.62 0.21 25 / 0.18);
}
/* Rail segment reuses .now-line for the line but drops its dot — one dot only,
   carried by the main columns line. Two-class specificity beats .now-line::before. */
.now-line.now-line--rail::before { content: none; }
/* Past overlay */
.past-overlay {
  position: absolute; left: 0; right: 0; top: 0;
  background: oklch(0.50 0.005 250 / 0.07);
  pointer-events: none;
  z-index: 1;
}
html.dark .past-overlay { background: oklch(0.10 0.005 250 / 0.32); }
.lic-col .booking.past, .collapsed-bar .occ-cell.past { opacity: 0.55; filter: saturate(0.55); }

/* Booking block */
.booking {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: 3px;
  padding: 4px 5px;
  font-size: 12px;
  line-height: 1.2;
  overflow: hidden;
  cursor: pointer;
  z-index: 2;
  background: var(--book-bg, var(--surface-2));
  color: var(--book-fg, var(--fg));
  border: 1px solid var(--book-border, var(--border-strong));
  box-shadow: var(--shadow-sm);
  user-select: none;
  display: flex; flex-direction: column; gap: 1px;
  transition: filter .12s, transform .12s;
}
.booking:hover { filter: brightness(1.04); }
html.dark .booking:hover { filter: brightness(1.12); }
.booking.mine {
  --book-bg: color-mix(in oklch, var(--accent), white 78%);
  --book-fg: color-mix(in oklch, var(--accent), black 35%);
  --book-border: color-mix(in oklch, var(--accent), transparent 40%);
}
html.dark .booking.mine {
  --book-bg: color-mix(in oklch, var(--accent), black 42%);
  --book-fg: color-mix(in oklch, var(--accent), white 55%);
  --book-border: var(--accent);
}
.booking.tinted {
  --book-bg: color-mix(in oklch, var(--user-color), white 78%);
  --book-fg: color-mix(in oklch, var(--user-color), black 45%);
  --book-border: color-mix(in oklch, var(--user-color), transparent 55%);
}
html.dark .booking.tinted {
  --book-bg: color-mix(in oklch, var(--user-color), black 46%);
  --book-fg: color-mix(in oklch, var(--user-color), white 55%);
  --book-border: color-mix(in oklch, var(--user-color), white 8%);
}

.b-row { display: flex; align-items: center; gap: 5px; min-width: 0; }
.b-initials {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--user-color);
  color: white; font-size: 9.5px; font-weight: 600; font-family: var(--font-mono);
  flex-shrink: 0;
  box-shadow: 0 1px 0 oklch(0 0 0 / 0.1) inset;
}
.b-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.b-time { font-family: var(--font-mono); font-size: 11px; opacity: .8; }
.b-note { font-size: 11px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking.short { padding: 2px 6px; }
.booking.short .b-time { display: none; }

/* Drag-to-move (own, not-yet-started bookings) */
.booking.movable { cursor: grab; }
.booking.moving {
  /* Let elementFromPoint hit the column underneath, and eat the post-drop click. */
  pointer-events: none;
  z-index: 6;
  opacity: 0.9;
  box-shadow: var(--shadow-md);
}
.booking.moving.invalid {
  --book-border: var(--danger);
  border-style: dashed;
}
body:has(.booking.moving) { cursor: grabbing; }

/* Edge-resize handles (own bookings): slim grab zones on the top/bottom
   edges; a grip bar fades in on hover so the affordance is discoverable. */
.b-resize {
  position: absolute; left: 0; right: 0; height: 7px;
  cursor: ns-resize; z-index: 3;
  touch-action: none;
}
.b-resize-start { top: 0; }
.b-resize-end { bottom: 0; }
/* A 15-min booking is ~10px tall — shrink the zones so its middle stays
   grabbable for moving. */
.booking.short .b-resize { height: 4px; }
.b-resize::after {
  content: "";
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 22px; height: 3px; border-radius: 2px;
  background: currentColor; opacity: 0;
  transition: opacity .12s;
}
.b-resize-start::after { top: 1px; }
.b-resize-end::after { bottom: 1px; }
.b-resize:hover::after { opacity: .45; }
.booking.resizing {
  /* Eat the post-drop click; lift above neighbours while dragging. */
  pointer-events: none;
  z-index: 6;
  box-shadow: var(--shadow-md);
}
body:has(.booking.resizing) { cursor: ns-resize; }

/* Draft selection (drag-to-create preview) */
.draft {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: 4px;
  background: color-mix(in oklch, var(--accent), white 80%);
  border: 1.5px dashed var(--accent);
  z-index: 3;
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-family: var(--font-mono);
  color: color-mix(in oklch, var(--accent), black 25%);
}
html.dark .draft {
  background: color-mix(in oklch, var(--accent), black 55%);
  color: color-mix(in oklch, var(--accent), white 35%);
}

/* Collapsed tool: occupancy heat-strip */
.collapsed-bar {
  position: relative;
  width: 100%;
  height: 100%;
  background: oklch(0.97 0.003 250);
}
html.dark .collapsed-bar { background: oklch(0.20 0.005 250); }
.occ-cell {
  position: absolute;
  left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: oklch(0.22 0.04 145);
  overflow: hidden;
  white-space: nowrap;
}
html.dark .occ-cell { color: oklch(0.18 0.05 145); }
.occ-label { font-family: var(--font-mono); font-weight: 600; line-height: 1; letter-spacing: 0; }
.occ-of { opacity: 0.55; font-weight: 400; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0;
  background: oklch(0.20 0.01 250 / 0.32);
  z-index: 100;
  display: grid; place-items: center;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: 420px;
  max-width: calc(100% - 32px);
  overflow: hidden;
}
.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-title { font-weight: 600; font-size: 16px; flex: 1; }
.modal-title .modal-sub { font-weight: 400; font-size: 12.5px; color: var(--fg-muted); }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-field { display: flex; flex-direction: column; gap: 4px; }
.modal-field label {
  font-size: 12px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.modal-field .value { font-size: 14px; color: var(--fg); }
.modal-foot {
  padding: 12px 16px;
  display: flex; gap: 8px; justify-content: flex-end;
  /* Long (German) button labels wrap onto a second row instead of the
     row overflowing the modal and clipping buttons on the left. */
  flex-wrap: wrap; row-gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* Booking-details modal: status badge in the header */
.ctx-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--fg-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.ctx-status.running {
  background: oklch(0.94 0.05 150); color: oklch(0.42 0.11 150);
  border-color: oklch(0.85 0.08 150);
}
html.dark .ctx-status.running {
  background: oklch(0.32 0.06 150); color: oklch(0.85 0.10 150);
  border-color: oklch(0.45 0.08 150);
}
.ctx-status.running::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: oklch(0.62 0.15 150);
}
@media (prefers-reduced-motion: no-preference) {
  .ctx-status.running::before { animation: ctx-pulse 1.6s ease-in-out infinite; }
}
@keyframes ctx-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.modal-error { color: var(--danger); font-size: 13px; padding: 0 16px 12px; }
.modal-hint { color: var(--fg-muted); font-size: 12.5px; }
/* Make unavailable (busy/past) time slots readable instead of washed-out. */
.modal-field select option:disabled { color: var(--fg-muted); font-style: italic; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-primary:hover { filter: brightness(1.1); background: var(--fg); }
.btn-danger { color: var(--danger); border-color: color-mix(in oklch, var(--danger), transparent 70%); }
.btn-danger:hover { background: color-mix(in oklch, var(--danger), transparent 92%); }
.btn-success { color: var(--bg); background: var(--success); border-color: var(--success); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 360px;
  box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 18px; margin: 0 0 4px; font-weight: 600; }
.login-subtitle { color: var(--fg-muted); font-size: 12.5px; margin-bottom: 22px; }
.login-card .form-group { margin-bottom: 14px; }

/* ─── Forms (admin + login) ──────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=number] {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; background: var(--bg); color: var(--fg);
}
.form-group input[type=text]:focus,
.form-group input[type=password]:focus,
.form-group input[type=number]:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.form-group input[type=color] { width: 100%; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.form-group--sm { max-width: 100px; }
.form-group--action { justify-content: flex-end; }
.form-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }
.import-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; }
.import-form input[type=file] { font-size: 13px; color: var(--fg-muted); }
.import-form .modal-hint { flex-basis: 100%; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: color-mix(in oklch, var(--danger), transparent 88%); color: var(--danger); border: 1px solid color-mix(in oklch, var(--danger), transparent 60%); }
.alert-success { background: color-mix(in oklch, var(--success), transparent 88%); color: var(--success); border: 1px solid color-mix(in oklch, var(--success), transparent 60%); }
.input-inline { width: 150px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--fg); font-size: 13px; }

/* ─── Admin pages (legacy layout, restyled) ──────────────────────────────── */
.admin-page { max-width: 960px; margin: 0 auto; padding: 24px 20px; }
.admin-page--wide { max-width: 1200px; }
.admin-page h2 { font-size: 20px; margin-bottom: 20px; font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; }
.add-form h3 { font-size: 13px; font-weight: 600; margin-bottom: 14px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px; border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.row-inactive td { opacity: 0.5; }
.actions { display: flex; gap: 6px; }
.color-swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--border); vertical-align: middle; }
.empty-row { color: var(--fg-muted); text-align: center; padding: 24px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--fg-muted); }
.empty-state p { margin-bottom: 16px; }

.tool-card { padding: 16px 20px; }
.tool-card.card-inactive { opacity: 0.55; }
.tool-card.dragging { opacity: 0.45; }
.drag-handle {
  display: grid; place-items: center;
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 4px; color: var(--fg-faint);
  cursor: grab;
}
.drag-handle:hover { background: var(--surface-2); color: var(--fg-muted); }
.drag-handle:active { cursor: grabbing; }
.tool-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.tool-card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tool-card-title .color-swatch { width: 18px; height: 18px; flex-shrink: 0; }
.tool-card-name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tool-card-status { font-size: 11px; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.licence-table { margin-bottom: 12px; }
.licence-table .col-actions { width: 100px; text-align: right; }
.inline-edit { display: flex; gap: 8px; align-items: center; }
.inline-edit input[type=text] {
  flex: 1; padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: var(--bg); color: var(--fg);
}
.add-licence-form { display: flex; gap: 8px; }
.add-licence-form input[type=text] {
  flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; background: var(--bg); color: var(--fg);
}
.empty-state-card { text-align: center; color: var(--fg-muted); padding: 30px; }

/* Legacy modal-overlay (admin tools edit modal) — make it look like the new modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: oklch(0.20 0.01 250 / 0.32);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay .modal {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
  width: 380px;
}
.modal-overlay .modal h3 { font-size: 15px; margin-bottom: 14px; font-weight: 600; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.modal-overlay .form-group { margin-bottom: 10px; }

/* ═══════════════════════════════════════════════════════════════════════════
   BLUEPRINT INSTRUMENT — aesthetic override layer
   Typography, chrome, texture and motion. Layout geometry above is untouched.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Blueprint graph-paper atmosphere behind the whole app (covered by opaque
   surfaces; visible around cards on login + admin pages). */
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  background-attachment: fixed;
}

/* ── Brand: instrument badge + wordmark ──────────────────────────────────── */
.brand { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; letter-spacing: -0.015em; }
.brand-logo {
  border-radius: 2px;
  font-family: var(--font-mono); font-weight: 700; font-size: 11px; letter-spacing: 0.08em;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent-fg), transparent 72%);
}
.brand-sub {
  font-family: var(--font-mono); text-transform: uppercase;
  letter-spacing: 0.16em; font-size: 14px;  /* match .tb-date */
}

/* ── Buttons: amber CTA, mechanical edges ────────────────────────────────── */
.btn-primary, .tb-btn[aria-pressed="true"] { font-weight: 600; }
.btn-primary {
  background: var(--accent); color: var(--accent-fg);
  border-color: color-mix(in oklch, var(--accent), black 14%);
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.tb-btn, .btn { letter-spacing: -0.005em; }

/* ── Headings: display face with an amber registration tick ──────────────── */
.admin-page h2 {
  font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 11px;
}
.admin-page h2::before {
  content: ""; width: 4px; height: 0.82em; flex: none;
  background: var(--accent); border-radius: 1px;
}
.login-card h1, .modal-title { font-family: var(--font-display); letter-spacing: -0.02em; }

/* ── Data tables: instrument readout ─────────────────────────────────────── */
.data-table th {
  font-family: var(--font-mono); font-weight: 600; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-strong);
}
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover td { background: color-mix(in oklch, var(--accent), transparent 93%); }
.data-table .num, .data-table td .mono { font-family: var(--font-mono); }
.data-table .num { white-space: nowrap; }

/* ── Login: access panel with corner registration marks + entrance ───────── */
.login-page {
  background-color: var(--bg);
  background-image:
    radial-gradient(125% 80% at 50% -10%, color-mix(in oklch, var(--accent), transparent 90%), transparent 55%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  background-attachment: fixed;
}
.login-card {
  position: relative;
  border-color: var(--border-strong);
  animation: rm-rise .55s cubic-bezier(.2,.75,.2,1) both;
}
/* Drafting corner ticks on the card */
.login-card::before, .login-card::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border: 1.5px solid var(--accent);
}
.login-card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.login-card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.login-mark {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 3px; margin-bottom: 16px;
  background: var(--accent); color: var(--accent-fg);
  font-family: var(--font-mono); font-weight: 700; font-size: 15px; letter-spacing: 0.06em;
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent-fg), transparent 70%);
}
.login-card h1 { font-size: 21px; font-weight: 700; }
.login-tag {
  display: block; margin: -2px 0 20px;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--fg-faint);
}
.login-card > * { animation: rm-rise .5s cubic-bezier(.2,.75,.2,1) both; }
.login-card .login-mark { animation-delay: .04s; }
.login-card h1 { animation-delay: .09s; }
.login-card .login-tag { animation-delay: .13s; }
.login-card form { animation-delay: .18s; }
.login-divider {
  display: flex; align-items: center; gap: 10px; margin: 16px 0;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--fg-faint);
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.login-card .btn svg { flex-shrink: 0; }
.login-signout { margin-top: 16px; text-align: center; }
.btn-link {
  border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 12.5px; color: var(--fg-muted); text-decoration: underline;
}
.btn-link:hover { color: var(--fg); }

/* ── Motion ──────────────────────────────────────────────────────────────── */
@keyframes rm-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes rm-pulse {
  0%, 100% { box-shadow: 0 0 0 2px color-mix(in oklch, var(--now), transparent 72%); }
  50%      { box-shadow: 0 0 0 5px color-mix(in oklch, var(--now), transparent 88%); }
}
/* The "now" marker reads as a live instrument signal. */
.now-line::before { animation: rm-pulse 2.4s ease-in-out infinite; }

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

/* ── Serviva logo plates (render the brand mark on white in any theme) ────── */
.brand-plate {
  display: inline-grid; place-items: center;
  padding: 4px 8px; border-radius: 3px;
  background: #fff; border: 1px solid var(--border);
}
.brand-logo-img { display: block; height: 27px; width: auto; }
html.dark .brand-plate { box-shadow: 0 0 0 1px oklch(1 0 0 / 0.04); }

/* Login: the brand mark sits on a white panel above the product name. */
.login-mark {
  width: auto; height: auto; padding: 12px 16px; margin-bottom: 18px;
  background: #fff; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.login-logo-img { display: block; height: 30px; width: auto; }

/* ── Interaction-tips help button + popover ──────────────────────────────── */
.help-wrap { display: inline-flex; }
.help-btn {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; border: 1px solid var(--border-strong);
  background: transparent; color: var(--fg-muted); cursor: pointer;
  font-family: var(--font-mono); font-size: 13px; font-weight: 700; line-height: 1;
  transition: color .12s, border-color .12s, background .12s;
}
.help-btn:hover { color: var(--accent); border-color: var(--accent); }
.help-btn[aria-expanded="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.help-popover {
  position: fixed; z-index: 60; width: 300px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 11px 13px;
  animation: rm-rise .16s ease both;
}
.help-popover[hidden] { display: none; }
.hp-head {
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  margin-bottom: 8px; color: var(--fg); letter-spacing: -0.01em;
}
.hp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.hp-list li {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.4;
  color: var(--fg-muted); letter-spacing: -0.01em;
}
.hp-sep { height: 1px; background: var(--border); margin: 10px 0; }
.hp-sub {
  font-family: var(--font-mono); font-size: 9.5px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--fg-faint); margin-bottom: 7px;
}
.hp-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.hp-legend li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-muted); }
.lg-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.lg-sq { border-radius: 2px; }
.hp-bell { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; color: var(--fg-muted); line-height: 1.4; }
.hp-bell svg { flex: none; margin-top: 1px; color: var(--accent); }
