* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --border: #334155;
  --text: #f8fafc;
  --text2: #94a3b8;
  --text3: #64748b;
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --purple: #a855f7;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Sidebar */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-logo { padding: 0 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-logo h1 { font-size: 22px; font-weight: 700; }
.sidebar-logo span { color: var(--blue); }
.sidebar-logo p { color: var(--text3); font-size: 12px; margin-top: 2px; }
.brand-logo { height: 56px; display: block; }
.brand-logo-mobile { height: 36px; display: block; }
/* Only the nav scrolls; the logo above and the user/logout below stay put.
   min-height:0 is what makes that work — a flex item defaults to min-height:auto, which
   refuses to shrink below its content, so without it a nav taller than the viewport
   pushes .sidebar-bottom off the screen instead of scrolling (which is exactly what the
   four new pages did). overscroll-behavior stops the page scrolling once the nav ends. */
.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sidebar-nav::-webkit-scrollbar { width: 8px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: var(--text3); }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; color: var(--text2);
  text-decoration: none; font-size: 14px; margin-bottom: 4px; transition: all 0.15s;
}
.sidebar-nav a:hover { background: var(--surface2); color: var(--text); }
.sidebar-nav a.active { background: #3b82f620; color: var(--blue); }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-count {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-grid; place-items: center; border-radius: 10px;
  color: #fff; background: #c42644; font-size: 10px; font-weight: 800;
  box-shadow: 0 0 0 3px rgba(196, 38, 68, .13);
}

/* Nav groups: a quiet heading over each cluster of related pages, so twenty
   items read as five jobs. Whole groups are hidden when a role may see none
   of their pages — see applyRoleRestrictions. */
