/* ============================================================
   VERGED INTERNAL — App tokens + base components
   Light-only, medium density, Qonto-style structure
   Builds on /colors_and_type.css for brand + typography
   ============================================================ */

/* App tokens (surfaces, grey scale, text, status, radii, density, shadows,
   type scale) are declared in tokens.css, generated from tokens.json.
   colors_and_type.css imports it; link that file before this one. */

/* ============================================================
   APP RESET (scoped under .app)
   ============================================================ */
.app, .app * { box-sizing: border-box; }
.app {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--app-fs-body);
  line-height: var(--app-lh);
  color: var(--app-text);
  background: var(--app-canvas);
  -webkit-font-smoothing: antialiased;
}
.app h1, .app h2, .app h3, .app h4, .app h5 {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--app-text);
}
.app h1 { font-size: var(--app-fs-3xl); line-height: var(--app-lh-tight); }
.app h2 { font-size: var(--app-fs-2xl); line-height: var(--app-lh-tight); }
.app h3 { font-size: var(--app-fs-xl); line-height: var(--app-lh-tight); }
.app h4 { font-size: var(--app-fs-lg); }
.app p { margin: 0; }
.app a { color: inherit; text-decoration: none; }
.app button { font-family: inherit; cursor: pointer; }

/* ============================================================
   APP SHELL — sidebar + topbar + main
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--app-canvas);
}
.app-sidebar {
  background: var(--app-sidebar);
  border-right: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ---------- Sidebar parts ---------- */
.sb-org {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  cursor: pointer;
  border-radius: var(--r);
  margin: 8px;
  transition: background 140ms;
}
.sb-org:hover { background: var(--app-hover); }
.sb-org-avatar {
  width: 28px; height: 28px;
  border-radius: var(--r-pill);
  background: var(--av-lavender);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--app-text);
  flex-shrink: 0;
}
.sb-org-name {
  font-weight: 500;
  font-size: var(--app-fs-md);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.sb-org-caret {
  color: var(--app-text-subtle);
  flex-shrink: 0;
}
.sb-search {
  margin: 0 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  background: var(--app-active);
  border-radius: var(--r-sm);
  color: var(--app-text-muted);
  font-size: var(--app-fs-body);
  cursor: pointer;
  transition: background 140ms;
}
.sb-search:hover { background: var(--gray-200); }
.sb-search-icon { color: var(--app-text-subtle); }
.sb-search-kbd {
  margin-left: auto;
  font-size: var(--app-fs-xs);
  color: var(--gray-600);
  font-family: var(--font-code);
}
.sb-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
  flex: 1;
}
.sb-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--app-text-muted);
  padding: 16px 12px 6px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--app-text);
  font-size: var(--app-fs-md);
  font-weight: 400;
  transition: background 140ms, color 140ms;
  position: relative;
}
.sb-item:hover { background: var(--app-hover); }
.sb-item.is-active {
  background: var(--app-active);
  font-weight: 500;
}
.sb-item svg { flex-shrink: 0; color: var(--app-text-2); }
.sb-item.is-active svg { color: var(--app-text); }
.sb-item-badge {
  margin-left: auto;
  background: var(--app-accent);
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-pill);
}
.sb-footer {
  padding: 8px;
  border-top: 1px solid var(--app-border);
}

/* ---------- Topbar ---------- */
.app-topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  background: var(--app-canvas);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-topbar h1 {
  font-size: var(--app-fs-2xl);
  font-weight: 600;
  flex: 1;
}
.app-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-mobile-menu {
  display: none;
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--app-border);
  background: var(--app-surface);
  align-items: center;
  justify-content: center;
  color: var(--app-text);
}

/* ---------- Content ---------- */
.app-content {
  padding: 8px 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 16px;
  border-radius: var(--r-sm);
  font-size: var(--app-fs-body);
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--app-text);
  transition: all 140ms;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--app-text);
  color: white;
  border-color: var(--app-text);
}
.btn-primary:hover { background: black; border-color: black; }

.btn-secondary {
  background: var(--app-surface);
  border-color: var(--app-border);
  color: var(--app-text);
}
.btn-secondary:hover { background: var(--app-hover); border-color: var(--app-border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--app-text);
}
.btn-ghost:hover { background: var(--app-active); }

.btn-danger {
  background: var(--app-danger);
  border-color: var(--app-danger);
  color: white;
}
.btn-danger:hover { background: #B81E1E; border-color: #B81E1E; }

.btn-icon {
  width: var(--btn-h);
  padding: 0;
}
.btn-sm { height: var(--btn-h-sm); padding: 0 12px; font-size: var(--app-fs-sm); }
.btn-lg { height: var(--btn-h-lg); padding: 0 20px; font-size: var(--app-fs-md); }

.btn-circle {
  width: 44px; height: 44px;
  border-radius: var(--r-pill);
  background: var(--app-text);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms, transform 140ms;
}
.btn-circle:hover { background: black; transform: scale(1.05); }

/* Close control of drawers, dialogs and popovers.
   <button class="btn-close" aria-label="Close"><svg …/></button> */
.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--btn-h-sm); height: var(--btn-h-sm);
  padding: 0;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--app-text-muted);
  transition: background 140ms, color 140ms;
}
.btn-close:hover { background: var(--app-active); color: var(--app-text); }
.btn-close:focus-visible { outline: 2px solid var(--app-text); outline-offset: 2px; }

/* ============================================================
   INPUTS
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: var(--app-fs-sm);
  font-weight: 500;
  color: var(--app-text);
}
.field-hint {
  font-size: var(--app-fs-xs);
  color: var(--app-text-muted);
}
.field-error { color: var(--app-danger); }

.input, .select, .textarea {
  height: var(--input-h);
  padding: 0 14px;
  border: 1px solid var(--app-border);
  border-radius: var(--r-sm);
  background: var(--app-surface);
  font-size: var(--app-fs-body);
  font-family: inherit;
  color: var(--app-text);
  transition: border-color 140ms, box-shadow 140ms;
  width: 100%;
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 96px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--app-text);
  box-shadow: 0 0 0 3px rgba(21, 39, 63, 0.08);
}
.input::placeholder, .textarea::placeholder { color: var(--app-text-muted); }
.input-search::placeholder { color: var(--gray-600); }   /* on --app-active */
.input-search {
  background: var(--app-active);
  border-color: transparent;
}

