/* ========================================================================
   Bean Block UI System v2.5.2 — CSS Tokens & Components
   Source: UI_Doctrine reference HTML :root
   ======================================================================== */
:root {
  /* Brand & ink */
  --color-ink: #111721;
  --color-ink-soft: #181E29;
  --color-primary: #F67E0F;
  --color-on-primary: #FFFFFF;
  --accent: #F67E0F;
  --accent-bg: #FFF0DC;
  --color-coffee: #784C1D;
  --color-coffee-dark: #3F210C;
  --color-cream: #FFE5CD;

  /* Surfaces */
  --surface-page: #FFFAF4;
  --surface-main: #FFFFFF;
  --surface-card: #FFF1E4;
  --surface-tonal: #FADEBC;
  --surface-nested: #F0E0CE;
  --surface-list: #FFFFFF;
  --surface-input: #FFFFFF;
  --surface-dark: #111721;
  --scrim: rgba(17, 23, 33, 0.62);

  /* Text */
  --text-strong: #1F0F04;
  --text: #2C1607;
  --text-muted: #7A5A3A;
  --text-soft: #86684A;
  --text-inverse: #FFF7ED;
  --text-tonal: #662C00;
  --state-layer-inverse-hover: rgba(255, 255, 255, 0.06);

  /* Borders & focus */
  --border-strong: #9A7A5A;
  --border-soft: rgba(120, 76, 29, 0.50);
  --border-chip: rgba(120, 76, 29, 0.10);
  --border-subtle: rgba(120, 76, 29, 0.11);
  --divider: rgba(120, 76, 29, 0.13);
  --focus-ring: rgba(246, 126, 15, 0.28);

  /* Semantic */
  --success-bg: #E7F5EC;
  /* Progress bar fills (calendar PMS) */
  --progress-healthy: #14A44A;
  --progress-overdue: #DD2528;
  --success-border: #B7DEC6;
  --success-text: #0E3D25;
  --warning-bg: #FFF3D6;
  --warning-border: #F3D28A;
  --warning-text: #5F3B00;
  --danger: #B42318;
  --danger-bg: #FDE8E5;
  --danger-border: #F5B8B1;
  --danger-text: #65120C;
  --field-required: var(--danger);
  --info-bg: #E7EFFF;
  --info-border: #B8CCFF;
  --info-text: #153E96;
  --neutral-bg: #EFE5DA;
  --neutral-border: #D8C7B7;
  --neutral-text: #3A2A20;

  /* Selection (filter chips, button groups) */
  --selection-bg: #FAECDD;
  --selection-fill: #FECC85;
  --selection-text: #3F210C;

  /* Dark-surface navigation */
  --bottom-nav-surface: var(--surface-dark);
  --bottom-nav-active: var(--color-primary);
  --bottom-nav-text: rgba(255, 247, 237, 0.72);
  --bottom-nav-active-text: #FFFFFF;

  --font-brand: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-body: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;

  /* Type Scale Tokens — size establishes hierarchy; weight reinforces it */
  --fs-display: 2.5rem;        /* 40px - Hero numbers / dashboard KPIs */
  --fs-stat: 2.5rem;           /* 40px - Stat figures and metric values */
  --fs-page-title: 2rem;       /* 32px - Screen titles */
  --fs-lead: 1.125rem;         /* 18px - Page introductions / lead copy */
  --fs-section-head: 1.5rem;   /* 24px - Section headings and modal titles */
  --fs-card-title: 1.25rem;    /* 20px - Card, record, and container titles */
  --fs-body: 0.9375rem;        /* 15px - Operational reading baseline */
  --fs-subheadline: 0.875rem;  /* 14px - Supporting text / metadata */
  --fs-label: 0.75rem;         /* 12px - Labels, kickers, table headers */
  --fs-btn: var(--fs-body);    /* 15px - Control labels */

  /* Line Height Tokens */
  --lh-display: 1.1;
  --lh-heading: 1.25;
  --lh-body: 1.5;

  --shape-corner-sm: 4px;
  --shape-corner-md: 6px;
  --shape-corner-lg: 8px;
  --shape-corner-xl: 16px;
  --shape-corner-2xl: 16px;
  --shape-corner-pill: 999px;

  --elevation-main: 0 10px 28px rgba(120, 76, 29, 0.10);
  --elevation-card: 0px 1px 2px rgba(0, 0, 0, 0.30), 0px 2px 6px 2px rgba(0, 0, 0, 0.15);
  --elevation-shell: 0 14px 36px rgba(17, 23, 33, 0.16);
  --elevation-modal: 0 26px 70px rgba(17, 23, 33, 0.28);
  --elevation-access: 0 28px 80px rgba(0, 0, 0, 0.30);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;

  --control-desktop: 40px;
  --control-mobile: 48px;
  --mobile-header-height: calc(var(--control-mobile) + var(--space-4) + env(safe-area-inset-top));
  --mobile-nav-height: 66px;
  --mobile-nav-clearance: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 88px);

  /* Shell layout (Doctrine §10.2, §5 — compact desktop density) */
  --sidebar-width: 230px;
  --layout-sidebar-padding-block: 20px;
  --layout-sidebar-padding-inline: 12px;

  --z-header: 9000;
  --z-nav: 9200;
  --z-modal: 10000;
  --z-toast: 11000;

  /* Access shell (Doctrine §2.6 / §13.5) — access-only component tokens */
  --touch-target-min: 48px;
  --access-input-inset: inset 0 2px 8px rgba(17, 23, 33, 0.20);
  --access-error-ring: rgba(245, 184, 177, 0.38);
  --access-submit-hover: #FFA040;

  /* Motion (Doctrine §6.1) */
  --motion-duration-page: 300ms;
  --motion-duration-enter: 400ms;
  --motion-duration-exit: 220ms;
  --motion-easing-decelerate: cubic-bezier(0.05, 0.7, 0.1, 1.0);
  --motion-easing-accelerate: cubic-bezier(0.3, 0, 0.8, 0.15);
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--surface-page);
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--surface-page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-weight: 400;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }
input, select, textarea { font-size: 1rem; }

svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

img { display: block; max-width: 100%; }

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

/* ---- Shell ---- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--surface-page);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface-dark);
  color: var(--text-inverse);
  padding: var(--layout-sidebar-padding-block) var(--layout-sidebar-padding-inline);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; padding: 0 4px; }
.new-log-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: auto; align-self: flex-start;
  height: 56px; padding: 0 20px;
  background: var(--surface-tonal);
  border: none;
  border-radius: var(--shape-corner-2xl);
  color: var(--color-coffee-dark);
  font-size: var(--fs-body); font-weight: 650;
  cursor: pointer;
  margin-bottom: 14px;
  transition: filter 140ms ease;
}
.new-log-btn:hover { filter: brightness(1.08); }
.new-log-btn svg { width: 18px; height: 18px; }
.mobile-new-log-btn { display: none; }

.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  flex: 0 0 auto;
  border-radius: var(--shape-corner-xl);
  background: var(--surface-page);
  color: var(--color-ink);
  font-family: var(--font-brand);
  font-size: var(--fs-lead); font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 0 0 4px var(--state-layer-inverse-hover);
}

.sidebar-logo-img { width: 32px; height: 38px; }
.sidebar-brand-name { margin: 0; color: var(--text-inverse); font-family: var(--font-brand); font-size: 1rem; font-weight: 800; line-height: 1.15; letter-spacing: 0.01em; white-space: normal; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-button {
  width: 100%; min-height: 36px;
  display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center;
  gap: 10px; padding: 6px 12px;
  border-radius: var(--shape-corner-pill);
  background: transparent;
  color: var(--bottom-nav-text);
  font-size: var(--fs-body); font-weight: 650;
  text-align: left;
  overflow: hidden;
  transition: background 140ms ease, color 140ms ease;
}

.nav-button:hover { background: var(--state-layer-inverse-hover); }
.nav-button.active { background: var(--color-primary); color: var(--color-on-primary); }
.nav-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-button svg { justify-self: center; width: 18px; height: 18px; }

.sidebar-footer { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--state-layer-inverse-hover); display: grid; gap: 10px; }
.sidebar-note { margin: 0; color: var(--bottom-nav-text); font-size: var(--fs-label); font-weight: 400; }
/* Dark-surface outline treatment for the sidebar footer Back to Hub action */
.sidebar-footer .btn-outline {
  border-color: color-mix(in srgb, var(--text-inverse) 35%, transparent);
  color: var(--text-inverse);
}

.main { min-width: 0; padding: 22px; }
.page-wrap { max-width: 1280px; margin: 0 auto; }

