/* === HOTELBOX BACKOFFICE — DESIGN TOKENS === */

:root {
  /* Type */
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* Accent (overrideable via Tweaks) */
  --accent-h: 195;
  --accent: oklch(55% 0.10 var(--accent-h));
  --accent-hover: oklch(50% 0.11 var(--accent-h));
  --accent-soft: oklch(95% 0.025 var(--accent-h));
  --accent-fg: white;

  /* Status — shared chroma/lightness, only hue varies */
  --ok: oklch(58% 0.11 155);
  --ok-soft: oklch(95% 0.03 155);
  --warn: oklch(68% 0.13 75);
  --warn-soft: oklch(96% 0.04 75);
  --danger: oklch(58% 0.16 25);
  --danger-soft: oklch(96% 0.03 25);
  --info: oklch(58% 0.11 250);
  --info-soft: oklch(95% 0.025 250);
  --neutral: oklch(60% 0.005 270);
  --neutral-soft: oklch(96% 0.003 270);

  /* Light theme — slate */
  --bg: oklch(98.5% 0.003 270);
  --surface: #ffffff;
  --surface-2: oklch(97.5% 0.003 270);
  --surface-3: oklch(95.5% 0.004 270);
  --hover: oklch(96.5% 0.004 270);
  --border: oklch(91.5% 0.005 270);
  --border-strong: oklch(85% 0.006 270);
  --text: oklch(22% 0.01 270);
  --text-muted: oklch(48% 0.01 270);
  --text-faint: oklch(62% 0.008 270);

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.04), 0 1px 1px oklch(0% 0 0 / 0.03);
  --shadow-md: 0 4px 10px oklch(0% 0 0 / 0.06), 0 1px 3px oklch(0% 0 0 / 0.04);
  --shadow-lg: 0 12px 32px oklch(0% 0 0 / 0.10), 0 4px 12px oklch(0% 0 0 / 0.05);

  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Density */
  --row-h: 40px;
  --pad-x: 14px;
  --pad-y: 10px;
  --gap: 12px;

  /* Layout */
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 56px;
  --topbar-h: 52px;
}

:root[data-density="compact"] {
  --row-h: 32px;
  --pad-x: 10px;
  --pad-y: 6px;
  --gap: 8px;
}

:root[data-theme="dark"] {
  --bg: oklch(15.5% 0.008 270);
  --surface: oklch(19% 0.009 270);
  --surface-2: oklch(21% 0.009 270);
  --surface-3: oklch(24% 0.01 270);
  --hover: oklch(23% 0.01 270);
  --border: oklch(28% 0.01 270);
  --border-strong: oklch(35% 0.012 270);
  --text: oklch(95% 0.005 270);
  --text-muted: oklch(68% 0.008 270);
  --text-faint: oklch(52% 0.008 270);

  --accent: oklch(70% 0.10 var(--accent-h));
  --accent-hover: oklch(75% 0.11 var(--accent-h));
  --accent-soft: oklch(28% 0.05 var(--accent-h));
  --accent-fg: oklch(15% 0.008 270);

  --ok: oklch(70% 0.12 155);
  --ok-soft: oklch(28% 0.05 155);
  --warn: oklch(78% 0.13 75);
  --warn-soft: oklch(30% 0.06 75);
  --danger: oklch(70% 0.14 25);
  --danger-soft: oklch(28% 0.06 25);
  --info: oklch(70% 0.11 250);
  --info-soft: oklch(28% 0.05 250);
  --neutral-soft: oklch(24% 0.005 270);

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.3);
  --shadow-md: 0 4px 10px oklch(0% 0 0 / 0.4);
  --shadow-lg: 0 12px 32px oklch(0% 0 0 / 0.5);
}

/* === RESET === */

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.mono { font-family: var(--font-mono); font-feature-settings: "zero"; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* === LAYOUT === */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100vh;
  background: var(--bg);
}
.app[data-sidebar="collapsed"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--text);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.logo-text {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
}
.logo-text small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}
.nav-group {
  margin-bottom: 6px;
}
.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 8px 10px 4px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  position: relative;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[data-active="true"] {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 500;
}
.nav-item .nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 1.75;
}
.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10.5px;
  background: var(--surface-3);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 99px;
  font-family: var(--font-mono);
}
.nav-item[data-active="true"] .nav-badge { background: var(--surface); }
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 99px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
}
.user-meta { line-height: 1.2; overflow: hidden; }
.user-meta strong { font-size: 12.5px; font-weight: 600; display: block; }
.user-meta span { font-size: 11px; color: var(--text-muted); }

/* === MAIN === */

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  flex-shrink: 0;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.crumbs .crumb-sep { color: var(--text-faint); }
.crumbs .crumb-current { color: var(--text); font-weight: 500; }

.search-box {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0 10px;
  border-radius: var(--radius);
  height: 30px;
  width: 280px;
  color: var(--text-muted);
  font-size: 12.5px;
}
.search-box input {
  background: transparent;
  border: 0;
  outline: 0;
  flex: 1;
  font-size: 12.5px;
  color: var(--text);
}
.search-box kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text-faint);
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.75; }

.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}

/* === PAGE === */