/* Search input with icon */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap .input { padding-left: 40px; }
.input-wrap > svg {
  position: absolute;
  left: 14px;
  color: var(--app-text-subtle);
  pointer-events: none;
}

/* Toggle */
.toggle {
  appearance: none;
  width: 40px; height: 24px;
  border-radius: var(--r-pill);
  background: var(--gray-300);
  position: relative;
  cursor: pointer;
  transition: background 140ms;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  box-shadow: var(--sh-sm);
  transition: transform 140ms;
}
.toggle:checked { background: var(--app-text); }
.toggle:checked::after { transform: translateX(16px); }

/* Checkbox */
.check {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid var(--app-border-strong);
  border-radius: 4px;
  background: var(--app-surface);
  cursor: pointer;
  position: relative;
  transition: all 120ms;
  flex-shrink: 0;
}
.check:checked {
  background: var(--app-text);
  border-color: var(--app-text);
}
.check:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 1px;
  width: 6px; height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--app-surface);
  border-radius: var(--r-lg);
  padding: 24px;
  border: 1px solid transparent;
}
.card-bordered { border-color: var(--app-border); }
.card-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-title {
  font-size: var(--app-fs-md);
  font-weight: 500;
  color: var(--app-text-muted);
}
.card-actions { display: flex; gap: 6px; }

/* ============================================================
   AVATARS
   ============================================================ */
.av {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: var(--app-fs-sm);
  flex-shrink: 0;
  color: var(--app-text);
}
.av-sm { width: 28px; height: 28px; font-size: var(--app-fs-xs); }
.av-lg { width: 56px; height: 56px; font-size: var(--app-fs-lg); }
.av-mint     { background: var(--av-mint); }
.av-pink     { background: var(--av-pink); }
.av-lavender { background: var(--av-lavender); }
.av-peach    { background: var(--av-peach); }
.av-yellow   { background: var(--av-yellow); }
.av-blue     { background: var(--av-blue); }
.av-rose     { background: var(--av-rose); }
.av-sage     { background: var(--av-sage); }
.av-dark     { background: var(--app-text); color: white; }

/* ============================================================
   STEPPER (multi-step form / wizard)
   ============================================================ */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  list-style: none;
  padding: 0;
  margin: 0;
}
.step { display: flex; align-items: center; gap: 8px; font-size: var(--app-fs-sm); color: var(--gray-600); }   /* may sit on canvas */
.step-dot {
  width: 24px; height: 24px;
  border-radius: var(--r-pill);
  background: var(--app-active);
  color: var(--app-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--app-fs-xs);
  font-weight: 600;
}
.step.is-done .step-dot   { background: var(--app-success-soft); color: var(--app-success); }
.step.is-active .step-dot { background: var(--app-text); color: white; }
.step.is-active           { color: var(--app-text); font-weight: 500; }
.step-line                { flex: 1; height: 1px; background: var(--app-border); max-width: 48px; }

/* ============================================================
   CHIPS / PILLS / BADGES
   ============================================================ */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--app-active);
  font-size: var(--app-fs-sm);
  color: var(--app-text);
  cursor: pointer;
  transition: background 140ms;
  border: none;
}
.chip:hover { background: var(--gray-200); }
.chip.is-active { background: var(--app-text); color: white; }
.chip-add { background: transparent; border: 1px dashed var(--app-border-strong); color: var(--app-text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: var(--app-fs-xs);
  font-weight: 500;
  background: var(--app-active);
  color: var(--app-text);
}
.badge { white-space: nowrap; flex: none; }
.badge-success { background: var(--app-success-soft); color: var(--app-success); }
.badge-danger  { background: var(--app-danger-soft);  color: var(--app-danger); }
.badge-warning { background: var(--app-warning-soft); color: var(--app-warning); }
.badge-info    { background: var(--app-info-soft);    color: var(--app-info); }
.badge-accent  { background: var(--app-accent-soft);  color: var(--app-accent-deep); }
.badge-dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ============================================================
   TABLE
   ============================================================ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--app-fs-body);
}
.table thead th {
  text-align: left;
  font-size: var(--app-fs-sm);
  font-weight: 500;
  color: var(--app-text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-border);
  position: sticky;
  top: 0;
  background: var(--app-surface);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--app-divider);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 120ms; }