/* ---- Typography ---- */
.kicker { margin: 0 0 10px; color: var(--color-coffee); font-size: var(--fs-label); font-weight: 650; letter-spacing: 0.11em; text-transform: uppercase; opacity: 0.78; }
.page-subtitle { max-width: 800px; margin: 6px 0 0; color: var(--text-muted); font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 400; }
.section-title { margin: 0; color: var(--text-strong); font-size: var(--fs-section-head); line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; }
.card-title { margin: 0; color: var(--text-strong); font-size: var(--fs-card-title); line-height: var(--lh-heading); font-weight: 700; letter-spacing: -0.015em; }

/* ---- Buttons ---- */
.btn {
  min-height: var(--control-desktop);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 15px;
  border: 1px solid transparent;
  border-radius: var(--shape-corner-pill);
  background: var(--surface-tonal);
  color: var(--text-strong);
  font-size: var(--fs-subheadline); font-weight: 650; line-height: 1;
  white-space: nowrap;
  position: relative;
  isolation: isolate;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.btn:hover::after { opacity: 0.08; }
.btn:active { transform: scale(0.99); }

.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.btn-secondary { background: var(--color-coffee); color: var(--text-inverse); }
.btn-tonal { background: var(--surface-tonal); border-color: transparent; color: var(--text-tonal); }
.btn-outline { background: transparent; border-color: var(--border-soft); color: var(--text-strong); }
.btn-text { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-text.cycle-discard-btn { color: var(--danger); }
.btn-small { min-height: 32px; padding: 7px 11px; font-size: var(--fs-label); font-weight: 650; }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--color-on-primary); }
.btn[disabled] { cursor: not-allowed; opacity: 0.72; }

/* ---- Surfaces ---- */
.surface-main {
  background: var(--surface-main);
  border: none;
  border-radius: var(--shape-corner-2xl);
  padding: 20px;
}

.surface-card {
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 16px;
}

.surface-tonal {
  background: var(--surface-tonal);
  border: none;
  border-radius: var(--shape-corner-xl);
  padding: 16px;
}

.surface-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: var(--space-4); }
.surface-header p:not(.kicker) { margin: 6px 0 0; color: var(--text-muted); font-size: var(--fs-subheadline); font-weight: 400; }

/* ---- Chips ---- */
.status-chip {
  min-height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 4px 9px;
  border: 1px solid var(--border-chip);
  border-radius: var(--shape-corner-md);
  background: var(--surface-tonal);
  color: var(--text-strong);
  font-size: var(--fs-label); font-weight: 650;
  line-height: 1; white-space: nowrap;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.status-chip::before { display: none; }

.status-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.status-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.status-neutral { background: var(--neutral-bg); border-color: var(--neutral-border); color: var(--neutral-text); }
.status-danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.status-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }

.badge {
  min-height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 3px 8px;
  border: 1px solid var(--border-chip);
  border-radius: var(--shape-corner-md);
  background: var(--neutral-bg);
  color: var(--neutral-text);
  font-size: var(--fs-label); font-weight: 650;
  line-height: 1; white-space: nowrap;
  cursor: default;
}

.filter-chip {
  min-height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-pill);
  background: transparent;
  color: var(--text-muted);
  padding: 5px 9px;
  font-size: var(--fs-label); font-weight: 650; line-height: 1;
  box-shadow: none; white-space: nowrap;
  position: relative;
  isolation: isolate;
  transition: background 140ms ease, border-color 140ms ease;
}

.filter-chip::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.filter-chip:hover::after { opacity: 0.08; }

.filter-chip.active { background: var(--selection-fill); border-color: var(--selection-fill); color: var(--selection-text); }
.filter-chip:disabled { opacity: 0.6; cursor: not-allowed; }
.filter-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 6px; width: 16px; height: 16px; padding: 0;
  border: none; border-radius: 50%; background: transparent; color: currentColor;
  cursor: pointer; opacity: 0.7; transition: opacity 140ms ease, background 140ms ease;
}
.filter-chip-x:hover { opacity: 1; background: rgba(0, 0, 0, 0.1); }
.filter-chip-x svg { width: 12px; height: 12px; }

/* Button group — 2+ mutually exclusive choices; selected segment stays a
   filled tonal pill inside a pill-outlined container (no switch animation) */
.btn-group {
  --btn-group-height: 36px;
  --btn-group-radius: calc(var(--btn-group-height) / 2);
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: calc(var(--btn-group-radius) + 3px); /* pill incl. border + padding */
}

.btn-group button {
  min-height: var(--btn-group-height);
  border: none;
  background-color: transparent;
  color: var(--text-strong);
  border-radius: var(--btn-group-radius);
  font-size: var(--fs-subheadline);
  font-weight: 650;
  cursor: pointer;
  padding: 0 16px;
  white-space: nowrap;
}

.btn-group button:hover {
  background-color: var(--surface-nested);
  color: var(--text-strong);
}

.btn-group button.active {
  background-color: var(--selection-fill);
  color: var(--selection-text);
  font-weight: 700;
}

/* ---- Metrics ---- */
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }

.metric-card {
  min-height: 108px; text-align: left;
  position: relative;
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 14px;
  transition: transform 140ms ease;
}

.metric-card.brand { background: var(--color-cream); color: var(--color-coffee-dark); }
.metric-card.success { background: var(--success-bg); color: var(--success-text); }
.metric-card.warning { background: var(--warning-bg); color: var(--warning-text); }
.metric-card.danger { background: var(--danger-bg); color: var(--danger-text); }

/* Doctrine state-layer hover for interactive metric cards (buttons only) */
button.metric-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}
button.metric-card:hover::after {
  opacity: 0.08;
}

.metric-label { margin: 8px 0 0; color: currentColor; font-size: var(--fs-label); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.75; }
/* Label-row variant: chevron sits flush right on the same line as the label */
.metric-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.metric-label-row .metric-label { margin: 0; }
.metric-label-row .metric-card-chevron { position: static; right: auto; bottom: auto; }
.metric-card-chevron {
  position: absolute;
  right: 14px;
  bottom: 12px;
  color: var(--text-soft);
  opacity: 0.8;
}
.metric-card-chevron svg { width: 18px; height: 18px; }
.metric-value { color: var(--text-strong); font-size: var(--fs-stat); font-weight: 700; line-height: var(--lh-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.metric-unit { font-size: var(--fs-card-title); font-weight: 700; line-height: var(--lh-heading); color: inherit; margin-left: 3px; }

/* Overview: machine counters panel + compact status banners */
.overview-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.overview-title-icon {
  height: var(--fs-page-title);
  width: auto;
  flex: none;
}
.overview-page-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-strong);
  font-size: var(--fs-section-head);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.overview-title-icon {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-tonal);
}
/* Components header sits flush above the list */
.map-intro .surface-header { margin-bottom: 0; }
.overview-metrics { display: grid; gap: var(--space-3); }
/* Overview top row: GCB readout | Next Service card | stacked action banners */
.overview-metrics-3col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  align-items: stretch;
}
.status-banner-stack { display: grid; gap: var(--space-3); }
.status-banner-stack .status-banner { width: 100%; justify-content: flex-start; padding: 8px 16px; }
.counters-panel { padding: var(--space-3); }
.counters-grid { display: flex; align-items: stretch; }
/* Plain readouts — no card, not clickable; columns separated by a divider */
.counter-cell {
  flex: 1 1 0;
  min-width: 0;
  display: flex; flex-direction: column; justify-content: center;
  padding: 8px 20px;
}
/* GCB production counter — light-green card (matches the Next-service card shape) */
.counter-cell-gcb {
  background: var(--success-bg);
  border-radius: var(--shape-corner-xl);
  padding: 12px 20px;
}
/* GCB card footer — last-updated note + compact Sync Now (filter-chip height) */
.gcb-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}
.gcb-last-updated {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1.3;
}
.gcb-sync-btn {
  min-height: 28px;
  padding: 5px 9px;
  font-size: var(--fs-label);
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
  background: var(--success-border);
  border-color: var(--success-border);
  color: var(--success-text);
}
.gcb-sync-btn:hover:not(:disabled) {
  background: var(--success-border);
  border-color: var(--success-border);
  color: var(--success-text);
}
.counter-cell + .counter-cell { border-left: 1px solid var(--border-strong); }
.counter-cell + .counter-cell-next { border-left: none; }
.counter-value {
  color: var(--text-strong);
  font-size: var(--fs-stat); font-weight: 700; line-height: 1.1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.counter-unit { font-size: var(--fs-card-title); font-weight: 700; margin-left: 3px; }
.counter-label {
  margin: 6px 0 0; font-size: var(--fs-label); font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.7;
}
/* Sentence-case readout label (e.g. "GCB kg since Jun 2, 2026.") */
.counter-label--sentence {
  text-transform: none;
  letter-spacing: 0.02em;
  opacity: 0.75;
}
/* Next-service column label — full --fs-section-head type token */
.counter-label--section {
  margin: 0 0 10px; color: var(--text-strong); opacity: 1;
  font-size: var(--fs-section-head); line-height: 1.2; font-weight: 700;
  letter-spacing: -0.015em; text-transform: none;
}
/* Next-service column: calculated parameters + flags, in a borderless card */
.counter-cell-next {
  justify-content: center;
  background: var(--surface-tonal);
  border-left: none;
  border-radius: var(--shape-corner-xl);
  padding: 12px 20px;
}
.next-service-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.next-service-flag { margin: 0; font-size: var(--fs-label); color: var(--warning-text); font-weight: 650; white-space: nowrap; }
/* Next-service sentence: leading calendar icon + bold due date */
.next-service-sentence {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: var(--fs-lead);
  font-weight: 400;
  line-height: 1.45;
}
.next-service-sentence svg { width: 16px; height: 16px; flex: none; color: var(--text-muted); }
.next-service-sentence strong { color: var(--text-strong); font-variant-numeric: tabular-nums; }
.status-banner-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.status-banner {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 8px 12px;
  border: 1px solid transparent; border-radius: var(--shape-corner-lg);
  font-size: var(--fs-body); font-weight: 650; letter-spacing: 0.01em;
  cursor: pointer; transition: transform 140ms ease;
}
.status-banner strong { font-size: var(--fs-card-title); line-height: 1; font-variant-numeric: tabular-nums; }
.status-banner.danger { background: var(--danger-bg); color: var(--danger-text); }
.status-banner.warning { background: var(--warning-bg); color: var(--warning-text); }
/* Doctrine state-layer hover for compact status banners (buttons only) */
button.status-banner::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: currentColor; opacity: 0; pointer-events: none; transition: opacity 140ms ease;
}
button.status-banner:hover::after { opacity: 0.08; }
.status-banner-chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: currentColor;
  opacity: 0.7;
}
.status-banner-chevron svg { width: 16px; height: 16px; }
.skeleton-banner { min-height: 44px; background: var(--surface-card); }

