/* ==========================================================================
   Saintek Schedule — Anti-Slop Design System
   Synthesizes:
     - Leonxlnx/taste-skill: framed-sheet (seed 1865905840, IBM Plex Sans/Mono)
     - ObsidianUI: dashboard-shell, vertical status-bars, crisp active tables
     - 4hands Tactile Design: tactile raised controls, sticky left col, hover focus
     - Halo Designers DESIGN.md & Impeccable Operate Mode: zero gradients/slop
   ========================================================================== */

:root {
  /* Framed-sheet chrome & surfaces */
  --ground: #f4f7f9;
  --surface: #ffffff;
  --raised: #f7f9fa;
  --active: #e8ecef;
  --border: #e8eaec;
  --rule: #f0f1f2;
  --control: #cdced1;

  /* 3-tier ink (>= 4.5:1 on white and chrome) */
  --text: #131416;
  --muted: #52555a;
  --faint: #656970;

  /* Tactile near-black primary + Single data hue (<3% share) */
  --primary: #131416;
  --primary-hover: #25282d;
  --accent: #1b6c80;
  --accent-tint: #ebf4f7;
  --chart-1: #1b6c80;
  --chart-2: #2f70bb;
  --chart-3: #a86f0c;

  /* Semantic status pairs (pastel fill + >=4.5:1 dark ink) */
  --positive: #1e7b4f;
  --pill-positive-bg: #dcfae5;
  --pill-positive-ink: #04250e;
  --pill-positive-border: #86efac;

  --negative: #c4242a;
  --pill-negative-bg: #ffedea;
  --pill-negative-ink: #831c1e;
  --pill-negative-border: #fecaca;

  --warning: #92400e;
  --pill-warning-bg: #fffbeb;
  --pill-warning-ink: #92400e;
  --pill-warning-border: #fde68a;

  --pill-neutral-bg: #ebedee;
  --pill-neutral-ink: #353736;

  --blocked-bg: #eff2f5;

  /* Strict 3-tier radius + consistent layout tokens */
  --radius-sheet: 16px;
  --radius-card: 8px;
  --radius-control: 6px;
  --radius-chip: 4px;

  --sidebar-width: 228px;
  --topbar-height: 48px;
  --sheet-inset: 8px;
  --gap: 16px;
  --pad: 20px;
  --control-height: 32px;

  /* Typography */
  --font: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ground);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Browser surfaces themed to palette (craft-floor requirement) */
::selection {
  background: var(--accent-tint);
  color: var(--text);
}

input, textarea, select {
  caret-color: var(--accent);
  font-family: inherit;
}

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

* {
  scrollbar-width: thin;
  scrollbar-color: #cfd5dc transparent;
}

.num {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.text-positive { color: var(--positive); }
.text-negative { color: var(--negative); }
.text-warning { color: var(--warning); }
.meta-text { font-size: 12px; color: var(--muted); }

/* ==========================================================================
   FRAMED-SHEET L-SHELL (ObsidianUI Dashboard Shell + taste-skill framed-sheet)
   No border between sidebar and topbar; inset white sheet with 1px hairline.
   ========================================================================== */

.app-frame {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  grid-template-areas:
    'sidebar topbar'
    'sidebar sheet';
  min-height: 100vh;
  background: var(--ground);
}

.sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 14px 16px;
  background: var(--ground);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 14px;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-scope {
  font-size: 12px;
  color: var(--muted);
}

.nav-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--faint);
  padding: 4px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--faint);
}

.nav-item:hover {
  background: rgba(19, 20, 22, 0.045);
  color: var(--text);
}

.nav-item.active {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}

.nav-item.active svg {
  color: var(--text);
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-count {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: var(--radius-chip);
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

.sidebar-foot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 0 4px;
}

.foot-label {
  color: var(--faint);
}

.foot-value {
  color: var(--text);
  font-weight: 500;
}

.foot-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.foot-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

/* Topbar */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 0 8px;
  background: var(--ground);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.crumb-root {
  color: var(--muted);
}

.crumb-sep {
  color: var(--control);
}

.crumb-current {
  color: var(--text);
  font-weight: 500;
}

.search-shell {
  position: relative;
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--faint);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 32px;
  padding: 0 58px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 150ms ease;
}