.table tbody tr:hover { background: var(--app-hover); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .pos { color: var(--app-success); font-weight: 500; }
.table .neg { color: var(--app-text); font-weight: 500; }
.t-cell-2 {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.t-cell-2 .sub { font-size: var(--app-fs-xs); color: var(--app-text-muted); }

/* ============================================================
   QUICK ACTION CHIPS (Dashboard)
   ============================================================ */
.action-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  font-size: var(--app-fs-body);
  font-weight: 500;
  color: var(--app-text);
  transition: all 140ms;
}
.action-chip:hover {
  background: var(--app-hover);
  border-color: var(--app-border-strong);
}

/* ============================================================
   KPI / STAT CARDS
   ============================================================ */
.kpi {
  background: var(--app-surface);
  border-radius: var(--r-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 220px;
}
.kpi-label {
  font-size: var(--app-fs-md);
  font-weight: 500;
  color: var(--app-text-muted);
}
.kpi-period {
  font-size: var(--app-fs-xs);
  color: var(--app-text-muted);
  margin-top: -2px;
}
.kpi-value {
  font-size: var(--app-fs-2xl);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--app-text);
  margin-top: 4px;
}
.kpi-value.is-danger { color: var(--app-danger); }
.kpi-value.is-success { color: var(--app-success); }
.kpi-chart {
  margin-top: auto;
}

/* ============================================================
   KPI GRID + KPI TILE — row of headline figures
   <div class="kpi-grid">                 4 tiles (default)
   <div class="kpi-grid kpi-grid-3">      3 tiles
     <div class="kpi-tile">
       <div class="kpi-tile-label">Active users</div>
       <div class="kpi-tile-sub">vs. 4,410 prior period</div>   (optional)
       <div class="kpi-tile-value">4,812</div>
       <div class="kpi-tile-foot"><span class="badge …">+9.1%</span></div> (optional)
     </div>
   Responsive (viewport):
     4-up: 4 columns ≥ 1200px · 2 columns 480–1199px · 1 column < 480px
     3-up: 3 columns ≥ 768px · 1 column < 768px
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}
.kpi-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--app-surface);
  border-radius: var(--r-lg);
  padding: 22px 24px 20px;
  box-shadow: var(--sh-sm);
}
.kpi-tile-label { font-size: var(--app-fs-md); font-weight: 600; color: var(--app-text); }
.kpi-tile-sub { font-size: var(--app-fs-xs); color: var(--app-text-muted); margin-top: 3px; }
.kpi-tile-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--app-fs-3xl);
  line-height: var(--app-lh-tight);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--app-text);
  margin: 16px 0 12px;
  overflow-wrap: anywhere;
}
.kpi-tile-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: auto; }
@media (max-width: 1199px) { .kpi-grid:not(.kpi-grid-3) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px)  { .kpi-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 479px)  { .kpi-grid { grid-template-columns: 1fr; } }

/* ============================================================
   FORM LAYOUT
   ============================================================ */
.form-section {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  padding: 32px 0;
  border-bottom: 1px solid var(--app-divider);
}
.form-section:last-child { border-bottom: none; }
.form-section-head h3 {
  font-size: var(--app-fs-lg);
  font-weight: 600;
  margin-bottom: 6px;
}
.form-section-head p {
  font-size: var(--app-fs-sm);
  color: var(--app-text-muted);
  line-height: var(--app-lh-loose);
}
.form-grid {
  display: grid;
  gap: 20px;
}
.form-grid-2 { grid-template-columns: 1fr 1fr; }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  display: flex;
  flex-direction: column;
  position: relative;
}
.timeline-day {
  font-size: var(--app-fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-600);   /* may sit on canvas */
  font-weight: 500;
  padding: 24px 0 12px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  padding: 14px 0;
  align-items: flex-start;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 19px; top: 38px; bottom: -14px;
  width: 2px;
  background: var(--app-divider);
}
.timeline-item:last-child::before { display: none; }
.timeline-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  background: var(--app-active);
  color: var(--app-text);
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}
.timeline-body .ti-title { font-weight: 500; font-size: var(--app-fs-md); }
.timeline-body .ti-detail { font-size: var(--app-fs-sm); color: var(--app-text-muted); margin-top: 2px; }
.timeline-time { font-size: var(--app-fs-sm); color: var(--gray-600); white-space: nowrap; }   /* may sit on canvas */

/* ============================================================
   AI ASSISTANT FAB (floating bottom-right pill)
   ============================================================ */
.ai-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 6px 6px 6px 18px;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--r-pill);
  box-shadow: var(--sh-md);
  font-size: var(--app-fs-body);
  color: var(--app-text-muted);
  z-index: 50;
  transition: all 140ms;
}
.ai-fab:hover { box-shadow: var(--sh-lg); }
.ai-fab-orb {
  width: 36px; height: 36px;
  border-radius: var(--r-pill);
  background: radial-gradient(circle at 30% 30%, #BDDEF5, #2E7AA0);
  flex-shrink: 0;
}

/* ============================================================
   NOTICE — block message for one act or section
   (refusal, confirmed outcome, warning, neutral note)
   Markup: <div class="notice notice-danger" role="alert">
             <svg class="notice-icon">…</svg>            (optional)
             <div class="notice-body">
               <div class="notice-title">Title</div>   (optional)
               <p>Message</p>
             </div>
           </div>
   Text contrast on the soft background (WCAG AA ≥ 4.5:1):
   --app-danger, --app-success and --app-info reach only 3.95 / 3.00 / 3.70
   as text, so the notice text uses a darker, documented value:
     --notice-danger-text  #991B1B  6.80:1 on --app-danger-soft
     --notice-success-text #166534  6.49:1 on --app-success-soft
     --notice-info-text    #1F5A78  5.84:1 on --app-info-soft
   --app-warning (4.51:1) and --app-text-2 (8.53:1) pass unchanged.
   Border and icon keep the status token; only the text is darkened.
   ============================================================ */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid;
  border-radius: var(--r-sm);
  font-size: var(--app-fs-body);
  line-height: var(--app-lh-loose);
}
.notice-icon { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--notice-icon, currentColor); }
.notice-body { flex: 1; min-width: 0; }
.notice-body > p { margin: 0; font-size: inherit; line-height: inherit; color: inherit; }
.notice-title { font-weight: 600; }
.notice-title + p { margin-top: 2px; }

