/* =====================================================================
   TOURISM OS - Application stylesheet.

   RIGHT TO LEFT IS BUILT IN, NOT BOLTED ON.

   Every directional rule uses a logical property: margin-inline instead of
   margin-left, inset-inline-start instead of left, padding-block instead of
   padding-top. Setting dir="rtl" on <html> then mirrors the whole interface
   with no second set of rules to keep in step, which is how Arabic stays
   correct as the product grows rather than drifting one screen at a time.

   The few things that must NOT mirror (a latin amount, a plate, a phone
   number, an email) are handled by .ltr and by unicode-bidi: plaintext on
   value cells, which is the fix Rental OS had to add screen by screen.

   2.0 interface: sections 1 to 16 are the design system (shell, controls,
   tables, overlays, command palette). Every screen specific section after
   them reads the same tokens, so a screen is restyled by the system rather
   than one by one.

   No build step. One file, served directly, versioned by content hash.
   ===================================================================== */

/* =====================================================================
   1. Reset and base
   ===================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--fs);
  line-height: var(--lh);
  letter-spacing: -0.006em;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss03";
}
/* Arabic reads better without latin tracking. */
[dir="rtl"] body { letter-spacing: 0; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: var(--lh-tight); color: var(--text); }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.022em; }
h2 { font-size: var(--fs-xl); letter-spacing: -0.018em; }
h3 { font-size: var(--fs-lg); letter-spacing: -0.012em; }
h4 { font-size: var(--fs-md); }
[dir="rtl"] :is(h1, h2, h3, h4) { letter-spacing: 0; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary-text); text-decoration: none; transition: color var(--fast); }
a:hover { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }

ul, ol { margin: 0; padding-inline-start: 1.25em; }

img, svg, video { max-width: 100%; height: auto; vertical-align: middle; }

hr { border: 0; border-block-start: 1px solid var(--border); margin: 1.5rem 0; }

code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }

kbd {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
  font-family: var(--font);
  font-size: 11px; font-weight: 500; line-height: 1;
  color: var(--text-3);
}

/* A visible focus ring on everything keyboard reachable. Removing it would
   make the product unusable for anyone who does not use a mouse. */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection { background: var(--primary-100); color: var(--text); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; inset-block-start: -100px; inset-inline-start: var(--gutter);
  z-index: 200; padding: 10px 16px; border-radius: var(--radius);
  background: var(--primary); color: var(--primary-contrast); font-weight: 600;
}
.skip-link:focus { inset-block-start: 12px; text-decoration: none; }

/* Thin, quiet scrollbars inside panels; the page keeps the platform one. */
.sidebar-nav, .gsearch-results, .dropdown-menu, .sheet-body, .modal-body, .picker-list {
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

/* ---- Directionality helpers ----
   Latin content inside an Arabic page: an amount, a plate, an email, a code.
   unicode-bidi isolate keeps the browser from reordering the surrounding
   sentence around it. */
.ltr { direction: ltr; unicode-bidi: isolate; }
.rtl { direction: rtl; unicode-bidi: isolate; }
.num, .mono, .amount {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}
td, th { unicode-bidi: plaintext; }
td.num, th.num, td .amount { unicode-bidi: isolate; }

.icon { width: 18px; height: 18px; flex: none; }
.icon-sm { width: 15px; height: 15px; }
.icon-md { width: 20px; height: 20px; }
.icon-lg { width: 24px; height: 24px; }
/* An icon that means a direction must flip in RTL; a neutral one must not. */
[dir="rtl"] .icon-flip { transform: scaleX(-1); }

/* ---- Page transitions ----
   Same origin navigations cross fade with a small lift (Chrome, Edge,
   Safari 18). The sidebar and the top bar are named, so they stay put while
   the page underneath changes: the application feels like one window. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
.topbar { view-transition-name: topbar; }
.bottom-nav { view-transition-name: bottomnav; }
::view-transition-group(*) { animation-duration: var(--normal); animation-timing-function: var(--ease-out); }
::view-transition-old(root) { animation: vt-out 110ms var(--ease-in) both; }
::view-transition-new(root) { animation: vt-in 200ms var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---- Navigation progress: a hairline at the top while a page loads ---- */
.nav-progress {
  position: fixed; inset-block-start: 0; inset-inline-start: 0; z-index: 300;
  height: 2px; width: 0; opacity: 0;
  background: var(--primary);
  box-shadow: 0 0 8px var(--ring);
  pointer-events: none;
}
.nav-progress.is-active { opacity: 1; width: 72%; transition: width 2.4s var(--ease-out), opacity var(--fast); }
.nav-progress.is-done { opacity: 0; width: 100%; transition: width var(--normal) var(--ease), opacity var(--slow) 120ms; }

/* =====================================================================
   2. Application shell
   ===================================================================== */

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

/* ---- Sidebar: a native source list ----
   A light column one step darker than the canvas, compact rows, the active
   row lifted onto a white chip. Sections group the modules by what the
   operator is doing (run the day, sell, manage the resources, the money). */
.sidebar {
  width: var(--sidebar-width);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-inline-end: 1px solid var(--sidebar-border);
  position: sticky;
  inset-block-start: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 40;
  transition: width var(--slow) var(--ease-out), transform var(--slow) var(--ease-out);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 14px;
  height: var(--topbar-height);
  flex: none;
}
.brand-mark {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 650; font-size: var(--fs-sm);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 1px 2px rgba(0, 0, 0, 0.12);
}
.brand-text { min-width: 0; flex: 1; }
.brand-name {
  color: var(--text); font-weight: 600; font-size: var(--fs-sm); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub {
  font-size: var(--fs-xs); color: var(--text-3); line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-collapse {
  width: 28px; height: 28px; color: var(--text-3);
}
.sidebar-collapse:hover { color: var(--text); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 10px 16px;
  overscroll-behavior: contain;
}

.nav-section + .nav-section { margin-block-start: 14px; }
.nav-section-label, .sidebar-section, .sidebar-group {
  display: block;
  padding: 0 10px 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: var(--text-muted);
  opacity: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-section { margin-block-start: 14px; }
.sidebar-group { margin-block-start: 14px; }
.sidebar-group:first-child { margin-block-start: 0; }

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.nav-item + .nav-item, .nav-children + .nav-item { margin-block-start: 1px; }
.nav-item .icon { width: 17px; height: 17px; color: var(--text-3); transition: color var(--fast); }
.nav-item:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-active); text-decoration: none; }
.nav-item:active { background: var(--surface-press); }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav-item.active .icon { color: var(--primary); }
:root[data-theme="dark"] .nav-item.active { box-shadow: none; }
:root[data-theme="dark"] .nav-item.active .icon { color: var(--primary-text); }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  min-width: 18px; padding: 0 5px;
  border-radius: var(--radius-full);
  background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: 600; text-align: center; line-height: 18px;
}
.nav-caret { width: 14px; height: 14px; transition: transform var(--normal) var(--ease-out); color: var(--text-muted) !important; }
.nav-item[aria-expanded="true"] .nav-caret { transform: rotate(180deg); }

/* Children expand with a height transition: a grid row from 0fr to 1fr. */
.nav-children {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--slow) var(--ease-out);
}
.nav-children.open { grid-template-rows: 1fr; }
.nav-children-inner {
  min-height: 0;
  overflow: hidden;
  position: relative;
  padding-inline-start: 28px;
}
.nav-children-inner::before {
  content: ""; position: absolute;
  inset-block: 4px; inset-inline-start: 18px;
  width: 1px; background: var(--border);
}
.nav-children.open .nav-children-inner { padding-block: 2px 4px; }
.nav-child {
  display: flex; align-items: center;
  height: 29px;
  padding: 0 10px;
  margin-block: 1px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: var(--fs-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background var(--fast), color var(--fast);
}
.nav-child:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-text-active); text-decoration: none; }
.nav-child.active { color: var(--sidebar-text-active); font-weight: 600; background: var(--sidebar-hover-bg); }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 14px;
  border-block-start: 1px solid var(--sidebar-border);
  font-size: var(--fs-xs); color: var(--text-muted);
  flex: none;
}

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 39;
  background: var(--overlay);
  opacity: 0; visibility: hidden;
  transition: opacity var(--slow) var(--ease-out), visibility 0s linear var(--slow);
}

/* ---- Collapsed sidebar (desktop): an icon rail ----
   html.sb-collapsed is set by boot.js before the first paint, from the
   choice the user made last time, so the page never jumps. */
@media (min-width: 900px) {
  html.sb-collapsed .sidebar { width: var(--sidebar-collapsed); }
  html.sb-collapsed .sidebar-brand { padding-inline: 16px; justify-content: center; }
  html.sb-collapsed .brand-text,
  html.sb-collapsed .nav-label,
  html.sb-collapsed .nav-caret,
  html.sb-collapsed .nav-badge,
  html.sb-collapsed .nav-children,
  html.sb-collapsed .sidebar-footer .brand-lockup,
  html.sb-collapsed .sidebar-footer .truncate { display: none; }
  html.sb-collapsed .sidebar-brand .sidebar-collapse { display: none; }
  html.sb-collapsed .sidebar-nav { padding-inline: 10px; }
  html.sb-collapsed .nav-section-label, html.sb-collapsed .sidebar-group, html.sb-collapsed .sidebar-section {
    height: 1px; padding: 0; margin: 10px 6px; background: var(--sidebar-border); color: transparent;
  }
  html.sb-collapsed .nav-section + .nav-section { margin-block-start: 0; }
  html.sb-collapsed .nav-item { justify-content: center; padding: 0; height: 36px; }
  html.sb-collapsed .sidebar-footer { justify-content: center; padding-inline: 0; }
  html.sb-collapsed .sidebar-footer .icon-btn .icon { transform: scaleX(-1); }
  [dir="rtl"].sb-collapsed .sidebar-footer .icon-btn .icon { transform: none; }
  .sidebar-footer .sb-expand { display: none; }
  html.sb-collapsed .sidebar-footer .sb-expand { display: grid; }
}

/* A floating label for the icon rail (assets/js/app.js places it). */
.tip {
  position: fixed; z-index: 250;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg);
  font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: fade-in var(--fast) var(--ease-out);
}

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

/* The top bar is translucent over the page. The blur lives on a pseudo
   element: backdrop-filter on the bar itself would make it the containing
   block of its fixed children, and the mobile menus are fixed. */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-height);
  padding-inline: 20px 16px;
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  isolation: isolate;
}
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  backdrop-filter: saturate(1.6) blur(14px);
  border-block-end: 1px solid transparent;
  transition: border-color var(--normal);
}
html.is-scrolled .topbar::before { border-block-end-color: var(--border); }

.topbar-context {
  display: flex; align-items: center; gap: 6px;
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.topbar-context a { color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.topbar-context a:hover { color: var(--text); text-decoration: none; }
.topbar-context .current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-context .sep { color: var(--text-muted); flex: none; }
.topbar-context .icon { color: var(--text-3); }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px;
  height: 34px;
  padding: 0 6px 0 11px;
  margin-inline-start: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-sm);
  transition: border-color var(--fast), box-shadow var(--fast), color var(--fast);
}
.topbar-search:hover { border-color: var(--border-2); color: var(--text-3); }
.topbar-search span { flex: 1; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-search kbd { flex: none; }

.topbar-actions { display: flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.topbar-search + .topbar-actions { margin-inline-start: 8px; }
.notif-list { max-height: min(60vh, 440px); overflow-y: auto; }
.notif-list .dropdown-item { align-items: flex-start; }
.notif-dot { width: 7px; height: 7px; margin-block-start: 7px; border-radius: 50%; background: var(--primary); flex: none; }
.notif-dot.is-read { background: transparent; }
.topbar-actions .btn-primary { margin-inline-end: 6px; }

.icon-btn {
  position: relative;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--text-3);
  cursor: pointer;
  transition: background var(--fast), color var(--fast), transform var(--fast);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn:active { background: var(--surface-press); transform: scale(0.96); }
.icon-btn[aria-expanded="true"] { background: var(--surface-press); color: var(--text); }
.icon-btn .count {
  position: absolute; inset-block-start: 3px; inset-inline-end: 3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--danger); color: #fff;
  box-shadow: 0 0 0 2px var(--bg);
  font-size: 10px; font-weight: 650; line-height: 16px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.user-menu-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 3px; border: 0; border-radius: var(--radius-full);
  background: transparent; cursor: pointer; color: var(--text);
  font-family: inherit; font-size: var(--fs-sm);
  margin-inline-start: 4px;
  transition: background var(--fast), box-shadow var(--fast);
}
.user-menu-btn:hover, .user-menu-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--surface-press); }
.avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--radius-full);
  background: linear-gradient(145deg, var(--primary-100), var(--primary-200));
  color: var(--primary-700);
  font-weight: 650; font-size: 11.5px; letter-spacing: 0.02em;
  overflow: hidden;
}
:root[data-theme="dark"] .avatar { color: var(--primary-text); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-menu-btn .name { display: block; font-weight: 600; line-height: 1.2; }
.user-menu-btn .role { display: block; font-size: var(--fs-xs); color: var(--text-3); line-height: 1.2; }
.dropdown-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; }
.dropdown-user .avatar { width: 34px; height: 34px; font-size: var(--fs-xs); }
.dropdown-user .who { min-width: 0; display: flex; flex-direction: column; }
.dropdown-user .who b { font-size: var(--fs); font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropdown-user .who span { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* A segmented control in a menu: the appearance (light, dark, system). */
.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  margin: 4px 6px 6px; padding: 2px;
  border-radius: var(--radius);
  background: var(--surface-3);
}
.theme-switch button {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  height: 28px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-3);
  font: inherit; font-size: var(--fs-xs); font-weight: 500; cursor: pointer;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-switch .icon { width: 14px; height: 14px; }

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: 12px 32px 56px;
}
.content-fluid { max-width: none; }

/* ---- Support session banner ---- */
.support-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px;
  background: var(--accent);
  color: #fff;
  font-size: var(--fs-sm); font-weight: 500;
}
.support-banner a { color: #fff; text-decoration: underline; margin-inline-start: auto; font-weight: 600; }
.support-banner form { margin-inline-start: auto; }
.main > .announcement { margin: 12px 32px 0; }

/* ---- Mobile bottom bar ---- */
.bottom-nav { display: none; }

/* =====================================================================
   3. Page furniture
   ===================================================================== */

.page-header {
  display: flex;
  align-items: flex-end;
  gap: 12px 16px;
  flex-wrap: wrap;
  margin-block: 8px 24px;
}
.page-header .titles { flex: 1; min-width: 220px; }
.page-header h1 { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.page-header h1 .badge { margin: 0 !important; vertical-align: middle !important; }
.page-header .lead { margin: 6px 0 0; color: var(--text-3); font-size: var(--fs); max-width: 72ch; }
.page-header .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* In-page breadcrumbs, used where the top bar does not carry them. */
.breadcrumbs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-block-end: 8px;
  font-size: var(--fs-sm); color: var(--text-3);
}
.breadcrumbs a { color: var(--text-3); }
.breadcrumbs a:hover { color: var(--text); text-decoration: none; }
.breadcrumbs .sep { opacity: 0.5; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  min-width: 0;
}
.card + .card { margin-block-start: 16px; }
a.card { color: inherit; transition: border-color var(--fast), box-shadow var(--fast); }
a.card:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.card-header {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  min-height: 52px;
  padding: 12px 18px;
  border-block-end: 1px solid var(--border);
}
.card-header h2, .card-header h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em;
}
.card-header h2 .icon, .card-header h3 .icon { color: var(--text-3); width: 16px; height: 16px; }
.card-header .actions { margin-inline-start: auto; display: flex; gap: 8px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-footer {
  padding: 12px 18px;
  border-block-start: 1px solid var(--border);
  background: var(--surface-2);
  border-end-start-radius: var(--radius-lg);
  border-end-end-radius: var(--radius-lg);
}
.card-hint { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--text-3); }

.section-title {
  margin-block: 28px 10px;
  font-size: var(--fs-sm); font-weight: 600;
  text-transform: none; letter-spacing: 0;
  color: var(--text-3);
}
.section-title:first-child { margin-block-start: 0; }

/* =====================================================================
   4. Buttons
   ===================================================================== */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 550;
  line-height: 1;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background var(--fast), border-color var(--fast), color var(--fast),
              box-shadow var(--fast), transform 80ms var(--ease);
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.975); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--btn-spin, var(--text-3)) transparent var(--btn-spin, var(--text-3)) var(--btn-spin, var(--text-3));
  animation: spin 0.7s linear infinite;
}
.btn-primary[aria-busy="true"], .btn-danger[aria-busy="true"] { --btn-spin: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary {
  background: var(--primary); border-color: transparent; color: var(--primary-contrast);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(15, 23, 20, 0.18), 0 0 0 1px var(--primary-600);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }

.btn-secondary {
  background: var(--surface); border-color: var(--border-2); color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
:root[data-theme="dark"] .btn-secondary { background: var(--surface-3); }
:root[data-theme="dark"] .btn-secondary:hover:not(:disabled) { background: color-mix(in srgb, var(--surface-3) 80%, #fff); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: var(--danger); border-color: transparent; color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(15, 23, 20, 0.18);
}
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }

.btn-danger-ghost { background: transparent; color: var(--danger-text); border-color: transparent; }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-bg); }

.btn-sm { height: 30px; min-height: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--radius-sm); }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-lg { height: 42px; min-height: 42px; padding: 0 20px; font-size: var(--fs); }
.btn-block { width: 100%; }
/* A button whose label wraps (long translations) grows instead of clipping. */
.btn-wrap, .btn-block { height: auto; padding-block: 8px; white-space: normal; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* =====================================================================
   5. Forms: native settings screens
   ===================================================================== */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px 16px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label {
  font-size: var(--fs-sm);
  font-weight: 550;
  color: var(--text-2);
}
.field .hint { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.45; }
.field .error {
  display: flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); color: var(--danger-text); font-weight: 500;
  animation: fade-in var(--normal) var(--ease-out);
}
.required-mark { color: var(--danger); margin-inline-start: 2px; }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs);
  line-height: 1.4;
  min-height: 36px;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:hover:not(:disabled):not(:focus), .select:hover:not(:disabled):not(:focus), .textarea:hover:not(:disabled):not(:focus) {
  border-color: var(--border-strong);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary) 70%, var(--surface));
  box-shadow: 0 0 0 3px var(--ring);
}
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] {
  background: var(--surface-3); color: var(--text-3); cursor: not-allowed; box-shadow: none;
}
.input[readonly] { cursor: default; }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input.is-invalid:focus, .select.is-invalid:focus, .textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.textarea { height: auto; min-height: 96px; padding-block: 9px; resize: vertical; line-height: var(--lh); }
input[type="file"].input { height: auto; padding: 6px; }
input[type="file"]::file-selector-button {
  margin-inline-end: 10px; padding: 5px 10px;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
input[type="date"].input, input[type="time"].input, input[type="datetime-local"].input { padding-inline-end: 8px; }
:root[data-theme="dark"] :is(.input, .select, .textarea) { background: var(--surface-2); }
:root[data-theme="dark"] ::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* The select arrow is drawn on the inline end, so it moves in RTL. */
.select {
  appearance: none;
  padding-inline-end: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23788280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5-5 5 5M7 14l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 15px;
  cursor: pointer;
}
[dir="rtl"] .select { background-position: left 9px center; }
select[multiple].select { height: auto; padding-block: 6px; background-image: none; padding-inline-end: 11px; }

/* Latin-only inputs keep their direction whatever the page language. */
input[type="email"], input[type="url"], input[type="tel"],
input[type="number"], input[type="password"], .input-ltr {
  direction: ltr;
  text-align: start;
}
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"],
[dir="rtl"] input[type="tel"], [dir="rtl"] input[type="password"],
[dir="rtl"] .input-ltr { text-align: right; }

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group .input { flex: 1; }

/* Checkboxes and radios drawn by the system, not the browser default:
   a 16px rounded square, the check stroked in white on the primary. */
input[type="checkbox"], input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px; height: 17px; flex: none; margin: 0;
  display: inline-grid; place-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  vertical-align: middle;
  transition: background var(--fast), border-color var(--fast), box-shadow var(--fast);
}
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]::before {
  content: ""; width: 10px; height: 10px;
  background: #fff;
  clip-path: polygon(14% 44%, 0 58%, 38% 96%, 100% 22%, 86% 8%, 38% 68%);
  transform: scale(0); transition: transform var(--fast) var(--ease-out);
}
input[type="radio"]::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff;
  transform: scale(0); transition: transform var(--fast) var(--ease-out);
}
input[type="checkbox"]:checked, input[type="radio"]:checked,
input[type="checkbox"]:indeterminate {
  background: var(--primary); border-color: var(--primary);
}
input[type="checkbox"]:checked::before, input[type="radio"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate::before { clip-path: none; height: 2px; transform: scale(1); }
input[type="checkbox"]:hover:not(:disabled):not(:checked), input[type="radio"]:hover:not(:disabled):not(:checked) { border-color: var(--primary); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: 0.5; cursor: not-allowed; }
:root[data-theme="dark"] :is(input[type="checkbox"], input[type="radio"]):not(:checked) { background: var(--surface-2); }

.checkbox, .radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  font-size: var(--fs);
  min-height: 36px;
}
.checkbox input, .radio input { margin-block-start: 2px; }
.checkbox .text, .radio .text { flex: 1; min-width: 0; }
.checkbox .sub, .radio .sub { display: block; font-size: var(--fs-sm); color: var(--text-3); }
.checkbox input:disabled, .radio input:disabled { cursor: not-allowed; }
.checkbox:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; font-size: var(--fs-md); }

.color-input { width: 52px; height: 36px; padding: 3px; cursor: pointer; }

/* A form laid out as a settings list: grouped rows, the label on the start
   side, the control on the end side (used by .settings-group wrappers). */
.settings-group {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.settings-row {
  display: grid; grid-template-columns: minmax(180px, 34%) minmax(0, 1fr); gap: 8px 24px;
  align-items: center; padding: 14px 18px;
}
.settings-row + .settings-row { border-block-start: 1px solid var(--border); }
.settings-row .label { color: var(--text); }
.settings-row .hint { display: block; margin-block-start: 2px; font-size: var(--fs-xs); color: var(--text-3); font-weight: 400; }

/* =====================================================================
   6. Tables
   ===================================================================== */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: inherit; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs); }
.table th, .table td {
  padding: 11px 14px;
  text-align: start;
  border-block-end: 1px solid var(--border);
  vertical-align: middle;
}
.table th:first-child, .table td:first-child { padding-inline-start: 18px; }
.table th:last-child, .table td:last-child { padding-inline-end: 18px; }
.table thead th {
  position: sticky; inset-block-start: 0; z-index: 1;
  height: 38px;
  padding-block: 8px;
  background: var(--surface-2);
  font-size: var(--fs-xs); font-weight: 550; color: var(--text-3);
  text-transform: none; letter-spacing: 0.01em;
  white-space: nowrap;
}
.card > .table-wrap:first-child .table thead th:first-child,
.card > .table:first-child thead th:first-child { border-start-start-radius: var(--radius-lg); }
.card > .table-wrap:first-child .table thead th:last-child,
.card > .table:first-child thead th:last-child { border-start-end-radius: var(--radius-lg); }
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-3) 55%, var(--surface)); }
.table tbody tr.is-selected, .table tbody tr:has(> td > input[type="checkbox"]:checked) { background: var(--primary-50); }
.table tbody tr:last-child td { border-block-end: 0; }
.table td.num, .table th.num { text-align: end; }
.table td.actions, .table th.actions { text-align: end; white-space: nowrap; width: 1%; }
.table td.actions .btn-ghost { color: var(--text-3); }
.table tbody tr:hover td.actions .btn-ghost { color: var(--text); }
.table a.row-link { color: var(--text); font-weight: 600; }
.table a.row-link:hover { color: var(--primary-text); text-decoration: none; }
.table .sub, .table .sub-block { color: var(--text-3); }

.table-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; }
.table-sort:hover { color: var(--text); text-decoration: none; }

/* =====================================================================
   7. Badges, status, alerts, empty states
   ===================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs); font-weight: 550;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0;
  background: var(--c-gray-bg); color: var(--c-gray-text);
}
.badge .icon { width: 12px; height: 12px; }
.badge-gray   { background: var(--c-gray-bg);   color: var(--c-gray-text); }
.badge-slate  { background: var(--c-slate-bg);  color: var(--c-slate-text); }
.badge-blue   { background: var(--c-blue-bg);   color: var(--c-blue-text); }
.badge-indigo { background: var(--c-indigo-bg); color: var(--c-indigo-text); }
.badge-purple { background: var(--c-purple-bg); color: var(--c-purple-text); }
.badge-pink   { background: var(--c-pink-bg);   color: var(--c-pink-text); }
.badge-red    { background: var(--c-red-bg);    color: var(--c-red-text); }
.badge-amber  { background: var(--c-amber-bg);  color: var(--c-amber-text); }
.badge-green  { background: var(--c-green-bg);  color: var(--c-green-text); }
.badge-teal   { background: var(--c-teal-bg);   color: var(--c-teal-text); }

/* The unified status: a neutral chip with a coloured dot. Status badges
   (status_badge()) read the colour only through the dot and a tinted text,
   so a table of twenty statuses stays calm and still scans by colour. */