.page {
  padding: 20px 24px 80px;
  max-width: 1600px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.page-sub { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* === BUTTONS === */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s;
}
.btn:hover { background: var(--hover); border-color: var(--border-strong); }
.btn svg { width: 14px; height: 14px; stroke-width: 2; }
.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { background: var(--text); opacity: 0.88; }
.btn-accent {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger {
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn-lg { height: 36px; padding: 0 16px; font-size: 13px; }

/* === CARD === */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 13.5px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 16px; }

/* === BADGES === */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--neutral-soft);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: currentColor;
  opacity: 0.85;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.outline { background: transparent; border: 1px solid var(--border); }

/* === CHIPS (filter chips) === */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px 0 10px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.chip:hover { background: var(--hover); }
.chip[data-active="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.chip .chip-key { color: var(--text-muted); }
.chip-x {
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  border-radius: 99px;
  color: var(--text-muted);
}
.chip-x:hover { background: var(--surface-3); color: var(--text); }
.chip-add {
  border-style: dashed;
  color: var(--text-muted);
}

/* === FORM === */

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field .hint { font-size: 11px; color: var(--text-faint); }
.input, .select, textarea.input {
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0 10px;
  font-size: 13px;
  outline: 0;
  color: var(--text);
  width: 100%;
  transition: border-color 0.1s, box-shadow 0.1s;
}
textarea.input { height: auto; padding: 8px 10px; line-height: 1.5; }
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* === TABLE === */

.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
  user-select: none;
}
.tbl tbody td {
  padding: 0 12px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.tbl tbody tr:hover td { background: var(--hover); }
.tbl tbody tr[data-selected="true"] td { background: var(--accent-soft); }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl .col-num { font-family: var(--font-mono); font-size: 12.5px; text-align: right; }
.tbl .col-check { width: 36px; padding-right: 0; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr td:first-child { border-left: 2px solid transparent; }
.tbl tbody tr[data-selected="true"] td:first-child { border-left-color: var(--accent); }

.cb {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.cb[data-checked="true"], .cb[data-indeterminate="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.cb svg { width: 10px; height: 10px; stroke-width: 3; }

/* Toolbar */
.tbl-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tbl-toolbar .spacer { flex: 1; }
.search-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0 10px;
  border-radius: var(--radius);
  height: 28px;
  width: 240px;
  font-size: 12px;
  color: var(--text-muted);
}
.search-inline input {
  background: transparent;
  border: 0;
  outline: 0;
  flex: 1;
  font-size: 12.5px;
  color: var(--text);
}

/* Bulk action bar */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border-strong);
  font-size: 12.5px;
}
.bulk-bar strong { font-weight: 600; }

/* Inline edit cell */
.edit-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  margin: 0 -6px;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: text;
  min-width: 80px;
}
.edit-cell:hover {
  border-color: var(--border);
  background: var(--surface);
}
.edit-cell:hover .edit-pencil { opacity: 1; }
.edit-pencil {
  opacity: 0;
  width: 11px;
  height: 11px;
  color: var(--text-faint);
}
.edit-cell input {
  border: 1px solid var(--accent);
  background: var(--surface);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 13px;
  outline: 0;
  height: 22px;
}

/* === KPI === */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.kpi-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.kpi-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 8px 0 4px;
  color: var(--text);
}
.kpi-delta {
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--danger); }

/* === KANBAN === */

.kanban {
  display: flex;
  gap: 12px;
  padding: 4px;
  overflow-x: auto;
  height: calc(100vh - var(--topbar-h) - 130px);
}
.kanban-col {
  flex: 0 0 280px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: 100%;
}
.kanban-col[data-drop="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.kanban-col-head {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.kanban-col-head .col-name { font-weight: 600; font-size: 12.5px; }
.kanban-col-head .col-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 99px;
}
.kanban-col-head .col-amt {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-col-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow 0.1s, transform 0.1s;
  font-size: 12.5px;
}
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card[data-dragging="true"] {
  opacity: 0.4;
  cursor: grabbing;
}
.kanban-card .kc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.kanban-card .kc-id { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); }
.kanban-card .kc-title { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.kanban-card .kc-sub { color: var(--text-muted); font-size: 11.5px; margin-bottom: 8px; line-height: 1.4; }
.kanban-card .kc-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.kanban-card .kc-foot .kc-amt {
  margin-left: auto;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  font-size: 12px;
}

/* === TIMELINE === */

.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border);
}
.tl-item {
  position: relative;
  padding-bottom: 14px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 5px;
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
}
.tl-item[data-kind="status"]::before { border-color: var(--accent); background: var(--accent); }
.tl-item[data-kind="note"]::before { border-color: var(--info); }
.tl-item[data-kind="email"]::before { border-color: var(--warn); }
.tl-item[data-kind="call"]::before { border-color: var(--ok); }
.tl-when {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  margin-bottom: 2px;
}
.tl-who { font-weight: 500; font-size: 13px; }
.tl-what { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; line-height: 1.45; }

/* === WIZARD === */

.wizard-shell {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 18px;
  align-items: flex-start;
}
.wizard-steps {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
}
.step {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.step:hover { background: var(--hover); }
.step[data-active="true"] { background: var(--accent-soft); }
.step-num {
  width: 22px;
  height: 22px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.step[data-active="true"] .step-num { background: var(--accent); color: var(--accent-fg); }
.step[data-done="true"] .step-num { background: var(--ok); color: white; }
.step-label { font-size: 13px; font-weight: 500; }
.step-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.wizard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 460px;
  display: flex;
  flex-direction: column;
}
.wizard-card-head {
  padding: 18px 22px 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}
.wizard-card-body { padding: 22px; flex: 1; }
.wizard-card-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.wizard-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  position: sticky;
  top: 0;
}