/* ---- Dashboard ---- */
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr); gap: var(--space-5); align-items: start; }
/* Overview heat map: side panel top aligned with the top of the heat map card */
.dashboard-grid.map-aligned > .map-intro { grid-column: 1; grid-row: 1; }
.dashboard-grid.map-aligned > .map-shell { grid-column: 1; grid-row: 2; }
.dashboard-grid.map-aligned > .side-panel-stack { grid-column: 2; grid-row: 2; }
.side-panel-stack { display: grid; gap: var(--space-5); }
.total-hours-value { margin: 8px 0 0; color: var(--text-strong); font-size: clamp(2rem, 4vw, var(--fs-display)); font-weight: 800; line-height: var(--lh-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.map-shell {
  background: var(--surface-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-xl);
  padding: var(--space-3);
}

/* Overview: all-equipment list (replaces the roaster diagram) */
.equipment-list {
  display: grid;
  gap: 4px;
}
.equipment-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--shape-corner-lg);
  background: transparent;
  color: var(--text-strong);
  font-size: var(--fs-body);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 140ms ease;
}
.equipment-list-item:hover { background: var(--surface-nested); }
.equipment-list-item.active { background: var(--selection-fill); color: var(--selection-text); }
.equipment-list-item .part-number { width: 28px; height: 28px; font-size: var(--fs-label); border-width: 2px; flex: none; }
.equipment-list-name { flex: 0 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.equipment-list-progress {
  flex: 1 1 auto;
  min-width: 40px;
  height: 6px;
  border-radius: var(--shape-corner-pill);
  background: var(--surface-nested);
  overflow: hidden;
}
.equipment-list-progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.equipment-list-item .status-chip { flex: none; }

.diagram {
  --diagram-height: 620px;
  --diagram-frame-width: 738.58px;
  position: relative;
  width: 100%; height: var(--diagram-height);
  display: grid; place-items: center;
  border-radius: var(--shape-corner-lg);
  overflow: hidden;
  background: var(--surface-main);
}

.image-layer { position: relative; width: min(100%, var(--diagram-frame-width)); aspect-ratio: 705/591; }
.image-layer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; z-index: 1; pointer-events: none; }

.heat-target {
  position: absolute;
  border-radius: var(--shape-corner-pill);
  transform: translate(-50%, -50%);
  cursor: pointer; z-index: 2;
  border: 0; background: currentColor;
  opacity: 0.16;
  transition: opacity 140ms ease;
}

.heat-target.active, .heat-target:hover { opacity: 0.44; }

.part-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--color-on-primary); font-weight: 700; font-size: var(--fs-subheadline);
  border: 3px solid var(--color-on-primary);
  pointer-events: none;
}

.image-layer .part-pin { opacity: 0.46; transition: opacity 140ms ease, transform 140ms ease; }
.image-layer .part-pin.active { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }

/* Enlarged static pin in part detail — inline width/height/background, lead-scale numeral */
.part-pin-detail { font-size: var(--fs-lead); font-weight: 700; }

/* ---- Record cards ---- */
.record-list { display: grid; gap: var(--space-3); }

.record-card {
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 14px;
  text-align: left;
}

.record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.record-title { margin: 0; color: var(--text-strong); font-size: var(--fs-card-title); font-weight: 700; line-height: var(--lh-heading); letter-spacing: -0.01em; }
.record-meta { margin: 3px 0 0; color: var(--text-muted); font-size: var(--fs-subheadline); font-weight: 400; }
.modal-note { font-size: var(--fs-body); }

.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }

.detail-cell {
  background: var(--surface-nested);
  border-radius: max(4px, calc(var(--shape-corner-xl) - 6px));
  padding: 10px 11px;
}

.detail-label { color: var(--text-muted); font-size: var(--fs-label); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; }
.detail-value { margin-top: 3px; color: var(--text-strong); font-size: var(--fs-body); font-weight: 700; }

.progress-track { height: 8px; background: var(--surface-page); border-radius: var(--shape-corner-pill); overflow: hidden; margin-top: var(--space-4); }
.progress-fill { height: 100%; border-radius: var(--shape-corner-pill); }

.note-panel {
  margin-top: var(--space-4); padding: var(--space-4);
  border-radius: max(4px, calc(var(--shape-corner-xl) - 6px));
  background: var(--surface-nested);
  color: var(--text-muted);
  font-size: var(--fs-subheadline); line-height: 1.45; font-weight: 400;
}

.list-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; }

.part-number {
  width: 40px; height: 40px;
  border-radius: var(--shape-corner-pill);
  display: grid; place-items: center;
  color: var(--color-on-primary); font-weight: 700; font-size: var(--fs-subheadline);
  border: 3px solid var(--color-on-primary);
}

/* ---- Forms ---- */
.inline-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.form-full { grid-column: 1/-1; }

.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field label { color: var(--text-muted); font-size: var(--fs-label); font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1.1; }
.field-required-mark { color: var(--field-required); font-weight: 800; letter-spacing: 0; }
.field-required-text { color: var(--field-required); font-size: var(--fs-label); font-weight: 650; letter-spacing: 0; }

/* Base checkbox-label — styled inline checkbox (also used by the reset-hours control) */
.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.field label.checkbox-label {
  font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 400;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}
.checkbox-label input[type="checkbox"] {
  position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0;
}
.checkbox-label::before {
  content: ""; width: 18px; height: 18px; flex: none;
  border: 2px solid var(--border-strong);
  border-radius: var(--shape-corner-sm);
  background: var(--surface-input);
  transition: background 140ms ease, border-color 140ms ease;
}
.checkbox-label:has(input:checked)::before {
  background: var(--color-primary);
  border-color: var(--color-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 12px 12px; background-position: center; background-repeat: no-repeat;
}

/* ── Doctrine §11.7 — Custom date-range picker (single or range) ── */
.date-picker-wrap { position: relative; display: block; }
.date-picker-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  width: 100%; min-height: var(--control-desktop);
  padding: 6px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--shape-corner-lg);
  background: var(--surface-input);
  color: var(--text-strong);
  cursor: pointer;
  font-size: 1rem; font-weight: 400;
  text-align: left;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.date-picker-trigger:hover { border-color: var(--border-strong); }