.notice-danger  { --notice-danger-text: #991B1B;  background: var(--app-danger-soft);  border-color: var(--app-danger);  color: var(--notice-danger-text);  --notice-icon: var(--app-danger); }
.notice-success { --notice-success-text: #166534; background: var(--app-success-soft); border-color: var(--app-success); color: var(--notice-success-text); --notice-icon: var(--app-success); }
.notice-warning { background: var(--app-warning-soft); border-color: var(--app-warning); color: var(--app-warning); }
.notice-info    { --notice-info-text: #1F5A78;    background: var(--app-info-soft);    border-color: var(--app-info);    color: var(--notice-info-text);    --notice-icon: var(--app-info); }
.notice-neutral { background: var(--app-active); border-color: var(--app-border-strong); color: var(--app-text-2); }

/* ============================================================
   RESPONSIVE — tablet + mobile
   ============================================================ */
@media (max-width: 1023px) {
  .app-shell { grid-template-columns: var(--sidebar-w-compact) 1fr; }
  .app-sidebar .sb-org-name,
  .app-sidebar .sb-org-caret,
  .app-sidebar .sb-search-kbd,
  .app-sidebar .sb-group-label,
  .app-sidebar .sb-item-label,
  .app-sidebar .sb-search-text { display: none; }
  .app-sidebar .sb-item { justify-content: center; padding: 10px; }
  .app-sidebar .sb-search { justify-content: center; padding: 0; }
  .app-sidebar .sb-org { justify-content: center; padding: 12px 8px; }
  .form-section { grid-template-columns: 1fr; gap: 20px; padding: 24px 0; }
  .form-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(.22,.61,.36,1);
    z-index: 100;
    box-shadow: var(--sh-lg);
  }
  .app-shell.is-mobile-open .app-sidebar { transform: translateX(0); }
  .app-sidebar .sb-org-name,
  .app-sidebar .sb-org-caret,
  .app-sidebar .sb-search-kbd,
  .app-sidebar .sb-group-label,
  .app-sidebar .sb-item-label,
  .app-sidebar .sb-search-text { display: block; }
  .app-sidebar .sb-item { justify-content: flex-start; padding: 9px 12px; }
  .app-sidebar .sb-search { justify-content: flex-start; padding: 0 12px; }
  .app-sidebar .sb-org { justify-content: flex-start; padding: 18px 16px; }
  .app-mobile-menu { display: inline-flex; }
  .app-topbar { padding: 0 16px; gap: 12px; }
  .app-topbar h1 { font-size: var(--app-fs-xl); }
  .app-content { padding: 8px 16px 32px; gap: 16px; }
  .card { padding: 16px; border-radius: var(--r); }
  .kpi { padding: 16px; min-height: 160px; }
  .ai-fab { right: 16px; bottom: 16px; }
  .ai-fab-text { display: none; }
  .ai-fab { padding: 6px; }
}

/* ---------- Mobile sidebar backdrop ---------- */
.app-mobile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 99;
}
.app-shell.is-mobile-open .app-mobile-backdrop { display: block; }

/* ============================================================
   TAG INPUT — a field holding a list of values as separate chips
   <div class="tag-input [is-error]">
     <span class="chip tag-input-chip">
       <span class="tag-input-value">Design principal</span>
       <button type="button" class="tag-input-remove" aria-label="Remove Design principal">×</button>
     </span>
     <input class="tag-input-field" aria-label="…" placeholder="Add a value">
   </div>
   Disabled: disabled on .tag-input-field (and on each remove button), or .is-disabled.
   Error: .is-error on .tag-input, or aria-invalid="true" on the field.
   Behaviour (Enter confirms, spaces and quotes are literal, Backspace in
   the empty field removes the last chip, pasted lines become chips) is
   script, not CSS — see the reference script in components/TagInput/preview.html.
   ============================================================ */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: var(--input-h);
  padding: 5px 6px;
  border: 1px solid var(--app-border);
  border-radius: var(--r-sm);
  background: var(--app-surface);
  cursor: text;
  transition: border-color 140ms, box-shadow 140ms;
}
.tag-input:focus-within, .tag-input.is-focused {
  border-color: var(--app-text);
  box-shadow: 0 0 0 3px rgba(21, 39, 63, 0.08);
}
.tag-input-chip {
  height: auto;
  min-height: var(--btn-h-sm);
  max-width: 100%;
  padding: 4px 4px 4px 12px;
  gap: 4px;
  cursor: default;
  position: relative;
}
.tag-input-chip:hover { background: var(--app-active); }
.tag-input-value { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--app-lh); }
.tag-input-remove {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px; height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--app-text-2);
  font-size: var(--app-fs-md);
  line-height: 1;
}
.tag-input-remove:hover { background: var(--gray-200); color: var(--app-text); }
.tag-input-remove:focus-visible { outline: 2px solid var(--app-text); outline-offset: 1px; }
.tag-input-field {
  flex: 1 1 120px;
  min-width: 120px;
  height: var(--btn-h-sm);
  padding: 0 8px;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: var(--app-fs-body);
  color: var(--app-text);
}
.tag-input-field::placeholder { color: var(--app-text-muted); }
/* Error — whole field */
.tag-input.is-error, .tag-input:has(.tag-input-field[aria-invalid="true"]) { border-color: var(--app-danger); }
.tag-input.is-error:focus-within, .tag-input:has(.tag-input-field[aria-invalid="true"]):focus-within {
  border-color: var(--app-danger);
  box-shadow: 0 0 0 3px var(--app-danger-soft);
}
/* Disabled — text --app-text-muted: 4.77:1 on the field, 5.03:1 on the chip */
.tag-input.is-disabled, .tag-input:has(.tag-input-field:disabled) {
  background: var(--app-hover);
  border-style: dashed;
  cursor: not-allowed;
  box-shadow: none;
}
.tag-input.is-disabled .tag-input-chip, .tag-input:has(.tag-input-field:disabled) .tag-input-chip {
  background: var(--app-surface);
  box-shadow: inset 0 0 0 1px var(--app-border);
  color: var(--app-text-muted);
}
.tag-input.is-disabled .tag-input-remove, .tag-input:has(.tag-input-field:disabled) .tag-input-remove { display: none; }
.tag-input-field:disabled { cursor: not-allowed; -webkit-text-fill-color: var(--app-text-muted); }
/* Touch: remove control hit area ≥ --hit-min, form text 16px (no iOS zoom) */
@media (pointer: coarse) {
  .tag-input-remove::before { content: ''; position: absolute; top: 50%; left: 50%; width: var(--hit-min); height: var(--hit-min); transform: translate(-50%, -50%); }
  .tag-input { gap: 10px; }
  .tag-input-field { font-size: var(--fs-body); }
}
.app.touch .tag-input-remove::before { content: ''; position: absolute; top: 50%; left: 50%; width: var(--hit-min); height: var(--hit-min); transform: translate(-50%, -50%); }
.app.touch .tag-input { gap: 10px; }
.app.touch .tag-input-field { font-size: var(--fs-body); }