/* === DETAIL PAGE === */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: flex-start;
}

.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  row-gap: 8px;
  column-gap: 12px;
  font-size: 13px;
}
.kv dt { color: var(--text-muted); font-weight: 400; }
.kv dd { margin: 0; font-weight: 500; }

/* === CALENDAR === */

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}
.cal-head {
  background: var(--surface-2);
  padding: 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.cal-cell {
  min-height: 92px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  position: relative;
  cursor: pointer;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell[data-other="true"] { background: var(--surface-2); color: var(--text-faint); }
.cal-cell[data-today="true"] { background: var(--accent-soft); }
.cal-date {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-muted);
}
.cal-event {
  font-size: 10.5px;
  padding: 2px 5px;
  border-radius: 3px;
  margin-top: 3px;
  background: var(--info-soft);
  color: var(--info);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event.warn { background: var(--warn-soft); color: var(--warn); }
.cal-event.ok { background: var(--ok-soft); color: var(--ok); }
.cal-event.danger { background: var(--danger-soft); color: var(--danger); }
.cal-event {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-weight: 500;
}
.cal-event:hover { border-color: currentColor; }
.cal-event svg { width: 10px; height: 10px; flex: 0 0 10px; }
.cal-more {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  cursor: pointer;
  font-weight: 500;
}
.cal-more:hover { color: var(--text); }
.cal-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.cal-count {
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--text-faint);
  display: flex;
  gap: 4px;
}
.cal-count em { font-style: normal; }
.cal-count .in { color: var(--ok); }
.cal-count .out { color: var(--danger); }

/* === SPARKBAR === */

.spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 28px;
}
.spark-bar {
  flex: 1;
  background: var(--accent);
  opacity: 0.7;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}

/* === TABS === */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 2px;
}
.tab {
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab[data-active="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* Misc */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 180px;
  z-index: 50;
}
.menu-item {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 12.5px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Datepicker popup */
.dp-pop {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 50;
  width: 260px;
}
.dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
}
.dp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.dp-dow {
  font-size: 10.5px;
  text-align: center;
  color: var(--text-faint);
  font-weight: 600;
  padding: 4px 0;
  text-transform: uppercase;
}
.dp-day {
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: var(--font-mono);
  cursor: pointer;
  color: var(--text);
}
.dp-day:hover { background: var(--hover); }
.dp-day[data-other="true"] { color: var(--text-faint); }
.dp-day[data-in-range="true"] { background: var(--accent-soft); color: var(--accent); border-radius: 0; }
.dp-day[data-end="start"] { background: var(--accent); color: var(--accent-fg); border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.dp-day[data-end="end"] { background: var(--accent); color: var(--accent-fg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.dp-day[data-end="single"] { background: var(--accent); color: var(--accent-fg); }

/* Drawer backdrop */
.drawer-back {
  position: fixed;
  inset: 0;
  background: oklch(15% 0 0 / 0.35);
  z-index: 80;
  animation: fade-in 0.15s ease-out;
}
:root[data-theme="dark"] .drawer-back { background: oklch(0% 0 0 / 0.6); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  animation: slide-in 0.2s ease-out;
  display: flex;
  flex-direction: column;
}
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Status pills used inline in tables */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--neutral-soft);
  color: var(--text-muted);
}
.pill .dot { width: 5px; height: 5px; border-radius: 99px; background: currentColor; }

/* ====================================================================== */
/* === AI INTELLIGENCE LAYER ============================================ */
/* ====================================================================== */

:root {
  /* AI uses its own hue — distinct from product accent so it reads as "system" */
  --ai: oklch(58% 0.14 290);
  --ai-2: oklch(64% 0.16 310);
  --ai-soft: oklch(96% 0.025 290);
  --ai-fg: white;
  --ai-border: oklch(86% 0.04 290);
  --ai-grad: linear-gradient(135deg, var(--ai) 0%, var(--ai-2) 100%);
}
:root[data-theme="dark"] {
  --ai: oklch(72% 0.13 290);
  --ai-2: oklch(76% 0.14 310);
  --ai-soft: oklch(26% 0.05 290);
  --ai-fg: oklch(15% 0.008 270);
  --ai-border: oklch(36% 0.06 290);
}

/* AI Sparkle icon background — used inline */
.ai-spark {
  width: 16px; height: 16px;
  display: inline-grid; place-items: center;
  flex-shrink: 0;
  color: var(--ai);
}
.ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px 1px 5px;
  border-radius: 99px;
  background: var(--ai-soft);
  color: var(--ai);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ai-pill svg { width: 10px; height: 10px; stroke-width: 2; }

/* Topbar AI button gets a subtle pulse dot */
.topbar-ai-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px 0 8px;
  border-radius: 99px;
  border: 1px solid var(--ai-border);
  background: var(--ai-soft);
  color: var(--ai);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
}
.topbar-ai-btn:hover { filter: brightness(0.97); }
.topbar-ai-btn .ai-dot {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--ai);
  position: relative;
  box-shadow: 0 0 0 0 var(--ai);
  animation: ai-pulse 2.4s ease-out infinite;
}
@keyframes ai-pulse {
  0%   { box-shadow: 0 0 0 0   oklch(58% 0.14 290 / 0.45); }
  70%  { box-shadow: 0 0 0 8px oklch(58% 0.14 290 / 0);    }
  100% { box-shadow: 0 0 0 0   oklch(58% 0.14 290 / 0);    }
}