.search-input::placeholder {
  color: var(--faint);
}

.search-input:focus {
  border-color: var(--accent);
  outline: none;
}

.kbd-hint {
  position: absolute;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-chip);
  padding: 1px 5px;
  pointer-events: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.freshness-stamp {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Inset White Main Sheet (Zero shadow, 1px hairline, 16px radius) */
.main-sheet {
  grid-area: sheet;
  margin: 0 var(--sheet-inset) var(--sheet-inset) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sheet);
  padding: 20px var(--pad);
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.view-pane {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.view-pane[hidden] {
  display: none;
}

/* ==========================================================================
   PAGE HEADER & TACTILE BUTTONS (4hands Tactile Design)
   ========================================================================== */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-subtitle {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
  max-width: 72ch;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tactile controls: physical press response, crisp 1px edge, uniform 32px height */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control-height);
  padding: 0 12px;
  border-radius: var(--radius-control);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color 140ms ease, border-color 140ms ease, transform 90ms ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid #131416;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--control);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--raised);
  border-color: #aeb3ba;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-full {
  width: 100%;
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
}

.text-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.mobile-only {
  display: none;
}

/* Segmented Control */
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 4px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  height: 36px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-chip);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ==========================================================================
   DIVIDED METRIC STRIP + OBSIDIANUI VERTICAL STATUS BARS
   One container split by 1px rules (zero icon-in-circle KPI tiles!)
   ========================================================================== */

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(220px, 1.35fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}

#uasMetricStrip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-cell {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.metric-cell + .metric-cell {
  border-left: 1px solid var(--border);
}

.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.metric-value {
  font-size: 26px;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text);
}

.metric-unit {
  font-size: 13px;
  color: var(--faint);
}

.metric-cell-bars {
  justify-content: space-between;
  gap: 6px;
}

.status-bars-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ObsidianUI-inspired compact vertical proportion status bars */
.obsidian-status-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 40px;
}

.status-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 24px;
}

.status-bar-track {
  width: 100%;
  height: 24px;
  background: var(--raised);
  border-radius: 3px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.status-bar-fill {
  width: 100%;
  background: var(--chart-1);
  border-radius: 3px 3px 0 0;
  transform-origin: bottom;
  transition: transform 180ms ease, opacity 180ms ease;
}

.status-bar-fill.is-muted {
  background: var(--chart-1);
  opacity: 0.42;
}

.status-bar-lbl {
  font-size: 12px;
  color: var(--muted);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   INLINE NOTICES & INLINE REPAIR DIFF BAR (No lazy modals!)
   ========================================================================== */

.inline-notice {
  padding: 9px 14px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  background: var(--raised);
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.inline-notice.is-positive {
  background: var(--pill-positive-bg);
  border-color: var(--pill-positive-border);
  color: var(--pill-positive-ink);
}

.inline-notice.is-warning {
  background: var(--pill-warning-bg);
  border-color: var(--pill-warning-border);
  color: var(--pill-warning-ink);
}

.inline-notice.is-negative {
  background: var(--pill-negative-bg);
  border-color: var(--pill-negative-border);
  color: var(--pill-negative-ink);
}

.repair-diff-bar {
  border: 1px solid var(--accent);
  background: var(--accent-tint);
  border-radius: var(--radius-card);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.repair-diff-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.repair-diff-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.repair-diff-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.repair-diff-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
  max-height: 150px;
  overflow-y: auto;
}

.diff-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 6px 10px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diff-chip-course {
  font-weight: 500;
  color: var(--text);
}

.diff-chip-move {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ==========================================================================
   TOOLBAR & UNDERLINE DAY TABS (framed-sheet signature 2px underline)
   ========================================================================== */

.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  flex-wrap: wrap;
}

.day-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab-btn {
  position: relative;
  height: 36px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 140ms ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--text);
  font-weight: 600;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -1px;
  height: 2px;
  background: var(--accent);
}

.tab-num {
  font-size: 11.5px;
  color: var(--faint);
  font-weight: 400;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
  flex-wrap: wrap;
}

.select-ctrl {
  height: var(--control-height);
  padding: 0 10px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.inline-check input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   WORKBENCH SPLIT: TIMELINE GRID + DOCKED INSPECTOR RAIL
   ========================================================================== */

.workbench-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  gap: var(--gap);
  align-items: start;
}

.timeline-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  min-width: 0;
  overflow: hidden;
}

.timeline-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 14px;
  background: var(--raised);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid var(--control);
}