/* ============================================================
   MODAL BACKDROP: dims the page behind a dialog
   <div class="modal-backdrop"><div role="dialog" aria-modal="true" class="card">…</div></div>
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--app-scrim);
  overflow-y: auto;
}

/* ============================================================
   TOAST: short confirmation or status message, dismissible
   <div class="toast-region">                       (fixed stack, bottom right)
     <div class="toast" role="status">
       <svg class="toast-icon toast-icon-success">…</svg>   (optional)
       <div class="toast-body"><p>Changes saved.</p></div>
       <button type="button" class="btn btn-ghost btn-sm">Dismiss</button>
     </div>
   </div>
   Text --app-text-on-dark on --app-inverse: 15.07:1. Icons use the soft
   status tokens (11.70:1 or more on --app-inverse); the full status
   colours reach only 3.00 to 4.57:1 there.
   ============================================================ */
.toast-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(420px, 100%);
  padding: 10px 8px 10px 16px;
  border-radius: var(--r);
  background: var(--app-inverse);
  color: var(--app-text-on-dark);
  box-shadow: var(--sh-lg);
  font-size: var(--app-fs-body);
  line-height: var(--app-lh-loose);
}
.toast-body { flex: 1; min-width: 0; }
.toast-body > p { margin: 0; font-size: inherit; line-height: inherit; color: inherit; }
.toast-title { font-weight: 600; }
.toast-icon { flex: none; width: 18px; height: 18px; }
.toast-icon-success { color: var(--app-success-soft); }
.toast-icon-danger  { color: var(--app-danger-soft); }
.toast-icon-warning { color: var(--app-warning-soft); }
.toast-icon-info    { color: var(--app-info-soft); }
.toast .btn-ghost { flex: none; color: var(--app-text-on-dark); }
.toast .btn-ghost:hover { background: var(--verge-navy-2); transform: none; }
.toast .btn-ghost:focus-visible { outline: 2px solid var(--app-text-on-dark); outline-offset: 1px; }
@media (max-width: 767px) {
  .toast-region { left: 16px; right: 16px; bottom: 16px; align-items: stretch; }
  .toast { width: 100%; }
}

/* ============================================================
   LONG VALUES — addresses, commit ids, keys wrap instead of widening the page
   ============================================================ */
.break-anywhere { overflow-wrap: anywhere; word-break: normal; min-width: 0; }

/* ============================================================
   TABLE WRAP — wide tables scroll inside their card, never the page
   <div class="table-wrap [table-sticky-first]"><table class="table">…</table></div>
   ============================================================ */
.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scroll-timeline: --table-wrap inline;
}
.table-sticky-first .table tr > :first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--app-surface);
  box-shadow: inset -1px 0 0 var(--app-border);
}
.table-sticky-first .table thead tr > :first-child { z-index: 3; }
.table-sticky-first .table tbody tr:hover > :first-child { background: var(--app-hover); }
/* Stronger edge only while scrolled (browsers with scroll-driven animations);
   elsewhere the 1px edge above stays visible. */
@supports (animation-timeline: scroll()) {
  .table-sticky-first .table tr > :first-child {
    animation: table-sticky-edge linear both;
    animation-timeline: --table-wrap;
  }
}
@keyframes table-sticky-edge {
  0%   { box-shadow: inset -1px 0 0 var(--app-border); }
  2%, 100% { box-shadow: inset -1px 0 0 var(--app-border-strong), 6px 0 10px -6px rgba(15, 23, 42, 0.18); }
}

/* ============================================================
   TABS — horizontal tab bar, scrolls when tabs do not fit
   <div class="tabs" role="tablist"><button class="tab is-active" role="tab" aria-selected="true">…</button></div>
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  border-bottom: 1px solid var(--app-border);
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--btn-h);
  padding: 0 12px;
  border: none;
  background: transparent;
  font-size: var(--app-fs-body);
  font-weight: 500;
  color: var(--app-text-2);
  white-space: nowrap;
  cursor: pointer;
  transition: color 140ms, box-shadow 140ms;
}
.tab:hover { color: var(--app-text); }
.tab.is-active, .tab[aria-selected="true"] { color: var(--app-text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--app-text); }

/* ============================================================
   DISABLED — .btn (all variants), .chip, inputs, selects
   Text --app-text-muted on --app-hover: 4.77:1 (AA).
   Use :disabled on native controls; .is-disabled / aria-disabled="true"
   on links or non-native elements.
   ============================================================ */