/* Sidebar nav group label for AI gets a tiny dot */
.nav-group-ai .nav-group-label::after {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 99px;
  background: var(--ai);
  margin-left: 6px;
  vertical-align: 1px;
}

/* AI insight card — single, repeatable atom for insights everywhere */
.insight {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.insight::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--ai);
}
.insight[data-sev="high"]::before   { background: var(--danger); }
.insight[data-sev="med"]::before    { background: var(--warn); }
.insight[data-sev="low"]::before    { background: var(--info); }
.insight[data-sev="opportunity"]::before { background: var(--ok); }

.insight-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--ai-soft);
  color: var(--ai);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.insight[data-sev="high"] .insight-icon   { background: var(--danger-soft); color: var(--danger); }
.insight[data-sev="med"]  .insight-icon   { background: var(--warn-soft);   color: var(--warn); }
.insight[data-sev="low"]  .insight-icon   { background: var(--info-soft);   color: var(--info); }
.insight[data-sev="opportunity"] .insight-icon { background: var(--ok-soft); color: var(--ok); }
.insight-icon svg { width: 16px; height: 16px; stroke-width: 1.75; }

.insight-body { flex: 1; min-width: 0; }
.insight-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 4px;
}
.insight-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.3;
  margin-bottom: 4px;
}
.insight-body p {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 8px;
}
.insight-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.insight-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.insight-action:hover { background: var(--hover); border-color: var(--border-strong); }
.insight-action.primary {
  background: var(--ai);
  border-color: var(--ai);
  color: var(--ai-fg);
}
.insight-action.primary:hover { filter: brightness(0.95); }
.insight-action svg { width: 11px; height: 11px; stroke-width: 2; }

.insight-confidence {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.insight-confidence::before {
  content: "";
  width: 30px; height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  display: inline-block;
  position: relative;
  overflow: hidden;
}

/* === AI COPILOT DRAWER === */

.copilot {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: slide-in 0.2s ease-out;
}
.copilot-head {
  height: var(--topbar-h);
  padding: 0 14px 0 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.copilot-head .ai-avatar {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ai-grad);
  color: white;
  display: grid; place-items: center;
}
.copilot-head .ai-avatar svg { width: 14px; height: 14px; stroke-width: 2; }
.copilot-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}
.copilot-head .copilot-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.copilot-head .copilot-sub::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--ok);
}

.copilot-context {
  padding: 10px 16px;
  background: var(--ai-soft);
  border-bottom: 1px solid var(--ai-border);
  font-size: 11.5px;
  color: var(--ai);
  display: flex;
  align-items: center;
  gap: 8px;
}
.copilot-context strong { font-weight: 600; }