.swatch-theory { background: #f2f5f8; border-color: #d5dce3; }
.swatch-wetlab { background: #eef6f8; border-color: var(--accent); }
.swatch-pin { background: #131416; border-color: #131416; }
.swatch-safe { background: var(--pill-positive-bg); border-color: var(--pill-positive-border); }
.swatch-repair { background: var(--pill-warning-bg); border-color: var(--pill-warning-border); }
.swatch-conflict { background: var(--pill-negative-bg); border-color: var(--pill-negative-border); }
.swatch-blocked { background: var(--blocked-bg); border-color: #d7dce3; }

.timeline-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 310px);
  min-height: 460px;
  position: relative;
}

.timeline-grid {
  min-width: 920px;
  position: relative;
}

/* Sticky time axis header */
.tl-header-row {
  display: grid;
  grid-template-columns: 184px 1fr;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tl-corner {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 22;
  background: var(--surface);
}

.tl-axis {
  position: relative;
  height: 32px;
}

.tl-hour-tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dotted #dfe3e8;
  padding: 8px 0 0 5px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
}

.tl-ishoma-header {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #f5f6f8;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--faint);
}

/* Building group subheader */
.tl-group-row {
  display: grid;
  grid-template-columns: 184px 1fr;
  background: var(--raised);
  border-bottom: 1px solid var(--border);
}

.tl-group-label {
  position: sticky;
  left: 0;
  z-index: 12;
  background: var(--raised);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  border-right: 1px solid var(--border);
}

.tl-group-meta {
  padding: 5px 12px;
  font-size: 12px;
  color: var(--muted);
}

/* Room row */
.tl-room-row {
  display: grid;
  grid-template-columns: 184px 1fr;
  border-bottom: 1px solid var(--rule);
  min-height: 52px;
}

.tl-room-row:hover .tl-room-cell {
  background: #f9fbfc;
}

.tl-room-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.tl-room-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-room-sub {
  font-size: 12px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.tl-lane {
  position: relative;
  min-height: 52px;
  background: var(--surface);
}

.tl-lane-blocked {
  background: var(--blocked-bg);
}

.tl-blocked-caption {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--faint);
  pointer-events: none;
}

.tl-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dotted #eceff2;
  pointer-events: none;
}

.tl-ishoma-band {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(240, 242, 245, 0.72);
  border-left: 1px solid #e8eaec;
  border-right: 1px solid #e8eaec;
  pointer-events: none;
}

/* Interactive candidate drop zones during selection/drag */
.tl-drop-slot {
  position: absolute;
  top: 5px;
  bottom: 5px;
  border-radius: var(--radius-chip);
  border: 1px dashed transparent;
  cursor: pointer;
  z-index: 4;
  transition: opacity 140ms ease, background-color 140ms ease;
}

.tl-drop-slot.is-safe {
  background: rgba(220, 250, 229, 0.72);
  border-color: #4ade80;
}

.tl-drop-slot.is-safe:hover {
  background: rgba(187, 247, 208, 0.95);
}

.tl-drop-slot.is-repairable {
  background: rgba(255, 251, 235, 0.82);
  border-color: var(--chart-3);
}

.tl-drop-slot.is-repairable:hover {
  background: rgba(254, 243, 199, 0.96);
}

/* Session booking block (distinct visual marks, zero colored border-left >1px) */
.tl-card {
  position: absolute;
  top: 5px;
  bottom: 5px;
  border-radius: var(--radius-chip);
  border: 1px solid #d5dce3;
  background: #f3f6f9;
  padding: 4px 8px;
  overflow: hidden;
  cursor: grab;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  transition: opacity 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.tl-card:hover {
  border-color: var(--accent);
  z-index: 14;
}

.tl-card:active {
  cursor: grabbing;
}

.tl-card.is-wetlab {
  background: #dfeff3;
  border-color: var(--chart-1);
}

.tl-card.is-drylab {
  background: #e6effa;
  border-color: var(--chart-2);
}

.tl-card.is-pinned {
  background: #1a1d21;
  border-color: #131416;
  color: #ffffff;
}

.tl-card.is-pinned .tl-card-meta {
  color: #c7ccd4;
}

.tl-card.is-conflict {
  background: var(--pill-negative-bg);
  border-color: var(--negative);
}

.tl-card.is-selected {
  border: 2px solid var(--accent);
  z-index: 16;
}

.tl-card.is-preview-target {
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-tint);
  z-index: 15;
}

/* Tactile hover-focus: dim unrelated bookings so one schedule thread reads cleanly */
.timeline-grid.has-hover-focus .tl-card:not(.is-related):not(.is-selected) {
  opacity: 0.28;
}

.tl-card-top {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.tl-card-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}

.tl-card-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.pin-icon {
  flex-shrink: 0;
}

/* ==========================================================================
   DOCKED INSPECTOR PANEL (Zero-Scroll Rescheduling Rail)
   ========================================================================== */

.inspector-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 266px);
  overflow: hidden;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--raised);
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.inspector-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-kv {
  background: var(--raised);
  border-radius: var(--radius-control);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
}