.btn:disabled, .btn.is-disabled, .btn[aria-disabled="true"],
.chip:disabled, .chip.is-disabled, .chip[aria-disabled="true"] {
  background: var(--app-hover);
  border-color: var(--app-border);
  color: var(--app-text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn.is-disabled, .btn[aria-disabled="true"],
.chip.is-disabled, .chip[aria-disabled="true"] { pointer-events: none; }
.chip:disabled, .chip.is-disabled, .chip[aria-disabled="true"] { border: 1px dashed var(--app-border-strong); }
.btn:disabled svg, .btn.is-disabled svg, .chip:disabled svg { color: currentColor; }
.input:disabled, .select:disabled, .textarea:disabled,
.input[aria-disabled="true"], .select[aria-disabled="true"] {
  background: var(--app-hover);
  border-color: var(--app-border);
  border-style: dashed;
  color: var(--app-text-muted);
  -webkit-text-fill-color: var(--app-text-muted);
  cursor: not-allowed;
  opacity: 1;
}
.input:disabled::placeholder, .textarea:disabled::placeholder { color: var(--app-text-muted); }
.toggle:disabled, .check:disabled { cursor: not-allowed; opacity: .5; }

/* ============================================================
   TOUCH — pointer: coarse (phones, tablets)
   Hit areas ≥ --hit-min (44px); form text 16px so iOS does not zoom.
   .app.touch applies the same rules without a coarse pointer
   (preview cards, forced touch mode); the media query cannot share
   selectors with a class, so the block is written twice.
   ============================================================ */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-lg, .chip, .action-chip, .tab, .app-mobile-menu { min-height: var(--hit-min); }
  .btn-sm { height: var(--hit-min); }
  .btn-icon, .app-mobile-menu, .btn-close,
  .app-topbar-actions > button, .app-topbar-actions > a { min-width: var(--hit-min); min-height: var(--hit-min); }
  .btn-icon, .app-mobile-menu, .btn-close { height: var(--hit-min); }
  .btn-close { width: var(--hit-min); }
  .sb-item { min-height: var(--hit-min); }
  .chip { height: var(--hit-min); }
  .input, .select { min-height: var(--hit-min); }
  .input, .select, .textarea { font-size: var(--fs-body); }
  .toggle::before, .check::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: var(--hit-min); height: var(--hit-min);
    transform: translate(-50%, -50%);
  }
}
.app.touch .btn, .app.touch .btn-sm, .app.touch .btn-lg, .app.touch .chip, .app.touch .action-chip, .app.touch .tab, .app.touch .app-mobile-menu { min-height: var(--hit-min); }
.app.touch .btn-sm { height: var(--hit-min); }
.app.touch .btn-icon, .app.touch .app-mobile-menu, .app.touch .btn-close,
.app.touch .app-topbar-actions > button, .app.touch .app-topbar-actions > a { min-width: var(--hit-min); min-height: var(--hit-min); }
.app.touch .btn-icon, .app.touch .app-mobile-menu, .app.touch .btn-close { height: var(--hit-min); }
.app.touch .btn-close { width: var(--hit-min); }
.app.touch .sb-item { min-height: var(--hit-min); }
.app.touch .chip { height: var(--hit-min); }
.app.touch .input, .app.touch .select { min-height: var(--hit-min); }
.app.touch .input, .app.touch .select, .app.touch .textarea { font-size: var(--fs-body); }
.app.touch .toggle::before, .app.touch .check::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: var(--hit-min); height: var(--hit-min);
  transform: translate(-50%, -50%);
}

/* ============================================================
   SHELL — tablet width + coarse pointer: labelled drawer behind the
   menu button instead of the icon-only rail (no label depends on a
   hover tooltip). Fine pointers keep the rail. Opening still toggles
   .is-mobile-open on .app-shell, as on phones.
   ============================================================ */
@media (min-width: 768px) and (max-width: 1023px) and (pointer: coarse) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(.22,.61,.36,1);
    z-index: 100;
    box-shadow: var(--sh-lg);
  }
  .app-shell.is-mobile-open .app-sidebar { transform: translateX(0); }
  .app-sidebar .sb-org-name,
  .app-sidebar .sb-org-caret,
  .app-sidebar .sb-search-kbd,
  .app-sidebar .sb-group-label,
  .app-sidebar .sb-item-label,
  .app-sidebar .sb-search-text { display: block; }
  .app-sidebar .sb-item { justify-content: flex-start; padding: 9px 12px; }
  .app-sidebar .sb-search { justify-content: flex-start; padding: 0 12px; }
  .app-sidebar .sb-org { justify-content: flex-start; padding: 18px 16px; }
  .app-mobile-menu { display: inline-flex; }
}

/* ============================================================
   SMALL SCREENS — below 768px
   Long values wrap; help and caption text ≥ 12px.
   ============================================================ */