.copilot-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 90%;
  font-size: 13px;
  line-height: 1.5;
}
.msg-ai {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 10px 12px;
  color: var(--text);
}
.msg-user {
  background: var(--text);
  color: var(--bg);
  border-radius: 12px 12px 4px 12px;
  padding: 10px 12px;
  align-self: flex-end;
}
.msg-ai .msg-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--ai);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.msg-ai .msg-tag svg { width: 11px; height: 11px; }
.msg-ai .msg-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.msg-card {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.msg-card-head {
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}
.msg-card-body {
  padding: 10px;
  font-size: 12.5px;
}
.msg-card .kv {
  grid-template-columns: 80px 1fr;
  row-gap: 4px;
  font-size: 12px;
}

.copilot-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.copilot-sug-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}
.copilot-sug {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.copilot-sug:hover { background: var(--hover); border-color: var(--ai-border); }
.copilot-sug svg { width: 13px; height: 13px; color: var(--ai); flex-shrink: 0; stroke-width: 2; }

.copilot-input {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.copilot-input textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  min-height: 40px;
  padding: 6px 4px;
}
.copilot-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.copilot-input-row .spacer { flex: 1; }
.copilot-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.copilot-tag svg { width: 10px; height: 10px; }

/* === LIVE TRIGGER EVENT STREAM === */

.event-stream {
  display: flex;
  flex-direction: column;
}
.event {
  display: grid;
  grid-template-columns: 16px 90px 1fr auto;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.event:hover { background: var(--hover); }
.event-sev {
  width: 8px; height: 8px;
  border-radius: 99px;
  background: var(--neutral);
  margin-top: 6px;
}
.event[data-sev="high"] .event-sev { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.event[data-sev="med"]  .event-sev { background: var(--warn);   box-shadow: 0 0 0 3px var(--warn-soft); }
.event[data-sev="low"]  .event-sev { background: var(--info);   box-shadow: 0 0 0 3px var(--info-soft); }
.event[data-sev="ok"]   .event-sev { background: var(--ok);     box-shadow: 0 0 0 3px var(--ok-soft); }
.event-ts {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
.event-title { font-size: 13px; font-weight: 500; }
.event-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.45;
}
.event-tags {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* === ARCHITECTURE DIAGRAM === */

.arch-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.arch-tier {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.arch-tier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.arch-tier-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
}
.arch-tier-title { font-size: 14px; font-weight: 600; }
.arch-nodes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.arch-node {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface-2);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.arch-node[data-kind="ai"] {
  background: var(--ai-soft);
  border-color: var(--ai-border);
}
.arch-node[data-kind="existing"] {
  background: var(--surface);
}
.arch-node[data-kind="data"] {
  background: var(--info-soft);
  border-color: oklch(86% 0.05 250);
}
.arch-node-name {
  font-weight: 600;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.arch-node-name .arch-icon {
  width: 12px; height: 12px;
  color: var(--text-muted);
}
.arch-node[data-kind="ai"] .arch-node-name .arch-icon { color: var(--ai); }
.arch-node-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.arch-node-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
.arch-node[data-kind="ai"] .arch-node-tag { color: var(--ai); }

.arch-arrow {
  text-align: center;
  color: var(--text-faint);
  margin: 4px 0;
  font-size: 16px;
  line-height: 1;
}

/* === DIGEST === */

.digest-page {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: flex-start;
}
.digest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.digest-hero {
  padding: 20px 24px;
  background: var(--ai-grad);
  color: white;
  position: relative;
}
.digest-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 14px, oklch(100% 0 0 / 0.04) 14px 28px);
  pointer-events: none;
}
.digest-hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 6px;
}
.digest-hero-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 6px 0 0;
  line-height: 1.2;
}
.digest-hero-sub {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 6px;
}
.digest-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.digest-section:last-child { border-bottom: 0; }
.digest-section-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.digest-section-label svg { width: 11px; height: 11px; color: var(--ai); }
.digest-line {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text);
  margin: 4px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.digest-line .dot {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--ai);
  margin-top: 8px;
  flex-shrink: 0;
}
.digest-stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 4px;
}
.digest-stat {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.digest-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.digest-stat-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.digest-stat-delta {
  font-size: 11px;
  margin-top: 2px;
}
.digest-stat-delta.up { color: var(--ok); }
.digest-stat-delta.down { color: var(--danger); }

.delivery-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.delivery-list {
  padding: 4px 0;
}
.delivery-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.delivery-item:last-child { border-bottom: 0; }
.delivery-icon {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-muted);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.delivery-icon svg { width: 14px; height: 14px; stroke-width: 1.75; }
.delivery-meta { flex: 1; min-width: 0; }
.delivery-meta strong { font-size: 13px; font-weight: 500; display: block; }
.delivery-meta span { font-size: 11px; color: var(--text-muted); }
.toggle {
  width: 30px; height: 17px;
  border-radius: 99px;
  background: var(--surface-3);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 13px; height: 13px;
  border-radius: 99px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: left 0.15s;
}
.toggle[data-on="true"] { background: var(--ai); }
.toggle[data-on="true"]::after { left: 15px; }

/* === AI INSIGHTS BOARD === */

.insight-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.insight-board > .insight { margin: 0; }

/* === PREDICTION CARD === */
.predict-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.predict {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.predict-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.predict-h .label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}
.predict-h .conf {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ai);
}
.predict-num {
  font-family: var(--font-mono);
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 4px 0 2px;
}
.predict-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* === MEMORY: vector item === */
.vec-item {
  display: grid;
  grid-template-columns: 90px 1fr 80px 80px;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  align-items: center;
}
.vec-item:last-child { border-bottom: 0; }
.vec-id { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.vec-text { color: var(--text-muted); line-height: 1.4; }
.vec-text strong { color: var(--text); font-weight: 500; }
.vec-sim {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ai);
  text-align: right;
}
.vec-bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.vec-bar > div {
  height: 100%;
  background: var(--ai);
  border-radius: 2px;
}

/* Typing dots */
.typing {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 6px 2px;
}
.typing span {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--ai);
  opacity: 0.4;
  animation: typing 1.4s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Workflow flow diagram */
.flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 4px 0;
}
.flow-step {
  flex: 1;
  min-width: 140px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}
.flow-step + .flow-step { margin-left: 18px; }
.flow-step + .flow-step::before {
  content: "›";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 18px;
  line-height: 1;
}
.flow-step[data-ai="true"] {
  background: var(--ai-soft);
  border-color: var(--ai-border);
}
.flow-step .fs-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
}
.flow-step[data-ai="true"] .fs-label { color: var(--ai); }
.flow-step .fs-title { font-size: 13px; font-weight: 500; margin-top: 2px; }
.flow-step .fs-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Roadmap */
.roadmap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.phase {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface);
}
.phase-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ai);
  font-weight: 600;
}
.phase-title { font-size: 15px; font-weight: 600; margin: 4px 0 8px; }
.phase-when { font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; font-family: var(--font-mono); }
.phase ul { padding-left: 16px; margin: 0; font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.phase ul li::marker { color: var(--ai); }

/* Composer / Drawer fix: AI drawer shouldn't share the .drawer animation */

/* ====================================================================== */
/* === ENTERPRISE MODULES: AUDIT · SETTINGS · GEOGRAPHY ================ */
/* ====================================================================== */

/* === ACTIVITY HEATMAP === */
.heatmap {
  display: grid;
  grid-template-columns: 40px repeat(24, 1fr);
  gap: 2px;
  font-size: 10px;
}
.heatmap-cell {
  height: 14px;
  border-radius: 2px;
  background: var(--surface-3);
}
.heatmap-cell[data-level="1"] { background: oklch(94% 0.04 195); }
.heatmap-cell[data-level="2"] { background: oklch(86% 0.07 195); }
.heatmap-cell[data-level="3"] { background: oklch(75% 0.09 195); }
.heatmap-cell[data-level="4"] { background: oklch(62% 0.11 195); }
.heatmap-cell[data-level="5"] { background: oklch(50% 0.13 195); }
.heatmap-row-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  padding-right: 6px;
  text-align: right;
  align-self: center;
}
.heatmap-col-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--text-faint);
  text-align: center;
}