.kv-label {
  color: var(--faint);
  flex-shrink: 0;
}

.kv-val {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.inspector-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 6px;
}

.rec-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rec-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  transition: border-color 140ms ease;
}

.rec-item:hover {
  border-color: var(--accent);
}

.rec-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.rec-primary {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.rec-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue-item {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font);
  transition: border-color 140ms ease, background-color 140ms ease;
}

.queue-item:hover {
  border-color: var(--accent);
  background: var(--raised);
}

.queue-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.queue-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.queue-item-desc {
  font-size: 13px;
  color: var(--muted);
}

.manual-move-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.manual-move-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ==========================================================================
   TABLES, PILLS & STATUS DOTS (ObsidianUI + 4hands Tactile Tables)
   No zebra striping, no header bands, right-aligned tabular numbers.
   ========================================================================== */

.master-detail-split {
  display: grid;
  grid-template-columns: minmax(380px, 460px) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.list-card,
.week-detail-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
  padding: 8px;
}

.settings-panel.panel-flush {
  padding: 8px;
  background: var(--surface);
  overflow: hidden;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 960px) {
  .app-frame {
    grid-template-columns: 1fr;
    grid-template-areas:
      'topbar'
      'sheet';
  }
  .mobile-only {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    z-index: 50;
    border-right: 1px solid var(--border);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 0 4px 14px rgba(19, 20, 22, 0.07);
  }
  .topbar {
    padding: 0 16px;
    max-width: 100vw;
    overflow: hidden;
  }
  .search-shell,
  .freshness-stamp,
  #btnQuickSaveR2 {
    display: none;
  }
  .main-sheet {
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: 16px;
    overflow-x: clip;
  }
  .day-tabs {
    max-width: 100%;
    overflow-x: auto;
  }
  .week-cols {
    grid-template-columns: 1fr;
  }
  .week-col {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

.list-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.table-wrap {
  overflow-x: auto;
  max-height: calc(100vh - 280px);
}

.table-mid {
  max-height: 360px;
}

.table-tall {
  max-height: calc(100vh - 340px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 4;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--text);
  vertical-align: middle;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
}

.data-table tbody tr {
  transition: background-color 120ms ease;
}

.data-table tbody tr.is-clickable {
  cursor: pointer;
}

.data-table tbody tr.is-clickable:hover {
  background: var(--raised);
}

.data-table tbody tr.is-selected {
  background: var(--accent-tint);
}

/* Status dots & pastel pills */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  display: inline-block;
  flex-shrink: 0;
}