.badge-status {
  gap: 6px;
  padding-inline: 7px 8px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-2);
}
.badge-status::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--dot, var(--c-gray));
}
.badge-status.badge-gray   { --dot: var(--c-gray); }
.badge-status.badge-slate  { --dot: var(--c-slate); }
.badge-status.badge-blue   { --dot: var(--c-blue); }
.badge-status.badge-indigo { --dot: var(--c-indigo); }
.badge-status.badge-purple { --dot: var(--c-purple); }
.badge-status.badge-pink   { --dot: var(--c-pink); }
.badge-status.badge-red    { --dot: var(--c-red); color: var(--c-red-text); }
.badge-status.badge-amber  { --dot: var(--c-amber); }
.badge-status.badge-green  { --dot: var(--c-green); }
.badge-status.badge-teal   { --dot: var(--c-teal); }
:is(.badge-status, .badge-status.badge-gray, .badge-status.badge-slate, .badge-status.badge-blue,
    .badge-status.badge-indigo, .badge-status.badge-purple, .badge-status.badge-pink,
    .badge-status.badge-red, .badge-status.badge-amber, .badge-status.badge-green,
    .badge-status.badge-teal) { background: var(--surface); }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--fs);
  margin-block-end: 16px;
}
.alert > .icon { margin-block-start: 2px; }
.alert-body { flex: 1; min-width: 0; }
.alert strong { display: block; margin-block-end: 2px; font-weight: 600; }
.alert ul { margin: 6px 0 0; }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 24%, transparent); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: color-mix(in srgb, var(--danger) 22%, transparent); }

.notice {
  padding: 11px 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.notice-accent { border-inline-start: 3px solid var(--accent); }

/* An empty state says what to do next. It is never a blank card: a quiet
   icon in a soft tile, one line of explanation, one action. */
.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 48px 24px; text-align: center;
}
.empty > .icon-lg {
  width: 44px; height: 44px; padding: 11px; margin-block-end: 6px;
  border-radius: 12px;
  background: var(--surface-3);
  color: var(--text-3);
  box-shadow: inset 0 0 0 1px var(--border);
}
.empty h3 { font-size: var(--fs-md); font-weight: 600; }
.empty p { max-width: 400px; color: var(--text-3); font-size: var(--fs-sm); margin: 0; }
.empty .mt-2 { margin-block-start: 10px; }

/* Skeleton rows while something loads, instead of a spinner. */
.skeleton {
  display: block; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-3) 0%, color-mix(in srgb, var(--surface-3) 40%, var(--surface)) 50%, var(--surface-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton-row { display: flex; flex-direction: column; gap: 7px; padding: 11px 12px; }
.skeleton-row .skeleton:last-child { width: 45%; height: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* =====================================================================
   8. Dropdowns, modals, dialogs, toasts
   ===================================================================== */

.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  inset-block-start: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: 50;
  min-width: 220px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 5px;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  transform-origin: top right;
}
[dir="rtl"] .dropdown-menu { transform-origin: top left; }
:root[data-theme="dark"] .dropdown-menu { background: var(--surface-2); }
.dropdown-menu.open, details.dropdown[open] > .dropdown-menu {
  display: block;
  animation: pop-in 140ms var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: scale(0.96) translateY(-4px); } }
.dropdown-header {
  padding: 8px 10px 6px;
  font-size: var(--fs-xs); color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis;
}
.dropdown-label {
  padding: 8px 10px 4px;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
}
.dropdown-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font-family: inherit; font-size: var(--fs-sm); text-align: start;
  cursor: pointer;
  transition: background 80ms;
}
.dropdown-item .icon { color: var(--text-3); width: 16px; height: 16px; }
.dropdown-item:hover, .dropdown-item:focus-visible { background: var(--surface-hover); text-decoration: none; outline: none; }
.dropdown-item:active { background: var(--surface-press); }
.dropdown-item.danger, .dropdown-item.danger .icon { color: var(--danger-text); }
.dropdown-item.danger:hover { background: var(--danger-bg); }
.dropdown-item .shortcut { margin-inline-start: auto; color: var(--text-muted); font-size: var(--fs-xs); }
.dropdown-divider { height: 1px; margin: 5px -5px; background: var(--border); }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: center; justify-content: center;
  padding: var(--gutter);
  background: var(--overlay);
}
.modal-backdrop.open { display: flex; animation: fade-in var(--normal) var(--ease-out); }
.modal {
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: dialog-in var(--slow) var(--ease-out);
}
@keyframes dialog-in { from { opacity: 0; transform: scale(0.97) translateY(6px); } }
.modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-block-end: 1px solid var(--border);
}
.modal-header h2 { flex: 1; font-size: var(--fs-md); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-block-start: 1px solid var(--border); background: var(--surface-2);
}

/* ---- The confirmation dialog (App.confirm, data-confirm) ----
   Replaces window.confirm: says what will happen, the destructive button
   in red, Enter confirms, Escape cancels. */
dialog.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0; border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.confirm-dialog[open] { animation: dialog-in var(--slow) var(--ease-out); }
dialog.confirm-dialog::backdrop { background: var(--overlay); animation: fade-in var(--normal); }
.confirm-body { display: flex; gap: 14px; padding: 22px 22px 18px; }
.confirm-icon {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--warning-bg); color: var(--warning-text);
}
.confirm-dialog.is-danger .confirm-icon { background: var(--danger-bg); color: var(--danger-text); }
.confirm-title { margin: 6px 0 0; font-size: var(--fs-md); font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.confirm-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; background: var(--surface-2); border-block-start: 1px solid var(--border);
}

.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  z-index: 200;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  max-width: calc(100vw - 40px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  width: 360px; max-width: 100%;
  padding: 11px 8px 11px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in 260ms var(--ease-out);
}
:root[data-theme="dark"] .toast { background: var(--surface-3); }
.toast.is-leaving { animation: toast-out 180ms var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(0.98); } }
.toast-icon {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; margin-block-start: 0;
  background: var(--info); color: #fff;
}
.toast-icon .icon { width: 12px; height: 12px; stroke-width: 2.6; }
.toast-success .toast-icon { background: var(--success); }
.toast-error .toast-icon, .toast-danger .toast-icon { background: var(--danger); }
.toast-warning .toast-icon { background: var(--warning); }
.toast-text { flex: 1; min-width: 0; padding-block-start: 1px; overflow-wrap: anywhere; }
.toast .close { margin-inline-start: auto; width: 24px; height: 24px; margin-block: -2px; }

/* =====================================================================
   9. Command palette (global search)
   ===================================================================== */