.date-picker-trigger.open { border-color: var(--color-primary); box-shadow: 0 0 0 2px rgba(246, 126, 15, 0.22); }
.date-picker-trigger:disabled { opacity: 0.6; cursor: not-allowed; }
.date-picker-trigger-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-picker-caret { flex: 0 0 auto; display: inline-flex; color: var(--text-muted); }
.date-picker-caret svg { width: 16px; height: 16px; }
.date-picker-panel {
  width: 320px;
  background: var(--surface-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-xl);
  box-shadow: var(--elevation-card);
  padding: 12px;
}
.date-picker-month-label { flex: 1 1 auto; text-align: center; color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 650; }
.date-picker-header { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 8px; }
.date-picker-nav-btn {
  width: 32px; height: 32px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--shape-corner-pill);
  background: transparent; color: var(--text-strong);
  cursor: pointer;
}
.date-picker-nav-btn:hover { background: var(--surface-tonal); }
.date-picker-nav-btn svg { width: 18px; height: 18px; }
.date-picker-nav-btn[aria-label="Previous month"] svg { transform: rotate(180deg); }
.date-picker-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.date-picker-weekday { padding: 4px 0; text-align: center; color: var(--text-muted); font-size: var(--fs-label); font-weight: 650; }
.date-picker-day {
  height: 36px; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--shape-corner-md);
  background: transparent; color: var(--text);
  font-size: var(--fs-body); font-weight: 400; cursor: pointer;
}
.date-picker-day.empty { pointer-events: none; }
.date-picker-day:hover { background: var(--surface-tonal); }
.date-picker-day.is-today { font-weight: 800; position: relative; }
.date-picker-day.is-today::after { content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--color-primary); }
.date-picker-day.is-start, .date-picker-day.is-end { background: var(--color-primary); color: var(--color-on-primary); font-weight: 700; }
.date-picker-day.is-in-range { background: var(--surface-tonal); }
.date-picker-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: 12px; }
@media (max-width: 600px) {
  .date-picker-panel { position: fixed !important; left: 12px !important; right: 12px !important; width: auto; }
  .date-picker-day { height: 44px; }
  .counters-grid { flex-direction: column; }
  .counter-cell + .counter-cell { border-left: none; border-top: 1px solid var(--border-strong); }
  .counter-cell + .counter-cell-next { border-top: none; }
  .counter-cell-next { border-top: none; margin-top: 8px; }
  .overview-metrics-3col { grid-template-columns: 1fr; }
}

.input, .select, .textarea, input, select, textarea {
  width: 100%; min-height: var(--control-desktop);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--shape-corner-lg);
  background: var(--surface-input);
  color: var(--text);
  padding: 6px 12px;
  font-size: 1rem; font-weight: 400;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea, .textarea { min-height: 96px; resize: vertical; }

.input:focus, .select:focus, .textarea:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px var(--focus-ring);
}

select, .select {
  appearance: none; -webkit-appearance: none;
  padding-right: 40px;
  background-color: var(--surface-input);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23784C1D' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px 16px;
}

/* Native date input — prevents grid overflow and mobile text clipping (Doctrine §6.4) */
input[type="date"] {
  min-width: 0;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

input[type="date"]::-webkit-datetime-edit {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readonly-value {
  min-height: var(--control-desktop);
  display: flex; align-items: center;
  padding: 6px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--shape-corner-md);
  background: var(--surface-tonal);
  color: var(--text-strong);
  font-size: 1rem; font-weight: 400;
}

/* ---- Calendar ---- */
.maintenance-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Doctrine stat cards — transparent, divider rules between, label over value, semantic number color */
.maintenance-summary-grid .metric-card {
  min-height: 0;
  padding: 14px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  color: var(--text-strong);
}
.maintenance-summary-grid .metric-card.brand { color: var(--color-coffee-dark); }
.maintenance-summary-grid .metric-card.success { color: var(--success-text); }
.maintenance-summary-grid .metric-card.warning { color: var(--warning-text); }
.maintenance-summary-grid .metric-card.danger { color: var(--danger-text); }
.maintenance-summary-grid .metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--space-3) / -2);
  width: 1px;
  background: var(--divider);
}
.maintenance-summary-grid .metric-card:nth-child(4n+1)::before { display: none; }
.maintenance-summary-grid .metric-label {
  margin: 8px 0 0;
  color: currentColor;
  font-size: var(--fs-label);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.75;
}
.maintenance-summary-grid .metric-value {
  color: currentColor;
  font-size: clamp(1.75rem, 3vw, var(--fs-stat));
  font-weight: 700;
  line-height: var(--lh-display);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.maintenance-main-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.calendar-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: 14px; }
.calendar-controls { display: flex; gap: var(--space-2); align-items: center; }

.calendar-grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0; overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-xl);
  background: var(--surface-main);
}

.calendar-head {
  color: var(--text-muted);
  font-size: var(--fs-label); font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase;
  text-align: center; padding: 9px 6px;
  background: var(--surface-tonal);
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.calendar-head:nth-child(7) { border-right: 0; }

.day-cell {
  min-height: 96px;
  background: var(--surface-card);
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}

.day-cell:nth-child(7n) { border-right: 0; }
.day-cell:nth-last-child(-n+7) { border-bottom: 0; }
.day-cell.muted { background: var(--surface-tonal); color: var(--text-soft); opacity: 0.72; }

.day-number {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: var(--shape-corner-pill);
  font-weight: 700; font-size: var(--fs-label);
}

.day-cell.today .day-number { background: var(--color-primary); color: var(--color-on-primary); }

.event-pill {
  display: block; width: 100%;
  border-radius: var(--shape-corner-md); padding: 3px 6px;
  font-size: var(--fs-label); font-weight: 650; text-align: left;
  background: var(--surface-tonal);
  color: var(--text);
  border: 1px solid var(--border-subtle);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---- Library ---- */
.page-grid-2 { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); gap: var(--space-5); align-items: start; }
.library-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; }
.link-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.placeholder-card { min-height: 520px; display: grid; place-items: center; text-align: center; }

/* ---- Admin / Settings ---- */
.settings-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 280px); gap: var(--space-4); align-items: end; margin-bottom: var(--space-5); }

.role-card {
  background: var(--surface-tonal);
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-xl);
  padding: var(--space-4);
}
.role-card strong { display: block; color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 700; margin-bottom: 4px; }
.role-card p { margin: 0; color: var(--text-muted); font-size: var(--fs-subheadline); line-height: 1.4; font-weight: 400; }

.settings-grid { display: grid; gap: var(--space-3); }

/* PMS threshold list — proper table */
.settings-table-wrap { overflow-x: auto; }
.settings-table { width: 100%; border-collapse: collapse; }
.settings-table th {
  text-align: left; padding: 8px 12px;
  font-size: var(--fs-label); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted); background: var(--surface-tonal); border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.settings-table td { padding: 10px 12px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.settings-table tbody tr:hover { background: var(--surface-page); }
.settings-table .hours-input { width: 88px; vertical-align: middle; }
/* Schedule cell: gap + vertical alignment between the interval input and the unit toggle */
.settings-table .btn-group { margin-left: 8px; vertical-align: middle; }
.settings-table .select { min-width: 96px; }
.settings-table .settings-cell-title { min-width: 180px; }
.settings-table .part-number { width: 32px; height: 32px; font-size: var(--fs-label); border-width: 2px; }
.settings-table .settings-cell-title small { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-label); font-weight: 400; max-width: 340px; }

.settings-row {
  display: grid;
  grid-template-columns: 54px minmax(190px, 1.25fr) minmax(110px, 0.6fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr);
  gap: var(--space-2); align-items: center;
  background: var(--surface-card);
  border-radius: var(--shape-corner-lg);
  padding: var(--space-3);
}

.settings-row.header { background: var(--surface-tonal); box-shadow: none; color: var(--text-muted); font-size: var(--fs-label); font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; }

.settings-cell-title { min-width: 0; }
.settings-cell-title strong { display: block; color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 700; line-height: 1.25; }
.settings-cell-title small { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-label); font-weight: 400; }

.hours-input {
  width: 100%; min-height: 40px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--shape-corner-lg);
  background: var(--surface-input); color: var(--text-strong);
  padding: 8px 10px;
  font-size: 1rem; font-weight: 400;
}
.hours-input:disabled { background: var(--surface-tonal); border-color: var(--border-subtle); color: var(--text-muted); }

.settings-note {
  margin-top: var(--space-4);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-text);
  border-radius: var(--shape-corner-xl);
  padding: var(--space-4);
  font-size: var(--fs-subheadline); line-height: 1.45; font-weight: 400;
}