.dot-positive { background: var(--positive); }
.dot-negative { background: var(--negative); }
.dot-warning { background: #d97706; }
.dot-accent { background: var(--accent); }
.dot-neutral { background: #9ca3af; }

.status-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-chip);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}

.pill-positive { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.pill-negative { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill-warning { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.pill-neutral { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }

/* Weekly 5-column calendar matrix for Class / Lecturer detail */
.week-detail-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.week-cols {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: 360px;
}

.week-col {
  padding: 10px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.week-col:last-child {
  border-right: 0;
}

.week-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}

.week-session-card {
  padding: 8px;
  border-radius: var(--radius-control);
  border: 1px solid var(--border);
  background: var(--raised);
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  transition: border-color 140ms ease;
}

.week-session-card:hover {
  border-color: var(--accent);
}

.week-session-card.is-pinned {
  background: #1a1d21;
  border-color: #131416;
  color: #ffffff;
}

.week-session-card.is-pinned .meta-text {
  color: #c7ccd4;
}

.week-gap-tag {
  font-size: 11px;
  color: var(--warning);
  background: var(--pill-warning-bg);
  border: 1px solid var(--pill-warning-border);
  border-radius: var(--radius-chip);
  padding: 2px 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.empty-day-note {
  font-size: 12px;
  color: var(--faint);
  padding: 12px 4px;
  text-align: center;
}

/* ==========================================================================
   TWO-COLUMN SETTINGS / AUDIT / CLOUD R2 & WA LAYOUT (taste-skill blueprint)
   ========================================================================== */

.settings-stack {
  display: flex;
  flex-direction: column;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 24px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
  align-items: start;
}

.settings-row:first-child {
  border-top: 0;
  padding-top: 4px;
}

.settings-title {
  margin: 4px 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.settings-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}

.settings-panel {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-panel.panel-flush {
  padding: 0;
  background: var(--surface);
  overflow: hidden;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.switch-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.switch-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.switch-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* Tactile toggle switch (semantic green/near-black, not brand accent) */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cdd2d8;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 150ms ease;
}

.toggle input:checked + .toggle-track {
  background: var(--positive);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(16px);
}

.capacity-box {
  margin-top: 14px;
  padding: 12px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
}

.capacity-title {
  font-weight: 600;
  color: var(--text);
}

.capacity-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.text-input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.text-input:focus {
  border-color: var(--accent);
  outline: none;
}

.joined-field {
  display: flex;
}

.joined-field .text-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
}

.joined-field .btn {
  height: 36px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.field-help {
  font-size: 12px;
  color: var(--muted);
}

.inline-btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Live WhatsApp Preview Card (taste-skill §8.2: show what the setting produces) */
.wa-preview-box {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  overflow: hidden;
}

.wa-preview-head {
  padding: 8px 12px;
  background: var(--raised);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.wa-preview-body {
  margin: 0;
  padding: 12px;
  font-family: var(--font);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 290px;
  overflow-y: auto;
}

.uas-day-bars {
  width: 280px;
}

.r2-link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12px;
}

.r2-link-item:last-child {
  border-bottom: 0;
}

.r2-link-item a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.r2-link-item a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (Tablet <= 1120px, Phone <= 720px)
   ========================================================================== */

@media (max-width: 1160px) {
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric-cell:nth-child(3),
  .metric-cell:nth-child(5) {
    border-left: 0;
  }
  .metric-cell:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }
  .metric-cell-bars {
    grid-column: 1 / -1;
  }
  .workbench-split,
  .master-detail-split,
  .settings-row {
    grid-template-columns: 1fr;
  }
  .inspector-panel {
    max-height: none;
  }
}

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