.nav-group { margin-top: 14px; }
.nav-group-label {
  padding: 0 12px 5px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .9px; text-transform: uppercase;
  color: var(--text3);
}
.sidebar-bottom { padding: 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-bottom button {
  width: 100%; padding: 8px; background: transparent; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text2); font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.sidebar-bottom button:hover { background: var(--surface2); color: var(--text); }

/* Main content */
/* min-width:0 is load-bearing, not tidying. .main is a flex item, and a flex
   item defaults to min-width:auto — it refuses to shrink below its content's
   intrinsic width. The pipeline board is a flex row of fixed-width columns, so
   without this the board's full width pushes .main past the viewport and the
   whole PAGE scrolls sideways, sidebar and all, instead of just the board.
   With it, .ld-board's own overflow-x is what scrolls. */
.main { flex: 1; min-width: 0; margin-left: 240px; padding: 24px 32px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 600; }
.page-header p { color: var(--text2); font-size: 14px; margin-top: 4px; }

/* Activation requests: deliberate SincA/WPF geometry, softened for the web. */
.activation-page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  padding: 6px 0 4px;
}
.activation-eyebrow {
  display: block; color: #ee5a75; font-size: 10px; font-weight: 800;
  letter-spacing: 1.45px; text-transform: uppercase; margin-bottom: 5px;
}
.activation-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin-bottom: 16px;
}
.activation-stat {
  position: relative; overflow: hidden; min-height: 84px; padding: 16px 18px;
  background: linear-gradient(145deg, rgba(59,130,246,.09), transparent 70%), var(--surface);
  border: 1px solid var(--border); border-radius: 13px;
}
.activation-stat::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: #c42644;
}
.activation-stat:nth-child(2)::before { background: var(--green); }
.activation-stat:nth-child(3)::before { background: var(--orange); }
.activation-stat span { display: block; color: var(--text2); font-size: 11px; font-weight: 600; }
.activation-stat strong { display: block; margin-top: 7px; font-size: 25px; line-height: 1; }
.activation-toolbar {
  display: flex; gap: 10px; padding: 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.activation-search {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px;
  padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.activation-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.activation-search svg { width: 17px; height: 17px; color: var(--text3); flex: 0 0 auto; }
.activation-search input {
  width: 100%; padding: 9px 0; color: var(--text); background: transparent;
  border: 0; outline: 0; font: inherit; font-size: 13px;
}
.activation-request-list { display: grid; gap: 10px; }
.activation-loading, .activation-empty {
  min-height: 210px; display: grid; place-items: center; align-content: center; gap: 12px;
  color: var(--text2); background: var(--surface); border: 1px dashed var(--border); border-radius: 14px;
}
.activation-empty strong { color: var(--text); font-size: 15px; }
.activation-request-card {
  display: grid; grid-template-columns: minmax(240px, 1.2fr) minmax(220px, .9fr) auto;
  align-items: center; gap: 22px; min-height: 108px; padding: 18px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 13px;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.activation-request-card:hover { transform: translateY(-1px); border-color: #475569; box-shadow: 0 12px 30px rgba(0,0,0,.14); }
.activation-card-primary { display: flex; align-items: center; gap: 14px; min-width: 0; }
.activation-avatar {
  width: 44px; height: 44px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 12px; color: #fff; background: linear-gradient(145deg, #c42644, #8f1830);
  font-size: 15px; font-weight: 800; box-shadow: 0 8px 22px rgba(196,38,68,.22);
}
.activation-card-title { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.activation-card-title strong { font-size: 15px; }
.activation-card-primary p, .activation-card-meta p { color: var(--text2); font-size: 12px; margin-top: 5px; }
.activation-card-meta { min-width: 0; }
.activation-card-meta p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activation-status {
  display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px;
  font-size: 9px; font-weight: 800; letter-spacing: .65px; text-transform: uppercase;
}
.activation-status.pending { color: #fbbf24; background: rgba(245,158,11,.12); }
.activation-status.active { color: #4ade80; background: rgba(34,197,94,.12); }
.activation-status.failed { color: #fb923c; background: rgba(249,115,22,.12); }
.activation-status.rejected { color: #f87171; background: rgba(239,68,68,.12); }
.activation-status.provisioning { color: #60a5fa; background: rgba(59,130,246,.12); }
.activation-card-actions { display: flex; justify-content: flex-end; }
.activation-review-modal { width: min(760px, 95vw); }
.activation-review-body { padding: 22px 24px; overflow-y: auto; }
.activation-applicant {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 14px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 18px;
}
.activation-applicant div { min-width: 0; }
.activation-applicant small { display: block; color: var(--text3); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.activation-applicant span { display: block; margin-top: 4px; font-size: 12px; overflow-wrap: anywhere; }
.activation-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.activation-form-grid .form-group, .activation-reject-reason { display: block; }
.activation-form-grid .form-group > span, .activation-reject-reason > span {
  display: block; color: var(--text2); font-size: 12px; font-weight: 600; margin-bottom: 6px;
}
.activation-form-grid .form-group > small { display: block; color: var(--text3); font-size: 10px; margin-top: 5px; }
.activation-server-field, .activation-host-field, .activation-package-field { grid-column: 1 / -1; }
.activation-host-field input { font-family: 'Cascadia Code', Consolas, monospace; letter-spacing: .15px; }
.activation-rights-panel {
  margin-top: 18px; padding: 16px; border: 1px solid rgba(59,130,246,.28);
  background: rgba(59,130,246,.055); border-radius: 11px;
}
.activation-rights-panel > div:first-child { display: flex; justify-content: space-between; gap: 10px; }
.activation-rights-panel small { color: var(--text3); }
.activation-rights-title { font-size: 12px; font-weight: 700; }
.activation-right-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.activation-right-chips span {
  padding: 5px 8px; color: #93c5fd; background: rgba(59,130,246,.12);
  border: 1px solid rgba(59,130,246,.22); border-radius: 6px; font: 700 10px/1 'Cascadia Code', Consolas, monospace;
}
.activation-rights-panel p { color: var(--text3); font-size: 10px; line-height: 1.55; margin-top: 10px; }
.activation-reject-reason { margin-top: 16px; }
.activation-reject-reason small { color: var(--text3); font-weight: 400; }
.activation-modal-actions { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-top: 1px solid var(--border); }
.activation-primary-actions { display: flex; gap: 8px; }
.btn-outline.danger { color: #f87171; border-color: rgba(239,68,68,.34); }
.btn-outline.danger:hover { color: #fff; background: rgba(239,68,68,.16); }
.activation-credentials-modal { width: min(590px, 95vw); padding: 28px; text-align: center; }
.activation-success-mark {
  width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 14px;
  color: #fff; background: linear-gradient(145deg, #22c55e, #15803d); border-radius: 16px;
  font-size: 25px; font-weight: 800; box-shadow: 0 10px 28px rgba(34,197,94,.22);
}
.activation-credential-note { color: var(--text2); font-size: 12px; line-height: 1.55; margin: 8px auto 18px; }
.activation-email-status { margin: -8px auto 16px; padding: 8px 11px; border-radius: 7px; font-size: 11px; }
.activation-email-status:empty { display: none; }
.activation-email-status.success { background: rgba(34,197,94,.12); color: #86efac; }
.activation-email-status.warning { background: rgba(245,158,11,.12); color: #fcd34d; }
.activation-credential-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.activation-credential-grid div { padding: 11px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.activation-credential-grid small { display: block; color: var(--text3); font-size: 9px; text-transform: uppercase; letter-spacing: .55px; }
.activation-credential-grid code { display: block; margin-top: 5px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.activation-credential-grid .credential-wide { grid-column: 1 / -1; }
.activation-privileges { color: var(--text3); font-size: 10px; line-height: 1.55; margin: 13px 0 18px; }
.activation-credentials-modal .modal-footer { padding: 14px 0 0; }

.database-account-panel {
  margin: 14px 0; padding: 14px; border: 1px solid rgba(59,130,246,.24);
  background: linear-gradient(135deg, rgba(59,130,246,.07), rgba(15,23,42,.12)); border-radius: 11px;
}
.database-account-panel .form-row { margin-bottom: 7px; }
.database-host-help { color: var(--text3); font-size: 10px; line-height: 1.5; }
.database-host-help strong { color: #93c5fd; font-family: 'Cascadia Code', Consolas, monospace; font-weight: 600; }
.database-account-panel input { font-family: 'Cascadia Code', Consolas, monospace; }

@media (max-width: 900px) {
  .activation-request-card { grid-template-columns: 1fr auto; gap: 14px; }
  .activation-card-meta { grid-row: 2; grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .activation-page-header { align-items: flex-start; flex-direction: column; }
  .activation-refresh { width: 100%; }
  .activation-stats { grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
  .activation-stat { min-height: 70px; padding: 12px; }
  .activation-stat strong { font-size: 21px; }
  .activation-toolbar { flex-direction: column; }
  .activation-toolbar .filter-select { width: 100%; }
  .activation-search { min-height: 42px; }
  .activation-request-card { grid-template-columns: 1fr; padding: 15px; }
  .activation-card-actions { justify-content: stretch; }
  .activation-card-actions .btn-sm { width: 100%; }
  .activation-applicant, .activation-form-grid, .activation-credential-grid { grid-template-columns: 1fr; }
  .activation-package-field, .activation-credential-grid .credential-wide { grid-column: auto; }
  .activation-modal-actions { align-items: stretch; flex-direction: column-reverse; }
  .activation-primary-actions { display: grid; grid-template-columns: 1fr 1.4fr; }
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.stat-card .stat-label { color: var(--text2); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-card .stat-value.blue { color: var(--blue); }
.stat-card .stat-value.green { color: var(--green); }
.stat-card .stat-value.red { color: var(--red); }
.stat-card .stat-value.orange { color: var(--orange); }
.stat-card .stat-value.purple { color: var(--purple); }
.stat-card .stat-sub { color: var(--text3); font-size: 11px; margin-top: 4px; }

/* Filters */
.filters-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.search-box {
  flex: 1; min-width: 240px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; outline: none; transition: border-color 0.2s;
}
.search-box:focus { border-color: var(--blue); }
.filter-select {
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; outline: none; cursor: pointer;
  min-width: 140px;
}
.filter-select option { background: var(--surface); }
/* Date inputs have no form-group wrapper in the desk-work filter bar, so they need
   their own rule. color-scheme: dark is what makes the calendar icon and the
   dd-mm-yyyy placeholder follow the theme instead of rendering native white. */
.filter-date {
  padding: 9px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; outline: none; cursor: pointer;
  color-scheme: dark;
}
.filter-date:focus { border-color: var(--blue); }
.select-themed {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px; outline: none; cursor: pointer;
}
.select-themed:focus { border-color: var(--blue); }
.select-themed option { background: var(--surface); }

/* Filters popup (mobile-only; on desktop it's just an inline flex container) */
.filters-toggle-btn {
  display: none;
  align-items: center; gap: 6px;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; cursor: pointer; white-space: nowrap;
}
.filters-toggle-btn svg { width: 16px; height: 16px; }
.filter-badge {
  background: var(--blue); color: #fff; font-size: 11px; font-weight: 600;
  min-width: 18px; height: 18px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; padding: 0 5px;
}
.filters-popup { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.filters-popup-overlay,
.filters-popup-header,
.filters-popup-actions { display: none; }

/* Table */
/* The other table box the pages use (Tickets & Tasks, Leads, Performance…).
   Scrolls sideways itself so a wide table can never stretch the page — the
   difference between a scrollable table and a phone screen that pans. */
.table-container { overflow-x: auto; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #0f172a40;
  border-bottom: 1px solid var(--border);
}
th.sortable { cursor: pointer; user-select: none; position: relative; white-space: nowrap; }
th.sortable:hover { color: var(--text); background: #1e293b; }
th.sortable .sort-arrows { font-size: 9px; margin-left: 4px; color: var(--text3); letter-spacing: -2px; }
th.sortable.sort-asc .sort-arrows,
th.sortable.sort-desc .sort-arrows { color: var(--blue); }
th.sortable.sort-asc .sort-arrows::after { content: '▲'; }
th.sortable.sort-desc .sort-arrows::after { content: '▼'; }
th.sortable.sort-asc .sort-arrows,
th.sortable.sort-desc .sort-arrows { font-size: 0; }
th.sortable.sort-asc .sort-arrows::after,
th.sortable.sort-desc .sort-arrows::after { font-size: 10px; color: var(--blue); }
tbody td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid #1e293b;
  color: var(--text);
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: #334155; cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-active { background: #22c55e20; color: var(--green); }
.badge-block { background: #ef444420; color: var(--red); }
.badge-expired { background: #f59e0b20; color: var(--orange); }
.badge-pending { background: #3b82f620; color: var(--blue); }
.badge-ksa { background: #3b82f620; color: var(--blue); }
.badge-ind { background: #a855f720; color: var(--purple); }
.badge-wa { background: #22c55e20; color: var(--green); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-top: 1px solid var(--border);
}
.pagination .info { color: var(--text2); font-size: 13px; }
.pagination .pages { display: flex; gap: 6px; }
.pagination .pages button {
  padding: 6px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.pagination .pages button:hover { background: var(--surface2); color: var(--text); }
.pagination .pages button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination .pages button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .goto-page { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.pagination .goto-page input {
  width: 52px;
  padding: 4px 6px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  text-align: center;
}
.pagination .goto-page input::-webkit-inner-spin-button { opacity: 0.5; }
.pagination .per-page { display: flex; align-items: center; gap: 6px; color: var(--text2); font-size: 13px; }
.pagination .per-page select {
  padding: 4px 8px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text2); font-size: 22px;
  cursor: pointer; width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; border-radius: 6px;
}
.modal-close:hover { background: var(--surface2); color: var(--text); }
.modal-body { padding: 24px; }
.modal-section { margin-bottom: 20px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section h4 { font-size: 13px; color: var(--text2); font-weight: 600; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item label { display: block; font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.detail-item span { font-size: 14px; }
.detail-full { grid-column: 1 / -1; }

/* Customer Detail Drawer (wide slide-over panel, roomier than a centered modal) */
.drawer-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 1000;
}
.drawer-overlay.active { display: block; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(920px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -25px 0 50px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.drawer-overlay.active .drawer { transform: translateX(0); }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-header h3 { font-size: 17px; font-weight: 600; }
.drawer-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
}
.drawer-tab {
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.drawer-tab:hover { color: var(--text); }
.drawer-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }
.drawer-tab-panel { display: none; }
.drawer-tab-panel.active { display: block; }

/* Form controls inside modal */
.form-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }
.form-group { flex: 1; }
.form-group label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
/* textarea included: without it a textarea falls back to the browser's own look —
   white box, monospace, wrong size — which is why the textareas already in this file
   carry the same declarations inline. New ones do not need to. */
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; outline: none;
}
.form-group textarea { font-family: inherit; resize: vertical; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--blue); }

/* Print template modal: JSON editors and the job-card layout slots */
.form-group textarea.tpl-json { font-family: monospace; font-size: 12px; }
.tpl-slot-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.tpl-slot-head label { margin-bottom: 0; }
.form-group .tpl-slot-head select.tpl-copy-from { width: auto; max-width: 60%; min-width: 0; padding: 5px 8px; font-size: 12px; }
/* On/off switch (SincA Tools → Marketplace column) */
.mp-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.mp-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.mp-switch-track {
  position: relative; width: 34px; height: 18px; border-radius: 9px; flex-shrink: 0;
  background: var(--border); transition: background 0.15s;
}
.mp-switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
}
.mp-switch input:checked + .mp-switch-track { background: #10b981; }
.mp-switch input:checked + .mp-switch-track .mp-switch-thumb { transform: translateX(16px); }
.mp-switch input:focus-visible + .mp-switch-track { outline: 2px solid var(--blue); outline-offset: 2px; }
.mp-switch input:disabled + .mp-switch-track { opacity: 0.5; cursor: not-allowed; }
.mp-switch-label { font-size: 12px; color: var(--text2); min-width: 44px; }
.mp-switch-muted { opacity: 0.55; }

.tpl-hint { font-size: 12px; color: var(--text2); margin: 4px 0 10px; }
/* Template preview picture: cropped from the top, like the app's Marketplace card */
.tpl-image { display: flex; gap: 14px; align-items: flex-start; }
.tpl-image-thumb {
  width: 120px; height: 90px; flex-shrink: 0; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text3);
}
.tpl-image-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.tpl-image-actions { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tpl-image-actions .tpl-hint { margin: 0; }
.tpl-note {
  font-size: 12px; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-left: 3px solid var(--blue); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px;
}
.btn-sm {
  padding: 10px 18px; border: none; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #2563eb; }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #16a34a; }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: #dc2626; }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--text2);
}
.btn-outline:hover { background: var(--surface2); color: var(--text); }

/* Toggle switch */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle {
  position: relative; width: 44px; height: 24px; background: var(--surface2);
  border-radius: 12px; cursor: pointer; transition: background 0.2s;
}
.toggle.on { background: var(--green); }
.toggle::after {
  content: ''; position: absolute; width: 18px; height: 18px; background: white;
  border-radius: 50%; top: 3px; left: 3px; transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(20px); }
.toggle-label { font-size: 13px; color: var(--text2); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 14px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  z-index: 2000;
  transform: translateY(100px); opacity: 0;
  transition: all 0.3s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: #166534; color: #bbf7d0; border: 1px solid #22c55e40; }
.toast-error { background: #7f1d1d; color: #fecaca; border: 1px solid #ef444440; }
.toast-warning { background: #78350f; color: #fde68a; border: 1px solid #f59e0b40; }
/* Neither good news nor bad — "this needs something from you before it can
   happen". The base .toast carries no background of its own, so a type without
   a rule here renders as unstyled text on the page. */
.toast-info { background: #1e3a5f; color: #bfdbfe; border: 1px solid #3b82f640; }

/* Loading */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px; color: var(--text2);
}
.spinner {
  width: 24px; height: 24px; border: 3px solid var(--border);
  border-top-color: var(--blue); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Menu checkbox grid */
.menu-group { margin-bottom: 12px; }
.menu-group:last-child { margin-bottom: 0; }
.menu-group-header {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; margin-bottom: 6px;
  background: var(--surface); user-select: none;
}
.menu-group-header:hover { background: var(--surface2); }
.menu-group-header .group-toggle {
  width: 16px; height: 16px; border: 2px solid var(--text3); border-radius: 4px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: all 0.15s; font-size: 10px; color: transparent;
}
.menu-group-header .group-toggle.checked { background: var(--blue); border-color: var(--blue); color: #fff; }
.menu-group-header .group-toggle.partial { background: var(--surface2); border-color: var(--blue); color: var(--blue); }
.menu-group-header .group-name { font-size: 12px; font-weight: 600; color: var(--text); flex: 1; }
.menu-group-header .group-count { font-size: 11px; color: var(--text3); }
.menu-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding-left: 4px; }
.menu-item {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  border-radius: 4px; cursor: pointer; user-select: none;
}
.menu-item:hover { background: var(--surface); }
.menu-item input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--blue); cursor: pointer; flex-shrink: 0;
}
.menu-item label { font-size: 11px; color: var(--text2); cursor: pointer; line-height: 1.3; }
.menu-item input:checked + label { color: var(--text); }

/* Default Integrations: one row per integration with its mode */
.int-mode-list { max-height: 55vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px 10px 8px; }
.int-mode-group { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; margin: 10px 0 4px; }
.int-mode-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 13px; color: var(--text); }
.form-group .int-mode-row select { width: 190px; padding: 6px 8px; }

/* Manage Integrations: name, key, group, remove */
.int-manage-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 8px; align-items: center; padding: 4px 0; }
.int-manage-row code { font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-group .int-manage-row input, .form-group .int-manage-row select { padding: 6px 8px; }
.int-manage-add { margin-top: 8px; }
@media (max-width: 640px) { .int-manage-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* Add-on modal: details on the left, what it unlocks on the right */
.addon-modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 900px) { .addon-modal-grid { grid-template-columns: minmax(0, 1fr); gap: 0; } }

/* Assignee chips — picking who a task goes to.
   flex-shrink:0 and nowrap are what keep a chip a chip: as flex items in a wrapping row
   they would otherwise shrink to fit and break a name like "SincA Admin portal" across
   two lines. The checkbox stays in the DOM, only visually replaced by the chip's own
   checked state, so it is still focusable and still what querySelectorAll reads. */
.assignee-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.assignee-chip {
  position: relative;
  display: inline-flex; align-items: center;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--surface); color: var(--text2);
  font-size: 13px; font-weight: 500; line-height: 1.2;
  white-space: nowrap; flex-shrink: 0;
  cursor: pointer; user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.assignee-chip:hover { border-color: var(--text3); color: var(--text); }
/* Hidden, not removed: the fill below is the only thing that says "selected", but the
   checkbox is still what the label toggles, what :has() reads and what submitTask()
   collects. display:none would drop it out of the tab order, so it is clipped instead
   and the chip's own focus ring stands in for it. */
.assignee-chip input[type="checkbox"] {
  position: absolute; width: 1px; height: 1px;
  opacity: 0; margin: 0; pointer-events: none;
}
.assignee-chip:has(input:checked) {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
/* Keyboard focus has to stay visible once the chip itself carries the checked state. */
.assignee-chip:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Customer feedback dialog — tabs, star picker, number picks and the pool. */
.fb-tabs { padding: 0; margin: -4px 0 0; }
.fb-stars { display: flex; align-items: center; gap: 2px; }
.fb-star {
  background: none; border: none; padding: 0 2px; cursor: pointer;
  font-size: 28px; line-height: 1; color: var(--surface2);
  transition: color 0.1s, transform 0.1s;
}
.fb-star:hover { transform: scale(1.12); }
.fb-star.on { color: #f5b301; }
.fb-star:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
.fb-star-word { margin-left: 10px; font-size: 13px; color: var(--text2); }
.fb-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fb-picks:empty { display: none; }
.fb-pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left;
}
.fb-pick:hover { border-color: var(--text3); }
.fb-pick.active { border-color: var(--green); background: rgba(34, 197, 94, 0.12); }
.fb-pick-num { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.fb-pick-why { font-size: 11px; color: var(--text2); }
.fb-num-list { display: flex; flex-direction: column; gap: 6px; }
.fb-num {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
}
.fb-num .btn-sm { text-decoration: none; }
.fb-danger {
  margin-top: 18px; padding: 12px; border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px; background: rgba(239, 68, 68, 0.06);
}

/* Mobile header */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
}
.mobile-header h1 { font-size: 20px; font-weight: 700; }
.mobile-header h1 span { color: var(--blue); }
.hamburger {
  background: none; border: none; color: var(--text); cursor: pointer;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
}
.hamburger:hover { background: var(--surface2); }
.hamburger svg { width: 22px; height: 22px; }
.sidebar-overlay {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); z-index: 998;
}
.sidebar-overlay.open { display: block; }

/* Responsive table scroll */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Bottom Navigation (Mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 900;
  justify-content: space-around;
  align-items: center;
  padding: 4px 0;
  padding-bottom: env(safe-area-inset-bottom, 4px);
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--text3); font-size: 10px;
  padding: 6px 4px; border-radius: 8px; min-width: 56px;
  transition: color 0.15s;
}
.bottom-nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.bottom-nav-item span { line-height: 1.2; }
.bottom-nav-item:hover,
.bottom-nav-item.active { color: var(--blue); }

/* More Menu */
.more-menu-overlay {
  display: none; position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 950;
}
.more-menu-overlay.open { display: block; }
.more-menu {
  display: none; position: fixed;
  bottom: 60px; right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  /* Two columns: the list outgrew one — a single column taller than the phone
     screen cut its top rows off with no way to reach them. */
  grid-template-columns: 1fr 1fr;
  column-gap: 4px;
  width: min(430px, calc(100vw - 16px));
  /* And a height cap with its own scrolling as the escape hatch, so however
     many pages a role gains, every row stays reachable. */
  max-height: calc(100vh - 140px);
  max-height: calc(100dvh - 140px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 960;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.more-menu.open { display: grid; }
.more-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; color: var(--text2); text-decoration: none;
  font-size: 13px; border-radius: 8px; transition: background 0.15s;
}
.more-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.more-menu-item:hover { background: var(--surface2); color: var(--text); }
.more-menu-item.active { color: var(--blue); }
.more-menu-signout { color: var(--red); }
.more-menu-signout:hover { background: #ef444420; color: var(--red); }
/* Spans both columns — a one-column divider reads as a broken row. */
.more-menu-divider { height: 1px; background: var(--border); margin: 4px 0; grid-column: 1 / -1; }

/* Central Dashboard access groups */
.access-groups { display: grid; gap: 16px; }
.access-groups-empty {
  padding: 32px; text-align: center; color: var(--text3);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.access-group { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.access-group-header {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); background: #0f1b31;
}
.access-group-eyebrow {
  display: block; margin-bottom: 4px; color: var(--blue); font-size: 10px;
  font-weight: 700; letter-spacing: 0.7px; text-transform: uppercase;
}
.access-group-header h3, .access-account-card h4 { font-size: 14px; font-weight: 600; }
.access-group-header p, .access-account-card p { margin-top: 4px; color: var(--text3); font-size: 11px; }
.access-group-header p span, .access-account-card p span { color: var(--text2); }
.access-group-header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.access-group-count { color: var(--text2); font-size: 12px; }
.access-account-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px;
  padding: 16px;
}
.access-account-card {
  padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
}
.access-account-card-header { display: flex; justify-content: space-between; gap: 10px; }
.access-account-badges { display: flex; align-items: flex-start; justify-content: flex-end; gap: 5px; flex-wrap: wrap; }
.access-level-badge { background: #3b82f620; border: 1px solid #3b82f640; color: var(--blue); }
.access-account-meta {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border);
}
.access-account-meta div { min-width: 0; }
.access-account-meta dt {
  margin-bottom: 3px; color: var(--text3); font-size: 10px; font-weight: 600;
  letter-spacing: 0.4px; text-transform: uppercase;
}
.access-account-meta dd { color: var(--text2); font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.access-account-controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px;
  margin-top: 14px;
}
.access-account-controls label {
  display: block; color: var(--text3); font-size: 10px; font-weight: 600;
  letter-spacing: 0.4px; text-transform: uppercase;
}
.access-account-controls input, .access-account-controls select {
  width: 100%; margin-top: 4px; padding: 7px 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 11px;
}
.access-account-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; }
.access-account-actions .btn-sm { padding: 6px 10px; font-size: 11px; }
.access-groups-footer .pagination { padding: 12px 0 0; border-top: 0; }

/* Responsive */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .mobile-header {
    display: flex;
    padding: 10px 16px;
    width: 100%;
  }
  .mobile-header .hamburger { display: none; }
  .sidebar { display: none !important; }
  .sidebar-overlay { display: none !important; }
  .bottom-nav { display: flex; }
  .main {
    margin-left: 0; padding: 16px;
    padding-bottom: 72px;
  }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 12px; }
  .stat-card .stat-value { font-size: 22px; }
  .detail-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
  .search-box { min-width: 100%; }
  .filter-select { min-width: 100%; }

  /* Customers page: keep just the search box inline; everything else moves into a popup */
  .filters-bar-customers { flex-direction: row; flex-wrap: nowrap; }
  .filters-bar-customers .search-box { min-width: 0; }
  .filters-toggle-btn { display: flex; flex-shrink: 0; }
  .filters-popup-overlay {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 965; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .filters-popup-overlay.open { opacity: 1; pointer-events: auto; }
  .filters-popup {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    background: var(--surface); border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0; padding: 18px; z-index: 970;
    max-height: 80vh; overflow-y: auto;
    flex-direction: column; gap: 12px;
    transform: translateY(100%); transition: transform 0.25s ease;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.4);
  }
  .filters-popup.open { transform: translateY(0); }
  .filters-popup-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 4px;
  }
  .filters-popup-header h3 { font-size: 16px; color: var(--text); }
  .filters-popup-actions { display: flex; gap: 8px; margin-top: 4px; }
  .filters-popup-actions button { flex: 1; }
  .page-header { margin-bottom: 16px; }
  .page-header h2 { font-size: 18px; }
  .access-group-header { align-items: flex-start; flex-direction: column; }
  .access-group-header-actions { width: 100%; justify-content: space-between; }
  .access-account-grid { grid-template-columns: 1fr; padding: 12px; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 700px; }
  /* ── Every dialog is a bottom drawer on a phone ──
     The overlay is sized to the VISIBLE viewport, not to 100vh: on a phone
     100vh includes the strip under the browser's toolbar, and once the
     keyboard is up the visible area is half that. sheets.js keeps --sheet-vh
     and --sheet-top in step with window.visualViewport, so the drawer always
     sits inside what the person can actually see and its buttons are never
     under the keyboard. Without the script the vars are unset and the
     fallbacks give the old behaviour. */
  .modal-overlay {
    align-items: flex-end;
    justify-content: stretch;
    top: var(--sheet-top, 0px);
    bottom: auto;
    height: var(--sheet-vh, 100vh);
  }
  .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: calc(var(--sheet-vh, 100vh) - 20px);
    border-radius: 16px 16px 0 0 !important;
    margin: 0;
    /* Header and footer stay put; only the body scrolls. One scroll container
       instead of the drawer AND its body each scrolling, which is what left
       Save buttons stranded below the fold. */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: sheet-up 0.22s ease-out;
  }
  .modal-header {
    flex: 0 0 auto;
    position: relative;
    padding: 18px 18px 12px;
    background: var(--surface);
    z-index: 2;
  }
  /* The grab handle every phone drawer has, so it reads as one. */
  .modal-header::before {
    content: '';
    position: absolute;
    top: 6px; left: 50%;
    width: 40px; height: 4px;
    border-radius: 2px;
    background: var(--border);
    transform: translateX(-50%);
  }
  .modal-header h3 { font-size: 15px; }
  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px 18px;
    overflow-y: auto !important;
    max-height: none !important;   /* beats the inline 70vh/74vh caps */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .modal-footer {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
  .modal-footer .btn-sm { flex: 1; }
  /* The page behind must not scroll while a drawer is up, or a swipe inside
     the drawer walks the page instead and the drawer ends up mid-screen. */
  body.sheet-open { overflow: hidden; touch-action: none; }
  body.sheet-open .modal-overlay { touch-action: auto; }
  @keyframes sheet-up {
    from { transform: translateY(24px); opacity: 0.6; }
    to   { transform: none; opacity: 1; }
  }
  .modal-section { margin-bottom: 16px; }
  .modal-section h4 { font-size: 12px; margin-bottom: 8px; }
  .drawer { width: 100vw; }
  .drawer-header { padding: 16px 18px; }
  .drawer-header h3 { font-size: 15px; }
  .drawer-tabs { padding: 0 8px; }
  .drawer-tab { padding: 10px 10px; font-size: 12px; }
  .drawer-body { padding: 16px 18px; }
  .form-row { flex-direction: column; gap: 8px; align-items: stretch; }
  .form-row .btn-sm { width: 100%; }
  .detail-item span { font-size: 13px; word-break: break-all; }
  .quick-btns { gap: 4px; }
  .btn-quick { padding: 3px 8px; font-size: 10px; }
  .menu-items { grid-template-columns: repeat(2, 1fr); }
  .pagination { flex-direction: column; gap: 10px; text-align: center; }
  .toast { bottom: 72px; }
}
.ss-toggle { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text); cursor:pointer; user-select:none; }
.ss-toggle input[type="checkbox"] { width:16px; height:16px; accent-color:#3b82f6; cursor:pointer; }
.quick-btns { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-top:8px; }
.btn-quick { background:var(--bg); border:1px solid var(--border); color:var(--text2); padding:4px 10px; border-radius:6px; font-size:11px; cursor:pointer; transition:all .2s; }
.btn-quick:hover { background:#3b82f6; color:#fff; border-color:#3b82f6; }

/* ── Pipeline boards ──────────────────────────────────────────────────────
   One column per stage, with the thing being worked as a card. Shared by the
   Leads pipeline and the Bugs pipeline: two boards that look different would
   suggest they behave differently, and they do not.

   The `.ld-*` names are the originals, kept as grouped selectors so leads.js
   goes on working untouched; new screens use the neutral `.board-*` names.

   The board scrolls sideways rather than the page, so a team with ten stages
   does not make every other screen scrollable. */
.ld-board,
.board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  align-items: flex-start;
  /* Belt to .main's min-width:0 braces: whatever the ancestors do, the board
     never renders wider than the space it is given. */
  max-width: 100%;
}
.ld-col,
.board-col {
  flex: 0 0 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 62vh;
}
.ld-col-head,
.board-col-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Leads: the colour the sales team chose for the status in SincA, so the board
   reads the same as their desktop. Bugs: the colour of the stage's badge, so a
   card on the board and a row in the list say the same thing. */
.ld-col-dot,
.board-col-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.ld-col-name,
.board-col-name { font-size: 13px; font-weight: 600; flex: 1; }
.ld-col-count,
.board-col-count { font-size: 12px; color: var(--text2); }
.ld-col-body,
.board-col-body { padding: 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.ld-card,
.board-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: grab;
  font-size: 13px;
}
.ld-card:active,
.board-card:active { cursor: grabbing; }
.board-card[draggable="false"] { cursor: pointer; }
.board-card[draggable="false"]:active { cursor: pointer; }
.ld-card:hover,
.board-card:hover { border-color: var(--text3); }
.ld-card-sub,
.board-card-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }
.ld-card-due,
.board-card-due { font-size: 11px; margin-top: 4px; }
.ld-card.dragging,
.board-card.dragging { opacity: .45; }
/* Only the column being hovered lights up, so the drop target is unambiguous. */
.ld-col.drop-target,
.board-col.drop-target { border-color: var(--blue, #3b82f6); }
.ld-col.drop-target .ld-col-body,
.board-col.drop-target .board-col-body { background: rgba(59, 130, 246, .08); }
.ld-col-empty,
.board-col-empty { font-size: 12px; color: var(--text2); opacity: .7; text-align: center; padding: 10px 0; }

/* ── Pipeline column picker ───────────────────────────────────────────────
   A team with a dozen statuses does not want a dozen columns; REJETED alone
   can hold hundreds of dead leads. Which columns to show is a per-person
   choice, saved against the login rather than the browser so it survives a
   sign-out and follows the user to another machine. */
.ld-cols-wrap { position: relative; }
.ld-cols-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}
.ld-cols-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.ld-cols-panel label:hover { background: var(--surface2); }
.ld-cols-panel .ld-cols-actions {
  display: flex;
  gap: 6px;
  padding: 6px 4px 2px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
}
.ld-cols-count { font-size: 11px; color: var(--text2); margin-left: auto; }

/* ── Quick due-time buttons on the task dialog ────────────────────────────
   A row of the answers people actually give. Wraps rather than scrolls, so
   nothing is hidden on a narrow dialog. */
.quick-due { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.quick-due .btn-quick { padding: 4px 10px; font-size: 12px; }
/* The one that was pressed stays marked, so the datetime box below is never a
   value with no explanation. */
.quick-due .btn-quick.chosen {
  background: var(--blue, #3b82f6);
  border-color: var(--blue, #3b82f6);
  color: #fff;
}

/* ── The campaign picker ──────────────────────────────────────────────────
   A menu rather than a <select>. A desk that opens "Daily leads <today>" every
   morning fills a dropdown with a month of near-identical rows; here a run of
   them is one row that opens sideways, so a date is a hover away instead of
   forty rows down.

   The <select> it replaces is still in the markup, hidden: it holds the value
   the page reads and its change event is what reloads the list. */
.ld-camp-wrap { position: relative; display: inline-block; }
.ld-camp-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.ld-camp-trigger { display: inline-flex; align-items: center; gap: 10px; text-align: left; }
.ld-camp-trigger .ld-camp-caret { margin-left: auto; font-size: 10px; color: var(--text3); }
.ld-camp-wrap.open .ld-camp-trigger { border-color: var(--blue); }

.ld-camp-menu, .ld-camp-sub {
  z-index: 60;
  min-width: 210px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .45);
}
.ld-camp-menu { position: absolute; top: calc(100% + 6px); left: 0; }

/* Fixed, not absolute: the menu above scrolls once there are enough rows, and an
   absolutely-positioned flyout inside a scrolling box is clipped by it. Fixed
   escapes that — at the price of coordinates, which ldPlaceCampaignSub sets. */
.ld-camp-group { position: relative; }
.ld-camp-sub { display: none; position: fixed; z-index: 61; min-width: 160px; }
.ld-camp-group.open > .ld-camp-sub { display: block; }

.ld-camp-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 7px 9px;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text); font-size: 13px; text-align: left;
  white-space: nowrap; cursor: pointer;
}
.ld-camp-item:hover, .ld-camp-item:focus { background: var(--surface2); outline: none; }
.ld-camp-item.chosen { background: var(--blue); color: #fff; }
/* The group holding what is chosen says so, or a selection made two levels down
   leaves the menu looking as though nothing is selected at all. */
.ld-camp-parent.holds-chosen { color: var(--blue); }
.ld-camp-count { margin-left: auto; font-size: 11px; color: var(--text2); }
.ld-camp-item.chosen .ld-camp-count { color: rgba(255, 255, 255, .8); }
.ld-camp-parent.holds-chosen .ld-camp-count { color: var(--blue); }
.ld-camp-arrow { font-size: 13px; color: var(--text3); display: inline-block; transition: transform .12s ease; }
/* Points at the flyout while it is open — the one cue that survives both the
   sideways layout and the indented one a phone gets. */
.ld-camp-group.open .ld-camp-arrow { transform: rotate(90deg); }
.ld-camp-parent .ld-camp-count + .ld-camp-arrow { margin-left: 0; }
.ld-camp-empty { padding: 8px 9px; font-size: 12px; color: var(--text2); }

@media (max-width: 768px) {
  /* Nowhere to fly to on a phone, so a group opens downward and indented
     instead. !important beats the coordinates ldPlaceCampaignSub leaves behind
     on a window that was wide a moment ago. */
  .ld-camp-wrap { width: 100%; }
  .ld-camp-menu { width: 100%; min-width: 0; }
  .ld-camp-sub {
    position: static !important;
    top: auto !important; left: auto !important;
    max-height: 240px;
    margin: 2px 0 4px 12px;
    padding: 2px 0 2px 6px;
    border: 0; border-left: 2px solid var(--surface2); border-radius: 0;
    box-shadow: none;
  }
}

/* ── Dragging a lead status into place ────────────────────────────────────
   The order of these rows is the order of the pipeline board's columns, so
   they are dragged rather than numbered. The grip is the affordance; the whole
   row is the drag target, which is the easier thing to aim at. */
.ll-row .ll-grip {
  cursor: grab;
  color: var(--text3);
  font-size: 15px;
  text-align: center;
  user-select: none;
}
.ll-row.ll-dragging { opacity: .45; }
.ll-row.ll-dragging .ll-grip { cursor: grabbing; }

/* ── The pipeline board, filling the window ──────────────────────────────
   The columns stopped at 62vh and left a screen's worth of empty page beneath
   them, so every list scrolled inside a box half the height it could have had.
   With this the board takes the rest of the window instead.

   Only the leads board: `.board` on the bugs page keeps its 62vh, because its
   height is not measured and a column with no ceiling would simply run off the
   bottom. The class is put on by ldFitBoard(), which is what supplies the
   height — the board's top moves as the notice bar and the filters come and go,
   so it cannot be a constant in here. */
.ld-board.ld-board-fit { align-items: stretch; }
.ld-board.ld-board-fit .ld-col { max-height: none; }
/* min-height:0 is what lets the body scroll rather than stretching its column
   past the bottom of the board — a flex child will not shrink below its content
   without it. */
.ld-board.ld-board-fit .ld-col-body { flex: 1 1 auto; min-height: 0; }

/* ── Permissions & Rules ──────────────────────────────────────────────── */
.permission-page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
}
.permission-eyebrow {
  display: block; margin-bottom: 5px; color: var(--blue); font-size: 10px;
  font-weight: 700; letter-spacing: .11em; text-transform: uppercase;
}
.permission-workspace {
  display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 16px;
  align-items: start;
}
.permission-role-panel,
.permission-editor-panel {
  border: 1px solid var(--border); border-radius: 12px; background: var(--card);
}
.permission-role-panel { position: sticky; top: 16px; padding: 10px; }
.permission-role-heading {
  padding: 6px 9px 10px; color: var(--text3); font-size: 10px;
  font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
}
.permission-role-list { display: flex; flex-direction: column; gap: 4px; }
.permission-role-button {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  min-height: 42px; padding: 9px 10px; border: 1px solid transparent;
  border-radius: 8px; background: transparent; color: var(--text2);
  font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.permission-role-button:hover { background: var(--bg); color: var(--text1); }
.permission-role-button.active {
  border-color: rgba(59, 130, 246, .35); background: rgba(59, 130, 246, .12);
  color: var(--blue); font-weight: 600;
}
.permission-role-count {
  min-width: 24px; padding: 2px 6px; border-radius: 999px; background: var(--bg);
  color: var(--text3); font-size: 10px; text-align: center;
}
.permission-role-button.active .permission-role-count { background: rgba(59,130,246,.18); color: var(--blue); }
.permission-editor-panel { min-width: 0; overflow: hidden; }
.permission-editor-toolbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.permission-editor-toolbar strong { display: block; color: var(--text1); font-size: 15px; }
.permission-editor-toolbar > div span { display: block; margin-top: 2px; color: var(--text3); font-size: 11px; }
.permission-search {
  display: flex; align-items: center; gap: 7px; width: min(320px, 100%);
  padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  color: var(--text3);
}
.permission-search input {
  width: 100%; height: 36px; padding: 0; border: 0; outline: 0;
  background: transparent; color: var(--text1); font-size: 12px;
}
.permission-editor-content { padding: 16px; }
.permission-summary {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 15px; padding: 11px 13px; border: 1px solid rgba(59,130,246,.22);
  border-radius: 9px; background: rgba(59,130,246,.07); font-size: 12px;
}
.permission-section + .permission-section { margin-top: 22px; }
.permission-section-header { margin-bottom: 8px; }
.permission-section-header strong { display: block; color: var(--text1); font-size: 13px; }
.permission-section-header span { display: block; margin-top: 2px; color: var(--text3); font-size: 11px; }
.permission-row-list { display: flex; flex-direction: column; gap: 6px; }
.permission-rule-row {
  display: grid; grid-template-columns: minmax(170px, .8fr) minmax(230px, 1.35fr) auto;
  gap: 16px; align-items: center; min-height: 58px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg);
}
.permission-rule-row:hover { border-color: rgba(59,130,246,.35); }
.permission-rule-resource strong,
.permission-rule-action strong { display: block; color: var(--text1); font-size: 12px; }
.permission-rule-resource code {
  display: inline-block; margin-top: 3px; padding: 1px 5px; border-radius: 4px;
  background: var(--card); color: var(--text3); font-size: 9px;
}
.permission-rule-action span { display: block; margin-top: 3px; color: var(--text3); font-size: 10px; line-height: 1.35; }
.permission-toggle-wrap { display: flex; align-items: center; gap: 8px; min-width: 92px; justify-content: flex-end; }
.permission-toggle-status { width: 42px; color: var(--text3); font-size: 10px; text-align: right; }
.permission-toggle { position: relative; display: inline-flex; width: 38px; height: 22px; flex: 0 0 auto; }
.permission-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.permission-toggle-track {
  position: absolute; inset: 0; border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); cursor: pointer; transition: .16s ease;
}
.permission-toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--text3); transition: .16s ease;
}
.permission-toggle input:checked + .permission-toggle-track { border-color: var(--blue); background: var(--blue); }
.permission-toggle input:checked + .permission-toggle-track::after { left: 19px; background: #fff; }
.permission-toggle input:disabled + .permission-toggle-track { opacity: .55; cursor: not-allowed; }
.permission-savebar {
  position: sticky; bottom: 0; display: flex; justify-content: space-between;
  align-items: center; gap: 12px; margin: 20px -16px -16px; padding: 12px 16px;
  border-top: 1px solid var(--border); background: var(--card);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(8px);
}
.permission-savebar span { color: var(--text3); font-size: 11px; }
.permission-rule-modal { width: min(620px, calc(100vw - 24px)); }
.permission-modal-intro { margin: 0 0 15px; color: var(--text2); font-size: 12px; line-height: 1.5; }

@media (max-width: 900px) {
  .permission-workspace { grid-template-columns: 1fr; }
  .permission-role-panel { position: static; overflow-x: auto; }
  .permission-role-heading { display: none; }
  .permission-role-list { flex-direction: row; width: max-content; }
  .permission-role-button { width: auto; min-width: 120px; }
}
@media (max-width: 640px) {
  .permission-editor-toolbar { align-items: stretch; flex-direction: column; }
  .permission-search { width: 100%; }
  .permission-rule-row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .permission-rule-action { grid-column: 1 / -1; grid-row: 2; }
  .permission-toggle-wrap { grid-column: 2; grid-row: 1; }
  .permission-savebar { align-items: stretch; flex-direction: column; }
  .permission-savebar button { width: 100%; min-height: 44px; }
}

/* AI Assistant + Knowledge Base */
.ai-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.ai-hint { font-size: 12px; color: var(--text2); margin: 0 0 12px; line-height: 1.5; }
.ai-textarea { width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px; outline: none; resize: vertical; font-family: inherit; box-sizing: border-box; }
.ai-textarea:focus { border-color: var(--blue); }
.ai-mono { font-family: Consolas, 'Cascadia Mono', monospace; font-size: 12.5px; }
.ai-try-log { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.ai-bubble { max-width: 80%; padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ai-bubble.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.ai-bubble.bot { align-self: flex-start; background: var(--surface2); border-bottom-left-radius: 4px; }
.ai-bubble.handoff { align-self: flex-start; background: #3a2f12; color: #e0a030; }
.ai-meta { font-size: 11px; color: var(--text3); align-self: flex-start; margin-top: -4px; }
.ai-sum { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; }
.ai-sum h4 { margin: 0 0 6px; font-size: 14px; }
.ai-sum .ai-sum-text { font-size: 13px; line-height: 1.55; margin: 0 0 8px; }
.ai-sum dl { display: grid; grid-template-columns: 110px 1fr; gap: 3px 10px; font-size: 12px; margin: 0; }
.ai-sum dt { color: var(--text3); }
.ai-sum dd { margin: 0; color: var(--text2); }
.ai-pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--surface2); color: var(--text2); }
.ai-pill.green { background: rgba(34,197,94,.15); color: var(--green); }
.ai-pill.red { background: rgba(239,68,68,.15); color: var(--red); }
.ai-pill.orange { background: rgba(245,158,11,.15); color: var(--orange); }
.ai-pill.blue { background: rgba(59,130,246,.15); color: var(--blue); }

/* ─── Dashboard: ticket flow charts (public/js/ticketFlow.js) ─── */
.tf-panel { margin-top: 8px; }
.tf-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 8px 0 12px; }
.tf-title { font-size: 15px; margin-bottom: 4px; }
.tf-sub { color: var(--text2); font-size: 12px; max-width: 640px; }
.tf-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tf-controls .filter-select { padding: 8px 10px; font-size: 13px; }
.tf-controls .btn-sm { padding: 8px 14px; }
.tf-note { font-size: 12px; color: var(--text2); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--orange); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.tf-stats { margin-bottom: 12px; }
.stat-card .stat-value.tf-live { color: #9085e9; }
.tf-insight { font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; line-height: 1.5; }
.tf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.tf-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 10px; min-width: 0; }
.tf-wide { grid-column: 1 / -1; }
.tf-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.tf-card-head h4 { font-size: 13px; font-weight: 600; }
.tf-muted { color: var(--text2); font-weight: 400; }
.tf-legend { color: var(--text2); font-size: 11px; display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tf-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.tf-legend i:first-child { margin-left: 0; }
.tf-c-new { background: #3987e5; }
.tf-c-closed { background: #d95926; }
.tf-c-live { background: #9085e9; }
.tf-legend-shade { background: rgba(217, 89, 38, 0.25); }
.tf-chart { width: 100%; }
.tf-top { margin-top: 14px; font-size: 12px; }
.tf-top-title { color: var(--text2); font-weight: 600; margin-bottom: 6px; }
.tf-top-row { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; padding: 4px 0; color: var(--text); }
.tf-top-row b { text-align: right; }
.tf-top-bar { height: 8px; background: rgba(148,163,184,0.10); border-radius: 4px; overflow: hidden; }
.tf-top-bar i { display: block; height: 100%; background: #3987e5; border-radius: 0 4px 4px 0; }
.tf-chart svg { display: block; overflow: visible; }
.tf-details { margin-top: 8px; font-size: 12px; color: var(--text2); }
.tf-details summary { cursor: pointer; padding: 4px 0; }
.tf-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 12px; }
.tf-table th, .tf-table td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--border); color: var(--text); }
.tf-table th { color: var(--text2); font-weight: 500; }
.tf-table th:first-child, .tf-table td:first-child { text-align: left; }
.tf-table td.tf-up { color: var(--orange); font-weight: 600; }
.tf-tip { position: fixed; z-index: 9999; pointer-events: none; display: none; background: #0b1222; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--text); box-shadow: 0 6px 20px rgba(0,0,0,0.4); line-height: 1.6; max-width: 260px; }
.tf-swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.tf-tip-muted { color: var(--text2); }
.tf-tip-warn { color: var(--orange); }
@media (max-width: 900px) { .tf-grid { grid-template-columns: minmax(0, 1fr); } }

/* ─── Staff Structure (public/js/orgChart.js) ─── */
.oc-tabs { padding: 0; margin-bottom: 20px; }
.oc-panel { display: none; }
.oc-panel.active { display: block; }

.oc-tree { display: flex; flex-direction: column; align-items: center; }
.oc-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.oc-stem { width: 2px; height: 20px; background: var(--border); }
.oc-node {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  min-width: 180px; max-width: 280px; padding: 10px 14px;
  background: var(--surface); color: var(--text); font: inherit;
  border: 1px solid var(--border); border-top: 3px solid var(--oc-c, var(--blue)); border-radius: 10px;
  cursor: pointer; transition: background 0.15s, transform 0.15s;
}
.oc-node:hover { background: var(--surface2); transform: translateY(-1px); }
.oc-node:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.oc-node-title { font-size: 12px; color: var(--text2); font-weight: 500; }
.oc-node-name { font-size: 15px; font-weight: 600; }
.oc-node-sm { min-width: 0; max-width: none; width: 100%; padding: 8px 12px; border-top-width: 1px; border-left: 3px solid var(--oc-c, var(--blue)); }
.oc-node-sm .oc-node-title { font-size: 13px; color: var(--text); }
.oc-node-sm .oc-node-name { font-size: 12px; font-weight: 400; color: var(--text2); }

.oc-depts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; width: 100%; max-width: 1100px;
  border-top: 2px solid var(--border); padding-top: 20px; }
.oc-dept { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.oc-dept > .oc-node { max-width: none; width: 100%; }
.oc-dept-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; color: var(--oc-c); }
.oc-children { display: flex; flex-direction: column; gap: 8px; margin-left: 14px; padding-left: 14px; border-left: 2px solid var(--border); }
.oc-team { display: flex; flex-direction: column; gap: 8px; }
.oc-team + .oc-team { margin-top: 6px; }
.oc-team-label { font-size: 12px; color: var(--text2); font-weight: 600; }
.oc-rule { margin: 24px auto 0; max-width: 1100px; font-size: 13px; line-height: 1.6; color: var(--text2);
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: 8px; padding: 10px 14px; }
.oc-rule strong { color: var(--text); }

.oc-section { margin-bottom: 28px; }
.oc-section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; padding-left: 10px; border-left: 3px solid var(--oc-c); }
.oc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.oc-card { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--oc-c); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.oc-card header { margin-bottom: 10px; }
.oc-card h4 { font-size: 14px; font-weight: 600; line-height: 1.35; }
.oc-count { font-size: 11px; font-weight: 500; color: var(--text2); background: var(--surface2); border-radius: 10px; padding: 1px 8px; margin-left: 4px; white-space: nowrap; }
.oc-people { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.oc-chip { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 14px; padding: 2px 10px; }
.oc-reports { font-size: 12px; color: var(--text2); margin-top: 8px; }
.oc-reports strong { color: var(--text); font-weight: 500; }
.oc-card ul, .oc-plain { padding-left: 18px; font-size: 13px; line-height: 1.6; color: var(--text); }
.oc-card li + li { margin-top: 2px; }
.oc-note { margin-top: 10px; font-size: 12px; line-height: 1.5; color: var(--orange); background: #f59e0b14; border-radius: 6px; padding: 6px 10px; }
.oc-flash { animation: oc-flash 1.6s ease-out; }
@keyframes oc-flash { 0%, 30% { box-shadow: 0 0 0 3px var(--oc-c); } 100% { box-shadow: 0 0 0 0 transparent; } }

.oc-lead { font-size: 13px; color: var(--text2); margin-bottom: 16px; }
.oc-h { font-size: 14px; font-weight: 600; margin: 22px 0 10px; }
.oc-panel > .oc-h:first-child { margin-top: 0; }
.oc-flow { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.oc-flow li { display: flex; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.oc-flow-n { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%; background: #3b82f620; color: var(--blue); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.oc-flow strong { font-size: 13px; }
.oc-flow p { font-size: 12px; color: var(--text2); line-height: 1.5; margin-top: 2px; }
.oc-stat-sub { font-size: 11px; color: var(--text2); margin-top: 4px; line-height: 1.4; }
.oc-warn { margin: 14px 0 10px; font-size: 13px; line-height: 1.5; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--orange); border-radius: 8px; padding: 10px 14px; }
.oc-warn strong { color: var(--orange); }
.oc-rules { display: grid; gap: 8px; }
.oc-rules > div { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 13px; line-height: 1.5; }
.oc-rt { font-weight: 600; }
.oc-rt + .oc-rd::before { content: ' \2014 '; color: var(--text3); font-weight: 400; }
.oc-rd { color: var(--text2); }
.oc-open { list-style: none; display: grid; gap: 6px; }
.oc-open li { position: relative; padding: 8px 12px 8px 36px; font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.oc-open li::before { content: ''; position: absolute; left: 12px; top: 10px; width: 12px; height: 12px; border: 2px solid var(--text3); border-radius: 3px; }
#page-orgchart tbody tr:hover { background: transparent; cursor: default; }

@media (max-width: 900px) {
  .oc-depts { grid-template-columns: minmax(0, 1fr); border-top: none; padding-top: 0; gap: 24px; }
  .oc-flow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .oc-flow { grid-template-columns: minmax(0, 1fr); }
  .oc-cards { grid-template-columns: minmax(0, 1fr); }
  .oc-node { min-width: 0; }
  #ocSearch { flex: 1 1 100%; }
}
.oc-toolbar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 16px; }
.oc-add { padding: 7px 12px; font-size: 12px; }
.oc-edit { flex-shrink: 0; width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: transparent; color: var(--text2); cursor: pointer; font-size: 13px; line-height: 1; }
.oc-edit:hover { background: var(--surface2); color: var(--text); }
.oc-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.oc-node-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; color: var(--oc-c); }
.oc-vacant { border-style: dashed; }
.oc-vacant .oc-node-name { color: var(--orange); }
.oc-branch { display: flex; flex-direction: column; gap: 8px; }
.oc-chip-vacant { color: var(--orange); border-style: dashed; }
.oc-muted { color: var(--text2); font-size: 12px; }
.oc-empty { padding: 32px; text-align: center; color: var(--text2); }
.oc-sub { font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin: 12px 0 8px; }
.oc-value { font-weight: 700; white-space: nowrap; }
.oc-h-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 22px 0 10px; }
.oc-h-row .oc-h { margin: 0; }
.oc-panel > .oc-h-row:first-child { margin-top: 0; }
.oc-hint { font-size: 12px; color: var(--text2); margin: -4px 0 10px; }
.oc-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
.oc-inline { max-width: 340px; width: 100%; padding: 6px 8px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 12px; }
.oc-actions { white-space: nowrap; text-align: right; }
.oc-actions .oc-edit + .oc-edit { margin-left: 4px; }
.oc-short { color: var(--orange); font-weight: 600; }
.oc-form-group { margin-bottom: 12px; }
.oc-form-group input[type=color] { height: 38px; padding: 4px; }
.oc-modal-footer { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 14px 24px 20px; flex-wrap: wrap; }
.oc-modal-footer #ocModalDelete { margin-right: auto; }
.oc-modal-error { flex-basis: 100%; order: -1; color: #e56a54; font-size: 13px; }
.oc-tree-cell { display: flex; align-items: baseline; min-width: 220px; }
.oc-tree-cell .oc-swatch { flex-shrink: 0; }

/* ── Settings page ───────────────────────────────────────────────────────── */
.settings-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px; max-width: 1100px;
}
.settings-card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.settings-card-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.settings-card-head .settings-card-title { margin-bottom: 4px; }
.settings-card-sub { font-size: 12px; color: var(--text2); margin: 0 0 12px; max-width: 640px; }
.settings-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dbb-status { font-size: 13px; display: grid; gap: 4px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.dbb-status:empty { display: none; }
.dbb-running { display: flex; align-items: center; gap: 8px; color: var(--blue); }
.dbb-running .spinner { width: 14px; height: 14px; margin: 0; }
.dbb-problems { font-size: 12px; color: var(--orange); border: 1px solid rgba(245,158,11,.35); background: rgba(245,158,11,.08); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; display: grid; gap: 2px; }
.dbb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 8px; }
.dbb-col { min-width: 0; }
.dbb-col .form-group { margin-bottom: 10px; }
.dbb-sub { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; font-weight: 600; }
.dbb-check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; margin-bottom: 10px; }
.dbb-hint { font-size: 11px; color: var(--text3); }
.dbb-hint code, .dbb-server code { font-size: 11px; word-break: break-all; }
.dbb-state { font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text3); }
.dbb-server { display: grid; gap: 4px; font-size: 12px; }
.dbb-server div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.dbb-server span { color: var(--text2); }
.dbb-save-row { display: flex; justify-content: flex-end; margin-top: 14px; }
.dbb-history { display: grid; gap: 2px; font-size: 12px; }
.dbb-history-row { display: grid; grid-template-columns: 150px 130px 1fr auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.dbb-history-when, .dbb-history-who { color: var(--text2); }
#dbbFiles a.btn-sm { display: inline-block; text-decoration: none; }
#dbbFiles .btn-sm { padding: 6px 12px; font-size: 12px; }
@media (max-width: 768px) {
  .settings-card { padding: 14px; }
  .dbb-grid { grid-template-columns: 1fr; gap: 8px; }
  .dbb-history-row { grid-template-columns: 1fr; gap: 2px; }
}