.settings-row.hour-rules { grid-template-columns: 54px minmax(180px, 1.1fr) minmax(90px, 0.5fr) minmax(100px, 0.55fr) minmax(80px, 0.45fr) minmax(80px, 0.45fr) minmax(80px, 0.45fr) minmax(80px, 0.45fr) minmax(130px, 0.6fr); }

.hours-basis-card {
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 16px;
}
.hours-basis-card .section-title { font-size: var(--fs-card-title); }

/* ---- Modals ---- */
/* Doctrine v2.5.2 §2.4 / §13.4 — root overlays: default 560px, confirm 460px, wide 760px;
   sheet slide-up on mobile for task dialogs; confirmations stay centered on every viewport. */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  background: var(--scrim);
  animation: backdrop-fade-in 200ms ease both;
}

.modal-backdrop.closing { animation: backdrop-fade-out 200ms ease both; }

.modal {
  width: min(100%, 560px);
  max-height: min(88dvh, 820px);
  display: flex; flex-direction: column;
  overflow: hidden;
  border: none;
  border-radius: var(--shape-corner-2xl);
  background: var(--surface-page);
  color: var(--text);
  box-shadow: var(--elevation-modal);
  animation: modal-in 170ms ease both;
}

.modal.closing { animation: modal-out 150ms ease both; }

.modal.confirm {
  max-width: 460px;
  animation: confirm-in 180ms var(--motion-easing-decelerate) both;
}

.modal.wide { width: min(100%, 760px); }

.modal-head {
  position: relative;
  flex-shrink: 0;
  padding: var(--space-4) var(--space-5) var(--space-2) var(--space-5);
  border: none;
}

.modal-title {
  margin: 0;
  color: var(--text-strong);
  font-size: var(--fs-section-head);
  font-weight: 700;
  line-height: var(--lh-heading);
  letter-spacing: -0.02em;
}

.modal-head .record-meta { margin-top: 4px; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-2) var(--space-5) var(--space-4) var(--space-5);
}

.modal-actions {
  display: flex; flex-shrink: 0;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5) var(--space-5) var(--space-5);
}

.modal-close-x {
  position: absolute;
  top: var(--space-4);
  right: var(--space-5);
  width: 36px; height: 36px;
  display: none;
  align-items: center; justify-content: center;
  border: none;
  border-radius: var(--shape-corner-pill);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.modal-close-x:hover { background: var(--surface-tonal); color: var(--text-strong); }
.modal-close-x:active { background: var(--selection-bg); color: var(--text-strong); transform: scale(0.94); }
.modal-close-x svg { width: 18px; height: 18px; pointer-events: none; }

@media (min-width: 920px) {
  .modal:not(.confirm) .modal-head { padding-right: calc(var(--space-5) + 36px + var(--space-1)); }
  .modal:not(.confirm) .modal-close-x { display: flex; }
  .modal:not(.confirm) .modal-close-btn { display: none; }
}

@keyframes modal-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }
@keyframes confirm-in { from { opacity: 0; transform: scale(1.2); } to { opacity: 1; transform: scale(1); } }
@keyframes modal-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.97); } }
@keyframes modal-slide-up { from { opacity: 1; transform: translateY(100%); } to { opacity: 1; transform: translateY(0); } }
@keyframes modal-slide-down { from { opacity: 1; transform: translateY(0); } to { opacity: 1; transform: translateY(100%); } }
@keyframes backdrop-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-fade-out { from { opacity: 1; } to { opacity: 0; } }

/* ---- History ---- */
.history-filter-chips { display: flex; flex-wrap: nowrap; gap: 6px; margin: 0 0 12px; overflow-x: auto; }

.history-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.45fr) minmax(150px, 0.45fr) minmax(150px, 0.45fr);
  gap: var(--space-3); align-items: end;
  margin-bottom: 14px;
}

.history-log-list { display: grid; gap: var(--space-4); }

.history-log-group { display: grid; gap: 8px; }
.history-log-group-date {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.history-log-group-card {
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 14px;
}
.history-log-group-body { display: grid; }
.history-log-group-card .history-log-card {
  background: transparent;
  border-radius: 0;
  padding: 0;
}
.history-log-group-card .history-log-card + .history-log-card {
  border-top: 1px solid var(--divider);
  margin-top: 14px;
  padding-top: 14px;
}

.history-log-card {
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 12px; text-align: left;
}

.history-log-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.history-log-head > div:first-child { margin-right: auto; }
.history-log-title { margin: 0; color: var(--text-strong); font-size: var(--fs-card-title); font-weight: 700; line-height: var(--lh-heading); }
.history-log-meta { margin: 3px 0 0; color: var(--text-muted); font-size: var(--fs-subheadline); font-weight: 400; }

.history-detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin-top: 8px; }
.history-compact-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 0; }
.history-compact-chips .history-actions { display: flex; gap: 8px; margin-left: auto; }

.history-mini-chip {
  display: inline-flex; align-items: center;
  min-height: 24px;
  border-radius: var(--shape-corner-md);
  background: var(--surface-nested);
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: var(--fs-label); font-weight: 650;
}

.history-empty {
  min-height: 160px;
  display: grid; place-items: center; text-align: center;
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: var(--shape-corner-xl);
  padding: 16px;
  color: var(--text-muted);
}

.maintenance-main-grid .history-toolbar { grid-template-columns: 1fr 1fr; }
.maintenance-main-grid .history-toolbar .field:first-child { grid-column: 1/-1; }
.maintenance-main-grid .history-detail-grid { grid-template-columns: 1fr; }
.maintenance-main-grid .history-log-card { padding: 10px 12px; }
.maintenance-main-grid .note-panel { font-size: var(--fs-label); padding: 10px; margin-top: 10px; }

/* ---- Maintenance log form ---- */
/* Cycle form: GCB input + Pull button on one row */
.gcb-pull-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.gcb-pull-row .input { flex: 1 1 auto; }
.gcb-pull-row .btn { flex: 0 0 auto; }
.log-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.log-form-full { grid-column: 1/-1; }

.log-target-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); }

.log-section {
  background: var(--surface-card);
  border-radius: var(--shape-corner-xl);
  padding: 16px;
}
.log-section + .log-section { margin-top: 14px; }

.log-section-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.log-section-header p { margin: 4px 0 0; color: var(--text-muted); font-size: var(--fs-subheadline); font-weight: 400; }

.log-inline-note {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: var(--fs-label); line-height: 1.4;
}
.log-danger-note { color: var(--warning-text); font-weight: 650; }

.quick-log-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.quick-log-grid .full { grid-column: 1/-1; }

/* ---- Activity table ---- */
.activity-table-wrap {
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-lg);
  background: var(--surface-list);
}

.activity-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.activity-table th, .activity-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; font-size: var(--fs-subheadline); font-weight: 400; }
.activity-table th { color: var(--text-muted); font-size: var(--fs-label); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-tonal); }
.activity-table tr:last-child td { border-bottom: 0; }
.activity-table td strong { font-weight: 400; }
.activity-value { font-size: var(--fs-body); font-weight: 700; color: var(--text-strong); white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-modal-list { max-height: 62vh; overflow: auto; }

/* ---- Access shell (Doctrine v2.5.2 §2.6 / §13.5) ---- */
.access-shell {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--surface-dark);
  color: var(--text-inverse);
}

.access-wave {
  position: absolute;
  inset-inline: 0;
  z-index: -1;
  width: 100%;
  pointer-events: none;
  user-select: none;
}

.access-wave--top { top: 0; height: clamp(116px, 14vw, 204px); }
.access-wave--bottom { bottom: 0; height: clamp(176px, 22vw, 296px); }
.access-wave svg { width: 100%; height: 100%; }
.access-wave path { stroke: none; }
.access-wave .access-wave-primary { fill: var(--color-primary); }
.access-wave .access-wave-secondary { fill: var(--color-coffee); }

.access-main {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
  animation: pageIn var(--motion-duration-page) var(--motion-easing-decelerate) both;
}

.access-stack {
  width: min(100%, 344px);
  display: grid;
  justify-items: center;
  text-align: center;
  transform: translateY(clamp(-24px, -2vh, -8px));
}

.access-logo-img { width: 40px; height: 48px; margin-bottom: var(--space-3); }

.access-brand {
  margin: 0;
  color: var(--color-primary);
  font-size: var(--fs-card-title);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
}

.access-title {
  max-width: 10ch;
  margin: 7px 0 0;
  color: var(--text-inverse);
  font-size: clamp(2.25rem, 7.2vw, var(--fs-display));
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.055em;
}