/* === AUDIT EVENT ROW === */
.audit-row {
  display: grid;
  grid-template-columns: 110px 24px 1fr 180px 100px 80px;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  align-items: center;
  font-size: 12.5px;
}
.audit-row:hover { background: var(--hover); }
.audit-row[data-sev="high"]   { background: oklch(99% 0.02 25 / 0.4); }
:root[data-theme="dark"] .audit-row[data-sev="high"] { background: oklch(28% 0.06 25 / 0.3); }
.audit-row .ts {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}
.audit-row .sev-dot {
  width: 8px; height: 8px;
  border-radius: 99px;
  background: var(--neutral);
  justify-self: center;
}
.audit-row[data-sev="high"] .sev-dot   { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.audit-row[data-sev="med"]  .sev-dot   { background: var(--warn);   box-shadow: 0 0 0 3px var(--warn-soft); }
.audit-row[data-sev="low"]  .sev-dot   { background: var(--info);   box-shadow: 0 0 0 3px var(--info-soft); }
.audit-row[data-sev="ok"]   .sev-dot   { background: var(--ok);     box-shadow: 0 0 0 3px var(--ok-soft); }
.audit-row .actor {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text);
}
.audit-row .actor .actor-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}
.audit-row .action {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--text-muted);
  width: fit-content;
}
.audit-row .target {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text);
}
.audit-row .meta-col {
  color: var(--text-muted);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* === DIFF VIEW === */
.diff {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.diff-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  border-bottom: 1px solid var(--border);
}
.diff-row:last-child { border-bottom: 0; }
.diff-row .diff-field {
  padding: 6px 10px;
  background: var(--surface);
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  font-size: 11.5px;
}
.diff-row .diff-pair {
  display: grid;
  grid-template-columns: 1fr 14px 1fr;
  align-items: center;
}
.diff-from, .diff-to {
  padding: 6px 10px;
  font-size: 12px;
}
.diff-from {
  background: var(--danger-soft);
  color: var(--danger);
  text-decoration: line-through;
}
.diff-to {
  background: var(--ok-soft);
  color: var(--ok);
}
.diff-arrow {
  text-align: center;
  color: var(--text-faint);
}

/* Audit drawer */
.drawer-wide {
  width: 640px;
}

/* === SETTINGS LAYOUT === */
.settings-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 18px;
  align-items: flex-start;
}
.settings-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  position: sticky;
  top: 0;
}
.settings-nav-group { margin-bottom: 4px; }
.settings-nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 8px 10px 4px;
  font-weight: 600;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12.5px;
  cursor: pointer;
  color: var(--text-muted);
}
.settings-nav-item:hover { background: var(--hover); color: var(--text); }
.settings-nav-item[data-active="true"] {
  background: var(--surface-3);
  color: var(--text);
  font-weight: 500;
}
.settings-nav-item svg { width: 14px; height: 14px; stroke-width: 1.75; flex-shrink: 0; }
.settings-nav-item .badge { margin-left: auto; font-size: 10px; }

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.settings-card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.settings-card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.settings-card-head p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.settings-card-body { padding: 16px 18px; }

.setting-row {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-row:first-child { padding-top: 0; }
.setting-row .s-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.setting-row .s-label .s-hint {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}
.setting-row .s-control { font-size: 13px; }

.kv-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.kv-list-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px;
  padding: 10px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.kv-list-row:last-child { border-bottom: 0; }

/* RBAC matrix */
.rbac {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.rbac th, .rbac td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.rbac th:first-child, .rbac td:first-child { text-align: left; font-weight: 500; }
.rbac thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
}
.perm {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-faint);
}
.perm.full { background: var(--ok); color: white; }
.perm.read { background: var(--info-soft); color: var(--info); }
.perm.none { color: var(--text-faint); }
.perm svg { width: 11px; height: 11px; stroke-width: 2.5; }

/* === GEOGRAPHY TREE === */
.geo-shell {
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  gap: 14px;
  align-items: flex-start;
}
.geo-tree {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
}
.geo-tree-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.geo-tree-body {
  overflow-y: auto;
  padding: 4px;
  flex: 1;
}
.tree-node {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  font-size: 12.5px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text);
  position: relative;
}
.tree-node:hover { background: var(--hover); }
.tree-node[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.tree-node .twist {
  width: 12px;
  height: 12px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  font-size: 9px;
  flex-shrink: 0;
}
.tree-node .tn-icon {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.tree-node[data-active="true"] .tn-icon { color: var(--accent); }
.tree-node .tn-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
}
.tree-node[data-status="inactive"] .tn-name { color: var(--text-faint); }

/* Geo map */
.geo-map {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  height: 280px;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  background-color: var(--surface-2);
}
.geo-pin {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 99px;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sm);
  transform: translate(-50%, -50%);
  cursor: pointer;
}
.geo-pin[data-hot="true"] {
  background: var(--danger);
  width: 18px; height: 18px;
}
.geo-pin[data-hot="true"]::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 99px;
  background: var(--danger);
  opacity: 0.25;
  animation: ai-pulse 2s ease-out infinite;
}
.geo-pin .geo-label {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10.5px;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
}