@media (max-width: 767px) {
  /* break-word (not anywhere): wraps long values without shrinking the
     column's minimum width, so short words and badges never break per letter. */
  .table td, .t-cell-2, .t-cell-2 .sub { overflow-wrap: break-word; word-break: normal; min-width: 0; }
  .field-hint, .t-cell-2 .sub, .kpi-period, .timeline-day, .sb-search-kbd, .step, .badge { font-size: max(12px, var(--app-fs-xs)); }
  .sb-group-label { font-size: var(--app-fs-xs); }
  .sb-item-badge { font-size: var(--app-fs-xs); }
  /* Sticky first column: at most 40% of the scroll container, content wraps. */
  .table-wrap.table-sticky-first { container-type: inline-size; }
  .table-sticky-first .table tr > :first-child {
    max-width: 40cqw;
    white-space: normal;
    overflow-wrap: break-word;
  }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.muted { color: var(--app-text-muted); }
.subtle { color: var(--app-text-muted); }   /* text-safe; --app-text-subtle is non-text only */
/* Small uppercase heading above cards and blocks (usually on canvas).
   Works on h2-h6; use a real heading when the label heads a section. */
.section-label, .app .section-label {
  font-family: inherit;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: var(--app-lh);
  color: var(--gray-600);
}
/* Keys, commit ids, paths, addresses — system monospace, no web font. */
.code { font-family: var(--font-code); font-size: 0.92em; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.tabular { font-variant-numeric: tabular-nums; }
.divider { height: 1px; background: var(--app-border); border: none; margin: 0; }
.row { display: flex; align-items: center; gap: 12px; }
/* Visually hidden, still read by screen readers (table header rows, labels). */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.col { display: flex; flex-direction: column; gap: 12px; }

/* ============================================================
   APPROVED 2026-11-07 (operator, SDL-0164): eight components
   proposed on 2026-10-31 and 2026-11-07, first drawn in the
   Verged application substrate's design artifact. Open questions
   of their READMEs were settled with the proposals.
   ============================================================ */

/* ---------- Link as button ----------
   ".app a { color: inherit }" above outranks .btn-primary and
   .btn-danger; a link styled as one of them keeps the button's text. */
.app a.btn-primary, .app a.btn-danger { color: var(--app-text-on-dark); }
.app a.btn { text-decoration: none; }
.app a.btn:focus-visible { outline: 2px solid var(--app-text); outline-offset: 2px; }

/* ---------- SidebarStatus ----------
   This instance's health at the foot of the sidebar. Standard lines
   first; optional system lines below .sb-status-system. Links nowhere. */
.sb-status { display: flex; flex-direction: column; gap: 2px; margin: 4px 0 8px; padding: 12px 14px; border: 1px solid var(--app-border); border-radius: var(--r-sm); background: var(--app-surface); color: var(--app-text); }
.sb-status-head { display: flex; gap: 8px; align-items: center; font-weight: 600; font-size: var(--app-fs-body); margin-bottom: 4px; }
.sb-status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--app-success); flex: none; }
.sb-status-dot.is-warning { background: var(--app-warning); }
.sb-status-dot.is-unknown { background: transparent; border: 1.5px solid var(--app-text-muted); }
.sb-status-line { font-size: 12.5px; line-height: 1.45; color: var(--app-text-muted); }
.sb-status-line.code { font-family: var(--font-code); }
.sb-status-line.is-ok { color: #166534; }
.sb-status-line.is-warning { color: var(--app-warning); }
.sb-status-system { display: flex; flex-direction: column; gap: 2px; border-top: 1px dashed var(--app-border-strong); margin-top: 6px; padding-top: 6px; }
.sb-status-note { font-size: 12px; line-height: 1.45; color: var(--app-text-muted); border-top: 1px solid var(--app-border); margin-top: 6px; padding-top: 6px; }
@media (min-width: 768px) and (max-width: 1023px) { .app-sidebar .sb-status { display: none; } }

/* ---------- AuthCard ----------
   The shell of every sign-in and access screen: brand row, one card. */
.auth { min-height: 100vh; display: flex; flex-direction: column; background: var(--app-canvas); }
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 24px 32px 0; }
.auth-top-brand { display: flex; align-items: center; gap: 10px; }
.auth-help { font-size: var(--app-fs-sm); color: var(--app-text-muted); }
.auth-main { flex: 1; display: grid; place-items: center; padding: 48px 16px 32px; }
.auth-card { width: 100%; max-width: 480px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--r-lg); box-shadow: var(--sh); }
.auth-card.is-wide { max-width: 560px; }
.auth-body { display: flex; flex-direction: column; gap: 20px; padding: 40px; }
.auth-body h1 { font-size: var(--app-fs-2xl); text-wrap: balance; }
.auth-sub { font-size: var(--app-fs-md); line-height: 1.55; color: var(--app-text-2); margin-top: 8px !important; }
.auth-btn { width: 100%; justify-content: center; }
.auth-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: var(--app-fs-body); }
.auth-link { color: var(--app-text) !important; text-decoration: underline !important; text-underline-offset: 3px; }
.auth-center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 8px; }
.auth-icon svg { width: 24px; height: 24px; }
.auth-icon.is-info { background: var(--app-info-soft); color: #1F5A78; }
.auth-icon.is-success { background: var(--app-success-soft); color: #166534; }
.auth-icon.is-warning { background: var(--app-warning-soft); color: var(--app-warning); }
.auth-icon.is-danger { background: var(--app-danger-soft); color: #991B1B; }
.auth-icon.is-neutral { background: var(--app-active); color: var(--app-text-2); }
.auth-acts { display: flex; gap: 12px; flex-wrap: wrap; }
.auth-acts > * { flex: 1 1 160px; justify-content: center; }
.auth-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--app-fs-sm); color: var(--app-text-muted); }
.auth-rules li { display: flex; gap: 8px; align-items: center; }
.auth-rules li.is-ok { color: #166534; }
.auth-rules li.is-no { color: #991B1B; }
@media (max-width: 600px) { .auth-top { padding: 16px 16px 0; } .auth-main { padding: 24px 16px; place-items: start center; } .auth-body { padding: 28px 20px; } .auth-body h1 { font-size: var(--app-fs-xl); } }

/* ---------- RefusedByRole ---------- */
.refused { max-width: 560px; margin: 48px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.refused-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--app-active); color: var(--app-text-2); }
.refused-reason { font-family: var(--font-code); font-size: 13px; background: var(--app-active); border-radius: var(--r-sm); padding: 8px 12px; color: var(--app-text); overflow-wrap: anywhere; }

/* ---------- UnnamedFailure (variant A, dashed box) ---------- */
.failure { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px dashed var(--app-border-strong); border-radius: var(--r); background: var(--app-surface); color: var(--app-text); }
.failure-mark { flex: none; width: 22px; height: 22px; border-radius: 4px; border: 1.5px solid var(--app-text-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--app-text-2); }
.failure p { font-size: var(--app-fs-body); line-height: 1.5; }
.failure-title { font-weight: 600; }

/* ---------- SecretOnce ---------- */
.secret-once { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret-once code { font-family: var(--font-code); font-size: 13px; background: var(--app-canvas); border: 1px solid var(--app-border); border-radius: var(--r-sm); padding: 8px 10px; overflow-wrap: anywhere; flex: 1 1 280px; min-width: 0; }

/* ---------- EmptyState (dashed) ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 16px; text-align: center; border: 1px dashed var(--app-border-strong); border-radius: var(--r); color: var(--app-text-2); font-size: var(--app-fs-body); line-height: 1.55; }
.empty-state p { max-width: 60ch; }

/* ---------- TableCards (label column 112 px) ---------- */
@media (max-width: 767px) {
  .table-wrap:has(.table-cards) { overflow: visible; border: none; background: transparent; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-cards tbody tr { border: 1px solid var(--app-border); border-radius: var(--r); background: var(--app-surface); padding: 12px 14px; margin-bottom: 12px; }
  .table-cards tbody td { border: none; padding: 4px 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: baseline; }
  .table-cards tbody td::before { content: attr(data-label); font-size: 12.5px; color: var(--app-text-muted); }
  .table-cards tbody td.tc-title { display: block; font-weight: 600; font-size: var(--app-fs-md); padding-bottom: 6px; }
  .table-cards tbody td.tc-title::before, .table-cards tbody td.tc-acts::before { content: none; }
  .table-cards tbody td.tc-acts { display: block; padding-top: 10px; margin-top: 6px; border-top: 1px solid var(--app-border); }
  .table-cards .num { text-align: left; }
}

/* ---------- Loading ----------
   Four cases: a read pending (.loading-sk, after --app-loading-delay);
   a short act (.btn.is-busy with .spinner); a long act (.loading-long,
   after --app-loading-long-after); no answer (hand over to .failure or
   a notice-danger). Timing tokens are in colors_and_type.css. */
@keyframes app-spin { to { transform: rotate(360deg); } }
@keyframes app-shine { 0% { background-position: -240px 0; } 100% { background-position: 240px 0; } }
@keyframes app-appear { from { opacity: 0; } to { opacity: 1; } }
.loading-sk { display: flex; flex-direction: column; gap: 12px; animation: app-appear var(--dur-fast) linear var(--app-loading-delay) both; }
.loading-sk-row { display: flex; gap: 16px; align-items: center; }
.sk { display: block; height: 12px; border-radius: 6px; background: var(--app-active); background-image: linear-gradient(90deg, var(--app-active) 0, var(--app-hover) 60px, var(--app-active) 120px); background-size: 480px 100%; background-repeat: no-repeat; animation: app-shine 1.4s linear infinite; }
.sk.is-short { width: 120px; } .sk.is-mid { width: 220px; } .sk.is-line { flex: 1 1 auto; } .sk.is-title { height: 18px; width: 180px; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: app-spin .8s linear infinite; flex: none; }
.btn.is-busy { pointer-events: none; gap: 8px; }
.loading-long { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--app-border); border-radius: var(--r); background: var(--app-surface); }
.loading-long .spinner { margin-top: 3px; color: var(--app-text-2); }
.loading-long-title { font-weight: 600; font-size: var(--app-fs-body); }
.loading-long-meta { font-size: var(--app-fs-sm); color: var(--app-text-muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { .sk, .spinner, .loading-sk { animation: none; } .spinner { border-right-color: currentColor; opacity: .6; } }

/* ============================================================
   APPROVED 2026-11-07 (operator, SDL-0164, option A): the generic
   frame parts of the Verged application substrate. PageHeader,
   AccountMenu, SidebarBrand. Source: the substrate's design artifact.
   ============================================================ */

/* ---------- SidebarBrand: the product at the head of the sidebar,
   and the same mark and name on the access screens ---------- */
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 12px; text-decoration: none; color: var(--app-text); }
.sb-brand:focus-visible { outline: 2px solid var(--app-text); outline-offset: -2px; border-radius: var(--r-sm); }
.brand-mark { min-width: 30px; padding: 0 6px; box-sizing: border-box; height: 30px; border-radius: var(--r-sm); background: var(--app-text); color: var(--app-surface); display: grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: .02em; flex: none; }
.brand-name { font-weight: 600; font-size: var(--app-fs-md); line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-brand-env { margin-left: auto; }
@media (max-width: 1023px) {
  .app-sidebar .sb-brand .brand-name, .app-sidebar .sb-brand-env { display: none; }
  .app-sidebar .sb-brand { justify-content: center; padding: 16px 8px; }
}
@media (max-width: 767px), (min-width: 768px) and (max-width: 1023px) and (pointer: coarse) {
  .app-sidebar .sb-brand .brand-name { display: block; }
  .app-sidebar .sb-brand-env { display: inline-flex; }
  .app-sidebar .sb-brand { justify-content: flex-start; padding: 20px 20px 12px; }
}

/* ---------- PageHeader: route title, one sentence on what the route
   is for, and the account menu. Unlike .app-topbar it is not sticky and
   its height follows the statement. ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; padding: 28px 32px 8px; }
.page-head-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.page-head-title h1 { font-size: var(--app-fs-2xl); font-weight: 600; }
.page-head-statement { font-size: var(--app-fs-body); line-height: 1.55; color: var(--app-text-2); max-width: 78ch; }
@media (max-width: 767px) {
  .page-head { padding: 16px 16px 4px; gap: 12px; }
  .page-head-title h1 { font-size: var(--app-fs-xl); }
}

/* ---------- AccountMenu: the signed-in person, their profile, and
   sign out ---------- */
.account { position: relative; flex: none; }
.account-avatar { width: 40px; height: 40px; border-radius: var(--r-pill); border: 1px solid var(--app-border); background: var(--app-surface); color: var(--app-text); font-weight: 600; font-size: 13px; cursor: pointer; }
.account-avatar:hover { background: var(--app-hover); }
.account-avatar:focus-visible, .account-menu-item:focus-visible { outline: 2px solid var(--app-text); outline-offset: 2px; }
.account-menu { position: absolute; right: 0; top: 48px; width: 260px; background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--r); box-shadow: var(--sh-lg); padding: 6px; z-index: 20; display: flex; flex-direction: column; }
.account-menu-who { padding: 10px 12px; border-bottom: 1px solid var(--app-border); margin-bottom: 4px; }
.account-menu-name { font-weight: 600; font-size: var(--app-fs-md); }
.account-menu-mail { font-size: var(--app-fs-sm); color: var(--app-text-muted); overflow-wrap: anywhere; }
.app a.account-menu-item, .account-menu-item { display: flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); color: var(--app-text); font-size: var(--app-fs-body); text-decoration: none; }
.account-menu-item:hover { background: var(--app-hover); }
@media (pointer: coarse) { .account-avatar { width: var(--hit-min); height: var(--hit-min); } .account-menu { top: calc(var(--hit-min) + 8px); } .account-menu-item { min-height: var(--hit-min); } }
.app.touch .account-avatar { width: var(--hit-min); height: var(--hit-min); }
.app.touch .account-menu-item { min-height: var(--hit-min); }