.access-form {
  width: min(100%, 320px);
  display: grid;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.access-pin {
  width: 100%;
  min-height: 56px;
  border: 2px solid var(--border-strong);
  border-color: color-mix(in srgb, var(--color-cream) 42%, transparent);
  border-radius: var(--shape-corner-lg);
  background: var(--surface-input);
  color: var(--color-ink);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), var(--access-input-inset);
  padding: 0 14px;
  text-align: center;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.36em;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 160ms var(--motion-easing-decelerate), box-shadow 160ms var(--motion-easing-decelerate), background 160ms var(--motion-easing-decelerate);
}

.access-pin::placeholder { color: var(--text-soft); opacity: 1; letter-spacing: 0.26em; }
.access-pin:focus { border-color: var(--color-primary); background: var(--surface-input); box-shadow: 0 0 0 4px var(--focus-ring), var(--access-input-inset); }
.access-pin[aria-invalid="true"] { border-color: var(--danger-border); background: var(--danger-bg); box-shadow: 0 0 0 4px var(--access-error-ring), var(--access-input-inset); animation: pin-shake 300ms var(--motion-easing-accelerate); }
.access-pin:disabled { opacity: 0.78; cursor: wait; }

.access-message {
  min-height: 20px;
  margin: 0;
  color: var(--danger-border);
  font-size: var(--fs-subheadline);
  font-weight: 650;
  line-height: 1.4;
}
.access-message:empty { display: none; }

.access-submit {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: var(--shape-corner-pill);
  background: var(--color-primary);
  color: var(--color-ink);
  padding: 0 14px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  cursor: pointer;
  transition: transform 140ms var(--motion-easing-decelerate), background 140ms var(--motion-easing-decelerate), opacity 140ms var(--motion-easing-decelerate);
}
.access-submit:hover:not(:disabled) { background: var(--access-submit-hover); }
.access-submit:active:not(:disabled) { transform: translateY(1px); }
.access-submit:disabled { opacity: 0.48; cursor: not-allowed; }
.access-submit-content { display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }

.access-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.access-back {
  justify-self: center;
  min-height: var(--touch-target-min);
  border: none;
  border-radius: var(--shape-corner-pill);
  background: transparent;
  color: var(--text-inverse);
  padding: 0 13px;
  font-size: var(--fs-subheadline);
  font-weight: 700;
  cursor: pointer;
  transition: color 140ms var(--motion-easing-decelerate), background 140ms var(--motion-easing-decelerate);
}
.access-back:hover { color: var(--color-on-primary); background: var(--state-layer-inverse-hover); }

.access-version {
  position: absolute;
  z-index: 1;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  margin: 0;
  color: var(--surface-dark);
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
  user-select: none;
}

.access-toast {
  position: absolute;
  z-index: 2;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  width: min(calc(100% - 32px), 400px);
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--shape-corner-lg);
  background: var(--color-ink-soft);
  color: var(--text-inverse);
  box-shadow: var(--elevation-access);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 180ms var(--motion-easing-decelerate), transform 220ms var(--motion-easing-decelerate);
}
.access-toast.is-visible { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.access-toast-icon { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: rgba(245, 184, 177, 0.20); color: var(--danger-border); font-size: var(--fs-subheadline); font-weight: 800; }
.access-toast-message { font-size: var(--fs-subheadline); font-weight: 650; line-height: 1.35; }

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---- Sync banner ---- */
.sync-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; padding: 10px 12px;
  border-radius: var(--shape-corner-lg);
  background: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info-text);
  font-size: var(--fs-subheadline); font-weight: 650;
}
.sync-banner.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }

/* ---- Toast ---- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: grid;
  gap: var(--space-3);
  width: min(420px, calc(100vw - 32px));
}
@keyframes toast-in { from { opacity: 0; transform: translateY(calc(100% + 24px)); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(calc(100% + 24px)); } }
.toast {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--shape-corner-md);
  background: var(--color-ink);
  color: var(--text-inverse);
  box-shadow: var(--elevation-modal);
  animation: toast-in var(--motion-duration-page) var(--motion-easing-decelerate) both;
}
.toast.closing { animation: toast-out 220ms var(--motion-easing-decelerate) both; }
.toast-text { display: grid; gap: 2px; min-width: 0; }
.toast-title { margin: 0; color: var(--text-inverse); font-size: 0.875rem; font-weight: 700; }
.toast-message { margin: 0; color: rgba(255, 255, 255, 0.78); font-size: 0.875rem; font-weight: 400; }
.toast-dismiss {
  flex: 0 0 auto;
  padding: 0 var(--space-2);
  border: none;
  border-radius: var(--shape-corner-md);
  background: transparent;
  color: var(--color-primary);
  font-size: 0.875rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.toast.error .toast-dismiss { color: var(--danger); }

/* ---- Skeleton ---- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-tonal); border-radius: var(--shape-corner-lg); min-height: 14px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: var(--color-on-primary); opacity: 0; animation: skeleton-pulse 1.15s ease-in-out infinite; }
.skeleton-card { min-height: 104px; border-radius: var(--shape-corner-xl); }
.skeleton-map { min-height: 420px; border-radius: var(--shape-corner-2xl); }
.skeleton-row { height: 16px; margin-top: 10px; }
@keyframes skeleton-pulse { 0%, 100% { opacity: 0; } 50% { opacity: 0.5; } }

/* ---- Spinner ---- */
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--color-primary); display: inline-block; animation: spin 0.8s linear infinite; }
.btn-tonal .spinner, .btn-outline .spinner, .btn-text .spinner { border-color: var(--border-soft); border-top-color: var(--color-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Mobile ---- */
.mobile-header {
  display: none;
  position: fixed; inset: 0 0 auto 0;
  min-height: calc(var(--control-mobile) + var(--space-4) + env(safe-area-inset-top));
  z-index: var(--z-header);
  padding: var(--space-2) 14px;
  padding-top: calc(var(--space-2) + env(safe-area-inset-top));
  background: var(--surface-dark);
  color: var(--text-inverse);
  box-shadow: var(--elevation-shell);
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}
.mobile-subtitle { margin: 2px 0 0; color: var(--bottom-nav-text); font-size: var(--fs-subheadline); font-weight: 400; }

.mobile-bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  min-height: var(--mobile-nav-height);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--bottom-nav-surface);
  color: var(--text-inverse);
  box-shadow: var(--elevation-shell);
}

.mobile-nav-inner { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; max-width: 560px; margin: 0 auto; }

.mobile-nav-button {
  min-height: 48px;
  display: grid; place-items: center; gap: 3px;
  border-radius: var(--shape-corner-lg);
  background: transparent;
  color: var(--bottom-nav-text);
  font-size: var(--fs-label); font-weight: 800; text-align: center; letter-spacing: 0.03em;
}
.mobile-nav-button.active { background: var(--bottom-nav-active); color: var(--bottom-nav-active-text); }
.mobile-nav-button svg { width: 20px; height: 20px; }
.mobile-nav-button span { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Header ---- */
.desktop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: var(--space-5);
  background: transparent;
}

.header-context { display: flex; align-items: center; gap: var(--space-3); min-width: 0; flex: 1; }
.header-logo-img { display: none; }
.header-text-group { display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: 1; }
.header-title { margin: 0; color: var(--text-strong); font-size: var(--fs-page-title); line-height: var(--lh-display); font-weight: 700; letter-spacing: -0.03em; }
.header-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.header-action-cluster { display: flex; align-items: center; gap: var(--space-2); }
.header-profile-btn {
  min-height: var(--control-desktop);
  padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--shape-corner-pill);
  background: var(--color-coffee);
  color: var(--text-inverse);
  font-weight: 700; font-size: var(--fs-subheadline);
  border: 2px solid var(--border-strong);
  white-space: nowrap;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.header-profile-btn:hover { transform: scale(1.02); box-shadow: var(--elevation-card); }
.desktop-header .btn-small { min-height: var(--control-desktop); }
.header-sync-meta { color: var(--text-muted); font-size: var(--fs-label); font-weight: 650; line-height: 1.25; white-space: nowrap; text-align: right; }
.header-sync-meta strong { display: block; color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 700; margin-top: 2px; }
.account-menu { position: relative; }

.account-popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  z-index: 40; width: 260px;
  background: var(--surface-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-xl);
  box-shadow: var(--elevation-modal);
  padding: 12px;
}
.account-popover-name { margin: 0 0 10px; color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 700; }