/* Geo coverage table cell */
.coverage-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100px;
}
.coverage-bar .cb-track {
  flex: 1;
  height: 5px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.coverage-bar .cb-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.coverage-bar .cb-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  width: 32px;
  text-align: right;
}

/* split panel for audit detail drawer */
.drawer-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-section:last-child { border-bottom: 0; }
.drawer-section .ds-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 8px;
}

/* === RESPONSIVE LAYER ============================================ */

/* Visibility utilities — opt screens in/out per breakpoint */
.mobile-only { display: none !important; }
.desktop-only { display: inherit; }

/* Backdrop element rendered by app.jsx when mobile nav is open */
.sidebar-backdrop { display: none; }

/* ---------- Tablet & phone (≤ 880px) ---------- */
@media (max-width: 880px) {
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }

  /* App shell — sidebar becomes an off-canvas drawer */
  .app,
  .app[data-sidebar="collapsed"] {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 264px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: var(--shadow-lg);
  }
  /* Open via mobileNav state. Both expanded and collapsed labels stay hidden by default. */
  .app[data-mobile-nav="open"] .sidebar {
    transform: translateX(0);
  }
  /* Always show labels in the mobile drawer — collapsed-icon mode doesn't make sense here */
  .app[data-sidebar="collapsed"] .sidebar .logo-text,
  .app[data-sidebar="collapsed"] .sidebar .nav-group-label,
  .app[data-sidebar="collapsed"] .sidebar .user-meta { display: revert; }
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15, 17, 21, 0.45);
    z-index: 55;
  }

  /* Main column reclaims full width */
  .main { min-width: 0; }
  .content { padding: 14px; }

  /* Topbar — drop search, shrink copilot button */
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar .search-box { display: none; }
  .topbar-ai-btn {
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    justify-content: center;
    font-size: 0;
  }
  .topbar-ai-btn svg,
  .topbar-ai-btn .ai-dot { font-size: initial; }
  .crumbs {
    font-size: 12px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  /* Page head — title + actions wrap onto separate rows */
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .page-head > div:first-child { width: 100%; }
  .page-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .page-title { font-size: 20px; }
  .page-sub { font-size: 12px; }

  /* KPI grid — 4 → 2 cols */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 22px; }

  /* Multi-column inline grids → stack */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr"],
  [style*="grid-template-columns: minmax(0, 1fr) minmax(0, 1fr)"],
  [style*="grid-template-columns: minmax(0, 1fr) 360px"],
  [style*="grid-template-columns: minmax(0, 1fr) 460px"],
  [style*="grid-template-columns: repeat(3, 1fr)"],
  [style*="grid-template-columns: 180px 1fr 110px"],
  [style*="grid-template-columns: 140px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* 4-col tile rows → 2 cols on tablet */
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(7, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Tables — horizontal scroll via the surrounding card */
  .card:has(> .tbl),
  .card:has(> .tabs + .tbl-toolbar + .tbl),
  .card:has(.tbl) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Keep menu dropdowns out of scroll-clip when possible */
  .menu { right: 0 !important; }

  /* Table cell padding shrink */
  .tbl thead th,
  .tbl tbody td {
    padding: 8px 10px;
    font-size: 12.5px;
  }

  /* Toolbar above tables — wrap chips and search */
  .tbl-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
  }
  .search-inline { flex: 1 1 100%; }
  .chip { font-size: 11.5px; }

  /* Tabs — horizontal scroll */
  .tabs {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; }

  /* Tweaks panel — slim bottom-right card */
  .tweak-panel,
  [data-tweaks-panel] {
    right: 12px !important;
    bottom: 12px !important;
    width: calc(100vw - 24px) !important;
    max-width: 320px !important;
  }

  /* Copilot drawer — full screen */
  .ai-drawer,
  [data-ai-drawer] {
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* Calendar grid — 7 cols stays but cells shrink */
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-event {
    font-size: 9.5px;
    padding: 1px 4px;
  }
  .cal-event span { display: none; }   /* hide BK-id text, keep arrow icon */
  .cal-event svg { width: 9px; height: 9px; }

  /* Tweaks panel inner widths */
  .tweak-row { gap: 6px; }

  /* Document preview modal — shrink padding */
  [style*="place-items: start center"][style*="position: fixed"] { padding: 12px 8px 32px !important; }

  /* Sticky elements give up their stickiness on mobile (often cause z-index/flow issues) */
  [style*="position: sticky"] {
    position: static !important;
    top: auto !important;
  }
}

/* ---------- Phone only (≤ 520px) ---------- */
@media (max-width: 520px) {
  /* KPI grid: 1 column */
  .kpi-grid { grid-template-columns: 1fr !important; }

  /* 4-/7-col inline grids → 1 column */
  [style*="grid-template-columns: repeat(4, 1fr)"],
  [style*="grid-template-columns: repeat(7, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* Page actions stack full-width buttons */
  .page-actions .btn { flex: 1 1 calc(50% - 6px); justify-content: center; }
  .page-actions .btn-accent { flex: 1 1 100%; }

  /* Topbar gets even tighter */
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar .icon-btn { width: 34px; height: 34px; }

  /* Sidebar drawer takes more of the screen */
  .sidebar { width: 86vw; max-width: 320px; }

  /* Tighter card padding */
  .card { border-radius: var(--radius); }

  /* Make hotel detail hero shorter */
  .page .card + .card { margin-top: 0; }

  /* Smaller tweaks toggle */
  .tweak-toggle { transform: scale(0.95); }
}

/* ---------- Print (used by Documents → Print button) ---------- */
@media print {
  .sidebar, .topbar, .tweak-panel, .ai-drawer, .toast-stack, .page-head .page-actions { display: none !important; }
  .app { display: block; }
  .main { width: 100%; }
  .content { padding: 0; }
  .card { border: none; box-shadow: none; }
}


/* ============================================================
   LOGIN SCREEN + ROLE PICKER
   ============================================================ */
.login-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--bg);
  color: var(--text);
  z-index: 50;
  overflow: auto;
}