.gsearch {
  display: none;
  position: fixed; inset: 0; z-index: 150;
  padding: 12vh var(--gutter) var(--gutter);
  background: var(--overlay);
}
.gsearch.open { display: block; animation: fade-in var(--normal) var(--ease-out); }
.gsearch-box {
  max-width: 640px; margin-inline: auto;
  display: flex; flex-direction: column;
  max-height: min(76vh, 620px);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  overflow: hidden;
  animation: dialog-in var(--normal) var(--ease-out);
}
:root[data-theme="dark"] .gsearch-box { background: var(--surface-2); }
.gsearch-input {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 54px; flex: none;
  border-block-end: 1px solid var(--border);
}
.gsearch-input > .icon { color: var(--text-3); }
.gsearch-input input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent;
  font-family: inherit; font-size: 16px; color: var(--text); letter-spacing: -0.01em;
}
.gsearch-input input::placeholder { color: var(--text-muted); }
.gsearch-spin {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--border-2); border-top-color: var(--text-3);
  animation: spin 0.7s linear infinite; display: none;
}
.gsearch.is-loading .gsearch-spin { display: block; }
.gsearch-results { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.gsearch-group-title {
  padding: 10px 10px 4px;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  text-transform: none; letter-spacing: 0.01em;
}
.gsearch-result {
  display: flex; align-items: center; gap: 11px;
  min-height: 40px;
  padding: 6px 10px; border-radius: var(--radius); color: var(--text);
  scroll-margin: 6px;
}
.gsearch-result:hover { text-decoration: none; }
.gsearch-result.active { background: var(--surface-hover); }
:root[data-theme="dark"] .gsearch-result.active { background: rgba(255, 255, 255, 0.07); }
.gsearch-result .gs-icon {
  flex: none; width: 26px; height: 26px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3);
  box-shadow: inset 0 0 0 1px var(--border);
}
.gsearch-result .gs-icon .icon { width: 15px; height: 15px; }
.gsearch-result.active .gs-icon { background: var(--primary); color: #fff; box-shadow: none; }
.gsearch-result .grow { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.gsearch-result .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-result .subtitle { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gsearch-result .gs-hint { margin-inline-start: auto; flex: none; font-size: var(--fs-xs); color: var(--text-muted); opacity: 0; }
.gsearch-result.active .gs-hint { opacity: 1; }
.gsearch-result mark { background: none; color: var(--primary-text); font-weight: 650; }
.gsearch-empty { padding: 32px 20px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.gsearch-foot {
  display: flex; align-items: center; gap: 14px; flex: none;
  padding: 8px 14px;
  border-block-start: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-xs); color: var(--text-3);
}
:root[data-theme="dark"] .gsearch-foot { background: var(--surface-3); }
.gsearch-foot span { display: inline-flex; align-items: center; gap: 5px; }
.gsearch-foot kbd { min-width: 18px; height: 18px; font-size: 10.5px; }

/* =====================================================================
   10. Dashboard
   ===================================================================== */

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  grid-auto-flow: dense;
  gap: 16px;
}
.widget { grid-column: span 1; min-width: 0; display: flex; flex-direction: column; }
.widget + .widget { margin-block-start: 0; }
.widget-wide { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .widget-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget-wide { grid-column: span 2; }
}
@media (min-width: 1200px) {
  .widget-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1500px) {
  .widget-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.stat { display: flex; flex-direction: column; gap: 3px; }
.stat-label { font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.stat-value { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -0.025em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: var(--fs-sm); color: var(--text-3); }

.progress {
  height: 6px; border-radius: var(--radius-full);
  background: var(--surface-3); overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width var(--slow) var(--ease-out);
}

.checklist { display: flex; flex-direction: column; gap: 1px; }
.checklist-item {
  display: flex; align-items: center; gap: 11px;
  min-height: 38px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-size: var(--fs-sm);
}
.checklist-item:hover { background: var(--surface-hover); text-decoration: none; }
.checklist-mark {
  width: 18px; height: 18px; flex: none;
  display: grid; place-items: center;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-full);
  color: var(--text-muted);
}
.checklist-item.done .checklist-mark {
  border-color: var(--success); background: var(--success); color: #fff;
}
.checklist-item.done .checklist-text { color: var(--text-3); }
.checklist-item.later { opacity: 0.6; }
.checklist-text { flex: 1; min-width: 0; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  position: relative;
  display: flex; gap: 12px;
  padding-block: 10px;
}
.timeline-item:not(:last-child)::after {
  content: ""; position: absolute;
  inset-inline-start: 3.5px; inset-block: 24px -2px;
  width: 1px; background: var(--border);
}
.timeline-dot {
  width: 8px; height: 8px; flex: none; margin-block-start: 7px;
  border-radius: var(--radius-full); background: var(--border-strong);
  box-shadow: 0 0 0 3px var(--surface);
}
.timeline-body { flex: 1; min-width: 0; }
.timeline-label { font-size: var(--fs-sm); }
.timeline-meta { font-size: var(--fs-xs); color: var(--text-3); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--fs); }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; unicode-bidi: plaintext; }

/* =====================================================================
   11. Auth and centred pages
   ===================================================================== */

.auth { display: flex; min-height: 100vh; background: var(--bg); }
.auth-panel {
  flex: 1;
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
  padding: 56px;
  margin: 12px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 90% at 0% 0%, color-mix(in srgb, var(--primary) 70%, #fff) 0%, transparent 55%),
    linear-gradient(160deg, var(--primary-700), color-mix(in srgb, var(--primary-700) 70%, #000));
  color: #fff;
  position: relative;
  overflow: hidden;
}
.auth-panel h2 { font-size: var(--fs-3xl); max-width: 460px; color: #fff; letter-spacing: -0.03em; line-height: 1.15; }
.auth-panel p { color: rgba(255, 255, 255, 0.82); max-width: 440px; font-size: var(--fs-md); }
.auth-points { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 12px; max-width: 440px; }
.auth-points li { display: flex; align-items: flex-start; gap: 10px; color: rgba(255, 255, 255, 0.9); }
.auth-points .icon { margin-block-start: 2px; flex: none; opacity: 0.85; }

.auth-form {
  flex: none;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  padding: 40px 28px;
  margin-inline: auto;
}
.auth-form .brand { display: flex; align-items: center; gap: 10px; }
.auth-form h1 { font-size: var(--fs-2xl); }
.auth-form .lead { color: var(--text-3); margin: 6px 0 0; }
.auth-form form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn-primary.btn-block, .auth-form .btn-lg { height: 42px; }
.auth-footer { font-size: var(--fs-sm); color: var(--text-3); text-align: center; }

@media (min-width: 900px) {
  .auth-panel { display: flex; }
  .auth-form { margin-inline: 0; padding-inline: 56px; box-shadow: none; }
}

.centred-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}
.centred-card {
  width: 100%; max-width: 520px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* ---- Two factor ---- */
.code-input {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  letter-spacing: 0.35em;
  text-align: center;
  direction: ltr;
  padding-inline: 12px;
  height: 56px;
  min-height: 56px;
}
.qr-box {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}
.qr-box svg { border-radius: var(--radius-sm); background: #fff; padding: 6px; }
.secret-key {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  letter-spacing: 0.08em;
  direction: ltr;
  padding: 10px 14px;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  background: var(--surface);
  word-break: break-all;
  text-align: center;
}
.recovery-codes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 18px;
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.recovery-codes code {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--fs-md);
  letter-spacing: 0.05em;
  text-align: center;
  direction: ltr;
}

/* =====================================================================
   12. Permission matrix
   ===================================================================== */

.matrix { display: flex; flex-direction: column; gap: 6px; }
.matrix-module {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.matrix-module > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px;
  background: var(--surface-2);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.matrix-module > summary::-webkit-details-marker { display: none; }
.matrix-module > summary .count { margin-inline-start: auto; font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; }
.matrix-permissions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 2px 16px;
  padding: 10px 15px 14px;
}
.matrix-permissions .checkbox { min-height: 34px; padding: 4px 0; }

/* =====================================================================
   13. Capability screen
   ===================================================================== */

.capability-group { margin-block-end: 22px; }
.capability-list { display: flex; flex-direction: column; gap: 1px; }
.capability-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--fs);
}
.capability-row:nth-child(odd) { background: var(--surface-2); }
.capability-row .cap-name { flex: 1; min-width: 0; font-weight: 500; }
.capability-row .cap-key {
  font-family: var(--font-mono); font-size: var(--fs-xs);
  color: var(--text-muted); direction: ltr; unicode-bidi: isolate;
}
.capability-row .cap-reason { font-size: var(--fs-sm); color: var(--text-3); text-align: end; min-width: 0; }
.capability-row.is-off { opacity: 0.62; }

/* =====================================================================
   14. Pagination and filters
   ===================================================================== */

/* The filter bar is part of the list, not a form above it: one quiet row
   on a raised surface. */
.filters {
  display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.card > .filters, .card-body > .filters { border: 0; border-block-end: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 12px 18px; }
.filters .field { min-width: 160px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters .btn-group { margin-inline-start: auto; gap: 6px; }
.filters .checkbox { padding-inline: 4px; }
.filters > .input[type="search"] {
  padding-inline-start: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23788280' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: left 11px center;
}
[dir="rtl"] .filters > .input[type="search"] { background-position: right 11px center; }

.pagination {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 4px;
  font-size: var(--fs-sm); color: var(--text-3);
}
.card .pagination { padding-inline: 18px; border-block-start: 1px solid var(--border); }
.pagination .pages { display: flex; gap: 2px; margin-inline-start: auto; }
.pagination .page {
  display: grid; place-items: center;
  min-width: 32px; height: 32px; padding: 0 9px;
  border: 0; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: background var(--fast), color var(--fast);
}
.pagination .page:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.pagination .page.active { background: var(--surface); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.pagination .page.disabled { opacity: 0.35; pointer-events: none; }

/* =====================================================================
   15. Utilities
   ===================================================================== */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ms-auto { margin-inline-start: auto; }
.me-auto { margin-inline-end: auto; }
.mt-1 { margin-block-start: 4px; } .mt-2 { margin-block-start: 8px; }
.mt-3 { margin-block-start: 12px; } .mt-4 { margin-block-start: 16px; }
.mt-6 { margin-block-start: 24px; }
.mb-2 { margin-block-end: 8px; } .mb-3 { margin-block-end: 12px; } .mb-4 { margin-block-end: 16px; }
.text-sm { font-size: var(--fs-sm); } .text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.muted { color: var(--text-3); }
.muted-2 { color: var(--text-muted); }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.text-end { text-align: end; } .text-center { text-align: center; }
.text-danger { color: var(--danger-text); }
.text-success { color: var(--success-text); }
.text-warning { color: var(--warning-text); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hidden { display: none !important; }
.block { display: block; }
.divider { height: 1px; background: var(--border); margin-block: 16px; }

/* Viewport visibility. The breakpoint matches the shell breakpoint below,
   so an element hidden on mobile is hidden exactly when the drawer appears. */
@media (max-width: 899px) { .hidden-mobile { display: none !important; } }
@media (min-width: 900px) { .hidden-desktop { display: none !important; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font-size: var(--fs-sm);
}

/* =====================================================================
   16. Responsive
   =====================================================================
   Mobile is not a narrower desktop. Below 900px the sidebar becomes a
   drawer, a bottom tab bar carries the modules the role opens most, menus
   become bottom sheets within reach of the thumb, tables become record
   cards, and every control grows to a 44px touch target.
   ===================================================================== */

@media (max-width: 1199px) {
  .content { padding-inline: 24px; }
  .main > .announcement { margin-inline: 24px; }
  .topbar-search { width: 220px; }
}

@media (max-width: 899px) {
  :root { --topbar-height: 54px; }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    border-inline-end: 0;
    view-transition-name: none;
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop.open { opacity: 1; visibility: visible; transition: opacity var(--slow) var(--ease-out); }
  .sidebar-collapse { display: none; }
  .nav-item { height: 40px; font-size: var(--fs-md); }
  .nav-child { height: 38px; font-size: var(--fs); }

  .content { padding: 4px var(--gutter) calc(var(--bottomnav-height) + 28px + env(safe-area-inset-bottom, 0px)); }
  .main > .announcement { margin-inline: var(--gutter); }

  .topbar { padding-inline: 8px 10px; gap: 4px; }
  .topbar-context { flex: 1; font-size: var(--fs); }
  .topbar-context .crumb-parent, .topbar-context .sep { display: none; }
  .topbar-context .current { font-size: var(--fs-md); }

  /* Bottom tab bar: translucent, safe area aware, the active tab tinted. */
  .bottom-nav {
    display: flex;
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 35;
    height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px));
    padding: 4px 6px env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    backdrop-filter: saturate(1.6) blur(16px);
    border-block-start: 1px solid var(--border);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    min-width: 0;
    border: 0; background: transparent;
    color: var(--text-3);
    font-family: inherit; font-size: 10.5px; font-weight: 550; letter-spacing: 0;
    text-decoration: none; cursor: pointer;
    padding: 4px 2px;
    border-radius: var(--radius);
    transition: color var(--fast), transform 80ms;
  }
  .bottom-nav a:active, .bottom-nav button:active { transform: scale(0.94); }
  .bottom-nav .icon { width: 22px; height: 22px; stroke-width: 1.7; }
  .bottom-nav a.active { color: var(--primary-text); }
  .bottom-nav a.active .icon { stroke-width: 2.1; }
  .bottom-nav span {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }

  /* The search control collapses to an icon. */
  .topbar-search {
    flex: none;
    width: 38px;
    height: 38px;
    padding: 0;
    margin-inline-start: 0;
    justify-content: center;
    border: 0; box-shadow: none; background: transparent;
    color: var(--text-2);
  }
  .topbar-search .icon { width: 20px; height: 20px; }
  .topbar-search span, .topbar-search kbd { display: none; }
  .topbar > * { min-width: 0; }
  .topbar-actions { gap: 0; }
  .topbar-actions .btn-primary { width: 34px; padding: 0; margin-inline: 2px 4px; border-radius: var(--radius-full); }
  .icon-btn { width: 38px; height: 38px; }

  .page-header { margin-block: 8px 18px; align-items: stretch; }
  .page-header h1 { font-size: 1.45rem; }
  .page-header .actions { width: 100%; }
  .page-header .actions .btn { flex: 1; }

  .card-body { padding: 16px; }
  .card-header { padding: 12px 16px; min-height: 48px; }

  /* Controls grow to a comfortable touch target, and 16px text keeps iOS
     from zooming into a field on focus. */
  .btn { height: 42px; min-height: 42px; font-size: var(--fs); }
  .btn-sm { height: 36px; min-height: 36px; }
  .btn-lg { height: 48px; }
  .input, .select { height: 44px; min-height: 44px; font-size: 16px; }
  .textarea { font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .dropdown-item { min-height: 44px; font-size: var(--fs); }

  /* Tables become record cards: the first cell is the title of the card,
     the other cells a two column grid of label over value. The header text
     comes from data-label, filled by the view. When the only action is the
     open chevron, the whole card becomes the link. */
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody { display: block; width: 100%; }
  .card:has(> .table-wrap > .table-cards) { background: transparent; border: 0; box-shadow: none; }
  .table-cards tr {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px 14px;
    margin-block-end: 8px;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-card);
  }
  .table-cards tr:last-child { margin-block-end: 0; }
  .table-cards tr:hover { background: var(--surface); }
  .table-cards tr:active:has(td.actions > a:only-child) { background: var(--surface-2); }
  .table-cards td {
    display: block; min-width: 0;
    padding: 0 !important;
    border: 0;
    text-align: start;
    font-size: var(--fs);
    overflow-wrap: anywhere;
  }
  .table-cards td::before {
    content: attr(data-label);
    display: block;
    margin-block-end: 2px;
    font-size: 11.5px; font-weight: 500; color: var(--text-3);
  }
  .table-cards td[data-label=""]::before { display: none; }
  .table-cards td:first-child { grid-column: 1 / -1; padding-inline-end: 36px !important; font-size: var(--fs-md); }
  .table-cards td:first-child::before { display: none; }
  .table-cards td.actions {
    grid-column: 1 / -1;
    display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px;
    width: auto; white-space: normal;
  }
  .table-cards td.actions::before { content: none; }
  .table-cards td.actions:empty { display: none; }
  .table-cards td.actions > a.btn:only-child {
    position: absolute; inset-block-start: 10px; inset-inline-end: 8px;
    width: 32px; height: 32px; min-height: 32px; padding: 0;
    color: var(--text-muted);
  }
  .table-cards td.actions > a.btn:only-child::after { content: ""; position: absolute; inset: -400px; }
  .table-cards tr:has(td.actions > a.btn:only-child) { overflow: hidden; }
  .table-cards tr:has(td.actions > a.btn:only-child) :is(a, button, input, select, label, form):not(td.actions > a) { position: relative; z-index: 1; }
  .table-cards td.num { text-align: start; }

  .filters { flex-direction: column; align-items: stretch; }
  .filters .btn-group { margin-inline-start: 0; }

  .toasts { inset-inline: var(--gutter); inset-block-end: calc(var(--bottomnav-height) + 12px + env(safe-area-inset-bottom, 0px)); align-items: stretch; }
  .toast { width: auto; }
  .modal { max-height: 88vh; }

  /* Menus open as bottom sheets, within reach of the thumb. */
  .dropdown-menu {
    position: fixed;
    inset-inline: 8px;
    inset-block: auto calc(8px + env(safe-area-inset-bottom, 0px));
    min-width: 0 !important; max-width: none !important;
    max-height: 70vh;
    padding: 8px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), 0 0 0 100vmax var(--overlay);
    transform-origin: bottom center;
    z-index: 160;
  }
  .dropdown-menu.open, details.dropdown[open] > .dropdown-menu { animation: sheet-rise var(--slow) var(--ease-out); }
  @keyframes sheet-rise { from { transform: translateY(24px); opacity: 0; } }

  .gsearch { padding: 8px; }
  .gsearch-box { max-height: calc(100dvh - 16px); height: calc(100dvh - 16px); border-radius: var(--radius-xl); }
  .gsearch-foot { display: none; }
  .gsearch-result { min-height: 46px; }
}

@media (max-width: 599px) {
  :root { --fs-2xl: 1.4rem; --fs-3xl: 1.7rem; }
  .form-grid { grid-template-columns: 1fr; }
  .recovery-codes { grid-template-columns: repeat(2, 1fr); }
  .capability-row { flex-wrap: wrap; }
  .capability-row .cap-reason { width: 100%; text-align: start; }
  .btn-group { width: 100%; }
  .btn-group .btn { flex: 1; }
  .settings-row { grid-template-columns: 1fr; }
}

/* ---- Phase 2 utilities used by the console and the installer ---- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.py-2 { padding-block: 8px; }
.py-3 { padding-block: 12px; }
.w-full { inline-size: 100%; }
.sub { color: var(--text-3); font-size: var(--fs-sm); }
.sub-block { display: block; color: var(--text-3); font-size: var(--fs-xs); }

/* Semantic badge aliases over the colour palette, so a view says what it
   means rather than which colour it wants. */
.badge-success { background: var(--c-green-bg);  color: var(--c-green-text); }
.badge-warning { background: var(--c-amber-bg);  color: var(--c-amber-text); }
.badge-danger  { background: var(--c-red-bg);    color: var(--c-red-text); }
.badge-info    { background: var(--c-blue-bg);   color: var(--c-blue-text); }
.badge-neutral { background: var(--c-gray-bg);   color: var(--c-gray-text); }

@media (max-width: 899px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* =====================================================================
   PHASE 2 - Web installer
   A wizard, not an application shell: its own rail, its own card, and no
   dependency on a tenant, a session user or a database.
   ===================================================================== */

.install-body { background: var(--bg); }

.install {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.install-rail {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.install-brand { display: flex; align-items: center; gap: 12px; }
.install-brand .brand-name { font-weight: 650; color: #fff; }
.install-brand .brand-sub { font-size: var(--fs-xs); color: var(--sidebar-text); opacity: .75; }

.install-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.install-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  font-size: var(--fs-sm); color: var(--sidebar-text);
}
.install-step-mark {
  flex: none; inline-size: 26px; block-size: 26px;
  display: grid; place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid color-mix(in srgb, var(--sidebar-text) 35%, transparent);
  font-size: var(--fs-xs); font-weight: 650;
}
.install-step.is-current { background: var(--sidebar-active-bg); color: var(--sidebar-text-active); }
.install-step.is-current .install-step-mark { border-color: var(--sidebar-text-active); }
.install-step.is-done .install-step-mark {
  background: var(--success); border-color: var(--success); color: #fff;
}
.install-step.is-done a { color: var(--sidebar-text); text-decoration: none; }
.install-step.is-done a:hover { color: #fff; text-decoration: underline; }
.install-step.is-todo { opacity: .6; }

.install-rail-foot {
  margin-block-start: auto; font-size: var(--fs-xs);
  color: var(--sidebar-text); opacity: .7; line-height: var(--lh);
}

.install-main { padding: 28px var(--gutter) 48px; display: flex; flex-direction: column; gap: 20px; }
.install-topbar { display: flex; align-items: center; gap: 16px; }
.install-progress {
  flex: 1; block-size: 6px; border-radius: var(--radius-full);
  background: var(--surface-3); overflow: hidden;
}
.install-progress span {
  display: block; block-size: 100%; background: var(--primary);
  transition: inline-size var(--normal) var(--ease);
}
.install-topbar-meta { display: flex; align-items: center; gap: 10px; }
.install-step-counter { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; }

.install-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 32px; max-width: 760px; width: 100%;
}
.install-title { margin: 0 0 6px; font-size: var(--fs-2xl); }
.install-lead { margin: 0 0 24px; color: var(--text-2); }
.install-section {
  margin: 28px 0 12px; font-size: var(--fs-sm); font-weight: 650;
  text-transform: none; letter-spacing: 0; color: var(--text-3);
}
.install-note { margin: 12px 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.install-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-block-start: 28px;
}
.install-foot { font-size: var(--fs-xs); color: var(--text-3); margin: 0; }
.install-done-mark { color: var(--success); margin-block-end: 12px; }

.install-next { margin: 0; padding-inline-start: 20px; display: grid; gap: 12px; }
.install-next li { line-height: var(--lh); }
.install-next .sub { display: block; font-size: var(--fs-sm); color: var(--text-3); }
code.block {
  display: block; margin-block-start: 6px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: var(--fs-xs);
  font-family: var(--font-mono); overflow-x: auto; white-space: pre;
}
code.copyable {
  font-family: var(--font-mono); font-size: var(--fs-md);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 10px; user-select: all;
}

/* ---- Requirement and review lists ---- */
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.check-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid transparent;
}
.check-item + .check-item { border-block-start: 1px solid var(--border); border-radius: 0; }
.check-mark { flex: none; display: grid; place-items: center; padding-block-start: 1px; }
.check-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.check-label { font-size: var(--fs-sm); }
.check-hint { font-size: var(--fs-xs); color: var(--text-3); line-height: var(--lh); }
.check-value { flex: none; font-size: var(--fs-xs); color: var(--text-3); }
.check-item.is-ok .check-mark { color: var(--success); }
.check-item.is-fail .check-mark { color: var(--danger); }
.check-item.is-fail { background: var(--danger-bg); }
.check-item.is-warn .check-mark { color: var(--warning); }
.check-item.is-todo .check-mark { color: var(--text-3); }

/* ---- Key/value summary ---- */
.summary-list { margin: 0; display: grid; gap: 0; }
.summary-list > div {
  display: grid; grid-template-columns: minmax(140px, 32%) minmax(0, 1fr);
  gap: 16px; padding: 10px 0; border-block-end: 1px solid var(--border);
}
.summary-list > div:last-child { border-block-end: 0; }
.summary-list dt { font-size: var(--fs-sm); color: var(--text-3); margin: 0; }
.summary-list dd { margin: 0; font-size: var(--fs-sm); min-width: 0; overflow-wrap: anywhere; }
.summary-list dd .sub { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.summary-list.compact > div { padding: 6px 0; }
.summary-list dd.ltr { unicode-bidi: isolate; direction: ltr; text-align: start; }

/* =====================================================================
   PHASE 2 - Platform console
   Same design system as the tenant workspace, with one deliberate signal
   of difference: an indigo accent rail, so an administrator always knows
   they are above the tenants rather than inside one.
   ===================================================================== */

body.platform {
  --primary: var(--c-indigo);
  --sidebar-bg: #1b2036;
  --sidebar-active-bg: #262d4a;
}
body.platform .sidebar-brand { border-block-end: 2px solid var(--c-indigo); }

.platform-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .04em;
  text-transform: none; color: var(--c-indigo-text);
  background: var(--c-indigo-bg); border-radius: var(--radius-full);
  padding: 3px 10px;
}

.sidebar-group {
  margin-block-start: 18px; padding-inline: 12px;
  font-size: var(--fs-xs); font-weight: 650; letter-spacing: .06em;
  text-transform: none; color: var(--sidebar-text); opacity: .55;
}
.sidebar-group:first-child { margin-block-start: 0; }

/* ---- Stat grid ---- */
.stat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  display: grid; gap: 4px; align-content: start;
}
.stat-card .stat-label {
  font-size: var(--fs-xs); color: var(--text-3);
  text-transform: none; letter-spacing: 0;
}
.stat-card .stat-value { font-size: var(--fs-2xl); font-weight: 650; line-height: 1.1; }
.stat-card .stat-sub { font-size: var(--fs-xs); color: var(--text-3); }
.stat-card.is-warning { border-color: var(--warning); }
.stat-card.is-critical { border-color: var(--danger); }

/* ---- Distribution bars (tenants per preset, per plan) ---- */
.dist-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.dist-row { display: grid; grid-template-columns: minmax(96px, 26%) 1fr auto; gap: 12px; align-items: center; }
.dist-label { font-size: var(--fs-sm); color: var(--text-2); }
.dist-track { block-size: 8px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.dist-fill { display: block; block-size: 100%; background: var(--primary); }
.dist-value { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--text-2); }

/* ---- Usage meters ---- */
.usage-row { display: grid; gap: 6px; padding-block: 10px; border-block-end: 1px solid var(--border); }
.usage-row:last-child { border-block-end: 0; }
.usage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.usage-name { font-size: var(--fs-sm); }
.usage-figure { font-size: var(--fs-sm); color: var(--text-3); font-variant-numeric: tabular-nums; }
.usage-track { block-size: 6px; border-radius: var(--radius-full); background: var(--surface-3); overflow: hidden; }
.usage-fill { display: block; block-size: 100%; background: var(--success); }
.usage-row.is-warning .usage-fill { background: var(--warning); }
.usage-row.is-over .usage-fill { background: var(--danger); }
.usage-row.is-unavailable .usage-figure { font-style: italic; }

/* ---- Capability matrix ---- */
.matrix-wrap { overflow-x: auto; }
.matrix { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.matrix th, .matrix td {
  padding: 8px 10px; text-align: start;
  border-block-end: 1px solid var(--border); vertical-align: middle;
}
.matrix thead th {
  font-size: var(--fs-xs); text-transform: none; letter-spacing: 0;
  color: var(--text-3); white-space: nowrap;
}
.matrix tbody tr:hover { background: var(--surface-2); }
.matrix .cap-key { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-3); }
.matrix td.center, .matrix th.center { text-align: center; }
.matrix-group th {
  background: var(--surface-2); font-weight: 650;
  font-size: var(--fs-xs); text-transform: none; letter-spacing: 0;
}

.state-dot {
  display: inline-grid; place-items: center;
  inline-size: 22px; block-size: 22px; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 700;
}
.state-on  { background: var(--success-bg); color: var(--success-text); }
.state-off { background: var(--surface-3); color: var(--text-3); }
.state-available { background: var(--info-bg); color: var(--info-text); }
.state-forced-on  { background: var(--c-teal-bg); color: var(--c-teal-text); }
.state-forced-off { background: var(--danger-bg); color: var(--danger-text); }

.cap-source { font-size: var(--fs-xs); color: var(--text-3); }

/* ---- Health ---- */
.health-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.health-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
}
.health-item .health-body { min-width: 0; display: grid; gap: 2px; }
.health-item .health-label { font-size: var(--fs-sm); font-weight: 600; }
.health-item .health-value {
  font-size: var(--fs-sm); color: var(--text-2);
  overflow-wrap: anywhere; unicode-bidi: isolate;
}
.health-item .health-hint { font-size: var(--fs-xs); color: var(--text-3); line-height: var(--lh); }
.health-item.is-ok .health-mark { color: var(--success); }
.health-item.is-warning { border-color: var(--warning); background: var(--warning-bg); }
.health-item.is-warning .health-mark { color: var(--warning-text); }
.health-item.is-critical { border-color: var(--danger); background: var(--danger-bg); }
.health-item.is-critical .health-mark { color: var(--danger-text); }
.health-item.is-info .health-mark { color: var(--text-3); }

/* ---- Danger zone ---- */
.danger-zone {
  border: 1px solid var(--danger); border-radius: var(--radius-lg);
  background: var(--danger-bg); padding: 18px;
}
.danger-zone h3 { margin: 0 0 6px; font-size: var(--fs-md); color: var(--danger-text); }
.danger-zone p { margin: 0 0 12px; font-size: var(--fs-sm); color: var(--text-2); }

/* ---- Preset change preview ---- */
.diff-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.diff-col h4 { margin: 0 0 8px; font-size: var(--fs-sm); }
.diff-col ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.diff-col li {
  font-size: var(--fs-sm); padding: 6px 10px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px;
}
.diff-gain li { background: var(--success-bg); color: var(--success-text); }
.diff-loss li { background: var(--danger-bg); color: var(--danger-text); }
.diff-keep li { background: var(--surface-2); color: var(--text-2); }

/* ---- Log rows ---- */
.log-row {
  display: grid; grid-template-columns: 90px 96px minmax(0, 1fr) 150px;
  gap: 12px; padding: 10px 0; border-block-end: 1px solid var(--border);
  font-size: var(--fs-sm); align-items: baseline;
}
.log-row:last-child { border-block-end: 0; }
.log-time { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.log-message { overflow-wrap: anywhere; }
.log-meta { font-size: var(--fs-xs); color: var(--text-3); text-align: end; }

/* ---- Support session banner, extended ---- */
.support-banner .support-meta { font-size: var(--fs-xs); opacity: .85; }

/* ---- The capability matrix on a phone ----
   Six state columns is the right shape on a laptop and the wrong one at
   390px, where it becomes a sideways scroll that hides the column that
   matters. Each row becomes a card, like .table-cards elsewhere. */
@media (max-width: 699px) {
  .matrix-wrap { overflow-x: visible; }
  .matrix, .matrix tbody, .matrix tr, .matrix td { display: block; width: 100%; }
  .matrix thead { display: none; }

  .matrix tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-block-end: 10px;
    padding: 12px 14px;
    background: var(--surface);
  }
  .matrix tbody tr:hover { background: var(--surface); }

  .matrix td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 6px 0; text-align: start;
    border-block-end: 1px solid var(--border);
  }
  .matrix td:first-child {
    display: block; padding-block-start: 0;
    font-weight: 600; border-block-end: 1px solid var(--border);
  }
  .matrix td:last-child { border-block-end: 0; padding-block-end: 0; }
  .matrix td::before {
    content: attr(data-label);
    flex: none;
    font-size: var(--fs-xs); font-weight: 600; color: var(--text-3);
    text-transform: none; letter-spacing: 0;
  }
  .matrix td:first-child::before, .matrix td.actions::before { content: none; }
  .matrix td.center { justify-content: space-between; }

  /* A group heading stays a heading rather than becoming a card. */
  .matrix tr.matrix-group { padding: 0; border: 0; margin-block: 14px 6px; background: none; }
  .matrix tr.matrix-group th {
    display: block; background: none; padding: 0;
    color: var(--text-3);
  }
}
/* ---- Responsive ---- */
@media (max-width: 899px) {
  .install { grid-template-columns: 1fr; }
  .install-rail {
    flex-direction: row; align-items: center; justify-content: space-between;
    gap: 16px; padding: 14px var(--gutter);
  }
  .install-steps { display: none; }
  .install-rail-foot { display: none; }
  .install-card { padding: 22px; border-radius: var(--radius); }
  .install-main { padding-block-start: 18px; }

  .log-row { grid-template-columns: 1fr; gap: 4px; }
  .log-meta { text-align: start; }
  .summary-list > div { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 599px) {
  .install-card { padding: 18px; }
  .install-actions .btn { width: 100%; }
  .install-actions { gap: 8px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .dist-row { grid-template-columns: minmax(80px, 40%) 1fr auto; }
}
/* =====================================================================
   PHASE 3 - Resource screens
   Fleet, people, partners and the catalogue. Everything here serves one
   idea: a dispatcher reads these pages forty times a day, so the verdict
   - is this vehicle usable, is this driver legal - has to be visible
   without reading a sentence.
   ===================================================================== */

/* ---- A set of values as tappable boxes ----
   Languages, specialities, regions. A multiple select is unusable with a
   thumb, so the options are laid out as a wrapping grid instead. */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.checkbox-grid.is-invalid { border-color: var(--danger); }
.checkbox-grid .checkbox { margin: 0; }

/* ---- A secondary form folded away until it is wanted ----
   The document upload under a resource: present on every detail page,
   never in the way of the page's actual content. */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 10px 12px;
}
.disclosure > summary {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-2);
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.disclosure[open] > summary { margin-block-end: 4px; color: var(--text); }
.disclosure .form-grid { margin-block-end: 12px; }

/* Row actions inside a check-list: the verify and delete of a document. */
.check-actions { flex: none; display: flex; align-items: center; gap: 2px; }
.check-actions form { display: contents; }
.check-item.is-pass .check-mark { color: var(--text-3); }

/* ---- A dropdown that needs no JavaScript ----
   <details class="dropdown"> with a form inside: used where a transition
   must carry a reason, so the reason is typed before the button is
   pressed rather than asked for after it. */
details.dropdown > summary { list-style: none; cursor: pointer; }
details.dropdown > summary::-webkit-details-marker { display: none; }
details.dropdown[open] > .dropdown-menu { display: block; }
.dropdown-form { width: min(320px, calc(100vw - 32px)); padding: 14px; }
.dropdown-form .field { margin-block-end: 10px; }

/* A badge sitting beside a page title. */
.badge.align-mid { vertical-align: middle; margin-inline-start: 8px; }

/* A short list inside a detail card: inclusions, exclusions. */
.bullets { margin: 0; padding-inline-start: 18px; display: grid; gap: 2px; }
.bullets li { font-weight: 400; }

/* ---- The status line of one resource ----
   A vehicle's state machine, a driver's employment: the current value
   large, the transitions beside it. */
.state-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.state-bar .state-current { font-weight: 600; }
.state-bar .state-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-inline-start: auto; }

/* ---- A quick picker of two or three linked screens ---- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.tile {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
a.tile:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.tile .icon { flex: none; color: var(--primary); margin-block-start: 2px; }
.tile-body { display: grid; gap: 3px; min-width: 0; }
.tile-title { font-weight: 600; }
.tile-sub { font-size: var(--fs-sm); color: var(--text-3); }
.tile-count { font-size: var(--fs-sm); color: var(--text-3); margin-inline-start: auto; flex: none; }

/* ---- The filter bar of a resource list ----
   The Phase 2 screens wrapped each control in a .field; the Phase 3 lists
   emit the control directly, and .input/.select carry width:100%, so each
   one claimed a whole line and four filters cost four rows of the screen.
   Giving them a flex basis puts them back in a row, and they still wrap
   onto their own lines on a phone. */
.filters > .input,
.filters > .select {
  flex: 1 1 180px;
  min-width: 150px;
  max-width: 300px;
  width: auto;
}
.filters > .input[type="search"] { flex: 2 1 220px; max-width: 420px; }
.filters > .checkbox { flex: 0 0 auto; align-self: center; }

/* Below 900px the bar is a column (see the 899px block), so a flex basis
   would become a HEIGHT: the 220px basis of the search field drew a tall
   empty box. Stacked controls take their natural height and the full width. */
@media (max-width: 899px) {
  .filters > .input,
  .filters > .select,
  .filters > .input[type="search"] { flex: none; width: 100%; max-width: none; min-width: 0; }
}

@media (max-width: 599px) {
  /* One control per line below 600px: two half width selects side by side
     is how a label gets truncated to three characters. */
  .filters .btn-group { margin-inline-start: 0; width: 100%; }
  .filters .btn-group .btn { flex: 1; }
}

/* ---- A list of machine names ----
   The CSV columns an import understands. They wrap, because
   transport_authorisation_expiry does not fit a phone on one line and a
   name that runs off the side is a name nobody can copy. */
.code-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.code-list code {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* ---- CSV import report ----
   Per line, because "14 rows failed" is not something anybody can act
   on, and the line number is what they search for in Excel. */
.import-report { display: grid; gap: 2px; max-height: 420px; overflow: auto; }
.import-row {
  display: grid; grid-template-columns: 62px 1fr; gap: 12px;
  padding: 8px 10px; font-size: var(--fs-sm);
  border-block-end: 1px solid var(--border);
}
.import-row:last-child { border-block-end: 0; }
.import-row .line { color: var(--text-3); font-variant-numeric: tabular-nums; }
.import-row.is-error { background: var(--danger-bg); }
.import-row.is-error .line { color: var(--danger); }

/* ---- A pair of values the person is comparing ----
   minmax(0, 1fr) rather than 1fr: a grid column sized `1fr` still refuses
   to shrink below its content's intrinsic width, and a file input reports
   an intrinsic width of about 440px. That is how one field pushed a whole
   page past the edge of a phone. */
.compare { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }

/* The same guard for the fields themselves: a grid item that cannot
   shrink is the usual cause of a sideways scroll on a form. */
.field { min-width: 0; }
.field .input, .field .select, .field .textarea { max-width: 100%; }
input[type="file"].input { max-width: 100%; }

@media (max-width: 899px) {
  .compare { grid-template-columns: minmax(0, 1fr); }
  .state-bar .state-actions { margin-inline-start: 0; width: 100%; }
}

@media (max-width: 599px) {
  .checkbox-grid { grid-template-columns: 1fr 1fr; gap: 6px 10px; }
  .import-row { grid-template-columns: 1fr; gap: 2px; }
  /* The document row stacks: label, date, then the actions on their own
     line, so nothing is a 24px tap target squeezed against the edge. */
  .check-item { flex-wrap: wrap; }
  .check-value { width: 100%; padding-inline-start: 32px; }
  .check-actions { width: 100%; padding-inline-start: 26px; }
}

/* ---- Print ---- */
@media print {
  .sidebar, .topbar, .bottom-nav, .toasts, .support-banner,
  .page-header .actions, .filters, .pagination { display: none !important; }
  body { background: #fff; }
  .card { border-color: #ddd; box-shadow: none; break-inside: avoid; }
  .content { max-width: none; padding: 0; }
}

/* =====================================================================
   PHASE 4 - Pricing and quotations
   ---------------------------------------------------------------------
   Commercial screens read like a document, not a database. Four new
   shared ideas carry every Phase 4 screen:

   1. The SHEET. One <dialog> component: a drawer on the inline end of a
      desktop, a bottom sheet on a phone. Rate editors, the line editor and
      the pricing explanation open in it, so an edit never loses the grid
      or the quote behind it.
   2. The TOTALS RAIL. The figure that matters stays in view: sticky beside
      the lines on a wide screen, a compact bar above the bottom navigation
      on a phone.
   3. The INTERNAL PANEL. Cost and margin never sit among selling figures.
      They live on a dark ink surface marked with a lock, never mistaken
      for what the customer pays. For a user without the permission the
      panel is not rendered at all.
   4. The SOURCE CHIP. Every price says where it came from - agency grid,
      grid, cost plus markup, manual, to price - in one glance.
   ===================================================================== */

:root {
  --ink: #11201d;
  --ink-2: #1b2e2a;
  --ink-text: #d8e6e2;
  --ink-muted: #8fa8a1;
  --paper: #ffffff;
}

/* ---- Money, always tabular and left to right ------------------------ */
.money { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.money-lg { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; }
.money-xl { font-size: var(--fs-3xl); font-weight: 750; letter-spacing: -0.025em; line-height: 1.05; }
.money-muted { color: var(--text-3); font-weight: 500; }
.strike { text-decoration: line-through; color: var(--text-muted); }

/* ---- Segmented filters with counts ---------------------------------- */
.seg {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 4px; margin-block-end: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.seg a {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--radius);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 500;
  min-height: 36px;
}
.seg a:hover { background: var(--surface-3); text-decoration: none; }
.seg a.active { background: var(--primary); color: var(--primary-contrast); }
.seg .n {
  min-width: 22px; padding: 1px 7px; border-radius: var(--radius-full);
  background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 650; text-align: center;
  font-variant-numeric: tabular-nums;
}
.seg a.active .n { background: rgba(255, 255, 255, 0.2); color: #fff; }
@media (max-width: 599px) {
  .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg a { flex: none; }
}

/* ---- Price source chips --------------------------------------------- */
.src {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; line-height: 1.6;
}
.src::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.src-tariff        { background: var(--c-teal-bg);   color: var(--c-teal-text); }
.src-agency_tariff { background: var(--c-indigo-bg); color: var(--c-indigo-text); }
.src-cost_markup   { background: var(--c-amber-bg);  color: var(--c-amber-text); }
.src-manual        { background: var(--c-pink-bg);   color: var(--c-pink-text); }
.src-none          { background: var(--c-red-bg);    color: var(--c-red-text); }

/* ---- The sheet: drawer on desktop, bottom sheet on a phone ---------- */
dialog.sheet {
  padding: 0; border: 0; margin: 0;
  max-width: none; max-height: none;
  background: transparent; color: var(--text);
  position: fixed;
  inset-block: 0; inset-inline-end: 0; inset-inline-start: auto;
  width: min(560px, 100vw); height: 100vh; height: 100dvh;
}
dialog.sheet::backdrop { background: rgba(10, 17, 15, 0.45); }
dialog.sheet[open] { display: flex; }
.sheet-panel {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: sheet-in var(--normal) var(--ease);
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
[dir="rtl"] .sheet-panel { animation-name: sheet-in-rtl; }
@keyframes sheet-in-rtl { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px; border-block-end: 1px solid var(--border);
}
.sheet-head h2 { flex: 1; min-width: 0; font-size: var(--fs-lg); }
.sheet-head .sub { margin-block-start: 3px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 20px 24px; overscroll-behavior: contain; }
.sheet-foot {
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 20px; padding-block-end: calc(12px + env(safe-area-inset-bottom, 0px));
  border-block-start: 1px solid var(--border); background: var(--surface-2);
}
.sheet-grip { display: none; }
.sheet .form-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.sheet-section { margin-block: 18px 10px; font-size: var(--fs-xs); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-3); }
.sheet-section:first-child { margin-block-start: 0; }
.sheet-body .sheet-section { margin-block-start: 22px; padding-block-start: 16px; border-block-start: 1px solid var(--border); }
.sheet-body > .sheet-section:first-child { margin-block-start: 0; padding-block-start: 0; border-block-start: 0; }

@media (max-width: 899px) {
  dialog.sheet {
    inset: auto 0 0 0; width: 100vw; height: auto; max-height: 92vh; max-height: 92dvh;
  }
  .sheet-panel {
    border-start-start-radius: var(--radius-xl); border-start-end-radius: var(--radius-xl);
    max-height: 92vh; max-height: 92dvh; animation-name: sheet-up;
  }
  [dir="rtl"] .sheet-panel { animation-name: sheet-up; }
  @keyframes sheet-up { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
  .sheet-grip {
    display: block; width: 40px; height: 4px; margin: 8px auto 0; flex: none;
    border-radius: var(--radius-full); background: var(--border-2);
  }
  .sheet-head { padding-block-start: 10px; }
  .sheet-foot .btn { flex: 1; }
  .sheet .form-grid { grid-template-columns: 1fr 1fr; }
  .sheet .form-grid .span-2 { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  .sheet .form-grid { grid-template-columns: 1fr; }
}

/* ---- Builder layout: work area and totals rail ---------------------- */
.builder { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  .builder { grid-template-columns: minmax(0, 1fr) 340px; }
  .builder-rail { position: sticky; inset-block-start: calc(var(--topbar-height) + 16px); }
}
.builder-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.builder-rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ---- The quote header ------------------------------------------------ */
.qhead {
  position: relative; overflow: hidden;
  padding: 18px 20px;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface);
}
.qhead::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 0;
  width: 4px; background: var(--primary);
}
.qhead-top { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.qhead-id { flex: 1; min-width: 220px; }
.qhead-ref {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; letter-spacing: .02em;
}
.qhead-ref .mono { color: var(--text-2); }
.qhead h1 { margin-block: 6px 0; font-size: var(--fs-2xl); overflow-wrap: anywhere; }
.qhead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-grid {
  display: grid; gap: 12px 20px; margin-block-start: 16px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta-label { font-size: var(--fs-xs); color: var(--text-3); text-transform: none; letter-spacing: 0; font-weight: 600; }
.meta-value { font-weight: 600; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.meta-value .sub { font-weight: 400; }
@media (max-width: 699px) {
  .qhead { padding: 16px; }
  .qhead-actions { width: 100%; }
  .qhead-actions .btn, .qhead-actions details { flex: 1; }
  .qhead-actions details > summary { width: 100%; }
  .meta-grid { grid-template-columns: 1fr 1fr; }
}

/* Lifecycle stepper */
.stepper { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-block-start: 14px; }
.step {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 7px; border-radius: var(--radius-full);
  background: var(--surface-3); color: var(--text-3);
  font-size: var(--fs-xs); font-weight: 600;
}
.step .dot {
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--border-2);
}
.step .dot .icon { width: 11px; height: 11px; }
.step.done { background: var(--c-teal-bg); color: var(--c-teal-text); }
.step.done .dot { background: var(--primary); border-color: var(--primary); color: #fff; }
.step.current { background: var(--primary); color: #fff; }
.step.current .dot { border-color: #fff; background: rgba(255,255,255,.2); }
.step.off { background: var(--c-red-bg); color: var(--c-red-text); }
.step.warn { background: var(--c-amber-bg); color: var(--c-amber-text); }
.step-sep { width: 14px; height: 1.5px; background: var(--border-2); }

/* ---- Lines ------------------------------------------------------------ */
.lines { display: flex; flex-direction: column; }
.qline {
  display: grid; gap: 4px 16px; align-items: start;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  padding: 14px 16px;
  border-block-end: 1px solid var(--border);
  scroll-margin-block-start: calc(var(--topbar-height) + 20px);
}
.qline:last-child { border-block-end: 0; }
.qline:target { background: var(--primary-50); }
.qline-n {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-3); font-size: var(--fs-xs); font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.qline.needs-price .qline-n { background: var(--c-red-bg); color: var(--c-red-text); }
.qline-body { min-width: 0; }
.qline-title { font-weight: 650; font-size: var(--fs-md); overflow-wrap: anywhere; }
.qline-desc { font-size: var(--fs-sm); color: var(--text-2); margin-block-start: 3px; overflow-wrap: anywhere; }
.qline-meta {
  display: flex; flex-wrap: wrap; gap: 4px 12px; margin-block-start: 4px;
  font-size: var(--fs-sm); color: var(--text-3);
}
.qline-meta span { display: inline-flex; align-items: center; gap: 5px; }
.qline-meta .icon { width: 14px; height: 14px; }
.qline-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 8px; align-items: center; }
.qline-price { text-align: end; min-width: 132px; }
.qline-price .unit { font-size: var(--fs-xs); color: var(--text-3); margin-block-start: 2px; }
.qline-adj { font-size: var(--fs-xs); margin-block-start: 3px; display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.qline-adj.sup { color: var(--c-amber-text); }
.qline-adj.disc { color: var(--c-green-text); }
.qline-adj form { display: inline; }
.qline-adj .x { border: 0; background: none; color: inherit; cursor: pointer; padding: 0 2px; opacity: .7; font-size: 14px; line-height: 1; }
.qline-actions { grid-column: 2 / -1; display: flex; gap: 4px; justify-content: flex-end; margin-block-start: 6px; flex-wrap: wrap; }
.qline-actions form { display: contents; }
.qline-internal {
  grid-column: 2 / -1;
  display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center;
  margin-block-start: 8px; padding: 7px 10px;
  border-radius: var(--radius-sm);
  background: var(--ink); color: var(--ink-text);
  font-size: var(--fs-xs);
}
.qline-internal b { color: #fff; font-weight: 650; }
.qline-internal .icon { width: 13px; height: 13px; color: var(--ink-muted); }

@media (max-width: 699px) {
  .qline { grid-template-columns: 28px minmax(0, 1fr); padding: 14px; }
  .qline-n { width: 24px; height: 24px; }
  .qline-price {
    grid-column: 2; text-align: start; min-width: 0;
    display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin-block-start: 8px;
  }
  .qline-adj { justify-content: flex-start; width: 100%; }
  .qline-actions { grid-column: 1 / -1; justify-content: stretch; }
  .qline-actions .btn { flex: 1; }
  .qline-internal { grid-column: 1 / -1; }
}

/* ---- Totals ------------------------------------------------------------ */
.totals { display: flex; flex-direction: column; }
.totals-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 6px 0; font-size: var(--fs);
}
.totals-row .label { color: var(--text-2); min-width: 0; }
.totals-row.minor .label, .totals-row.minor .money { color: var(--text-3); font-size: var(--fs-sm); }
.totals-row.discount .money { color: var(--c-green-text); }
.totals-row form { display: inline; }
.totals-grand {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-block-start: 10px; padding-block-start: 14px;
  border-block-start: 1px dashed var(--border-2);
}
.totals-grand .label { font-size: var(--fs-sm); font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--text-3); }

/* ---- The internal panel ------------------------------------------------ */
.internal {
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-2) 100%);
  color: var(--ink-text);
  padding: 16px 18px;
  border: 1px solid #0b1513;
}
.internal-head {
  display: flex; align-items: center; gap: 8px; margin-block-end: 10px;
  font-size: var(--fs-xs); text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--ink-muted);
}
.internal-head .icon { width: 14px; height: 14px; }
.internal .totals-row { font-size: var(--fs-sm); }
.internal .totals-row .label { color: var(--ink-muted); }
.internal .money { color: #fff; }
.internal-margin { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-block-start: 8px; }
.internal-margin .money-lg { color: #fff; }
.pct-pill {
  padding: 2px 9px; border-radius: var(--radius-full);
  background: rgba(134, 207, 192, 0.16); color: #9fe0d1; font-weight: 700; font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}
.pct-pill.low { background: rgba(240, 164, 150, .16); color: #f3b3a7; }
.internal-note {
  margin-block-start: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06); border-inline-start: 3px solid var(--accent);
  font-size: var(--fs-xs); color: var(--ink-text);
}

/* ---- Warnings ------------------------------------------------------------ */
.warn-list { display: flex; flex-direction: column; gap: 6px; }
.warn {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: var(--fs-sm); line-height: 1.45;
  background: var(--warning-bg); color: var(--warning-text);
}
.warn .icon { width: 15px; height: 15px; margin-block-start: 2px; flex: none; }
.warn-danger { background: var(--danger-bg); color: var(--danger-text); }
.warn-info { background: var(--info-bg); color: var(--info-text); }

/* ---- Explanation steps ------------------------------------------------- */
.explain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.explain li {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px;
  padding: 10px 0; border-block-end: 1px solid var(--border);
}
.explain li:last-child { border-block-end: 0; }
.explain .n {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--text-3);
}
.explain .t { font-weight: 600; font-size: var(--fs-sm); }
.explain .d { font-size: var(--fs-sm); color: var(--text-3); overflow-wrap: anywhere; }
.explain .a { font-weight: 650; text-align: end; }
.explain li.tone-primary .n { background: var(--c-teal-bg); color: var(--c-teal-text); }
.explain li.tone-warning .n { background: var(--c-amber-bg); color: var(--c-amber-text); }
.explain li.tone-strong .a { font-size: var(--fs-md); color: var(--primary-700); }
.explain li.tone-internal { background: var(--ink); color: var(--ink-text); border-radius: var(--radius-sm); padding-inline: 8px; margin-block: 3px; border-block-end: 0; }
.explain li.tone-internal .n { background: rgba(255,255,255,.1); color: #fff; }
.explain li.tone-internal .d { color: var(--ink-muted); }

/* ---- Sticky action bar (below the wide breakpoint) ----------------------- */
.sticky-bar { display: none; }
@media (max-width: 1099px) {
  .sticky-bar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; inset-block-end: 0; z-index: 20;
    margin: 16px calc(-1 * var(--gutter)) 0;
    padding: 10px var(--gutter);
    background: var(--surface); border-block-start: 1px solid var(--border);
    box-shadow: 0 -6px 18px rgba(17, 32, 29, 0.08);
  }
  .sticky-bar .grow .label { font-size: var(--fs-xs); color: var(--text-3); display: block; }
  .sticky-bar .money { font-size: var(--fs-lg); font-weight: 750; }
}
@media (max-width: 899px) {
  .sticky-bar { inset-block-end: var(--bottomnav-height); }
}

/* ---- KPI ribbon ------------------------------------------------------------ */
.kpi-ribbon {
  display: grid; gap: 1px; margin-block-end: 18px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--border); overflow: hidden;
}
.kpi { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .v { font-size: var(--fs-xl); font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .l { font-size: var(--fs-xs); color: var(--text-3); text-transform: none; letter-spacing: 0; font-weight: 600; }
.kpi.accent .v { color: var(--accent); }
@media (max-width: 599px) {
  .kpi-ribbon { grid-template-columns: 1fr 1fr; }
  .kpi-ribbon.is-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi { padding: 12px; }
  .kpi .v { font-size: var(--fs-lg); }
}

/* ---- Rate grid ------------------------------------------------------------ */
.rate-group-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 18px; background: var(--surface-2); border-block: 1px solid var(--border);
  font-weight: 650; font-size: var(--fs-sm);
}
.rate-group-title:first-child { border-block-start: 0; }
.rate-group-title .sub { font-weight: 400; }
.rate-dims { display: flex; flex-wrap: wrap; gap: 6px; }
.dim {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 500;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.dim .icon { width: 12px; height: 12px; flex: none; }
.dim-season { color: #fff; }
.route-arrow { color: var(--text-muted); display: inline-block; }
[dir="rtl"] .route-arrow { transform: scaleX(-1); }

/* ---- Season timeline ------------------------------------------------------ */
.timeline-year { position: relative; padding: 24px 0 6px; }
.tl-months { position: absolute; inset: 0; pointer-events: none; }
.tl-month {
  position: absolute; inset-block: 0; border-inline-start: 1px dashed var(--border);
  font-size: 10.5px; color: var(--text-muted); padding-inline-start: 4px; text-transform: none; letter-spacing: 0;
}
.tl-lanes { position: relative; display: flex; flex-direction: column; gap: 6px; }
.tl-lane { position: relative; height: 30px; }
.tl-bar {
  position: absolute; inset-block: 0; border-radius: 8px;
  display: flex; align-items: center; padding-inline: 8px; overflow: hidden;
  font-size: var(--fs-xs); font-weight: 650; white-space: nowrap;
  color: #fff; box-shadow: var(--shadow-xs);
}
.tl-bar:hover { text-decoration: none; filter: brightness(1.06); color: #fff; }
.tl-bar.inactive { opacity: .45; }
.tl-today { position: absolute; inset-block: 0; width: 2px; background: var(--accent); z-index: 2; }
.bg-teal { background: var(--c-teal); } .bg-blue { background: var(--c-blue); } .bg-indigo { background: var(--c-indigo); }
.bg-purple { background: var(--c-purple); } .bg-pink { background: var(--c-pink); } .bg-red { background: var(--c-red); }
.bg-amber { background: var(--c-amber); } .bg-green { background: var(--c-green); } .bg-slate { background: var(--c-slate); }
.bg-gray { background: var(--c-gray); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
@media (max-width: 699px) {
  .timeline-card { display: none; }
}

/* ---- Cancellation ladder ------------------------------------------------ */
.ladder { display: flex; gap: 3px; align-items: flex-end; height: 74px; margin-block: 6px 4px; }
.ladder-step {
  flex: 1; min-width: 0; border-radius: 6px 6px 2px 2px; display: flex; align-items: flex-end; justify-content: center;
  padding-block-end: 5px; font-size: var(--fs-xs); font-weight: 700; color: #fff;
  background: var(--c-teal); min-height: 18px; direction: ltr;
}
.ladder-step.mid { background: var(--c-amber); }
.ladder-step.high { background: var(--c-red); }
.ladder-step.zero { background: var(--c-green); }
.ladder-labels { display: flex; gap: 3px; }
.ladder-labels span { flex: 1; min-width: 0; text-align: center; font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.policy-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.policy-grid .card + .card { margin-block-start: 0; }
.policy-card .card-body { display: flex; flex-direction: column; gap: 10px; }
.band-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.band-list li { display: flex; justify-content: space-between; gap: 10px; font-size: var(--fs-sm); padding: 5px 0; border-block-end: 1px dashed var(--border); }
.band-list li:last-child { border-block-end: 0; }
.rules-editor { display: flex; flex-direction: column; gap: 8px; }
.rule-row {
  display: grid; gap: 8px; align-items: end;
  grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(0, 1.2fr) minmax(0, 1fr);
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
}
.rule-row .field > label { font-size: var(--fs-xs); }
@media (max-width: 699px) {
  .policy-grid { grid-template-columns: 1fr; }
  .rule-row { grid-template-columns: 1fr 1fr; }
}

/* ---- Supplements and discounts ------------------------------------------ */
.cond { display: flex; flex-wrap: wrap; gap: 6px; margin-block-start: 6px; }
.adj-card { display: flex; gap: 14px; align-items: flex-start; padding: 14px 18px; border-block-end: 1px solid var(--border); }
.adj-card:last-child { border-block-end: 0; }
.adj-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--c-amber-bg); color: var(--c-amber-text);
}
.adj-card.discount .adj-icon { background: var(--c-green-bg); color: var(--c-green-text); }
.adj-card .grow { min-width: 0; }
.adj-title { font-weight: 650; overflow-wrap: anywhere; }
.adj-value { text-align: end; flex: none; }
.adj-card.inactive { opacity: .55; }
@media (max-width: 599px) {
  .adj-card { flex-wrap: wrap; padding: 14px; }
  .adj-value { text-align: start; width: 100%; padding-inline-start: 52px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
}

/* ---- Agency terms --------------------------------------------------------- */
.terms-hero {
  display: grid; gap: 1px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--border); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border);
}
.terms-hero > div { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.terms-hero .big { font-size: var(--fs-xl); font-weight: 700; overflow-wrap: anywhere; }
.mode-explain { font-size: var(--fs-sm); color: var(--text-3); }

/* ---- The customer document on screen ------------------------------------- */
.doc-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-block-end: 16px; }
.doc-stage { background: var(--surface-3); border-radius: var(--radius-lg); padding: 28px 16px; }
.doc-paper {
  max-width: 820px; margin-inline: auto; background: var(--paper); color: #16241f;
  box-shadow: 0 10px 40px rgba(17, 32, 29, .12), 0 1px 3px rgba(17,32,29,.08);
  border-radius: 6px; padding: 44px 48px; position: relative; overflow: hidden;
  font-size: 13.5px; line-height: 1.55;
}
.doc-draft {
  position: absolute; inset-block-start: 36%; inset-inline: -10%; text-align: center;
  font-size: 110px; font-weight: 600; letter-spacing: 0; text-transform: none;
  color: var(--doc-brand, var(--primary)); opacity: .06; transform: rotate(-24deg); pointer-events: none;
}
.doc-paper[dir="rtl"] .doc-draft { transform: rotate(24deg); }
.doc-head { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.doc-brand { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.doc-mark {
  width: 52px; height: 52px; border-radius: 12px; flex: none; display: grid; place-items: center; overflow: hidden;
  background: var(--doc-brand, var(--primary)); color: #fff; font-size: 24px; font-weight: 800;
}
.doc-mark.has-logo { background: transparent; }
.doc-mark img { max-width: 100%; max-height: 100%; }
.doc-company { font-size: 17px; font-weight: 750; }
.doc-small { font-size: 11.5px; color: #5c6b68; }
.doc-title-block { text-align: end; margin-inline-start: auto; }
.doc-kicker { font-size: 26px; font-weight: 600; letter-spacing: 0; color: var(--doc-brand, var(--primary)); text-transform: none; }
.doc-rule { height: 2px; background: var(--doc-brand, var(--primary)); margin-block: 18px; border-radius: 2px; }
.doc-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.doc-card { background: #f4f6f5; border-radius: 10px; padding: 14px 16px; }
.doc-card .k { font-size: 10.5px; text-transform: none; letter-spacing: 0; color: #6b7a77; font-weight: 600; margin-block-end: 4px; }
.doc-card .n { font-weight: 750; font-size: 15px; }
.doc-lines { width: 100%; border-collapse: collapse; margin-block-start: 22px; }
.doc-lines th {
  background: var(--doc-brand, var(--primary)); color: #fff; font-size: 10.5px; text-transform: none;
  letter-spacing: .06em; padding: 9px 10px; text-align: start;
}
.doc-lines th.num, .doc-lines td.num { text-align: end; }
.doc-lines td { padding: 11px 10px; border-block-end: 1px solid #e1e7e5; vertical-align: top; }
.doc-lines tr:nth-child(even) td { background: #fafbfa; }
.doc-lines .t { font-weight: 700; }
.doc-lines .m { font-size: 11.5px; color: #6b7a77; margin-block-start: 2px; }
.doc-lines .adj { font-size: 11.5px; margin-block-start: 3px; }
.doc-lines .adj.sup { color: #7d4c05; } .doc-lines .adj.disc { color: #1c5c3a; }
.doc-totals { display: flex; justify-content: flex-end; margin-block-start: 16px; }
.doc-totals table { width: min(360px, 100%); border-collapse: collapse; }
.doc-totals td { padding: 6px 10px; }
.doc-totals td.num { text-align: end; }
.doc-totals tr.grand td {
  background: var(--doc-brand, var(--primary)); color: #fff; font-weight: 800; font-size: 16px; padding: 10px;
}
.doc-section { margin-block-start: 22px; }
.doc-section h4 { font-size: 11px; text-transform: none; letter-spacing: 0; color: var(--doc-brand, var(--primary)); margin-block-end: 6px; }
.doc-section ul { margin: 0; padding-inline-start: 18px; }
.doc-two { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.doc-foot { margin-block-start: 26px; padding-block-start: 12px; border-block-start: 1px solid #e1e7e5; font-size: 11px; color: #6b7a77; }
.doc-banner { margin-block-end: 18px; padding: 8px 12px; border-radius: 8px; background: #fdf3e3; color: #7d4c05; font-size: 12px; font-weight: 600; }

@media (max-width: 699px) {
  .doc-stage { padding: 10px 0; background: transparent; }
  .doc-paper { padding: 22px 18px; border-radius: var(--radius); font-size: 13px; }
  .doc-title-block { text-align: start; margin-inline-start: 0; }
  .doc-kicker { font-size: 20px; }
  .doc-lines thead { display: none; }
  .doc-lines, .doc-lines tbody, .doc-lines tr, .doc-lines td { display: block; width: 100%; }
  .doc-lines tr { border-block-end: 1px solid #e1e7e5; padding-block: 8px; }
  .doc-lines td { border: 0; padding: 2px 0; background: transparent !important; }
  .doc-lines td.num { text-align: start; display: flex; justify-content: space-between; gap: 10px; }
  .doc-lines td.num::before { content: attr(data-label); color: #6b7a77; font-size: 11.5px; }
  .doc-draft { font-size: 60px; }
}

@media print {
  .doc-toolbar, .breadcrumbs, .page-header, .sticky-bar, .builder-rail { display: none !important; }
  .doc-stage { padding: 0; background: none; }
  .doc-paper { box-shadow: none; max-width: none; padding: 0; }
}

/* ---- Small shared helpers ------------------------------------------------- */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { display: contents; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 160px; }
.empty-hero {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 48px 24px;
}
.empty-hero .hero-icon { width: 56px; height: 56px; display: grid; place-items: center; color: var(--primary); background: var(--primary-50); border-radius: 14px; }
.empty-hero h3 { font-size: var(--fs-lg); }
.empty-hero p { max-width: 460px; color: var(--text-3); margin: 0; }
.muted-box { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--border-2); font-size: var(--fs-sm); color: var(--text-3); }
.hint-inline { font-size: var(--fs-xs); color: var(--text-3); }
.radio-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.radio-card {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  padding: 11px 12px; border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
}
.radio-card:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); background: var(--primary-50); }
.radio-card input { accent-color: var(--primary); margin-block-start: 3px; flex: none; }
.radio-card .t { font-weight: 600; font-size: var(--fs-sm); display: block; }
.radio-card .s { font-size: var(--fs-xs); color: var(--text-3); display: block; }
.live-price {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: var(--radius); background: var(--primary-50); border: 1px solid var(--primary-100);
  min-height: 56px;
}
.live-price .money { font-size: var(--fs-xl); font-weight: 750; color: var(--primary-700); }
.live-price.is-empty { background: var(--surface-2); border-color: var(--border); color: var(--text-3); }
.live-price.is-error { background: var(--danger-bg); border-color: rgba(200,68,47,.2); color: var(--danger-text); }
.live-price .grow { min-width: 0; }
.version-list { list-style: none; margin: 0; padding: 0; }
.version-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 14px 18px; border-block-end: 1px solid var(--border); align-items: center; }
.version-item:last-child { border-block-end: 0; }
.version-no {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; background: var(--surface-3); color: var(--text-2);
}
.version-item.current .version-no { background: var(--primary); color: #fff; }
.delta-up { color: var(--c-red-text); } .delta-down { color: var(--c-green-text); }
.compare-row.added td { background: var(--success-bg); }
.compare-row.removed td { background: var(--danger-bg); }
.compare-row.changed td { background: var(--warning-bg); }
@media (max-width: 599px) {
  .version-item { grid-template-columns: 36px minmax(0, 1fr); }
  .version-item > :last-child { grid-column: 2; }
}
.client-card { display: flex; gap: 12px; align-items: center; }
.client-avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-100); color: var(--primary-700); font-weight: 700; flex: none; }
.table .qref { font-weight: 700; color: var(--text); }
.table .qsub { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.badge-soft-warning { background: var(--c-amber-bg); color: var(--c-amber-text); }
.sheet-panel > form, .sheet-form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.w-full { width: 100%; }

/* ---- Agency pricing: contracts beside the contract form ------------------- */
.grid-2-1 { display: grid; gap: 20px; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-2-1 { grid-template-columns: minmax(0, 1fr); } }
.adj-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.adj-card.is-current { box-shadow: inset 3px 0 0 var(--c-green-text); }
[dir="rtl"] .adj-card.is-current { box-shadow: inset -3px 0 0 var(--c-green-text); }
.adj-card.is-editing { background: var(--surface-2); }
.card-body > .adj-card { padding-inline: 0; }
.form-error { font-size: var(--fs-sm); color: var(--danger-text); font-weight: 500; margin: 0; }
.disclosure-card > summary { list-style: none; }
.disclosure-card > summary::-webkit-details-marker { display: none; }
.disclosure-card:not([open]) > summary { border-block-end: 0; }

/* The hidden attribute always wins, whatever display a component sets. */
[hidden] { display: none !important; }
.adj-card.is-current { padding-inline-start: 14px; }

/* =====================================================================
   PHASE 5 - Bookings and operations
   ---------------------------------------------------------------------
   Operational screens answer "is it ready?" before anything else. Five
   shared ideas carry every Phase 5 screen, all built on the Phase 4
   tokens and components (qhead, meta-grid, stepper, sheets, KPI ribbon,
   ink panel), so a dossier reads like the quote it came from:

   1. READINESS is a colour with words: the pill (green / amber / red with
      the count of open issues), the bar under the dossier header that
      says the next thing to do, the issue list that links to the tab
      where it is fixed.
   2. The NEED chip: what a service or transfer still lacks - a supplier
      confirmation, a vehicle, a driver, a flight - red until it is there,
      green once it is, everywhere the same.
   3. The SLOT: one resource on one job (vehicle, driver, guide), filled
      or empty, with the action beside it. Assignment is a screen of
      candidates with their verdict in words, not a blind dropdown.
   4. The BOARD: arrivals and departures on a dark "flight board" band,
      large tabular times, one card per movement, built for a phone held
      in an arrivals hall.
   5. The CUSTOMER PAGE: the company's own page, the offer first, the
      answer panel sticky beside the document on a desk and before it on
      a phone.
   ===================================================================== */

.pill-count {
  display: inline-grid; place-items: center; min-width: 22px; padding: 1px 7px; margin-inline-start: 4px;
  border-radius: var(--radius-full); background: var(--surface-3); color: var(--text-2);
  font-size: var(--fs-xs); font-weight: 650; font-variant-numeric: tabular-nums; vertical-align: middle;
}
.crumbs { margin-block-end: 10px; }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; }
.crumbs a:hover { color: var(--primary); text-decoration: none; }
.select-sm, .input-sm { min-height: 32px; padding-block: 4px; font-size: var(--fs-sm); }
.link-btn { border: 0; background: none; padding: 0 4px; color: var(--primary); font: inherit; font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-block-start: 12px; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-block-end: 14px; }
.section-bar .sub { max-width: 640px; }
.day-title {
  display: flex; align-items: center; gap: 8px; margin-block: 20px 10px;
  font-size: var(--fs-sm); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-3);
}
.day-title:first-of-type { margin-block-start: 4px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list > li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; border-block-end: 1px solid var(--border); }
.plain-list > li:last-child { border-block-end: 0; }
.plain-list > li form { display: contents; }
.plain-list .grow { min-width: 180px; }
.kv-mini { display: grid; gap: 8px; margin: 0; }
.kv-mini > div { display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 10px; font-size: var(--fs-sm); }
.kv-mini dt { color: var(--text-3); }
.kv-mini dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.empty-hero.compact { padding: 28px 20px; }
.hero-icon.is-success { background: var(--success-bg); color: var(--success); }
.card-foot-note { margin: 0; padding: 10px 18px 14px; font-size: var(--fs-xs); color: var(--text-3); }
tr.is-muted td { opacity: .55; }
.table tr.has-missing td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
[dir="rtl"] .table tr.has-missing td:first-child { box-shadow: inset -3px 0 0 var(--danger); }

/* ---- KPI tiles that are links ---------------------------------------- */
a.kpi-link { color: inherit; transition: background var(--fast) var(--ease); }
a.kpi-link:hover { background: var(--surface-2); text-decoration: none; }
.kpi.is-critical .v { color: var(--danger); }
.kpi.is-attention .v { color: var(--warning); }

/* ---- Readiness ------------------------------------------------------- */
.readiness-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px;
  border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
  background: var(--c-green-bg); color: var(--c-green-text);
}
.readiness-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(255,255,255,.5); }
.readiness-pill .n { padding: 0 6px; border-radius: var(--radius-full); background: rgba(0,0,0,.08); font-variant-numeric: tabular-nums; }
.readiness-pill.is-attention { background: var(--c-amber-bg); color: var(--c-amber-text); }
.readiness-pill.is-critical { background: var(--c-red-bg); color: var(--c-red-text); }
.readiness-pill.is-critical .dot { animation: pulse-dot 1.8s var(--ease) infinite; }
@keyframes pulse-dot { 50% { box-shadow: 0 0 0 5px rgba(200, 68, 47, .18); } }
@media (prefers-reduced-motion: reduce) { .readiness-pill.is-critical .dot { animation: none; } }
.readiness-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c-green); }
.readiness-dot.is-attention { background: var(--c-amber); }
.readiness-dot.is-critical { background: var(--c-red); }

/* ---- The dossier header ---------------------------------------------- */
.dossier-head.is-attention::before { background: var(--c-amber); }
.dossier-head.is-critical::before { background: var(--c-red); }
.dossier-head.is-cancelled::before, .dossier-head.is-archived::before { background: var(--c-slate); }
.readiness-bar {
  display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap;
  margin: 16px -20px -18px; padding: 11px 20px;
  border-block-start: 1px solid var(--border); background: var(--c-green-bg); color: var(--c-green-text);
  font-size: var(--fs-sm);
}
.readiness-bar.is-attention { background: var(--c-amber-bg); color: var(--c-amber-text); }
.readiness-bar.is-critical { background: var(--c-red-bg); color: var(--c-red-text); }
.readiness-bar.is-cancelled { background: var(--surface-3); color: var(--text-2); }
.readiness-bar .readiness-pill { background: var(--surface); }
.readiness-bar .next-text { flex: 1; min-width: 200px; }
.readiness-bar .btn { color: inherit; }
@media (max-width: 699px) { .readiness-bar { margin-inline: -16px; margin-block-end: -16px; padding-inline: 16px; } }

/* ---- The dossier tabs: one URL each ------------------------------------ */
.dtabs {
  display: flex; gap: 2px; margin-block-end: 18px; overflow-x: auto; scrollbar-width: none;
  border-block-end: 1px solid var(--border);
  position: sticky; inset-block-start: var(--topbar-height); z-index: 15; background: var(--bg);
}
.dtabs::-webkit-scrollbar { display: none; }
.dtabs a {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 13px; margin-block-end: -1px; border-block-end: 2px solid transparent;
  color: var(--text-3); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
}
.dtabs a:hover { color: var(--text); text-decoration: none; }
.dtabs a.active { color: var(--primary); border-block-end-color: var(--primary); }
.dtabs .n { min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--surface-3); color: var(--text-2); font-size: 11px; text-align: center; }
.dtabs a.active .n { background: var(--primary-100); color: var(--primary-700); }
.dtabs .alert-dot { position: absolute; inset-block-start: 8px; inset-inline-end: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.dossier-body { min-width: 0; }

/* ---- Overview: check tiles and issues ------------------------------- */
.check-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check-tile {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: inherit;
}
.check-tile:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.ct-icon { grid-row: span 2; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--c-amber-bg); color: var(--c-amber-text); }
.check-tile.is-done .ct-icon { background: var(--c-green-bg); color: var(--c-green-text); }
.ct-label { font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; text-transform: none; letter-spacing: 0; }
.ct-value strong { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.ct-bar { grid-column: 1 / -1; display: block; height: 4px; margin-block-start: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.ct-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--c-amber); }
.check-tile.is-done .ct-bar > span, .ct-bar.is-done > span { background: var(--c-green); }
.issue-list { list-style: none; margin: 0; padding: 0; }
.issue { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-block-end: 1px solid var(--border); }
.issue:last-child { border-block-end: 0; }
.issue-mark { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--c-amber-bg); color: var(--c-amber-text); }
.issue.is-critical .issue-mark { background: var(--c-red-bg); color: var(--c-red-text); }
.issue-text { flex: 1; min-width: 0; font-size: var(--fs); }
.issue.is-critical .issue-text { font-weight: 600; }
.mini-timeline { list-style: none; margin: 0; padding: 0; }
.mini-timeline li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 11px 18px; border-block-end: 1px solid var(--border); }
.mini-timeline li:last-child { border-block-end: 0; }
.mini-timeline li.is-cancelled { opacity: .55; }
.mt-date { font-size: var(--fs-sm); font-weight: 650; font-variant-numeric: tabular-nums; }
.mt-body { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 599px) {
  .mini-timeline li { grid-template-columns: 78px minmax(0, 1fr); }
  .mini-timeline .mt-status { grid-column: 2; }
}
.task-mini { list-style: none; margin: 0; padding: 4px 0; }
.task-mini li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 18px; font-size: var(--fs-sm); }
.totals-row.is-danger .money, .totals-row.is-danger .label { color: var(--danger-text); }

/* ---- Needs, slots ---------------------------------------------------------- */
.need {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
a.need:hover { text-decoration: none; filter: brightness(.97); }
.need.is-ok { background: var(--c-green-bg); color: var(--c-green-text); }
.need.is-open { background: var(--c-amber-bg); color: var(--c-amber-text); }
.need.is-missing { background: var(--c-red-bg); color: var(--c-red-text); }
.need .mono { font-weight: 700; }
.slots { display: flex; gap: 8px; flex-wrap: wrap; margin-block-start: 10px; }
.slot {
  display: inline-flex; align-items: center; gap: 9px; padding: 6px 8px 6px 6px; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.slot.is-empty { border-style: dashed; border-color: var(--c-red); background: var(--c-red-bg); }
.slot-icon { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--c-teal-bg); color: var(--c-teal-text); }
.slot.is-empty .slot-icon { background: var(--surface); color: var(--c-red-text); }
.slot-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.slot-text strong { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.slot-label { font-size: 10.5px; text-transform: none; letter-spacing: 0; color: var(--text-3); font-weight: 600; }
.slot-action {
  border: 0; background: var(--surface-3); color: var(--primary-700); padding: 4px 9px; border-radius: var(--radius-sm);
  font: inherit; font-size: var(--fs-xs); font-weight: 700; cursor: pointer; white-space: nowrap;
}
.slot-action:hover { background: var(--primary-100); text-decoration: none; }
.slot-action.is-danger { color: var(--danger); background: transparent; padding: 4px; }

/* ---- Booked services ------------------------------------------------------ */
.svc-list { display: flex; flex-direction: column; }
.svc { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 14px; padding: 16px 18px; border-block-end: 1px solid var(--border); scroll-margin-block-start: 120px; }
.svc:last-child { border-block-end: 0; }
.svc:target { background: var(--primary-50); }
.svc.is-cancelled { opacity: .6; }
.svc.is-problem { box-shadow: inset 3px 0 0 var(--danger); }
[dir="rtl"] .svc.is-problem { box-shadow: inset -3px 0 0 var(--danger); }
.svc-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.svc-body { min-width: 0; }
.svc-top { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.svc-title { font-size: var(--fs-md); font-weight: 650; overflow-wrap: anywhere; margin: 0; }
.svc-needs { display: flex; gap: 6px; flex-wrap: wrap; margin-block-start: 10px; }
.svc-note { display: flex; gap: 7px; align-items: flex-start; margin: 8px 0 0; padding: 7px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: var(--fs-sm); color: var(--text-2); }
.svc-note .icon { margin-block-start: 2px; flex: none; color: var(--text-3); }
.svc-note.is-internal { background: var(--c-amber-bg); color: var(--c-amber-text); }
.svc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-block-start: 12px; }
.svc-actions form { display: contents; }
.svc .qline-internal { margin-block-start: 10px; }
@media (max-width: 599px) {
  .svc { grid-template-columns: 1fr; padding: 14px; }
  .svc-icon { display: none; }
  .svc-actions .btn { flex: 1 1 auto; }
}

/* ---- Passengers --------------------------------------------------------- */
.pax-summary { margin-block-end: 16px; }
.pax-summary-body { display: flex; gap: 14px 28px; align-items: center; flex-wrap: wrap; }
.pax-count { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.pax-count .big { font-size: var(--fs-2xl); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pax-count .big .sub { font-size: var(--fs-lg); font-weight: 500; }
.pax-count .ct-bar { width: 140px; }
.bulk-flight { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.check-col { width: 36px; }
.check-col input { width: 18px; height: 18px; accent-color: var(--primary); }
.flight-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.flight-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--c-blue-bg); color: var(--c-blue-text); font-size: var(--fs-xs); font-weight: 700;
}
@media (max-width: 899px) { .pax-table .check-col { justify-content: flex-start; } }

/* ---- Flights ---------------------------------------------------------------- */
.flight-list { display: flex; flex-direction: column; }
.flight-card { display: grid; grid-template-columns: 86px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 18px; border-block-end: 1px solid var(--border); }
.flight-card:last-child { border-block-end: 0; }
.fc-time { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: var(--radius); background: var(--ink); color: #fff; }
.fc-hour { font-size: var(--fs-xl); font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.fc-date { font-size: 10.5px; color: var(--ink-muted); text-transform: none; }
.fc-number { font-size: var(--fs-md); font-weight: 700; }
.fc-route { font-size: var(--fs-sm); color: var(--text-2); margin-block-start: 2px; }
@media (max-width: 599px) {
  .flight-card { grid-template-columns: 72px minmax(0, 1fr); padding: 12px 14px; }
  .flight-card .row-actions { grid-column: 1 / -1; }
}

/* ---- Transfers: legs --------------------------------------------------------- */
.leg-list { display: flex; flex-direction: column; gap: 10px; }
.leg {
  display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 16px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  scroll-margin-block-start: 120px;
}
.leg:target { box-shadow: 0 0 0 3px var(--ring); }
.leg.is-planned { border-inline-start: 4px solid var(--c-red); }
.leg.is-assigned { border-inline-start: 4px solid var(--c-amber); }
.leg.is-ready { border-inline-start: 4px solid var(--c-green); }
.leg.is-cancelled { opacity: .55; border-inline-start: 4px solid var(--c-slate); }
.leg-time { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.leg-hour { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; letter-spacing: -.01em; }
.leg-type { font-size: var(--fs-xs); text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--text-3); }
.leg-route { display: flex; flex-direction: column; gap: 6px; margin-block: 8px; position: relative; }
.leg-point { display: flex; gap: 10px; align-items: flex-start; }
.dot-from, .dot-to { width: 10px; height: 10px; flex: none; margin-block-start: 5px; border-radius: 50%; border: 2px solid var(--primary); background: var(--surface); }
.dot-to { background: var(--primary); }
@media (max-width: 599px) {
  .leg { grid-template-columns: 1fr; gap: 8px; padding: 14px; }
  .leg-time { flex-direction: row; align-items: center; justify-content: space-between; }
  .slot { flex: 1 1 100%; }
  .slot-text strong { max-width: none; }
}

/* ---- Resources: jobs, candidates ------------------------------------------- */
.job-list { display: flex; flex-direction: column; }
.job { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; padding: 14px 18px; border-block-end: 1px solid var(--border); }
.job:last-child { border-block-end: 0; }
.job-when { display: flex; flex-direction: column; font-size: var(--fs-sm); }
.job-title { font-weight: 650; overflow-wrap: anywhere; }
@media (max-width: 599px) { .job { grid-template-columns: 1fr; gap: 4px; } .job-when { flex-direction: row; gap: 8px; } }
.candidate-list { display: flex; flex-direction: column; gap: 8px; }
.candidate {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.cand-state { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; }
.candidate.is-free .cand-state { background: var(--c-green-bg); color: var(--c-green-text); }
.candidate.is-warning .cand-state { background: var(--c-amber-bg); color: var(--c-amber-text); }
.candidate.is-blocked { background: var(--surface-2); }
.candidate.is-blocked .cand-state { background: var(--c-red-bg); color: var(--c-red-text); }
.candidate.is-current { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.cand-body { min-width: 0; }
.cand-line { font-size: var(--fs-sm); margin-block-start: 3px; }
.cand-line.is-danger { color: var(--danger-text); font-weight: 600; }
.cand-line.is-warning { color: var(--warning-text); }
@media (max-width: 599px) { .candidate { grid-template-columns: 28px minmax(0, 1fr); } .candidate > .btn, .candidate > .badge { grid-column: 2; justify-self: start; } }

/* ---- Suppliers --------------------------------------------------------------- */
.request-trail { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.request-trail li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); padding-inline-start: 12px; border-inline-start: 2px solid var(--border); }
.request-trail li.is-current { border-inline-start-color: var(--primary); }
.request-body { font-family: inherit; line-height: 1.55; background: var(--surface-2); }
.send-options { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.send-options form { display: contents; }
.alt-card { border-color: var(--c-amber); }

/* ---- Rooming ---------------------------------------------------------------- */
.room-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.room-card { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); scroll-margin-block-start: 120px; }
.room-card.is-full { background: var(--surface); }
.room-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.room-type { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.guest-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.guest { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 10px; border-radius: var(--radius-full); background: var(--primary-50); color: var(--primary-700); font-size: var(--fs-sm); font-weight: 600; }
.guest form { display: inline; }
.guest .x { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; opacity: .7; padding: 0 3px; }
.guest.is-empty { background: transparent; border: 1px dashed var(--border-2); color: var(--text-3); font-weight: 500; padding-inline-end: 10px; }
.room-actions { display: flex; gap: 8px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }

/* ---- Manifests and papers ------------------------------------------------ */
.manifest-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.manifest-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.manifest-card h3 { font-size: var(--fs-md); }
.mc-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; background: var(--primary-50); color: var(--primary); flex: none; }
.mc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-block-start: auto; }
.mc-sensitive { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--warning-text); }
.ops-paper.is-wide { max-width: 1180px; }
.doc-meta { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.doc-kv { display: grid; gap: 0; margin: 0; }
.doc-kv > div { display: grid; grid-template-columns: minmax(120px, 32%) 1fr; gap: 12px; padding: 8px 0; border-block-end: 1px solid #e1e7e5; }
.doc-kv dt { color: #6b7a77; font-size: 12.5px; }
.doc-kv dd { margin: 0; font-weight: 700; }
.manifest-table td { font-size: 12.5px; }
.voucher-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text); font-size: var(--fs-xs); font-weight: 600; }
.voucher-chip:hover { text-decoration: none; background: var(--primary-50); }
.link-history summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.link-history ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.link-history li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
@media print {
  .dtabs, .crumbs, .qhead, .sidebar, .topbar, .bottom-nav, .doc-toolbar, .sign-options { display: none !important; }
  .ops-paper { padding: 0; }
}

/* ---- Meet & greet sign --------------------------------------------------- */
.sign-layout { display: grid; gap: 18px; grid-template-columns: 320px minmax(0, 1fr); align-items: start; }
.sign-stage { padding: 22px; border-radius: var(--radius-lg); background: var(--surface-3); }
.sign-paper {
  position: relative; container-type: inline-size; margin-inline: auto; max-width: 900px; aspect-ratio: 297 / 210;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2cqw;
  padding: 6cqw 5cqw; background: #fff; color: #0f1716; border-radius: 4px; overflow: hidden;
  box-shadow: 0 10px 40px rgba(17, 32, 29, .14);
}
.sign-paper.is-a5 { max-width: 640px; }
.sign-logo { position: absolute; inset-block-start: 4cqw; inset-inline-start: 4.5cqw; height: 7cqw; display: flex; align-items: center; }
.sign-logo img { max-height: 100%; max-width: 30cqw; }
.sign-logo span { font-weight: 800; font-size: 3cqw; color: var(--doc-brand); }
.sign-name { font-size: var(--sign-size, 10cqw); font-weight: 850; line-height: 1.05; text-align: center; letter-spacing: -.01em; overflow-wrap: anywhere; max-width: 100%; }
.sign-foot { position: absolute; inset-block-end: 6cqw; font-size: 2.6cqw; color: #5a6865; font-weight: 600; }
.sign-band { position: absolute; inset-inline: 0; inset-block-end: 0; height: 2cqw; background: var(--doc-brand); }
@media (max-width: 899px) { .sign-layout { grid-template-columns: 1fr; } .sign-stage { padding: 10px; order: -1; } }

/* ---- Arrivals board: the flight board band --------------------------------- */
.board-hero {
  padding: 20px 22px; margin-block-end: 16px; border-radius: var(--radius-xl);
  background: radial-gradient(120% 140% at 100% 0%, #1f3a34 0%, var(--ink) 55%), var(--ink);
  color: var(--ink-text); border: 1px solid #0b1513;
}
.board-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.board-kicker { display: inline-flex; align-items: center; gap: 7px; margin: 0; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-muted); }
.board-hero h1 { margin: 6px 0 2px; color: #fff; font-size: var(--fs-2xl); }
.board-date { margin: 0; color: #cfe1dc; font-weight: 600; }
.board-switch { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-lg); background: rgba(255,255,255,.07); }
.board-switch a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: var(--radius); color: #cfe1dc; font-size: var(--fs-sm); font-weight: 650; }
.board-switch a:hover { text-decoration: none; background: rgba(255,255,255,.06); }
.board-switch a.active { background: #fff; color: var(--ink); }
.board-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-block-start: 18px; border-radius: var(--radius-lg); overflow: hidden; background: rgba(255,255,255,.08); }
.board-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: rgba(8, 16, 14, .55); }
.board-stats .v { font-size: var(--fs-2xl); font-weight: 750; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.05; }
.board-stats .l { font-size: 10.5px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--ink-muted); }
.board-stats .is-alert .v { color: #ffb4a6; }
.board-controls { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.board-controls .seg { margin-block-end: 10px; }
.seg-more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; padding: 7px 12px; min-height: 36px; border-radius: var(--radius); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; }
.seg-more > summary::-webkit-details-marker { display: none; }
.seg-more.active > summary { background: var(--primary); color: var(--primary-contrast); }
.board-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-block-end: 10px; }
.board-honest { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; font-size: var(--fs-xs); color: var(--text-3); }
.board-group-block { margin-block-end: 18px; }
.board-group-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 8px; font-size: var(--fs-sm); font-weight: 750; color: var(--text-2); }
.mv-list { display: flex; flex-direction: column; gap: 8px; }
.mv {
  display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 14px; align-items: start;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  border-inline-start: 4px solid var(--c-green);
}
.mv.is-open { border-inline-start-color: var(--c-red); }
.mv-time { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px 4px; border-radius: var(--radius); background: var(--ink); color: #fff; }
.mv-hour { font-size: 1.55rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .02em; line-height: 1; }
.mv-day { font-size: 10px; margin-block-start: 3px; color: var(--ink-muted); text-transform: none; }
.mv-main { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.mv-flight { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.mv-code { font-size: var(--fs-md); font-weight: 800; letter-spacing: .03em; color: var(--primary-700); }
.mv-route { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.mv-who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mv-who strong { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.mv-pax { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-full); background: var(--surface-3); font-weight: 700; font-size: var(--fs-sm); }
.mv-call { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); font-weight: 600; }
.mv-where { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.mv-staff { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-2); }
.mv-staff > span { display: inline-flex; align-items: center; gap: 5px; }
.mv-staff .is-missing { color: var(--danger-text); font-weight: 650; }
.mv-missing { display: flex; gap: 5px; flex-wrap: wrap; }
.mv-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.mv-ref { font-weight: 700; font-size: var(--fs-sm); }
@media (max-width: 699px) {
  .board-hero { padding: 16px; border-radius: var(--radius-lg); }
  .board-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board-switch { width: 100%; }
  .board-switch a { flex: 1; justify-content: center; }
  .mv { grid-template-columns: 74px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .mv-hour { font-size: 1.3rem; }
  .mv-side { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; padding-block-start: 8px; border-block-start: 1px dashed var(--border); }
  .mv-who strong { font-size: var(--fs-md); }
}

/* ---- Transfer planning ------------------------------------------------------ */
.plan-card { margin-block-end: 8px; }
.plan-time { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.plan-slots { display: flex; gap: 5px; flex-wrap: wrap; }
.inline-dates { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---- Tasks ------------------------------------------------------------------ */
.task-list { list-style: none; margin: 0; padding: 0; }
.task { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 13px 18px; border-block-end: 1px solid var(--border); }
.task:last-child { border-block-end: 0; }
.task form { display: contents; }
.task-check {
  width: 22px; height: 22px; margin-block-start: 1px; display: grid; place-items: center;
  border: 2px solid var(--border-2); border-radius: 7px; background: var(--surface); color: #fff; cursor: pointer;
}
button.task-check:hover { border-color: var(--success); background: var(--success-bg); }
.task-check.is-done { background: var(--success); border-color: var(--success); }
.task.is-closed .task-title { text-decoration: line-through; color: var(--text-3); }
.task.is-overdue .task-check { border-color: var(--danger); }
.task-title { font-weight: 600; overflow-wrap: anywhere; }
.task-title .badge { margin-inline-start: 4px; }
.checklist { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.checklist li { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); }
.checklist li.is-done span { text-decoration: line-through; color: var(--text-3); }
.mini-check { width: 18px; height: 18px; display: grid; place-items: center; border: 1.5px solid var(--border-2); border-radius: 5px; background: var(--surface); color: var(--success); cursor: pointer; padding: 0; }
.suggest-card { border-color: var(--primary-200); background: linear-gradient(0deg, var(--surface), var(--primary-50)); }
.seg .seg-toggle { margin-inline-start: auto; }

/* ---- Notes, timeline, itinerary -------------------------------------------- */
.notes-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.notes-grid .card + .card { margin-block-start: 0; }
.note-internal_notes { border-top: 3px solid var(--c-amber); }
.note-customer_notes { border-top: 3px solid var(--c-teal); }
.tl-day + .tl-day { margin-block-start: 18px; }
.tl-day-title { font-size: var(--fs-xs); text-transform: none; letter-spacing: 0; color: var(--text-3); margin-block-end: 4px; }
.timeline-item.tone-success .timeline-dot { background: var(--c-green); }
.timeline-item.tone-danger .timeline-dot { background: var(--c-red); }
.timeline-item.tone-info .timeline-dot { background: var(--c-blue); }
.itinerary { list-style: none; margin: 0; padding: 0; }
.it-day { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 16px; position: relative; padding-block-end: 18px; }
.it-day::before { content: ""; position: absolute; inset-block: 42px 0; inset-inline-start: 32px; width: 2px; background: var(--border); }
.it-day:last-child::before { display: none; }
.it-marker { display: flex; justify-content: center; }
.it-n { display: grid; place-items: center; width: 60px; height: 38px; border-radius: 12px; background: var(--primary); color: #fff; font-size: var(--fs-xs); font-weight: 600; text-transform: none; letter-spacing: 0; }
.it-content { min-width: 0; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.it-date { font-size: var(--fs-md); margin-block-end: 8px; }
.it-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.it-items li { display: grid; grid-template-columns: 46px 28px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 8px 0; border-block-start: 1px dashed var(--border); }
.it-items li:first-child { border-block-start: 0; }
.it-time { font-size: var(--fs-sm); font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; padding-block-start: 3px; }
.it-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--primary-50); color: var(--primary); }
.it-text { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 599px) {
  .it-day { grid-template-columns: 1fr; gap: 6px; }
  .it-day::before { display: none; }
  .it-marker { justify-content: flex-start; }
  .it-n { width: auto; padding-inline: 12px; height: 28px; }
  .it-items li { grid-template-columns: 40px minmax(0, 1fr); }
  .it-items .it-icon { display: none; }
  .it-items .badge { grid-column: 2; justify-self: start; }
}

/* ---- Import steps ------------------------------------------------------------ */
.import-steps { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-block-end: 14px; }
.confirm-card { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

/* ---- Dashboard widgets --------------------------------------------------------- */
.w-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 8px; }
.w-stats > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 8px; border-radius: var(--radius); background: var(--surface-2); }
.w-stats .v { font-size: var(--fs-xl); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.w-stats .l { font-size: 11.5px; color: var(--text-3); font-weight: 600; line-height: 1.25; overflow-wrap: break-word; hyphens: auto; }
.w-stats .is-alert { background: var(--danger-bg); }
.w-stats .is-alert .v { color: var(--danger-text); }
/* Money figures in dashboard widgets (finance): wider columns, a smaller
   figure that wraps rather than clipping. Here, not in finance.css, which the
   dashboard does not load. */
.fin-w-stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.fin-w-stats .v.money { font-size: var(--fs-lg); white-space: normal; overflow-wrap: anywhere; }
.w-list, .day-rail { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; }
.w-list li, .day-rail li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-block-start: 1px solid var(--border); font-size: var(--fs-sm); min-width: 0; }
.w-list li > a, .day-rail li > a { color: inherit; min-width: 0; overflow-wrap: anywhere; }
.w-list li.is-stacked { flex-direction: column; align-items: flex-start; gap: 2px; }
.w-list li.is-stacked > * { max-width: 100%; }
/* In a column a zero flex basis is a zero HEIGHT: stacked rows size to content. */
.w-list li.is-stacked > a.w-trunc { flex: none; }
.w-list li > a:hover, .day-rail li > a:hover { color: var(--primary); text-decoration: none; }
.w-list li > a.w-trunc { flex: 1 1 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.w-list.is-wrap li { flex-wrap: wrap; row-gap: 4px; }
.w-list.is-wrap li > a.w-trunc { flex: 1 1 9ch; }
.w-time { flex: none; min-width: 48px; font-weight: 750; font-variant-numeric: tabular-nums; color: var(--text-2); }
.manifest-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.manifest-bars li { display: grid; grid-template-columns: minmax(120px, 30%) minmax(0, 1fr) 56px; gap: 12px; align-items: center; }
.manifest-bars .mb-label { display: flex; flex-direction: column; color: inherit; font-weight: 650; font-size: var(--fs-sm); }
.manifest-bars .ct-bar { margin: 0; height: 8px; }
.mb-count { text-align: end; font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }

/* ---- Acceptance, staff side -------------------------------------------------- */
.decision-seal { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); }
.decision-seal.is-accepted { background: var(--success-bg); color: var(--success-text); }
.decision-seal.is-rejected { background: var(--danger-bg); color: var(--danger-text); }
.seal-icon { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface); }
.booking-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--primary-200); border-radius: var(--radius); background: var(--primary-50); color: var(--text); }
.booking-link:hover { text-decoration: none; box-shadow: 0 0 0 3px var(--ring); }
.bl-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--primary); color: #fff; flex: none; }
.link-box { display: flex; flex-direction: column; gap: 6px; }
.link-row { display: flex; gap: 6px; }
.link-row .input { flex: 1; min-width: 0; font-size: var(--fs-xs); }
.penalty-box { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--ink); color: var(--ink-text); }
.penalty-box .money-lg { color: #fff; }
.penalty-box .meta-label { color: var(--ink-muted); }

/* ---- The customer's page ------------------------------------------------------ */
.public-body { background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
.public-top { background: var(--surface); border-block-end: 1px solid var(--border); }
.public-top-inner { max-width: 1180px; margin-inline: auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.public-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.public-mark { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--primary); color: #fff; font-weight: 800; font-size: 18px; overflow: hidden; }
.public-mark.has-logo { background: transparent; }
.public-mark img { max-width: 100%; max-height: 100%; }
.public-name { font-weight: 750; font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-contact { display: flex; gap: 14px; }
.public-contact a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; }
.public-main { flex: 1; width: 100%; max-width: 1180px; margin-inline: auto; padding: 24px 20px 96px; }
.public-foot { padding: 18px 20px; text-align: center; font-size: var(--fs-xs); color: var(--text-3); border-block-start: 1px solid var(--border); background: var(--surface); }
.offer-hero {
  position: relative; overflow: hidden; margin-block-end: 20px; padding: 26px 28px;
  border-radius: var(--radius-xl); color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-700) 100%);
}
.offer-hero::after { content: ""; position: absolute; inset-block-start: -40%; inset-inline-end: -10%; width: 360px; height: 360px; border-radius: 50%; background: rgba(255,255,255,.07); pointer-events: none; }
.offer-kicker { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0; text-transform: none; opacity: .8; }
.offer-hero h1 { margin: 8px 0 10px; color: #fff; font-size: clamp(1.4rem, 3vw, 2.1rem); line-height: 1.15; max-width: 760px; overflow-wrap: anywhere; }
.offer-facts { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: var(--fs-sm); opacity: .92; }
.offer-facts span { display: inline-flex; align-items: center; gap: 6px; }
.offer-total { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; margin-block-start: 18px; }
.offer-total-label { font-size: var(--fs-xs); text-transform: none; letter-spacing: 0; font-weight: 600; opacity: .75; }
.offer-total .money-xl { color: #fff; }
.offer-valid { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-full); background: rgba(255,255,255,.14); font-size: var(--fs-sm); font-weight: 600; }
.offer-layout { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.offer-panel { grid-column: 2; grid-row: 1; position: sticky; inset-block-start: 16px; display: flex; flex-direction: column; gap: 12px; }
.offer-doc { grid-column: 1; grid-row: 1; min-width: 0; }
.offer-doc .doc-paper { max-width: none; }
.answer-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.answer-card h2 { font-size: var(--fs-lg); margin-block-end: 4px; }
.answer-card.is-accepted { border-color: var(--success); background: linear-gradient(180deg, var(--success-bg), var(--surface) 60%); }
.answer-card.is-rejected { border-color: var(--border-2); }
.answer-card.is-closed { background: var(--surface-2); box-shadow: none; }
.answer-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-block-end: 10px; border-radius: 14px; background: var(--primary-50); color: var(--primary); }
.answer-card.is-accepted .answer-icon { background: var(--success); color: #fff; }
.answer-card.is-rejected .answer-icon { background: var(--surface-3); color: var(--text-2); }
.answer-switch { display: flex; gap: 4px; padding: 4px; margin-block: 14px; border-radius: var(--radius); background: var(--surface-3); }
.answer-switch a { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: var(--fs-sm); font-weight: 650; }
.answer-switch a:hover { text-decoration: none; }
.answer-switch a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.agree-line { align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm); }
.agree-line.is-invalid { border-color: var(--danger); background: var(--danger-bg); }
.offer-actions { display: flex; gap: 6px; }
.offer-actions .btn { flex: 1; }
.offer-bar { display: none; }
.invalid-link { max-width: 520px; margin: 60px auto; text-align: center; }
.invalid-link .answer-icon { margin-inline: auto; }
@media (max-width: 999px) {
  .offer-layout { grid-template-columns: minmax(0, 1fr); }
  .offer-panel, .offer-doc { grid-column: 1; grid-row: auto; position: static; }
  .offer-bar {
    display: flex; align-items: center; gap: 12px; position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 30;
    padding: 10px 16px; padding-block-end: calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--surface); border-block-start: 1px solid var(--border); box-shadow: 0 -8px 20px rgba(17,32,29,.1);
  }
  .offer-bar .label { display: block; font-size: var(--fs-xs); color: var(--text-3); }
  .offer-bar .money { font-size: var(--fs-lg); font-weight: 750; }
}
@media (max-width: 599px) {
  .public-main { padding: 14px 16px 96px; }
  .offer-hero { padding: 20px 18px; border-radius: var(--radius-lg); }
  .offer-total .money-xl { font-size: 1.7rem; }
  .public-top-inner { padding: 10px 16px; }
}
@media print {
  .public-top, .offer-panel, .offer-bar, .public-foot { display: none !important; }
  .offer-hero { background: none; color: #000; padding: 0; }
  .offer-hero h1, .offer-total .money-xl { color: #000; }
}

/* Phase 5: a service's document languages */
.lang-row { display: grid; grid-template-columns: 34px minmax(80px, 1fr) auto; gap: 4px 12px; align-items: center; }
.lang-row .ct-bar { margin: 0; height: 6px; }
.lang-row .hint-inline { grid-column: 2 / -1; }

/* ---- Brand lockup (1.3.0): logo, SaaS name, BY LUXIOUS ---- */
/* A logo keeps its own proportions: a wide wordmark widens the tile (up to a
   limit) instead of shrinking into a square. */
.brand-mark.has-logo { background: #fff; padding: 3px 5px; overflow: hidden; width: auto; min-width: 32px; }
.brand-mark.has-logo img { display: block; height: 26px; width: auto; max-width: 94px; object-fit: contain; }
.brand-lockup { display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; }
.brand-lockup-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-lockup-name { font-weight: 700; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-maker { font-size: 9.5px; font-weight: 600; letter-spacing: 0; text-transform: none; opacity: .62; margin-block-start: 2px; }
.brand-lockup-dark .brand-lockup-name { color: #fff; }
.brand-lockup-dark .brand-maker { color: var(--sidebar-text); }
.brand-lockup-sm .brand-mark { width: 24px; height: 24px; font-size: 12px; border-radius: 7px; }
.brand-lockup-sm .brand-lockup-name { font-size: var(--fs-xs); }
.brand-lockup-sm .brand-maker { font-size: 8px; }
.brand-lockup-lg .brand-mark { width: 42px; height: 42px; font-size: 18px; border-radius: 11px; }
.brand-lockup-lg .brand-mark.has-logo { width: auto; min-width: 42px; }
.brand-lockup-lg .brand-mark.has-logo img { height: 36px; max-width: 140px; }
.brand-lockup-sm .brand-mark.has-logo { width: auto; min-width: 24px; padding: 2px 3px; }
.brand-lockup-sm .brand-mark.has-logo img { height: 20px; max-width: 58px; }
.brand-lockup-lg .brand-lockup-name { font-size: var(--fs-lg); }
.sidebar-footer .brand-lockup { flex: 1; }

/* =====================================================================
   1.4.0 - Searchable picker (assets/js/picker.js)
   The native select stays in the form, visually hidden; the text box and
   its list replace it on screen. Logical properties: correct in RTL.
   ===================================================================== */
.picker-native {
  position: absolute !important; inline-size: 1px !important; block-size: 1px !important;
  opacity: 0; pointer-events: none; overflow: hidden; clip-path: inset(50%);
}
.picker { position: relative; }
.picker-input {
  padding-inline-end: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
[dir="rtl"] .picker-input { background-position: 13px 50%, 18px 50%; }
.picker-list {
  position: absolute; z-index: 60; inset-inline: 0; inset-block-start: calc(100% + 4px);
  max-block-size: min(320px, 50vh); overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}
.picker-option {
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; min-block-size: 40px; justify-content: center;
}
.picker-option.is-active { background: var(--primary-50); }
.picker-option[aria-selected="true"] .picker-label { font-weight: 650; }
.picker-label { color: var(--text); font-size: var(--fs); line-height: 1.3; }
.picker-sub { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.3; }
.picker-empty { padding: 10px; color: var(--text-3); font-size: var(--fs-sm); }
.sheet .picker-list { max-block-size: min(260px, 40vh); }
@media (max-width: 640px) {
  .picker-input { font-size: 16px; } /* no zoom on focus (iOS) */
  .picker-option { min-block-size: 44px; }
}

/* =====================================================================
   1.4.0 - Stop lists (itineraries) and the itinerary result
   ===================================================================== */
.stops { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; position: relative; }
.stop {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: end; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.stop.is-dragging { opacity: .55; border-style: dashed; }
.stop-grip {
  align-self: center; border: 0; background: none; color: var(--text-3); cursor: grab; padding: 4px; border-radius: var(--radius-sm);
}
.stop-mark {
  align-self: center; inline-size: 26px; block-size: 26px; border-radius: var(--radius-full); display: grid; place-items: center;
  font-size: var(--fs-xs); font-weight: 700; background: var(--surface-3); color: var(--text-2);
}
.stop.is-end .stop-mark { background: var(--primary); color: #fff; }
.stop-field { min-inline-size: 0; display: flex; flex-direction: column; gap: 4px; }
.stop-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); text-transform: none; }
.stop-actions { display: flex; gap: 2px; align-self: center; }
.stop-actions .btn[disabled] { opacity: .3; }
@media (max-width: 640px) {
  .stop { grid-template-columns: auto minmax(0, 1fr); row-gap: 6px; }
  .stop-grip { display: none; }
  .stop-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .stop-actions .btn { min-inline-size: 44px; min-block-size: 40px; }
}

.itin-result { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--surface-2); }
.itin-legs { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.itin-leg {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.itin-leg.is-unknown { border-color: var(--c-amber-bg); }
.itin-leg-no { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); inline-size: 20px; text-align: center; }
.itin-leg-route { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-inline-size: 0; }
.itin-leg-route strong { font-weight: 600; overflow-wrap: anywhere; }
.itin-arrow { color: var(--text-3); display: inline-flex; }
.itin-leg-figures { display: flex; gap: 8px; align-items: center; white-space: nowrap; font-size: var(--fs-sm); }
.itin-totals { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 0; }
.itin-totals div { display: flex; flex-direction: column; gap: 2px; }
.itin-totals dt { font-size: var(--fs-xs); color: var(--text-3); }
.itin-totals dd { margin: 0; font-size: var(--fs-md); font-weight: 700; }
.itin-note { margin: 10px 0 0; display: flex; gap: 6px; align-items: center; color: var(--c-amber-text); font-size: var(--fs-sm); }
@media (max-width: 640px) {
  .itin-leg { grid-template-columns: auto minmax(0, 1fr); }
  .itin-leg-figures { grid-column: 2; white-space: normal; flex-wrap: wrap; }
}

/* 1.4.0: a multi-day excursion's programme under its line */
.doc-program { margin: 4px 0 0; padding-inline-start: 18px; }
.doc-program li { margin: 1px 0; }

/* =====================================================================
   1.4.0 - Type of service first; the day by day programme
   ===================================================================== */
.nb-types { border: 0; margin: 0 0 12px; padding: 0; min-inline-size: 0; }
.nb-types-legend { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-block-end: 8px; padding: 0; }
.nb-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.nb-type { position: relative; display: block; }
.nb-type input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.nb-type-box {
  display: flex; align-items: center; gap: 8px; min-block-size: 44px; padding: 8px 10px;
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); line-height: 1.2;
  transition: border-color var(--fast), background var(--fast);
}
.nb-type-box .icon { flex: none; color: var(--text-3); }
.nb-type input:hover + .nb-type-box { border-color: var(--primary); }
.nb-type input:focus-visible + .nb-type-box { outline: 2px solid var(--primary); outline-offset: 2px; }
.nb-type input:checked + .nb-type-box { border-color: var(--primary); background: var(--primary-50); color: var(--text); }
.nb-type input:checked + .nb-type-box .icon { color: var(--primary); }
.nb-type-hint { margin-block-start: 8px; }
.nb-line-body[hidden] { display: none; }
@media (max-width: 640px) {
  .nb-type-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.prog { margin-block: 14px; padding: 12px; border: 1px dashed var(--border-2); border-radius: var(--radius-lg); background: var(--surface-2); }
.prog-top { margin-block-end: 10px; }
.prog-title { display: flex; align-items: center; gap: 6px; font-size: var(--fs-md); margin: 0 0 2px; }
.prog-days { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prog-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.prog-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 10px; cursor: pointer; list-style: none;
}
.prog-head::-webkit-details-marker { display: none; }
.prog-no {
  inline-size: 28px; block-size: 28px; border-radius: var(--radius-full); display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 700; font-size: var(--fs-sm);
}
.prog-head-text { display: flex; flex-direction: column; min-inline-size: 0; }
.prog-label { font-weight: 650; }
.prog-route { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-actions { display: flex; gap: 2px; }
.prog-actions .btn[disabled] { opacity: .3; }
.prog-body { padding: 4px 12px 12px; border-block-start: 1px solid var(--border); }
.prog-sub { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-block-end: 6px; }
.prog-meals { border: 0; padding: 0; margin: 0; display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px 16px; align-items: center; justify-content: flex-start; }
.prog-meals .checkbox { flex: none; min-block-size: 32px; align-items: center; }
.prog-meals legend { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); padding: 0; margin-block-end: 4px; inline-size: 100%; }
@media (max-width: 640px) {
  .prog { padding: 8px; }
  .prog-body { padding: 4px 8px 10px; }
  .prog-actions .btn { min-inline-size: 40px; min-block-size: 40px; }
}

/* 1.4.0: a field shown for some types of service only (resource-form 'families') */
.field-wrap { display: contents; }
.field-wrap[hidden] { display: none; }
[data-type-wait][hidden] { display: none; }

/* =====================================================================
   1.4.0 - Platform: a company's modules (switches) and activity
   ===================================================================== */
.mod-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.mod-stat {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.mod-stat-label { font-size: var(--fs-xs); color: var(--text-3); text-transform: none; letter-spacing: 0; font-weight: 600; }
.mod-stat-value { font-size: var(--fs-lg); font-weight: 700; }
.mod-stat-link { font-size: var(--fs-sm); }
.mod-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.mod-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  cursor: pointer; transition: border-color var(--fast), background var(--fast);
}
.mod-row:hover { border-color: var(--border-2); }
.mod-row.is-custom { background: var(--surface-2); }
.mod-row.is-changed { border-color: var(--primary); }
.mod-icon {
  inline-size: 34px; block-size: 34px; border-radius: var(--radius); display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary);
}
.mod-text { display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.mod-name { font-weight: 650; }
.mod-desc { font-size: var(--fs-sm); color: var(--text-3); line-height: 1.35; }
.mod-src { font-size: var(--fs-xs); color: var(--text-3); margin-block-start: 2px; }
.mod-src-activity { color: var(--c-green-text); }
.mod-src-custom { color: var(--c-amber-text); font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 8px; position: relative; flex: none; }
.switch input { position: absolute; opacity: 0; inset-inline: 0; inset-block: -9px; inline-size: 100%; block-size: auto; min-block-size: 44px; margin: 0; cursor: pointer; }
.switch-track {
  inline-size: 44px; block-size: 26px; border-radius: var(--radius-full); background: var(--border-2);
  position: relative; transition: background var(--fast); flex: none;
}
.switch-knob {
  position: absolute; inset-block-start: 3px; inset-inline-start: 3px; inline-size: 20px; block-size: 20px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: inset-inline-start var(--fast);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track .switch-knob { inset-inline-start: 21px; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch-state { font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); min-inline-size: 64px; }
.mod-savebar {
  position: sticky; inset-block-end: 0; z-index: 20; display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-block-end: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.mod-reason { flex: 1; min-inline-size: 220px; margin: 0; }
.mod-footer { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cap-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: var(--radius-full);
  background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-sm);
}
@media (max-width: 640px) {
  .mod-list { grid-template-columns: 1fr; }
  .mod-row { grid-template-columns: auto minmax(0, 1fr); }
  .mod-row .switch { grid-column: 1 / -1; justify-self: end; }
  .mod-savebar { inset-block-end: 64px; }
}

.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.act-card { position: relative; display: block; cursor: pointer; }
.act-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.act-body {
  display: flex; flex-direction: column; gap: 4px; block-size: 100%; padding: 12px 14px;
  border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--surface);
}
.act-card input:checked + .act-body { border-color: var(--primary); background: var(--primary-50); }
.act-card input:focus-visible + .act-body { outline: 2px solid var(--primary); outline-offset: 2px; }
.act-name { font-weight: 650; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.act-desc { font-size: var(--fs-sm); color: var(--text-3); }
.act-diff { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.act-col { padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--border); }
.act-col h3 { display: flex; gap: 6px; align-items: center; font-size: var(--fs-md); margin: 0 0 8px; }
.act-col ul { margin: 0; padding-inline-start: 18px; }
.act-col-gain { background: var(--c-green-bg, var(--surface-2)); }
.act-col-hide { background: var(--c-amber-bg, var(--surface-2)); }

.matrix-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 0; }
.matrix-help div { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.matrix-help dt { font-weight: 650; margin-block-end: 2px; }
.matrix-help dd { margin: 0; font-size: var(--fs-sm); color: var(--text-3); }

/* =====================================================================
   1.4.0 - Dashboard: finance preview (a full width widget)
   ===================================================================== */
.widget-full { grid-column: 1 / -1; }
.finprev-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.finprev-month { color: var(--text-3); font-weight: 500; font-size: var(--fs-sm); }
.finprev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.finprev-tile {
  display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border); min-inline-size: 0;
}
.finprev-label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-3); }
.finprev-value { font-size: clamp(1rem, 1.25vw, 1.3rem); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.finprev-sub { font-size: var(--fs-xs); color: var(--text-3); }
.finprev-sub.is-warning { color: var(--c-amber-text); font-weight: 600; }
.finprev-tile.is-negative .finprev-value { color: var(--c-red-text); }
.finprev-chart { margin-block-start: 16px; }
.finprev-chart-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-block-end: 8px; }
.finprev-legend { display: flex; gap: 14px; font-size: var(--fs-xs); color: var(--text-3); }
.finprev-legend i { display: inline-block; inline-size: 10px; block-size: 10px; border-radius: 2px; margin-inline-end: 4px; vertical-align: -1px; }
.finprev-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; block-size: 120px; }
.finprev-month-col { display: flex; flex-direction: column; align-items: stretch; gap: 4px; block-size: 100%; }
.finprev-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.finprev-bar { inline-size: min(18px, 40%); border-radius: 3px 3px 0 0; min-block-size: 2px; }
.finprev-bar-inv { background: var(--primary-700, var(--primary)); opacity: .45; }
.finprev-bar-col { background: var(--primary); }
.finprev-mlabel { text-align: center; font-size: var(--fs-xs); color: var(--text-3); }
.finprev-data { margin-block-start: 8px; font-size: var(--fs-sm); }
.finprev-data table { inline-size: 100%; }
.finprev-data td, .finprev-data th { padding: 4px 6px; text-align: end; }
.finprev-data th:first-child, .finprev-data td:first-child { text-align: start; }
@media (max-width: 640px) {
  .finprev-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finprev-bars { gap: 4px; }
}

/* =====================================================================
   2.0 - The module components on the new system
   ---------------------------------------------------------------------
   The Phase 2 to 1.4 sections above keep their structure; these rules
   give their shared components the 2.0 finish (segmented controls, quiet
   KPI figures, floating sheets, underline tabs, restrained pills), so every
   screen follows without being rewritten. Later in the file on purpose:
   same specificity, so they win the cascade.
   ===================================================================== */

/* ---- The platform console: the same light shell, an indigo accent ---- */
body.platform {
  --primary: var(--c-indigo);
  --sidebar-bg: color-mix(in srgb, var(--c-indigo) 5%, #eff1f0);
  --sidebar-active-bg: #ffffff;
}
:root[data-theme="dark"] body.platform {
  --sidebar-bg: color-mix(in srgb, var(--c-indigo) 8%, #121413);
  --sidebar-active-bg: rgba(255, 255, 255, 0.075);
}
body.platform .sidebar-brand { border-block-end: 0; }
.sidebar .brand-lockup-name { color: var(--text); font-size: var(--fs-sm); }
.sidebar .brand-maker { color: var(--text-muted); }
.sidebar-footer .brand-lockup-name { font-size: 11px; color: var(--text-2); }

/* ---- Segmented filters with counts: a native segmented control ---- */
.seg {
  display: inline-flex; gap: 2px; flex-wrap: wrap; max-width: 100%;
  padding: 3px; margin-block-end: 16px;
  border: 0; border-radius: var(--radius);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--border);
}
.seg a {
  gap: 7px; padding: 0 12px; min-height: 30px; height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-3); font-size: var(--fs-sm); font-weight: 550;
  transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.seg a:hover { background: transparent; color: var(--text); }
.seg a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
:root[data-theme="dark"] .seg a.active { background: color-mix(in srgb, var(--surface-3) 88%, #fff); }
.seg .n { min-width: 20px; padding: 0 6px; background: var(--surface-hover); color: var(--text-3); font-size: 11px; font-weight: 600; line-height: 18px; }
.seg a.active .n { background: var(--primary-100); color: var(--primary-text); }
@media (max-width: 599px) {
  .seg { display: flex; }
  .seg a { min-height: 34px; height: 34px; }
}

/* ---- KPI figures: numbers first, quiet labels, hairline dividers ---- */
.kpi-ribbon {
  gap: 0; background: var(--surface);
  border-color: var(--border); box-shadow: var(--shadow-card);
}
.kpi { padding: 14px 18px; gap: 4px; box-shadow: inset 1px 0 0 var(--border); }
[dir="rtl"] .kpi { box-shadow: inset -1px 0 0 var(--border); }
.kpi:first-child { box-shadow: none; }
.kpi .l { order: -1; font-size: var(--fs-xs); font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-3); }
.kpi .v { font-size: 1.375rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
a.kpi-link:hover { background: var(--surface-2); }
.kpi.is-critical .v { color: var(--danger-text); }
.kpi.is-attention .v { color: var(--warning-text); }
@media (max-width: 599px) {
  .kpi-ribbon:not(.is-3) .kpi { box-shadow: inset 0 1px 0 var(--border); }
  .kpi-ribbon:not(.is-3) .kpi:nth-child(even) { box-shadow: inset 0 1px 0 var(--border), inset 1px 0 0 var(--border); }
  [dir="rtl"] .kpi-ribbon:not(.is-3) .kpi:nth-child(even) { box-shadow: inset 0 1px 0 var(--border), inset -1px 0 0 var(--border); }
  .kpi-ribbon:not(.is-3) .kpi:first-child { box-shadow: none; }
  .kpi-ribbon:not(.is-3) .kpi:nth-child(2) { box-shadow: inset 1px 0 0 var(--border); }
  [dir="rtl"] .kpi-ribbon:not(.is-3) .kpi:nth-child(2) { box-shadow: inset -1px 0 0 var(--border); }
  .kpi-ribbon:not(.is-3) .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: var(--fs-xl); }
}

/* ---- Summary cards of the resource lists ---- */
.stat-grid { gap: 12px; }
.stat-card { padding: 14px 18px; border-color: var(--border); box-shadow: var(--shadow-card); gap: 4px; }
a.stat-card { color: inherit; transition: border-color var(--fast), box-shadow var(--fast); }
a.stat-card:hover { text-decoration: none; border-color: var(--border-2); box-shadow: var(--shadow-sm); }
.stat-card .stat-label { font-size: var(--fs-xs); font-weight: 500; text-transform: none; letter-spacing: 0; }
.stat-card .stat-value { font-size: 1.375rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card.is-warning { border-color: var(--border); box-shadow: inset 3px 0 0 var(--warning), var(--shadow-card); }
.stat-card.is-critical { border-color: var(--border); box-shadow: inset 3px 0 0 var(--danger), var(--shadow-card); }
[dir="rtl"] .stat-card.is-warning { box-shadow: inset -3px 0 0 var(--warning), var(--shadow-card); }
[dir="rtl"] .stat-card.is-critical { box-shadow: inset -3px 0 0 var(--danger), var(--shadow-card); }
.mod-stat-label, .finprev-label, .ct-label, .meta-label, .totals-grand .label {
  text-transform: none; letter-spacing: 0; font-weight: 500;
}

/* ---- Sheets: a floating panel on a desktop, a bottom sheet on a phone ---- */
dialog.sheet::backdrop { background: var(--overlay); animation: fade-in var(--normal) var(--ease-out); }
@media (min-width: 900px) {
  dialog.sheet { padding: 8px; width: min(576px, 100vw); }
  .sheet-panel { border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); }
}
.sheet-panel { animation-duration: var(--slow); animation-timing-function: var(--ease-out); }
:root[data-theme="dark"] .sheet-panel { background: var(--surface-2); }
.sheet-head { padding: 18px 20px 14px; }
.sheet-head h2 { font-size: var(--fs-lg); letter-spacing: -0.015em; }
.sheet-section { font-size: var(--fs-sm); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-2); }
@media (max-width: 899px) {
  .sheet-panel { border-start-start-radius: 20px; border-start-end-radius: 20px; }
  .sheet-grip { width: 36px; height: 5px; margin-block-start: 7px; background: var(--border-strong); }
}

/* ---- Document headers (quote, dossier) ---- */
.qhead { padding: 20px 22px; box-shadow: var(--shadow-card); }
.qhead::before { width: 3px; inset-block: 16px; border-start-end-radius: 3px; border-end-end-radius: 3px; }
.qhead-ref { font-weight: 550; letter-spacing: 0; }
.readiness-bar { margin: 16px -22px -20px; padding: 10px 22px; }
@media (max-width: 699px) { .readiness-bar { margin-inline: -16px; margin-block-end: -16px; padding-inline: 16px; } }

/* Lifecycle stepper: quieter chips, the current one outlined in primary. */
.step { height: 26px; padding: 0 10px 0 5px; background: transparent; box-shadow: inset 0 0 0 1px var(--border); color: var(--text-3); font-weight: 550; }
.step .dot { width: 16px; height: 16px; }
.step.done { background: transparent; color: var(--text-2); }
.step.current { background: var(--primary-50); color: var(--primary-text); box-shadow: inset 0 0 0 1px var(--primary-200); }
.step.current .dot { border-color: var(--primary); background: var(--surface); }
.step.off { background: var(--c-red-bg); box-shadow: none; }
.step.warn { background: var(--c-amber-bg); box-shadow: none; }
.step-sep { width: 10px; height: 1px; }

/* ---- Tabs (dossier, detail pages): underline tabs over the canvas ---- */
.dtabs {
  gap: 4px; margin-block-end: 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.dtabs a { padding: 12px 10px; font-weight: 550; color: var(--text-3); transition: color var(--fast), border-color var(--fast); }
.dtabs a.active { color: var(--text); border-block-end-color: var(--primary); }
.dtabs a.active .n { background: var(--primary-100); color: var(--primary-text); }

/* ---- Readiness: a restrained pill; only a critical dot pulses ---- */
.readiness-pill { height: 22px; padding: 0 8px 0 7px; font-weight: 600; border-radius: var(--radius-sm); }
.readiness-pill .dot { width: 6px; height: 6px; box-shadow: none; }
.readiness-pill .n { padding: 0 5px; background: color-mix(in srgb, currentColor 14%, transparent); line-height: 16px; }

/* ---- Link tiles, state bars, check tiles ---- */
.tile { border-color: var(--border); box-shadow: var(--shadow-card); transition: border-color var(--fast), box-shadow var(--fast); }
a.tile:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.tile > .icon { width: 34px; height: 34px; padding: 8px; margin: 0; border-radius: 9px; background: var(--primary-50); color: var(--primary-text); }
.state-bar { border-color: var(--border); background: var(--surface); box-shadow: var(--shadow-card); }
.check-tile { box-shadow: var(--shadow-card); }
.check-tile:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.ct-icon { border-radius: 9px; }
.disclosure, .checkbox-grid { background: var(--surface-2); border-color: var(--border); }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* ---- Dashboard widgets: calm figures, not coloured boxes ---- */
.widget { overflow: hidden; }
.w-stats { gap: 6px; }
.w-stats > div { padding: 8px 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); border-radius: var(--radius); }
.w-stats .v { font-size: 1.375rem; font-weight: 650; letter-spacing: -0.02em; }
.w-stats .l { font-size: 11.5px; font-weight: 500; }
.w-stats .is-alert { background: var(--danger-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 18%, transparent); }
.finprev-tile { background: var(--surface); box-shadow: var(--shadow-card); }
.finprev-value { font-weight: 650; letter-spacing: -0.015em; }
.finprev-bar { border-radius: 4px 4px 1px 1px; }
.finprev-bar-inv { background: var(--border-strong); opacity: 1; }
.mod-stat { box-shadow: var(--shadow-card); }
.mod-row { transition: border-color var(--fast), background var(--fast), box-shadow var(--fast); }
.mod-row:hover { box-shadow: var(--shadow-sm); }
.switch-track { box-shadow: inset 0 0 0 1px var(--border); transition: background var(--normal) var(--ease-out); }
.switch-knob { transition: inset-inline-start var(--normal) var(--ease-out); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(0, 0, 0, 0.06); }
.mod-savebar { box-shadow: var(--shadow-lg); border-color: var(--border); }

/* ---- Sticky action bars ---- */
@media (max-width: 1099px) {
  .sticky-bar {
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(16px); backdrop-filter: saturate(1.6) blur(16px);
    box-shadow: 0 -1px 0 var(--border);
    border-block-start: 0;
  }
}
@media (max-width: 899px) {
  .sticky-bar { inset-block-end: calc(var(--bottomnav-height) + env(safe-area-inset-bottom, 0px)); }
  .mod-savebar { inset-block-end: calc(var(--bottomnav-height) + 8px + env(safe-area-inset-bottom, 0px)); }
}

/* ---- Pills and chips that were loud ---- */
.need, .src { font-weight: 550; }
.pill-count { background: var(--surface-hover); font-weight: 600; }
.chip, .cap-chip { background: var(--surface); }

/* ---- Dark mode: surfaces the earlier sections drew in white ---- */
:root[data-theme="dark"] .brand-mark.has-logo { background: #fff; }
:root[data-theme="dark"] .card-footer,
:root[data-theme="dark"] .modal-footer,
:root[data-theme="dark"] .sheet-foot { background: var(--surface-2); }

/* Widget headers: the title takes the line, the "see all" link sits at the end. */
.widget > .card-header { gap: 8px; }
.widget > .card-header > :is(h2, h3) { flex: 1; min-width: 0; }
.widget > .card-header > .btn-ghost { margin-inline-end: -6px; color: var(--text-3); font-weight: 500; }
.widget > .card-header > .btn-ghost:hover { color: var(--text); }
.card-header > :is(h2, h3) + .btn:last-child { margin-inline-start: auto; }

/* Filter bars on a phone: search + a Filters button; the rest unfolds (app.js). */
@media (max-width: 899px) {
  .filters.is-collapsible { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .filters.is-collapsible > input[type="search"], .filters.is-collapsible > .field:has(input[type="search"]) { flex: 1 1 0 !important; width: auto !important; min-width: 0 !important; }
  .filters.is-collapsible:not(.is-expanded) > .filters-more, .filters.is-collapsible:not(.is-expanded) > .btn-group { display: none !important; }
  .filters.is-collapsible.is-expanded > .filters-more, .filters.is-collapsible.is-expanded > .btn-group { flex: 1 1 100% !important; width: 100% !important; max-width: none !important; animation: fade-in var(--normal) var(--ease-out); }
  .filters-toggle { flex: none; height: 44px; }
  .filters-toggle[aria-expanded="true"] { background: var(--surface-3); }
  .filters-count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
}

@media (max-width: 599px) {
  .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
  .stat-card { padding: 11px 12px; }
  .stat-card .stat-value { font-size: 1.2rem; }
}

.brand-name, .brand-sub { unicode-bidi: plaintext; text-align: start; }
@media (max-width: 899px) { .sidebar-footer .sb-expand { display: none; } }

/* An open menu of the top bar rises above the tab bar (the bar is its stacking context). */
.topbar:has(.dropdown-menu.open) { z-index: 170; }
.auth-panel .brand-maker, .auth-panel .brand-lockup-name { color: rgba(255, 255, 255, 0.72); }
.auth-panel .brand-lockup-name { color: #fff; }

/* The installer rail keeps its dark ink: it stands before any workspace exists. */
.install-rail {
  --sidebar-bg: #11201d; --sidebar-text: #a7bdb7; --sidebar-text-active: #ffffff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.09);
  background: var(--sidebar-bg); color: var(--sidebar-text);
}
.install-rail .brand-lockup-name { color: #fff; }
@media (min-width: 900px) { html.sb-collapsed .dx-selbar { inset-inline-start: calc(var(--sidebar-collapsed) + 16px); } }

/* Choice cards: the checked card is marked by its border, without a halo. */
.radio-card:has(input:checked) { box-shadow: inset 0 0 0 1px var(--primary); }
@media (max-width: 599px) {
  .radio-cards { grid-template-columns: 1fr; gap: 6px; }
  .radio-card { padding-block: 10px; }
  .qhead-actions > details { flex: 0 0 auto !important; }
  .qhead-actions > details > summary { width: auto !important; }
}

/* =====================================================================
   2.2.0 - Excursion day editor: sections, reveals, manual entries
   ===================================================================== */
.prog-body { display: flex; flex-direction: column; gap: 0; padding-block-start: 6px; }
.prog-section { padding-block: 14px; }
.prog-section + .prog-section { border-block-start: 1px solid var(--border); }
.prog-section > .form-grid { gap: 14px 16px; }
.prog-sub {
  display: flex; align-items: center; gap: 6px; margin: 0 0 10px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-2);
}
.prog-sub .icon, .prog-meals legend .icon, .prog-toggle .icon { width: 15px; height: 15px; color: var(--text-3); }
.prog-meals legend { display: flex; align-items: center; gap: 6px; }
.prog-toggle { padding-block: 2px; min-height: 0; }
.prog-toggle .text { display: flex; flex-direction: column; gap: 1px; font-weight: 550; }
.prog-toggle .text > .icon { display: none; }
.prog-reveal {
  margin-block-start: 12px; padding: 14px;
  border-radius: var(--radius-lg); background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  animation: fade-in var(--normal) var(--ease-out);
}
.prog-reveal[hidden] { display: none; }
.prog-reveal .form-grid { gap: 12px 14px; }

/* The manual entry of a picker ("+ Add manually") */
.picker-manual-add { border-block-start: 1px solid var(--border); margin-block-start: 4px; }
.picker-manual-add .picker-label { color: var(--primary-text); font-weight: 600; }
.picker-manual-chip {
  display: inline-flex; align-items: center; gap: 8px;
  margin-block-start: 6px; padding: 0; border: 0; background: none;
  font: inherit; font-size: var(--fs-xs); color: var(--primary-text); cursor: pointer;
}
.picker-manual-chip[hidden] { display: none; }
.picker-manual-chip:hover span:last-child { text-decoration: underline; }
.picker-manual-tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: var(--radius-sm); background: var(--c-amber-bg); color: var(--c-amber-text);
  font-weight: 600;
}
.picker-manual-form {
  margin-block-start: 8px; padding: 14px;
  border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop-in 160ms var(--ease-out);
}
.picker-manual-title { margin: 0 0 10px; font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.picker-manual-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.picker-manual-grid .span-2 { grid-column: 1 / -1; }
.picker-manual-grid .field { gap: 4px; }
.picker-manual-grid label { font-size: var(--fs-xs); font-weight: 550; color: var(--text-2); }
.picker-manual-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 12px; }
.picker-manual-save { margin-inline-start: auto; }
.picker-manual-error { margin: 8px 0 0; font-size: var(--fs-xs); color: var(--danger-text); }
.picker-manual-error[hidden] { display: none; }
.picker.is-manual .picker-input { background-color: var(--surface-2); }
@media (max-width: 599px) {
  .picker-manual-grid { grid-template-columns: 1fr; }
  .picker-manual-actions .btn { flex: 1 1 auto; }
  .picker-manual-save { margin-inline-start: 0; flex-basis: 100% !important; }
  .prog-reveal { padding: 12px; }
}

/* 2.2.0: trusted browsers (profile) */
.device-list { list-style: none; margin: 0; padding: 0; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; }
.device-row + .device-row { border-block-start: 1px solid var(--border); }
.device-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--text-3); }
.device-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.device-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 550; font-size: var(--fs-sm); }
.device-meta { font-size: var(--fs-xs); color: var(--text-3); }

/* 2.2.0: where a module appears; a module with no screen yet */
.mod-where { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; margin-block-start: 2px; }
.mod-src-unavailable { color: var(--text-muted); font-style: italic; }
.mod-row.is-unavailable { opacity: .62; cursor: default; }
.mod-row.is-unavailable .switch input { cursor: not-allowed; }

/* =====================================================================
   2.2.0 - Platform demo accounts: wizard, success card, detail
   ===================================================================== */
.demo-wizard { max-width: 860px; scroll-margin-top: calc(var(--topbar-height, 56px) + 16px); }
.wizard-steps {
  display: flex; gap: 6px; list-style: none; margin: 0 0 16px; padding: 4px;
  border-radius: var(--radius-lg); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border);
  counter-reset: step;
}
.wizard-step {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-radius: var(--radius); color: var(--text-3); font-size: var(--fs-sm); font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.wizard-dot {
  width: 22px; height: 22px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-2); font-size: 11px; font-weight: 650;
}
.wizard-step.is-current { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.wizard-step.is-current .wizard-dot { background: var(--primary); color: #fff; box-shadow: none; }
.wizard-step.is-done { color: var(--text-2); }
.wizard-step.is-done .wizard-dot { background: var(--success-bg); color: var(--success-text); box-shadow: none; }
.demo-wizard:not(.is-stepped) .wizard-panel + .wizard-panel { margin-block-start: 16px; }
.demo-wizard:not(.is-stepped) [data-wizard-next], .demo-wizard:not(.is-stepped) [data-wizard-back] { display: none; }
.wizard-panel { animation: fade-in var(--normal) var(--ease-out); }
.wizard-foot { display: flex; justify-content: space-between; gap: 8px; }
.wizard-foot > :only-child { margin-inline-start: auto; }
.demo-activities { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.demo-activities .act-name .icon { color: var(--text-3); }
.demo-activities .act-card input:checked + .act-body .act-name .icon { color: var(--primary); }
.demo-slug-preview { margin: -8px 0 0; min-height: 1.2em; }

/* A segmented control built from radios */
.seg-control {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  border-radius: var(--radius); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border);
}
.seg-option { position: relative; }
.seg-option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.seg-option span {
  display: inline-flex; align-items: center; height: 30px; padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--text-3); font-size: var(--fs-sm); font-weight: 550; transition: background var(--fast), color var(--fast), box-shadow var(--fast);
}
.seg-option input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg-option input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.demo-includes-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.demo-includes-list li { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); }
.demo-includes-list .icon { color: var(--success); margin-block-start: 2px; }

/* "Demo company ready" */
.demo-ready { overflow: hidden; box-shadow: var(--shadow), 0 0 0 1px color-mix(in srgb, var(--success) 30%, transparent); }
.demo-ready-head { display: flex; gap: 14px; align-items: center; padding: 18px 20px;
  background: linear-gradient(180deg, var(--success-bg), var(--surface)); }
.demo-ready-head h2 { font-size: var(--fs-lg); }
.demo-ready-icon { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%;
  background: var(--success); color: #fff; }
.demo-credentials { margin: 0; padding: 4px 20px 8px; }
.demo-credential { display: grid; grid-template-columns: minmax(150px, 32%) minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 0; }
.demo-credential + .demo-credential { border-block-start: 1px solid var(--border); }
.demo-credential dt { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-3); }
.demo-credential dd { margin: 0; display: flex; align-items: center; gap: 6px; min-width: 0; }
.demo-credential code { font-size: var(--fs-sm); padding: 4px 8px; border-radius: var(--radius-sm); background: var(--surface-3); overflow-wrap: anywhere; }
.demo-credential.is-secret code { background: var(--warning-bg); color: var(--warning-text); font-weight: 600; }
.demo-ready-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; border-block-start: 1px solid var(--border); background: var(--surface-2); }
.demo-ready-foot p { margin: 0; display: flex; align-items: center; gap: 6px; }

.demo-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.demo-login { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.demo-login .icon-btn { width: 28px; height: 28px; }
.demo-counts { font-size: var(--fs-sm); color: var(--text-2); }
@media (max-width: 999px) { .demo-grid { grid-template-columns: 1fr; } }
@media (max-width: 599px) {
  .wizard-step span:last-child { display: none; }
  .wizard-step.is-current span:last-child { display: inline; }
  .wizard-step { justify-content: center; }
  .demo-credential { grid-template-columns: 1fr; gap: 4px; }
  .wizard-foot .btn { flex: 1; }
  .seg-control { display: flex; }
  .seg-option { flex: 1; }
  .seg-option span { width: 100%; justify-content: center; height: 36px; }
}

/* =====================================================================
   2.3.0 - Suppliers as commercial files: family chooser, dossier, catalogue
   ===================================================================== */
.family-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.family-card {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; min-height: 96px;
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--border);
  transition: box-shadow var(--fast), transform var(--fast);
}
.family-card:hover { text-decoration: none; box-shadow: var(--shadow), 0 0 0 1px var(--primary-200, var(--border-2)); transform: translateY(-1px); }
.family-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.family-icon {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px;
  background: var(--primary-50); color: var(--primary);
}
.family-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.family-name { font-weight: 650; }
.family-desc { font-size: var(--fs-sm); color: var(--text-2); }
.family-types { font-size: 12px; color: var(--text-3); }
.family-go { color: var(--text-3); align-self: center; }

.supplier-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.offer-mini { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.offer-mini li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-block-end: 1px solid var(--border); }
.offer-mini li:last-child { border-block-end: 0; }
.offer-mini-name { font-weight: 550; min-width: 0; overflow-wrap: anywhere; }
.offer-mini-sub { color: var(--text-3); font-size: var(--fs-sm); white-space: nowrap; }

.catalog-intro { display: flex; align-items: flex-start; gap: 16px; margin-block-end: 16px; flex-wrap: wrap; }
.catalog-intro h2 { font-size: var(--fs-lg); margin: 0 0 2px; }
.offer-card { margin-block-end: 12px; overflow: hidden; }
.offer-card.is-archived { opacity: .72; }
.offer-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; flex-wrap: wrap; }
.offer-title { flex: 1 1 280px; min-width: 0; }
.offer-title h3 { font-size: var(--fs-md, 1rem); margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.offer-title .sub { margin: 4px 0 0; }
.offer-code { font-size: 12px; font-weight: 500; color: var(--text-3); padding: 1px 6px; border-radius: var(--radius-sm); background: var(--surface-3); }
.offer-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.offer-chips .chip { height: 24px; font-size: 12px; }
.offer-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.offer-empty { padding: 0 18px 16px; margin: 0; }
.offer-card > .table-wrap { border-block-start: 1px solid var(--border); }
.price-table td { vertical-align: top; }
.price-table tr.is-past td { color: var(--text-3); }
.price-table tr.is-past td strong { font-weight: 500; }
.cell-form { display: inline; }
@media (max-width: 599px) {
  .sr-only-mobile { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
  .offer-head { padding: 12px 14px; }
  .offer-actions { width: 100%; }
  .offer-actions .btn-secondary { flex: 1; }
  .catalog-intro .btn { width: 100%; }
  .supplier-overview { grid-template-columns: 1fr; }
  .family-card { min-height: 0; }
}

/* 2.3.0 - Super Admin modules: rights of the client administrator */
.mod-rights { display: flex; align-items: flex-start; gap: 4px; font-size: var(--fs-xs); line-height: 1.4; color: var(--success-text); margin-block-start: 4px; }
.mod-rights.is-missing { color: var(--warning-text); }
.mod-rights .icon { width: 13px; height: 13px; flex: none; margin-block-start: 2px; }
.rights-panel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rights-panel .grow { min-width: 220px; }
.mod-note { display: block; font-size: var(--fs-xs); color: var(--primary-text, var(--primary)); margin-block-start: 4px; line-height: 1.4; }
.page-actions form, .page-header form { display: inline-flex; }
.price-table td.num, .price-table th.num { white-space: nowrap; }

/* 2.3.1 - The phone's position in the driver and guide apps */
.fl-status { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 9px 12px; border-radius: 12px;
  background: var(--surface-3); color: var(--text-2); font-size: 14px; font-weight: 600; line-height: 1.35; }
.fl-status[hidden] { display: none; }
.fl-dot { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--text-3); flex: none; }
.fl-text { flex: 1; min-width: 0; }
.fl-action { flex: none; min-block-size: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--primary); color: #fff; font: inherit; font-weight: 650; cursor: pointer; }
.fl-status[data-state="sharing"] { background: var(--success-bg); color: var(--success-text); }
.fl-status[data-state="sharing"] .fl-dot { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 25%, transparent); animation: fl-pulse 2s ease-in-out infinite; }
.fl-status[data-state="waiting"] .fl-dot { background: var(--primary); }
.fl-status[data-state="permission"], .fl-status[data-state="consent"] { background: var(--warning-bg); color: var(--warning-text); }
.fl-status[data-state="permission"] .fl-dot, .fl-status[data-state="consent"] .fl-dot { background: var(--warning); }
.fl-status[data-state="denied"] { background: var(--danger-bg, var(--warning-bg)); color: var(--danger-text, var(--warning-text)); }
.fl-status[data-state="denied"] .fl-dot { background: var(--danger); }
@keyframes fl-pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--success) 8%, transparent); } }
@media (prefers-reduced-motion: reduce) { .fl-status .fl-dot { animation: none !important; } }
.fl-points { list-style: none; margin: 8px 0 12px; padding: 0; display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }
.fl-points li { display: flex; gap: 8px; align-items: flex-start; }
.fl-points .icon { flex: none; margin-block-start: 2px; color: var(--text-3); }
.fl-state { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; padding: 9px 12px; border-radius: 12px; font-size: 14px; font-weight: 650; }
.fl-state.is-ok { background: var(--success-bg); color: var(--success-text); }
.fl-state.is-warn { background: var(--warning-bg); color: var(--warning-text); }
.lv-guide-pos { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 6px; font-size: var(--fs-xs); flex-wrap: wrap; }

/* =====================================================================
   3.0.0 - Standalone edition: the client's own platform
   The client brand leads (logo, NAME); the creator credit "by Luxious"
   sits under it, smaller and quieter, and is always present.
   ===================================================================== */
.sa-sidebar-brand { height: auto; min-height: var(--topbar-height); padding: 14px 10px 12px 14px; align-items: flex-start; }
.sa-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
.sa-brand:hover { text-decoration: none; }
.sa-brand-mark { display: block; max-width: 100%; }
.sa-brand-mark img { display: block; width: auto; height: auto; max-height: 44px; max-width: 176px; object-fit: contain; }
.sa-brand.has-logo .sa-brand-mark { padding: 6px 9px; background: #fff; border-radius: var(--radius); box-shadow: inset 0 0 0 1px var(--sidebar-border); }
.sa-initial { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: var(--primary); color: var(--primary-contrast); font-weight: 700; font-size: 15px; }
.sa-brand-text { display: flex; flex-direction: column; min-width: 0; max-width: 100%; line-height: 1.2; }
.sa-brand-name { font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-brand-role { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-by { font-size: 10.5px; font-weight: 500; letter-spacing: .01em; color: var(--text-muted); margin-block-start: 2px; }
.sa-sidebar-brand .sidebar-collapse { margin-block-start: 2px; }

.sa-credit { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; color: var(--text-3); text-decoration: none; }
.sa-credit:hover { text-decoration: none; color: var(--text-2); }
.sa-credit-product { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-credit-maker { font-size: 10px; color: var(--text-muted); }

.sa-mobile-home { align-items: center; flex: none; margin-inline-end: 4px; }
@media (max-width: 899px) { .sa-mobile-home { display: inline-flex; } }
.sa-mobile-brand { display: inline-flex; align-items: center; }
.sa-mobile-brand img { display: block; height: 26px; width: auto; max-width: 84px; object-fit: contain; border-radius: 5px; background: #fff; }
.sa-mobile-brand .sa-initial { width: 26px; height: 26px; font-size: 12px; border-radius: 7px; }

@media (min-width: 900px) {
  html.sb-collapsed .sa-sidebar-brand { padding-inline: 10px; justify-content: center; }
  html.sb-collapsed .sa-brand { align-items: center; }
  html.sb-collapsed .sa-brand-text,
  html.sb-collapsed .sidebar-footer .sa-credit { display: none; }
  html.sb-collapsed .sa-brand.has-logo .sa-brand-mark { padding: 3px 4px; }
  html.sb-collapsed .sa-brand-mark img { max-height: 28px; max-width: 40px; }
}

/* Sign in: the client's own page */
.sa-auth-panel { align-items: flex-start; justify-content: space-between; }
.sa-login-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-block: auto; }
.sa-login-logo { display: block; max-height: 96px; max-width: 280px; width: auto; height: auto; object-fit: contain; background: #fff; padding: 12px 16px; border-radius: var(--radius-lg); margin-block-end: 18px; box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
.sa-initial-lg { width: 72px; height: 72px; font-size: 30px; border-radius: 18px; background: rgba(255, 255, 255, .14); color: #fff; margin-block-end: 18px; }
.sa-login-name { font-size: clamp(28px, 3.2vw, 40px); font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: #fff; line-height: 1.1; overflow-wrap: anywhere; }
.sa-login-app { font-size: var(--fs-md); color: rgba(255, 255, 255, .86); }
.sa-auth-panel .sa-by { color: rgba(255, 255, 255, .62); font-size: 12px; margin-block-start: 4px; }
.auth-panel p.sa-powered { font-size: 12px; color: rgba(255, 255, 255, .55); margin: 0; }
.sa-form-brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.sa-form-brand .sa-mobile-brand img { height: 32px; max-width: 110px; }
.sa-form-brand .sa-mobile-brand .sa-initial { width: 32px; height: 32px; font-size: 14px; }
.sa-form-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.sa-form-brand-name { font-weight: 700; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.sa-auth-footer { font-size: var(--fs-xs); }
.sa-brand-name, .sa-login-name, .sa-form-brand-name { unicode-bidi: plaintext; }

/* About / system information */
.sa-about { max-width: 640px; }
.sa-about-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sa-about-head .sa-brand-mark img { max-height: 56px; max-width: 200px; }
.sa-about-name { font-size: var(--fs-xl); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.sa-about-credit { padding-block-start: 14px; border-block-start: 1px solid var(--border); color: var(--text-3); font-size: var(--fs-sm); }
.sa-about-credit strong { color: var(--text-2); font-weight: 600; }
.sa-kv { display: grid; grid-template-columns: minmax(120px, 34%) 1fr; gap: 8px 16px; margin: 0; }
.sa-kv dt { color: var(--text-3); font-size: var(--fs-sm); }
.sa-kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 520px) { .sa-kv { grid-template-columns: 1fr; gap: 2px; } .sa-kv dd { margin-block-end: 8px; } }

/* Standalone installer: module switches (3.0.0) */
.sa-modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.sa-module { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color var(--fast), background var(--fast); }
.sa-module:hover { border-color: var(--border-strong); }
.sa-module input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sa-module-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.sa-module-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.sa-module-desc { font-size: var(--fs-sm); color: var(--text-3); }
.sa-switch { position: relative; flex: none; width: 34px; height: 20px; margin-block-start: 2px; border-radius: 999px; background: var(--border-strong); transition: background var(--fast); }
.sa-switch::after { content: ''; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform var(--fast); }
.sa-module:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.sa-module:has(input:checked) .sa-switch { background: var(--primary); }
.sa-module:has(input:checked) .sa-switch::after { transform: translateX(14px); }
[dir="rtl"] .sa-module:has(input:checked) .sa-switch::after { transform: translateX(-14px); }
.sa-module:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 3.0.0: cards side by side in a grid are spaced by the grid gap, not by the
   stacking margin, so the second card of a row starts level with the first. */
.grid-2 > .card + .card, .grid-3 > .card + .card { margin-block-start: 0; }

/* 3.0.0: support access - whose rights the session works with */
.sa-context { border: 0; margin: 0; padding: 0; min-width: 0; }
.sa-context legend { padding: 0; margin-block-end: 4px; }
.sa-context-list { display: grid; gap: 6px; }
.sa-context-row { display: grid; grid-template-columns: auto minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.3fr); align-items: center; gap: 4px 14px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.sa-context-row:has(input:checked) { border-color: var(--primary); background: var(--primary-50); box-shadow: 0 0 0 3px var(--ring); }
.sa-context-row input { margin: 0; accent-color: var(--primary); }
.sa-context-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.sa-context-role { color: var(--text-2); font-size: var(--fs-sm); }
.sa-context-email { color: var(--text-3); font-size: var(--fs-sm); overflow-wrap: anywhere; }
@media (max-width: 720px) {
  .sa-context-row { grid-template-columns: auto minmax(0, 1fr); }
  .sa-context-role, .sa-context-email { grid-column: 2; }
}

/* =====================================================================
   3.0.1 - Standalone sign in: the client's own page
   A white half where the client's transparent logo is the whole message
   (very large, never boxed, never cropped), the form on the client's
   green. On a phone: one green page, the logo large and centred on top.
   ===================================================================== */
.sa-auth .auth { background: #fff; }
.sa-auth-hero { display: none; }
.sa-auth .auth-form.sa-auth-main {
  max-width: none; margin: 0; flex: 1;
  min-height: 100vh; min-height: 100dvh;
  justify-content: flex-start; gap: 22px;
  padding: 24px 22px 28px;
  color: #fff;
  background: linear-gradient(165deg, var(--primary-700), color-mix(in srgb, var(--primary-700) 76%, #000));
}
.sa-auth-main > * { width: 100%; max-width: 420px; margin-inline: auto; }
.sa-auth-top { position: relative; justify-content: center; padding-block: 18px 2px; }
.sa-auth-top .brand { justify-content: center; }
.sa-auth-top .dropdown { position: absolute; inset-inline-end: 0; inset-block-start: 0; }
.sa-auth-top .icon-btn { color: rgba(255, 255, 255, .88); }
.sa-auth-top .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.sa-auth-form-logo {
  /* sized, not only capped: a small logo file is still shown large */
  display: block; width: min(78vw, 300px); height: auto; max-height: 128px; object-fit: contain;
  /* a hairline white edge keeps a dark logo legible on the green */
  filter: drop-shadow(0 0 .6px rgba(255, 255, 255, .95)) drop-shadow(0 0 .6px rgba(255, 255, 255, .95)) drop-shadow(0 6px 18px rgba(0, 0, 0, .22));
}
.sa-auth-form-name { font-size: 28px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: #fff; text-align: center; unicode-bidi: plaintext; }
.sa-auth-main h1 { color: #fff; }
.sa-auth-main .lead { color: rgba(255, 255, 255, .82); }
.sa-auth-main .field > label, .sa-auth-main label:not(.checkbox) { color: rgba(255, 255, 255, .94); }
.sa-auth-main .required-mark { color: #ffd2cb; }
.sa-auth-main .input, .sa-auth-main .select { background: #fff; color: #14201d; border-color: transparent; }
.sa-auth-main .input:focus, .sa-auth-main .select:focus { border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .42); outline: none; }
.sa-auth-main .input-group .btn-secondary { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .28); color: #fff; }
.sa-auth-main .checkbox .text { color: rgba(255, 255, 255, .9); }
.sa-auth-main .checkbox .text .sub, .sa-auth-main .hint, .sa-auth-main .sub, .sa-auth-main .muted { color: rgba(255, 255, 255, .72); }
.sa-auth-main .error { color: #ffd2cb; }
.sa-auth-main a:not(.btn) { color: #d4f2e8; }
.sa-auth-main a:not(.btn):hover { color: #fff; }
.sa-auth-main .btn-primary { background: #fff; color: var(--primary-700); border-color: #fff; }
.sa-auth-main .btn-primary:hover { background: #eef8f4; color: var(--primary-700); }
.sa-auth-main .btn-secondary, .sa-auth-main .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .4); background: transparent; }
.sa-auth-main .alert { color: var(--text); }
.sa-auth-main .auth-footer { color: rgba(255, 255, 255, .64); margin-block-start: auto; }
.sa-auth-main .code-input { background: #fff; color: #14201d; }
@media (min-width: 900px) {
  .sa-auth .auth { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(440px, 1fr); }
  .sa-auth-hero { display: flex; align-items: center; justify-content: center; padding: 64px; background: #fff; min-width: 0; }
  .sa-auth-hero-logo { display: block; width: min(80%, 600px); height: auto; max-height: 56vh; object-fit: contain; }
  .sa-auth-hero-name { font-size: clamp(40px, 5vw, 72px); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--primary-700); text-align: center; unicode-bidi: plaintext; }
  .sa-auth .auth-form.sa-auth-main { justify-content: center; padding: 48px 56px; }
  .sa-auth-main .auth-footer { margin-block-start: 8px; }
  .sa-auth-form-logo { max-height: 110px; }
}

/* 3.0.1 - Sidebar: the client's transparent logo, larger, never on a card.
   A hairline white edge (CSS only, the file is untouched) keeps it clean on
   any sidebar tone. */
.sa-sidebar-brand { padding: 16px 10px 14px 16px; }
.sa-brand { gap: 10px; }
.sa-brand.has-logo .sa-brand-mark { padding: 0; background: none; border-radius: 0; box-shadow: none; }
.sa-brand-mark img {
  max-height: 64px; max-width: 188px;
  filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .9)) drop-shadow(0 0 .5px rgba(255, 255, 255, .9));
}
.sa-brand-text { gap: 1px; }
.sa-brand-name { font-size: 13.5px; }
@media (min-width: 900px) {
  html.sb-collapsed .sa-brand.has-logo .sa-brand-mark { padding: 0; }
  html.sb-collapsed .sa-brand-mark img { max-height: 34px; max-width: 44px; }
}

/* =====================================================================
   3.0.2 - Standalone sign in on a phone: one clean white page (the
   computer keeps the white logo half and the green form). Fixed colours,
   not theme tokens: the page is white in the dark theme too.
   ===================================================================== */
.sa-auth-desk-only { display: none; }
@media (max-width: 899px) {
  .sa-auth .auth-form.sa-auth-main { background: #fff; color: #14201d; }
  .sa-auth-form-logo { filter: none; }
  .sa-auth-form-name { color: var(--primary-700); }
  .sa-auth-top .icon-btn { color: #4a5552; }
  .sa-auth-top .icon-btn:hover { color: #14201d; background: rgba(15, 23, 20, .06); }
  .sa-auth-main h1 { color: #14201d; }
  .sa-auth-main .lead { color: #4a5552; }
  .sa-auth-main .field > label, .sa-auth-main label:not(.checkbox) { color: #14201d; }
  .sa-auth-main .required-mark { color: var(--danger); }
  .sa-auth-main .input, .sa-auth-main .select, .sa-auth-main .code-input { background: #fff; color: #14201d; border-color: rgba(15, 23, 20, .22); }
  .sa-auth-main .input:focus, .sa-auth-main .select:focus, .sa-auth-main .code-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
  .sa-auth-main .input-group .btn-secondary { background: #fff; border-color: rgba(15, 23, 20, .22); color: #4a5552; }
  .sa-auth-main .checkbox .text { color: #14201d; }
  .sa-auth-main .checkbox .text .sub, .sa-auth-main .hint, .sa-auth-main .sub, .sa-auth-main .muted { color: #5f6966; }
  .sa-auth-main .error { color: var(--danger); }
  .sa-auth-main a:not(.btn) { color: var(--primary-700); }
  .sa-auth-main a:not(.btn):hover { color: var(--primary); }
  .sa-auth-main .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
  .sa-auth-main .btn-primary:hover { background: var(--primary-700); color: #fff; }
  .sa-auth-main .btn-secondary, .sa-auth-main .btn-ghost { color: #14201d; border-color: rgba(15, 23, 20, .22); background: #fff; }
  .sa-auth-main .auth-footer { color: #6b7471; }
}
/* On a computer: the company name above the heading, no second logo. */
@media (min-width: 900px) {
  .sa-auth-desk-only { display: block; }
  .sa-auth-form-logo { display: none; }
  .sa-auth-top, .sa-auth-top .brand { justify-content: flex-start; }
  .sa-auth-top { padding-block: 0; padding-inline-end: 44px; }
  .sa-auth-form-name { font-size: 22px; font-weight: 750; letter-spacing: .08em; text-align: start; line-height: 1.25; }
}

/* 3.0.2 - Sidebar: white, the client's transparent logo much larger and
   centred directly on it (no card), name and small "par Luxious" under it. */
:root:not([data-theme="dark"]) .sidebar:has(> .sa-sidebar-brand) {
  --sidebar-bg: #fff;
  --sidebar-active-bg: color-mix(in srgb, var(--primary) 9%, #fff);
  --sidebar-hover-bg: rgba(15, 23, 20, .045);
  --sidebar-border: rgba(15, 23, 20, .08);
}
.sa-sidebar-brand { position: relative; justify-content: center; padding: 22px 16px 16px; }
.sa-sidebar-brand .sidebar-collapse { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; margin: 0; }
.sa-sidebar-brand .sa-brand { align-items: center; text-align: center; gap: 10px; }
.sa-sidebar-brand .sa-brand-mark { display: flex; justify-content: center; width: 100%; }
.sa-sidebar-brand .sa-brand.has-logo .sa-brand-mark img {
  width: 176px; height: auto; max-width: 100%; max-height: 120px; object-fit: contain; filter: none;
}
.sa-sidebar-brand .sa-brand-text { align-items: center; }
.sa-sidebar-brand .sa-brand-name { font-size: 14px; }
@media (min-width: 900px) {
  html.sb-collapsed .sa-sidebar-brand { padding: 14px 8px; }
  html.sb-collapsed .sa-sidebar-brand .sa-brand.has-logo .sa-brand-mark img { width: 44px; max-height: 40px; }
}

/* =====================================================================
   3.0.3 - Standalone sign in fields: always white with dark text, in the
   light theme, the dark theme, a dark device or a browser's own dark mode
   ("only light" also opts the page out of forced darkening). Autofilled
   fields keep the same white (the browser paints its own colour otherwise).
   ===================================================================== */
:root:has(body.sa-auth) { color-scheme: only light; }
/* body.sa-auth: above the dark theme's own field colour (:root[data-theme=dark] :is(.input...)) */
body.sa-auth .sa-auth-main :is(.input, .select, .code-input) {
  color-scheme: only light;
  background-color: #fff; color: #14201d; -webkit-text-fill-color: #14201d; caret-color: #14201d;
}
.sa-auth-main .input::placeholder, .sa-auth-main .code-input::placeholder { color: #7a8582; -webkit-text-fill-color: #7a8582; opacity: 1; }
.sa-auth-main input:-webkit-autofill,
.sa-auth-main input:-webkit-autofill:hover,
.sa-auth-main input:-webkit-autofill:focus {
  -webkit-text-fill-color: #14201d; caret-color: #14201d;
  -webkit-box-shadow: 0 0 0 1000px #fff inset; box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 600000s 0s;
}
body.sa-auth .sa-auth-main input[type="checkbox"]:not(:checked) { background: #fff; border-color: rgba(15, 23, 20, .38); }
.sa-auth-main input:-webkit-autofill:focus { box-shadow: 0 0 0 1000px #fff inset, 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }

/* 3.0.3 - The sidebar logo follows the theme: the client's dark theme logo
   when the installation ships one, the normal logo otherwise. */
.sa-brand-mark .sa-logo-dark { display: none; }
:root[data-theme="dark"] .sa-brand-mark.has-dark .sa-logo-light { display: none; }
:root[data-theme="dark"] .sa-brand-mark.has-dark .sa-logo-dark { display: block; }

/* 3.0.3 - Reservation header on a phone: the main action on its own row,
   then PDF (filling the row), Edit and More, whatever the label lengths. */
@media (max-width: 599px) {
  .dossier-head .qhead-actions > :first-child:not(details) { flex: 1 1 100%; }
  .dossier-head .qhead-actions > form:first-child > .btn { width: 100%; }
  .dossier-head .qhead-actions > .btn[data-sheet-open="sheet-booking"] { flex: 0 0 auto; }
  .dossier-head .qhead-actions > details:has(> [data-programme-pdf]) { flex: 1 1 auto !important; }
  .dossier-head .qhead-actions > details > [data-programme-pdf] { width: 100% !important; justify-content: center; }
}

/* 3.0.3 - Desktop sidebar: never taller than the screen, whatever the
   browser does with dvh or flex sizing; the brand and the footer keep
   their place and only the menu scrolls, with a discreet scrollbar. */
@media (min-width: 900px) {
  .sidebar { max-height: 100vh; max-height: 100dvh; overflow: hidden; align-self: flex-start; }
  .sidebar-brand, .sidebar-footer { flex-shrink: 0; }
  .sidebar-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .sidebar-nav:hover { scrollbar-color: var(--border-strong) transparent; }
  .sidebar-nav::-webkit-scrollbar { width: 6px; }
  .sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; }
  .sidebar-nav:hover::-webkit-scrollbar-thumb { background: var(--border-strong); }
}

/* =====================================================================
   3.1.0 - TourismConnect By Luxious
   ===================================================================== */
/* The creator credit links to luxious.ma, discreetly: same colour as the
   line it sits in, a soft underline that firms up on hover. */
.lux-link { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; }
.lux-link:hover { color: inherit; text-decoration-color: currentColor; }

/* Sidebar brand: the home link (logo + name) and the credit side by side
   in the column (a link cannot hold a link). */
.sa-brand { gap: 2px; }
.sa-sidebar-brand .sa-brand { gap: 2px; }
.sa-brand-home { display: flex; flex-direction: column; align-items: inherit; gap: 10px; min-width: 0; max-width: 100%; color: inherit; text-decoration: none; }
.sa-brand-home:hover { text-decoration: none; }
.sa-brand > .sa-by { max-width: 100%; }
@media (min-width: 900px) {
  html.sb-collapsed .sa-sidebar-brand .sa-brand > .sa-by { display: none; }
}
.sa-credit-product { color: inherit; text-decoration: none; }
a.sa-credit-product:hover { color: var(--text-2); text-decoration: none; }

/* The phone top bar logo follows the theme too. */
.sa-mobile-brand .sa-logo-dark { display: none; }
:root[data-theme="dark"] .sa-mobile-brand.has-dark .sa-logo-light { display: none; }
:root[data-theme="dark"] .sa-mobile-brand.has-dark .sa-logo-dark { display: block; background: transparent; }

/* Two logos, each previewed on its own background (settings, installer). */
.brand-logos, .install-logo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.brand-logo-slot { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.brand-logo-slot h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--fs-sm); }
.brand-logo-state { margin: 0; }
.install-logo-slot { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.brand-logo-preview { display: grid; place-items: center; block-size: 112px; padding: 10px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }
.brand-logo-preview.is-light { background: #fff; color: #5f6966; }
.brand-logo-preview.is-dark { background: #15181a; color: #aab2b0; border-color: #2a2f2d; }
.brand-logo-preview img { display: block; max-inline-size: 92%; max-block-size: 88px; object-fit: contain; }
.install-logo-slot.is-same .input { opacity: .55; }
@media (max-width: 599px) {
  .brand-logos, .install-logo-grid { grid-template-columns: 1fr; }
}

/* Reservation dossier tabs: from tablet width up, a tab that does not fit
   goes to a second line instead of scrolling out of sight. Same tabs, same
   counters, same active state. Phones keep the swipeable single line. */
@media (min-width: 700px) {
  .dtabs.dtabs-wrap { flex-wrap: wrap; overflow: visible; row-gap: 0; }
}

/* =====================================================================
   3.1.0 - Emailing: prepared operational e-mails
   ===================================================================== */
.em-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.em-layout > .em-aside { order: 2; }
.em-layout > .em-main { order: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.em-aside { display: flex; flex-direction: column; gap: 16px; min-width: 0; position: sticky; inset-block-start: calc(var(--topbar-height) + 12px); }
.em-ctx { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: var(--radius); background: var(--surface-2); }
.em-ctx-k { color: var(--text-3); font-size: var(--fs-sm); }
.em-ctx-v { font-weight: 600; }
.em-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 10px; align-items: center; }
.em-row > label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); }
.em-body { min-block-size: 320px; font-family: inherit; line-height: 1.55; resize: vertical; }
.em-missing .alert-body { display: flex; flex-direction: column; gap: 6px; }
.em-missing-list { display: flex; flex-wrap: wrap; gap: 6px; }
.em-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.em-open { display: inline-flex; gap: 4px; align-items: stretch; }
.em-open details.dropdown > summary { block-size: 100%; }
.em-copy { flex-wrap: wrap; }
.em-send { margin-inline-start: auto; }
.em-status { min-block-size: 1.4em; margin: 0; font-size: var(--fs-sm); font-weight: 600; color: var(--success, #1d7a4f); opacity: 0; transition: opacity var(--fast); }
.em-status.is-on { opacity: 1; }
.em-status.is-error { color: var(--danger); }
.em-note { display: flex; gap: 6px; align-items: flex-start; margin: 0; }
.em-pref { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding-block-start: 12px; border-block-start: 1px solid var(--border); }
.em-pref label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 600; }
.em-pref .select { inline-size: auto; min-inline-size: 200px; }
.em-js-hidden { display: none; }
.em-vars > summary { list-style: none; cursor: pointer; }
.em-vars > summary::-webkit-details-marker { display: none; }
.em-var-list { display: flex; flex-direction: column; gap: 6px; margin: 0; max-block-size: 360px; overflow: auto; }
.em-var-list > div { display: flex; flex-direction: column; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface-2); }
.em-var-list > div.is-empty { opacity: .7; }
.em-var-list dt code { font-size: 12px; }
.em-var-list dd { margin: 0; font-size: var(--fs-xs); color: var(--text-3); }
.em-var-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.em-var-chips .chip { cursor: pointer; font-size: 12px; border: 1px solid var(--border); }
.em-var-chips .chip:hover { border-color: var(--primary); color: var(--primary); }
.em-history .nowrap { white-space: nowrap; }
.em-start-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.em-how { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.em-how li { display: flex; gap: 10px; align-items: flex-start; }
.em-preview-head { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; margin: 0; }
.em-preview-head dt { color: var(--text-3); font-size: var(--fs-sm); }
.em-preview-head dd { margin: 0; overflow-wrap: anywhere; }
.em-preview-body { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); line-height: 1.6; overflow-wrap: anywhere; }
.em-tpl-filters { flex-wrap: wrap; gap: 10px; }
.em-tpl-cat .select { min-inline-size: 220px; }
.em-tpl-list { margin: 0; padding: 0; list-style: none; }
.em-tpl { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 18px; border-block-start: 1px solid var(--border); }
.em-tpl:first-child { border-block-start: 0; }
.em-tpl.is-off .em-tpl-name { color: var(--text-3); }
.em-tpl-main { min-width: 0; }
.em-tpl-name { font-weight: 600; color: var(--text); margin-inline-end: 8px; }
.em-tpl-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.em-tpl-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-tpl-actions { display: flex; gap: 4px; flex: none; }
.em-tpl-actions form { margin: 0; }
@media (max-width: 1099px) {
  .em-layout { grid-template-columns: minmax(0, 1fr); }
  .em-layout > .em-aside { order: 0; position: static; }
}
@media (max-width: 699px) {
  .em-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .em-start-grid { grid-template-columns: minmax(0, 1fr); }
  .em-actions > *, .em-open { inline-size: 100%; }
  .em-open { display: flex; }
  .em-open > .btn { flex: 1 1 auto; min-width: 0; white-space: normal; text-align: center; line-height: 1.25; }
  .em-open > details { flex: none; }
  .em-copy { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); inline-size: 100%; }
  .em-copy > .btn:first-child { grid-column: 1 / -1; }
  .em-send { margin-inline-start: 0; }
  .em-actions .btn { justify-content: center; min-block-size: 44px; }
  .em-pref .select { inline-size: 100%; }
  .em-tpl { flex-direction: column; align-items: stretch; }
  .em-tpl-actions { flex-wrap: wrap; }
  .em-tpl-actions .btn span { display: inline; }
  .em-body { min-block-size: 260px; }
}
/* The reservation header on a phone: the e-mail action keeps its own width. */
@media (max-width: 599px) {
  .dossier-head .qhead-actions > [data-booking-email] { flex: 0 0 auto; }
}

/* 3.1.1 - Reservation dossier tabs on a computer or a tablet: never a
   horizontal scroll. Every tab shows at once; a full row continues on the
   next one (two, three rows as needed). Also matched by position (the tab
   bar that follows the dossier header), so it holds even for a page cached
   before the dtabs-wrap class existed. Phones keep the swipeable line. */
@media (min-width: 700px) {
  .dtabs.dtabs-wrap, .dossier-head ~ .dtabs {
    flex-wrap: wrap !important; overflow-x: visible !important; overflow-y: visible !important;
    row-gap: 0; column-gap: 4px; max-inline-size: 100%;
  }
  .dtabs.dtabs-wrap > a, .dossier-head ~ .dtabs > a { flex: 0 0 auto; white-space: nowrap; }
}

/* 3.1.1 - Platform: modules chosen when a company is created */
.company-modules-pick > summary { list-style: none; cursor: pointer; display: inline-flex; }
.company-modules-pick > summary::-webkit-details-marker { display: none; }
.company-modules-group { margin: 0; padding: 0; border: 0; }
.company-modules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 16px; }