/* ---- Page transition ---- */
.app-page { display: none; }
.app-page.active { display: block; animation: pageIn var(--motion-duration-page) var(--motion-easing-decelerate) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Maintenance Cycle form ---- */
/* Log Cycle cards: borderless, shadow-free surfaces */
/* Card titles — doctrine label style (--fs-label), sit above their cards */
.cycle-form-group {
  display: grid;
  gap: 10px;
  align-content: start;
}
.cycle-section-title {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Button group wraps only its buttons inside a form field (no full-width stretch) */
.cycle-section .btn-group { justify-self: start; }

.totals-unit { font-size: var(--fs-card-title); font-weight: 700; line-height: var(--lh-heading); color: inherit; margin-left: 3px; }

.people-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.people-group { min-width: 0; }
.participant-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.participant-row .inline-row { flex: 1; min-width: 120px; }

/* Fixed component checklist — table UI: tonal header row + divider rows */
.surface-main.cycle-section:has(.cycle-checklist) {
  padding: 0;
  overflow: hidden;
}
.cycle-checklist { display: grid; gap: 0; padding-bottom: 8px; }
.cycle-check-row { padding: 0 16px; }
.cycle-check-row + .cycle-check-row { border-top: 1px solid var(--divider); }
.select-all-row {
  background: var(--surface-tonal);
  border-bottom: 1px solid var(--divider);
  padding-top: 7px;
  padding-bottom: 7px;
}
.select-all-row + .cycle-check-row { border-top: none; }
.cycle-check-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
}
.cycle-check-toggle { min-height: 0; flex: 1; }
.cycle-check-name-wrap {
  display: grid;
  gap: 0;
  min-width: 0;
}
.cycle-check-name {
  color: var(--text-strong);
  font-size: var(--fs-subheadline);
  line-height: 1.25;
  font-weight: 600;
}
.cycle-check-sub {
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 400;
  line-height: 1.3;
}
.cycle-check-sub:empty { display: none; }
/* Per-row maintenance progress bar (between name and action input) */
.cycle-check-progress {
  flex: 0 1 120px;
  height: 6px;
  background: var(--surface-page);
  border-radius: var(--shape-corner-pill);
  overflow: hidden;
}
.cycle-check-progress-fill {
  display: block;
  height: 100%;
  border-radius: var(--shape-corner-pill);
}
.cycle-check-row.selected .cycle-check-name { font-weight: 700; }
.cycle-check-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--motion-duration-page) var(--motion-easing-decelerate), color var(--motion-duration-page) var(--motion-easing-decelerate);
}
.cycle-check-chevron:hover { background: var(--surface-nested); color: var(--text-strong); }
.cycle-check-chevron svg {
  width: 20px;
  height: 20px;
  transition: transform var(--motion-duration-page) var(--motion-easing-decelerate);
}
.cycle-check-chevron.open svg { transform: rotate(180deg); }
/* Accordion panel — same grid-row slide transition as the History page */
.cycle-check-panel {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  transition: grid-template-rows var(--motion-duration-page) var(--motion-easing-decelerate);
}
.cycle-check-panel > * { min-height: 0; }
.cycle-check-panel.open { grid-template-rows: 1fr; }
.cycle-check-panel-inner { padding: 0; }
.cycle-check-panel-inner > .form-grid { padding: 2px 0 16px; }
.item-notes { min-height: 64px; }
/* Role selector — checkbox cards per UI doctrine */
.roles-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}
.roles-group .checkbox-label {
  min-height: 48px;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--shape-corner-lg);
  background: var(--surface-card);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  letter-spacing: 0;
  color: var(--text);
  text-transform: none;
  cursor: pointer;
  transition: background var(--motion-duration-page) var(--motion-easing-decelerate);
}
.roles-group .checkbox-label:hover { background: var(--surface-tonal); }
.roles-group .checkbox-label:has(input:checked) {
  background: var(--surface-tonal);
  color: var(--color-coffee-dark);
  border-color: var(--color-primary);
}
.roles-group .checkbox-label input[type="checkbox"] {
  position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none;
}
.roles-group .checkbox-label::before {
  content: ""; width: 20px; height: 20px; flex: none;
  border: 2px solid var(--border-strong);
  border-radius: var(--shape-corner-sm);
  background: var(--surface-input);
  transition: background var(--motion-duration-page) var(--motion-easing-decelerate), border-color var(--motion-duration-page) var(--motion-easing-decelerate);
}
.roles-group .checkbox-label:has(input:checked)::before {
  background: var(--color-primary);
  border-color: var(--color-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 14px 14px; background-position: center; background-repeat: no-repeat;
}

.cycle-review {
  background: var(--surface-tonal);
  border: none;
  border-radius: var(--shape-corner-xl);
  padding: 16px;
}
.cycle-review-title { margin: 0 0 12px; color: var(--text-strong); font-size: var(--fs-card-title); line-height: var(--lh-heading); font-weight: 700; letter-spacing: -0.015em; }
/* Summary details — compact label/value rows per doctrine */
.cycle-summary-details {
  display: grid;
  gap: 0;
  margin-bottom: 10px;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}
.cycle-summary-detail {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
}
.cycle-summary-detail + .cycle-summary-detail {
  border-top: 1px solid var(--divider);
}
.cycle-summary-detail-label {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: var(--fs-label);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cycle-summary-detail-value {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
  color: var(--text-strong);
  font-size: var(--fs-subheadline);
  line-height: var(--lh-body);
  font-weight: 400;
  overflow-wrap: anywhere;
}
.cycle-summary-items {
  display: grid; gap: 0; margin-top: 12px;
  background: var(--surface-card);
  border: none;
  border-radius: var(--shape-corner-lg);
  padding: 6px 12px;
}
.cycle-summary-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 0;
}
.cycle-summary-item + .cycle-summary-item { border-top: 1px solid var(--divider); }
.cycle-summary-item-main { display: grid; gap: 1px; min-width: 0; }
.cycle-summary-item-main strong { color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cycle-summary-item-main span { color: var(--text-muted); font-size: var(--fs-label); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Log Cycle two-pane layout: left column = the stepwise sections, right 1/3 = sticky review card */
.cycle-form-layout {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  align-items: start;
}
.cycle-form-back {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: transparent; border: none; border-radius: var(--shape-corner-pill);
  color: var(--text-strong);
  cursor: pointer;
}
.cycle-form-back:hover { background: var(--surface-tonal); }
.cycle-form-back svg { width: 18px; height: 18px; }
.cycle-form-main {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  gap: 20px;
  align-content: start;
}
.cycle-form-layout > .cycle-review {
  grid-column: 2;
  grid-row: 1 / span 2;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
/* Stepwise section cards use the surface-card tone */
.surface-main.cycle-section {
  background: var(--surface-card);
  border: none;
}
.cycle-validation-error {
  margin: 12px 0 0; padding: 10px 12px;
  border-radius: var(--shape-corner-lg);
  background: var(--danger-bg); border: 1px solid var(--danger-border);
  color: var(--danger-text); font-size: var(--fs-label); font-weight: 650;
}

/* ---- Cycle history ---- */
.cycle-record { display: grid; gap: 8px; }
/* Title + status on one row; every other card row (chips, participants, actions, items) stacks below */
.cycle-record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.cycle-record-head > div { min-width: 0; }
.cycle-record .history-compact-chips { margin-top: 2px; }
.cycle-row { text-align: left; }
.cycle-item-line {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-nested);
  border-radius: var(--shape-corner-lg);
}
.cycle-item-line strong { color: var(--text-strong); font-size: var(--fs-subheadline); font-weight: 700; }
.cycle-item-line .record-meta { margin: 2px 0 0; }
/* Cycle items as a single card with inset dividers */
.record-list.cycle-items {
  display: grid; gap: 0;
  background: var(--surface-page);
  border: none;
  border-radius: var(--shape-corner-xl);
  padding: 0;
}
.record-list.cycle-items .cycle-item-line {
  padding: 10px 12px;
  background: transparent;
  border-radius: 0;
}
.record-list.cycle-items .cycle-item-line + .cycle-item-line { border-top: 1px solid var(--divider); }
/* Expanded-cycle footer actions (Edit / Delete) */
.cycle-items-inner {
  display: grid;
  gap: 0;
}
.cycle-items-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: 10px;
}
.cycle-items-actions .btn-danger {
  background: transparent;
  border-color: transparent;
  color: var(--danger);
}
.cycle-items-actions .btn-danger:hover {
  color: var(--danger-text);
  background: var(--danger-bg);
}
/* History accordion — slide expand/collapse with page-switch easing */
.cycle-items-panel {
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  margin-top: 0;
  transition: grid-template-rows var(--motion-duration-page) var(--motion-easing-decelerate), margin-top var(--motion-duration-page) var(--motion-easing-decelerate);
}
.cycle-items-panel > * {
  min-height: 0;
}
.cycle-items-panel.open {
  grid-template-rows: 1fr;
  margin-top: 12px;
}
.history-mini-chip.open { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }

/* ---- Overview ---- */

/* ---- Responsive ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  /* Essential state feedback keeps motion (Doctrine §12.6): spinners and toasts. */
  .spinner, .access-spinner, .btn-loading::before, .toast { animation-duration: 0.7s !important; transition-duration: var(--motion-duration-page) !important; }
}

@media (max-width: 920px) {
  :root {
    /* Expanded shape tier for touch friendliness */
    --shape-corner-sm: 8px;
    --shape-corner-md: 10px;
    --shape-corner-lg: 14px;
    --shape-corner-xl: 20px;
    --shape-corner-2xl: 28px;
  }
  .app-shell { display: block; padding-top: var(--mobile-header-height); }
  .access-title { font-size: clamp(2.25rem, 12vw, var(--fs-display)); }
  .sidebar, .desktop-header { display: none; }
  .main { padding: 16px 14px var(--mobile-nav-clearance); }
  .mobile-header { display: flex; }
  .mobile-header .header-logo-img { display: block; width: 32px; height: 38px; }
  .mobile-header .header-title { color: var(--text-inverse); font-size: clamp(1.25rem, 4.5vw, 1.75rem); letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mobile-header .account-menu { flex: 0 0 auto; }
  .mobile-header .header-profile-btn { min-height: var(--control-mobile); padding: 0 10px; font-size: var(--fs-label); }
  .mobile-header .account-popover { width: 220px; }
  .mobile-header .header-actions { gap: var(--space-2); }
  .mobile-header .btn-small { width: var(--control-mobile); height: var(--control-mobile); padding: 0; }
  .mobile-header .desktop-only-text { display: none; }
  .mobile-bottom-nav { display: block; }
  .mobile-new-log-btn {
    display: flex;
    position: fixed;
    right: 16px;
    bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 16px);
    z-index: calc(var(--z-nav) + 1);
    width: auto;
    height: 56px;
    padding: 0 20px;
    margin: 0;
    border-radius: var(--shape-corner-2xl);
    background: var(--surface-tonal);
    color: var(--color-coffee-dark);
    box-shadow: var(--elevation-card);
  }
  .page-wrap { display: grid; gap: var(--space-4); }
  .surface-main { padding: var(--space-4); border-radius: var(--shape-corner-xl); }
  .surface-card, .surface-tonal { padding: var(--space-4); }
  .surface-header {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: start; column-gap: var(--space-3); row-gap: 5px; margin-bottom: var(--space-4);
  }
  .surface-header>div:first-child { display: contents; }
  .surface-header .kicker { grid-column: 1; grid-row: 1; align-self: center; margin-bottom: 0; }
  .surface-header .section-title { grid-column: 1/-1; grid-row: 2; }
  .surface-header>div:first-child>p:not(.kicker) { grid-column: 1/-1; grid-row: 3; margin-top: 2px; }
  .surface-header>.status-chip, .surface-header>.inline-row, .surface-header>.btn { grid-column: 2; grid-row: 1; justify-self: end; align-self: center; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
  .dashboard-grid, .detail-grid, .page-grid-2, .form-grid, .link-grid { grid-template-columns: 1fr; }
  .dashboard-grid, .dashboard-grid > *, .page-wrap > * { min-width: 0; }
  .map-shell { min-width: 0; max-width: 100%; overflow-x: auto; }
  .map-shell .diagram { width: var(--diagram-frame-width); min-width: var(--diagram-frame-width); }
  .settings-table-wrap { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .settings-table { width: max-content; min-width: 680px; }
  .side-panel-stack { display: none; }
  .diagram { --diagram-height: 520px; --diagram-frame-width: 620.3px; }
  .btn { min-height: var(--control-mobile); font-size: 1rem; }
  .input, .select, .textarea { min-height: var(--control-mobile); }
  .calendar-top, .library-toolbar { grid-template-columns: 1fr; display: grid; align-items: stretch; }
  .calendar-grid { gap: 5px; }
  .day-cell { min-height: 72px; padding: 7px; border-radius: var(--shape-corner-md); }
  .event-pill { font-size: var(--fs-label); padding: 3px 5px; }
  .filter-chip { font-size: var(--fs-subheadline); }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-backdrop:has(.modal.confirm) { align-items: center; justify-content: center; }
  .modal { width: 100%; max-height: 86dvh; border-radius: var(--shape-corner-2xl) var(--shape-corner-2xl) 0 0; }
  .modal.sheet { animation: modal-slide-up var(--motion-duration-enter) var(--motion-easing-decelerate) both; }
  .modal.sheet.closing { animation: modal-slide-down var(--motion-duration-exit) var(--motion-easing-accelerate) both; }
  .modal.confirm { max-width: 380px; border-radius: var(--shape-corner-2xl); }
  .modal-actions .btn { padding: 12px 24px; }
  .history-toolbar, .history-detail-grid, .maintenance-main-grid, .maintenance-summary-grid { grid-template-columns: 1fr; }
  .cycle-form-layout { grid-template-columns: 1fr; }
  .cycle-form-main { grid-column: auto; }
  .cycle-form-layout > .cycle-review { grid-column: auto; grid-row: auto; position: static; }
  .maintenance-summary-grid .metric-card::before { display: none; }
  .quick-log-grid { grid-template-columns: 1fr; }
  .quick-log-grid .full { grid-column: auto; }
  .log-form-grid, .log-target-grid { grid-template-columns: 1fr; }
  .log-section { padding: 14px; border-radius: var(--shape-corner-lg); }
  .hours-basis-card.mobile-only { display: block; }
  .settings-row { grid-template-columns: 44px minmax(170px, 1fr) minmax(100px, 0.6fr) minmax(120px, 0.7fr); grid-auto-rows: auto; }
  .settings-row.header { display: none; }
  .settings-row.hour-rules { grid-template-columns: 44px minmax(170px, 1fr) minmax(110px, 0.6fr) minmax(120px, 0.7fr); grid-auto-rows: auto; }
  .settings-row.hour-rules.header { display: none; }
  .settings-toolbar { grid-template-columns: 1fr; }
  .people-grid { grid-template-columns: 1fr; }

  .participant-row .field { max-width: 100%; }
}

/* Inline actions input — mobile default hidden (accordion field is used);
   declared before the desktop media query so the media rule can re-show it */
.cycle-check-inline-actions { display: none; }

@media (min-width: 921px) {
  .hours-basis-card.mobile-only { display: none; }
  /* Cycle form checklist: accordion is mobile-only — compact inline rows on desktop */
  .cycle-check-inline-actions {
    display: block;
    flex: 0 1 320px;
    width: auto;
    height: var(--control-desktop);
    min-height: 0;
    margin: 0;
  }
  .cycle-check-panel .item-notes { display: none; }
  .cycle-check-panel { grid-template-rows: 1fr; overflow: visible; }
  .cycle-check-panel:not(:has(select)) { display: none; }
  .cycle-check-panel-inner > .form-grid { padding: 6px 0 0; }
  .cycle-check-chevron { display: none; }
  .cycle-check-row { padding: 5px 16px; }
  .select-all-row { padding-top: 12px; padding-bottom: 12px; }
}
@media (max-width: 1080px) {
  .settings-row.hour-rules { grid-template-columns: 44px minmax(170px, 1fr) minmax(110px, 0.6fr) minmax(120px, 0.7fr); }
  .settings-row.hour-rules.header { display: none; }
}



/* ---- Multi-trigger PMS details (Part Panel / Big Service) ---- */
.pms-rule-block {
  margin-top: var(--space-4);
}
.pms-rule-block + .pms-rule-block { margin-top: var(--space-3); }
.pms-effective-line {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 10px;
  color: var(--text-muted); font-size: var(--fs-label); font-weight: 650;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.pms-effective-line strong { color: var(--text-strong); font-size: var(--fs-subheadline); }
.pms-lead-note { margin-top: 8px; color: var(--text-muted); font-size: var(--fs-label); line-height: 1.45; }
.pms-manual-note {
  margin-top: 10px; padding: 10px 12px;
  background: var(--surface-nested); border-radius: var(--shape-corner-lg);
  color: var(--text-muted); font-size: var(--fs-label);
}
/* Calendar schedule line on the part panel */
.pms-schedule-line {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-subheadline);
  font-weight: 650;
}
.pms-rule-block + .pms-rule-block { margin-top: 16px; }
.big-service-card { background: var(--surface-card); border-radius: var(--shape-corner-xl); padding: 16px; }
.gcb-total { margin-top: 4px; font-size: 1.05rem; color: var(--text-strong); }
.gcb-total .totals-unit { font-size: var(--fs-label); }
.metric-sub { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.02em; }