/* Brand panel */
.login-brand {
  position: relative;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  background:
    radial-gradient(110% 120% at 0% 0%, oklch(62% 0.14 var(--accent-h)) 0%, transparent 55%),
    linear-gradient(155deg, oklch(40% 0.12 var(--accent-h)) 0%, oklch(26% 0.08 var(--accent-h)) 100%);
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, transparent 0 14px, oklch(100% 0 0 / 0.03) 14px 28px);
  pointer-events: none;
}
.login-brand-top { display: flex; align-items: center; gap: 12px; position: relative; }
.login-logo {
  width: 40px; height: 40px; font-size: 20px;
  background: oklch(100% 0 0 / 0.16);
  color: white;
  border: 1px solid oklch(100% 0 0 / 0.25);
}
.login-brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.login-brand-name small { font-weight: 500; font-size: 11px; opacity: 0.7; }
.login-brand-mid { position: relative; max-width: 460px; }
.login-brand-mid h1 {
  font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em;
  margin: 0 0 16px;
}
.login-brand-mid p { font-size: 14px; line-height: 1.6; opacity: 0.82; margin: 0 0 24px; }
.login-brand-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.login-brand-points li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; opacity: 0.92; }
.login-brand-points li span {
  width: 22px; height: 22px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 99px; background: oklch(100% 0 0 / 0.18);
}
.login-brand-points li span svg { width: 13px; height: 13px; stroke-width: 2.5; }
.login-brand-foot { position: relative; font-size: 11.5px; opacity: 0.6; }

/* Form panel */
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}
.login-card { width: 100%; max-width: 420px; }
.login-card-head h2 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.login-card-head p { font-size: 13.5px; color: var(--text-muted); margin: 0 0 24px; }

.login-form { display: grid; gap: 14px; }
.login-field { display: grid; gap: 6px; }
.login-field span { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.login-field input {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-error {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--danger);
  background: var(--danger-soft);
  padding: 8px 10px; border-radius: var(--radius);
}
.login-error svg { width: 15px; height: 15px; flex-shrink: 0; }
.login-submit { height: 42px; justify-content: center; font-size: 14px; font-weight: 600; margin-top: 4px; }
.login-submit svg { width: 16px; height: 16px; }
.login-hint { font-size: 11.5px; color: var(--text-faint); text-align: center; }

/* Role picker */
.login-roles { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 20px; }
.login-roles-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 12px;
}
.login-roles-grid { display: grid; gap: 8px; }
.login-role {
  display: flex; align-items: center; gap: 12px; text-align: left;
  width: 100%; padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
}
.login-role:hover { border-color: var(--border-strong); background: var(--surface-2); }
.login-role[data-active] {
  border-color: oklch(55% 0.10 var(--role-h, 195));
  box-shadow: 0 0 0 3px oklch(95% 0.04 var(--role-h, 195));
  background: var(--surface);
}
[data-theme="dark"] .login-role[data-active] {
  box-shadow: 0 0 0 3px oklch(40% 0.06 var(--role-h, 195) / 0.4);
}
.login-role-meta { flex: 1; min-width: 0; line-height: 1.3; }
.login-role-meta strong { display: block; font-size: 13px; font-weight: 600; }
.login-role-meta span {
  display: block; font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.login-role-check {
  width: 26px; height: 26px; flex-shrink: 0;
  display: inline-grid; place-items: center;
  border-radius: 99px; color: var(--text-faint);
}
.login-role[data-active] .login-role-check {
  background: oklch(55% 0.10 var(--role-h, 195)); color: white;
}
.login-role-check svg { width: 14px; height: 14px; stroke-width: 2.5; }

/* Topbar user chip */
.topbar-user { display: flex; align-items: center; gap: 8px; padding-left: 8px; margin-left: 4px; border-left: 1px solid var(--border); }
.topbar-user-meta { line-height: 1.2; }
.topbar-user-meta strong { display: block; font-size: 12px; font-weight: 600; }
.topbar-user-meta span { display: block; font-size: 10.5px; color: var(--text-muted); }

@media (max-width: 860px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .topbar-user-meta { display: none; }
}
