/* Sutra CRM — application stylesheet.
 * NetSuite-style enterprise palette: light topbar, blue-900 module nav,
 * tinted page header, white cards on cool blue-grey body, dark status footer.
 * Matches mockup-dashboard.html. No CSS framework dependency.
 */

:root {
  /* === Palette === */
  --bg: #e7ecf2;
  --bg-2: #dbe2ec;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --border: #cbd5e1;
  --border-strong: #94a3b8;
  --text: #0f172a;
  --muted: #475569;
  --tertiary: #94a3b8;

  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --brand-3: #1e40af;
  --brand-bg: #dbeafe;

  --topbar-bg: #ffffff;
  --topbar-text: #0f172a;
  --topbar-muted: #64748b;
  --topbar-hover: #f1f5f9;
  --topbar-border: #cbd5e1;

  --modules-bg: #1e3a8a;
  --modules-text: #c7d2fe;
  --modules-active: #ffffff;
  --modules-accent: #60a5fa;
  --modules-hover-bg: #2a4ba5;
  --modules-border: #1e40af;

  --statusbar-bg: #0b1220;
  --statusbar-text: #cbd5e1;
  --statusbar-link: #93c5fd;

  --success: #15803d;
  --success-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --purple: #6d28d9;
  --purple-bg: #ede9fe;
  --teal: #0f766e;
  --teal-bg: #ccfbf1;
  --indigo: #4338ca;
  --indigo-bg: #e0e7ff;

  --radius: 0;       /* square-corner design preference — set 2026-05-27 */
  --radius-lg: 0;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { font: 13px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
table { border-collapse: collapse; }
i.ti { line-height: 1; }

/* === Page shell (per-view layout container) === v5
 *
 *   'fluid'    full viewport, no rail — lists, dashboard
 *   'default'  main 1100px + rail filling rest — detail view
 *   'form'     main 1100px + rail filling rest (edit) or 1100px only (create)
 *
 * Topbar, module nav, page-head, sub-tabs, statusbar all render full-width
 * OUTSIDE the shell. The shell only wraps the active content (.shell-main
 * and optional .shell-rail).
 *
 * Inside .shell-rail, .rail-grid lays out System (320px fixed) + Activity
 * (1fr — fills remaining viewport width).
 */
.page-shell {
  display: grid;
  gap: 0;
  margin: 0;
}
.page-shell--fluid {
  grid-template-columns: 1fr;
}
.page-shell--default,
.page-shell--form {
  grid-template-columns: minmax(0, 1100px) minmax(0, 1fr);
}
.page-shell--no-rail {
  grid-template-columns: minmax(0, 1100px);
}

.shell-main { min-width: 0; }
/* shell-rail padding: top right bottom left.
 * Left was 16px and stacked with .main's 16px right-padding → 32px visual
 * gap between the General card and the System panel. Set to 0 so the rail's
 * left edge sits flush against .main's right padding — visual gap is now
 * just the 16px from .main, much closer to the 14px System↔Activity rhythm.
 */
.shell-rail { min-width: 0; padding: 14px 16px 16px 0; }

.rail-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
}

@media (max-width: 1499px) {
  .rail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1023px) {
  .page-shell--default,
  .page-shell--form { grid-template-columns: 1fr; }
  .page-shell--no-rail { grid-template-columns: 1fr; }
}

/* === Top utility bar (light) === */
.topbar {
  background: var(--topbar-bg);
  color: var(--topbar-text);
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--topbar-border);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 500; font-size: 14px;
  color: var(--topbar-text);
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-text { display: inline; }
.brand-mark {
  width: 26px; height: 26px;
  background: var(--brand); color: white;
  border-radius: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500;
}
.topbar-spacer { flex: 1; min-width: 0; }
.global-search {
  width: 300px; flex-shrink: 0;
  display: flex; align-items: center;
  background: var(--topbar-hover);
  border: 1px solid var(--topbar-border);
  border-radius: 0;
  padding: 5px 10px;
  margin-right: 6px;
  color: var(--topbar-muted);
  font-size: 12px;
}
.global-search:focus-within {
  border-color: var(--brand);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.global-search i.ti { font-size: 14px; margin-right: 6px; }
.global-search input {
  background: transparent; border: 0; outline: 0; flex: 1;
  font: inherit; color: var(--topbar-text);
}
.global-search input::placeholder { color: var(--topbar-muted); }
.global-search .kbd {
  background: var(--surface);
  border: 1px solid var(--topbar-border);
  border-radius: 0;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--topbar-muted);
}
.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 28px; height: 28px;
  border: 0; background: transparent;
  border-radius: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--topbar-muted);
  position: relative;
}
.icon-btn:hover { background: var(--topbar-hover); color: var(--topbar-text); }
.icon-btn i.ti { font-size: 16px; }
.icon-btn .badge-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; background: #ef4444; border-radius: 50%;
  border: 1.5px solid var(--topbar-bg);
}
.menu-toggle { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 0;
  border: 0; background: none; /* the default <button> outset border was the black box */
  cursor: pointer;
  color: var(--topbar-text);
  text-decoration: none;
}
.user-chip:hover { background: var(--topbar-hover); text-decoration: none; }
.user-chip .avatar {
  width: 24px; height: 24px;
  background: var(--brand); color: white;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 500;
}
.user-chip .name { font-size: 12px; }

/* Show focus outlines only for keyboard navigation, not after a mouse click —
 * keeps accessibility (keyboard users still get a visible ring) without the
 * hard box appearing around buttons/links/chips when clicked. */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible),
summary:focus:not(:focus-visible) { outline: none; }

/* The account-menu chip should never show a focus box, even on keyboard focus. */
.user-chip:focus, .user-chip:focus-visible { outline: none; box-shadow: none; }

/* === Module strip (blue, level-1 nav) === */
.modules {
  background: var(--modules-bg);
  color: var(--modules-text);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--modules-border);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}
.module {
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--modules-text);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.module.active {
  color: var(--modules-active);
  border-bottom-color: var(--modules-accent);
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
}
.module:hover:not(.active) {
  color: var(--modules-active);
  background: var(--modules-hover-bg);
  text-decoration: none;
}
.module i.ti { font-size: 14px; }
.module.module-end { margin-left: auto; }

.menu-backdrop {
  display: none;
  position: fixed; inset: 44px 0 0 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 39;
  opacity: 0;
  transition: opacity 180ms ease;
}
.menu-backdrop.visible { display: block; opacity: 1; }

/* === Page header === */
.page-head {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 10px;
}
.page-head h1 {
  margin: 0; font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
}
.page-head h1 i.ti { color: var(--brand); font-size: 18px; }
.page-head .meta { color: var(--muted); font-size: 11.5px; }
.page-head-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0;
  font-size: 12px;
  color: var(--text);
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none;
}
.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  text-decoration: none;
}
.btn i.ti { font-size: 14px; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand-2); }
.btn.primary:hover { background: var(--brand-2); }
.btn.full { width: 100%; justify-content: center; }

/* === Sub-tabs === */
.subtabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex; gap: 0;
  /* Keep overflow-x so too-many-tabs can still scroll via trackpad/wheel,
   * but hide the visible scrollbar — it leaked into view on browsers with
   * "always show scrollbars" set, and the strip rarely overflows in
   * practice. Accessibility note: keyboard users can still Tab through
   * off-screen items. */
  overflow-x: auto;
  scrollbar-width: none;          /* Firefox */
  -ms-overflow-style: none;       /* old Edge / IE11 */
}
.subtabs::-webkit-scrollbar { display: none; }  /* Chrome / Safari */
.subtab {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  text-decoration: none;
}
.subtab.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 500; }
.subtab:hover:not(.active) { color: var(--text); text-decoration: none; }
.subtab.subtab-end { margin-left: auto; color: var(--brand); }
.subtab-count {
  display: inline-block;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 0;
  margin-left: 4px;
  vertical-align: 1px;
}
.subtab.active .subtab-count { background: var(--brand-bg); color: var(--brand-3); }

/* Activity rows — used in the rail card and on the Activity sub-tab */
.activity-list {
  display: flex;
  flex-direction: column;
}
.activity-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 8px 12px;
  border-bottom: 1px dotted var(--surface-3);
  font-size: 12.5px;
  line-height: 1.5;
}
.activity-row:last-child { border-bottom: 0; }
.activity-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  font-size: 10px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.activity-text { color: var(--text); word-break: break-word; }
.activity-text strong { font-weight: 500; }
.activity-time { color: var(--tertiary); font-size: 11px; white-space: nowrap; }
.activity-more {
  text-align: center;
  padding: 8px 0 10px;
  border-top: 1px dotted var(--surface-3);
}
.activity-more a { font-size: 12px; color: var(--brand); }

.activity-list-full .activity-row { padding: 10px 14px; font-size: 13px; }
.activity-text .verb { color: var(--muted); }

/* === M1.4.7 — field-change diff sub-block + post sub-block === */
.diff-block,
.post-block {
  margin: 6px 0 2px 0;
  padding: 6px 10px 6px 12px;
  background: #fafbfc;
  border-radius: 0;
}
.diff-block { border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.post-block { border-left: 2px solid var(--brand); font-size: 13px; color: var(--text); white-space: pre-wrap; line-height: 1.45; }
.diff-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.diff-label {
  color: var(--muted); font-weight: 500;
  min-width: 120px; flex-shrink: 0; text-align: right;
}
.diff-old, .diff-new {
  padding: 1px 6px; border-radius: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.diff-old { background: var(--danger-bg); color: var(--danger); text-decoration: line-through; text-decoration-color: rgba(185,28,28,.45); }
.diff-new { background: var(--success-bg); color: var(--success); }
.diff-arrow { color: var(--tertiary); font-size: 11px; }
.diff-empty { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--tertiary); font-size: 11.5px; }

/* === Restore button (hover-revealed on field_change rows) === */
.activity-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.restore-form { margin: 0; }
.activity-row .restore-btn {
  visibility: hidden;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted);
  background: transparent; border: 1px solid transparent; border-radius: 0;
  padding: 2px 7px; cursor: pointer;
  font-family: inherit;
}
.activity-row:hover .restore-btn { visibility: visible; }
.restore-btn:hover { background: var(--warn-bg); border-color: #fde68a; color: var(--warn); }
.restore-btn i { font-size: 13px; }

/* === Restored-from footer line on restore events === */
.restored-from {
  margin-top: 4px; font-size: 11.5px; color: var(--muted);
  display: flex; align-items: center; gap: 5px;
}
.restored-from i { font-size: 12px; color: var(--warn); }

.card-head-count {
  display: inline-block;
  background: var(--brand-bg);
  color: var(--brand-3);
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 0;
  margin-left: 6px;
  vertical-align: 1px;
}

/* === Main content area === */
.main { padding: 14px 16px 16px; }

/* === KPI strip === */
.kpis {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 10px 9px;
  border-top: 3px solid var(--border-strong);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 90ms ease, border-color 90ms ease, box-shadow 90ms ease;
}
.kpi:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
  border-color: var(--border-strong);
}
.kpi.k-blue   { border-top-color: var(--brand); }
.kpi.k-teal   { border-top-color: var(--teal); }
.kpi.k-amber  { border-top-color: var(--warn); }
.kpi.k-purple { border-top-color: var(--purple); }
.kpi.k-red    { border-top-color: var(--danger); }
.kpi.k-green  { border-top-color: var(--success); }
.kpi.k-indigo { border-top-color: var(--indigo); }
.kpi.k-slate  { border-top-color: #475569; }
.kpi-label {
  font-size: 10.5px; color: var(--muted);
  display: flex; align-items: center; gap: 4px;
  font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kpi-label i.ti { font-size: 13px; }
.kpi.k-blue   .kpi-label i.ti { color: var(--brand); }
.kpi.k-teal   .kpi-label i.ti { color: var(--teal); }
.kpi.k-amber  .kpi-label i.ti { color: var(--warn); }
.kpi.k-purple .kpi-label i.ti { color: var(--purple); }
.kpi.k-red    .kpi-label i.ti { color: var(--danger); }
.kpi.k-green  .kpi-label i.ti { color: var(--success); }
.kpi.k-indigo .kpi-label i.ti { color: var(--indigo); }
.kpi-value { font-size: 19px; font-weight: 500; margin: 3px 0 1px; color: var(--text); }
.kpi-delta { font-size: 10.5px; color: var(--tertiary); }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

/* === Cards & grids === */
.grid { display: grid; gap: 12px; }
.grid.three { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr) minmax(0, 1fr); }
.grid.two   { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Reusable responsive card layout — cards sit side by side and wrap below
 * when there isn't room. Standard across tabbed pages (account, integration,
 * and future). Each direct child is a .card-col (can hold a card + related
 * rows). The 3-class override below intentionally beats page-scoped
 * `.scope .card { max-width/margin }` rules regardless of source order. */
.card-grid { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
/* Standard 550px cards on full-width pages: fixed size, side by side, wrapping
 * below when two don't fit; shrink only on viewports narrower than the card. */
.card-grid > .card-col { flex: 0 1 550px; max-width: 550px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.card-grid .card-col > .card { max-width: none; margin-bottom: 0; }

/* Country-access card chrome (reusable partial: account + admin pages). */
.acc-card .card-h { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.acc-card .card-h .badge { margin-left: auto; }
.acc-card .card-b { padding: 16px; }
.acc-card .card-f { display: flex; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.acc-card .fld label { display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: 5px; }
.acc-card .hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.acc-card .badge { font: 700 11px/1 inherit; padding: 4px 8px; }
.acc-card .badge.on { color: var(--success); background: var(--success-bg); }
.acc-card .badge.off { color: var(--muted); background: var(--surface-3); }
.acc-card .ok { color: var(--success); font-weight: 600; }
.acc-card .fail { color: var(--danger); font-weight: 600; }
/* Country chips / mode segmented / scope tag — global so account + admin share. */
.ca-seg { display: inline-flex; border: 1px solid var(--border-strong); }
.ca-seg label { padding: 8px 14px; font: 600 13px/1 inherit; cursor: pointer; color: var(--muted); border-right: 1px solid var(--border-strong); display: flex; align-items: center; gap: 6px; }
.ca-seg label:last-child { border-right: 0; }
.ca-seg label.on { background: var(--brand); color: #fff; }
.ca-seg input { display: none; }
.ca-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ca-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface-2); padding: 4px 8px; font-size: 12.5px; }
.ca-chip .ca-x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 15px; line-height: 1; padding: 0; }
.ca-tag { font: 700 10px/1 inherit; letter-spacing: .04em; text-transform: uppercase; padding: 3px 7px; background: var(--purple-bg); color: var(--purple); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  overflow: hidden;
}
.card-head {
  padding: 9px 12px;
  border-bottom: 1px solid var(--surface-3);
  background: var(--surface);
  display: flex; align-items: center; gap: 8px;
}
.card-head h3 {
  margin: 0; font-size: 11.5px;
  color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  display: inline-flex; align-items: center; gap: 5px;
}
.card-head h3 i.ti { color: var(--brand); font-size: 13px; }
.card-head .count {
  color: var(--tertiary); font-size: 11px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
}
.card-head .link { margin-left: auto; font-size: 11px; color: var(--brand); }
/* Any action button in a card-head (e.g. "+ New contact" on relation sub-tabs)
 * also gets pushed to the right edge so the head is "title left, action right". */
.card-head .btn { margin-left: auto; }
.card-body { padding: 10px 12px; }
.card-body.tight { padding: 0; }
.card-foot {
  padding: 6px 12px;
  border-top: 1px solid var(--surface-3);
  background: var(--surface-2);
  font-size: 11px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}

/* === Tables (records) === */
table.records { width: 100%; font-size: 12px; }
table.records th {
  text-align: left;
  padding: 7px 10px;
  color: var(--muted); font-weight: 500; font-size: 11px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.03em;
}
table.records td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--surface-3);
  vertical-align: top;
}
table.records tr:last-child td { border-bottom: 0; }
table.records tr:hover td { background: #f8fafc; }
.empty-state {
  padding: 24px 12px;
  text-align: center;
  color: var(--tertiary);
  font-style: italic;
  font-size: 12px;
}
.empty-state i.ti {
  font-size: 20px; display: block; margin: 0 auto 5px;
  color: var(--border-strong);
}

/* === Activity feed === */
.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex; gap: 9px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--surface-3);
  font-size: 12px;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: #f8fafc; }
.feed-icon {
  width: 24px; height: 24px;
  border-radius: 0;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.feed-icon.blue   { background: var(--brand-bg); color: var(--brand-3); }
.feed-icon.green  { background: var(--success-bg); color: var(--success); }
.feed-icon.purple { background: var(--purple-bg); color: var(--purple); }
.feed-icon.amber  { background: var(--warn-bg); color: var(--warn); }
.feed-icon i.ti { font-size: 14px; }
.feed-body { flex: 1; min-width: 0; }
.feed-time { color: var(--tertiary); font-size: 10.5px; margin-top: 1px; }

/* === Pipeline === */
.pipeline {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  padding: 4px 0 0;
}
.pipeline-stage {
  background: var(--surface-2);
  border-radius: 0;
  padding: 9px 10px;
  border-top: 3px solid var(--border-strong);
}
.pipeline-stage.s1 { border-top-color: #0d9488; background: #f0fdfa; }
.pipeline-stage.s2 { border-top-color: var(--brand); background: #eff6ff; }
.pipeline-stage.s3 { border-top-color: var(--indigo); background: #eef2ff; }
.pipeline-stage.s4 { border-top-color: #f59e0b; background: #fffbeb; }
.pipeline-stage.s5 { border-top-color: #fb923c; background: #fff7ed; }
.pipeline-stage.s6 { border-top-color: #ec4899; background: #fdf2f8; }
.pipeline-stage.s7 { border-top-color: var(--success); background: #f0fdf4; }
.pipeline-label {
  font-size: 10.5px; color: var(--muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.pipeline-value { font-size: 14px; font-weight: 500; margin-top: 2px; color: var(--text); }
.pipeline-count { font-size: 10.5px; color: var(--tertiary); }

/* === Quick add === */
.quick-add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 2px 0; }

/* === Calendar mini === */
.cal-head {
  font-size: 11px; color: var(--muted);
  margin-bottom: 8px;
  display: flex; justify-content: space-between;
}
.cal-list { display: flex; flex-direction: column; gap: 6px; }
.cal-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 9px;
  background: var(--surface-2);
  border-left: 3px solid var(--brand);
  border-radius: 0;
  font-size: 11.5px;
}
.cal-item.empty { border-left-color: var(--border); opacity: 0.7; }
.cal-time { color: var(--brand); font-weight: 500; font-size: 10.5px; min-width: 50px; }
.cal-title { color: var(--text); }
.cal-meta { color: var(--tertiary); font-size: 10.5px; }

/* === Saved searches === */
.ss-list { display: flex; flex-direction: column; }
.ss-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--surface-3);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
}
.ss-item:hover { background: var(--surface-2); text-decoration: none; }
.ss-item:last-child { border-bottom: 0; }
.ss-item .ss-meta {
  color: var(--muted); font-size: 10.5px;
  background: var(--surface-2);
  padding: 1px 8px; border-radius: 0;
}
.ss-item:hover .ss-meta { background: var(--surface); }

/* === Status bar (footer, dark) === */
.statusbar {
  margin-top: auto; /* sticky footer: sits at viewport bottom when content is short */
  background: var(--statusbar-bg);
  color: var(--statusbar-text);
  border-top: 1px solid #0b1220;
  padding: 7px 16px;
  font-size: 10.5px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
}
.statusbar a { color: var(--statusbar-link); }
.statusbar i.ti { font-size: 12px; vertical-align: -2px; margin-right: 3px; color: var(--topbar-muted); }
.statusbar .dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.18);
  margin-right: 6px;
}

/* === Auth (login) page === */
body.centered {
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  width: 100%; max-width: 420px;
  padding: 2rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}
.auth-brand {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 1.25rem;
  font-weight: 500;
}
.auth-card h1 { margin: 0 0 .25rem; font-size: 1.35rem; letter-spacing: -.02em; }
.auth-card form { margin-top: 1.25rem; }
.auth-card label { display: block; margin: .85rem 0 .35rem; font-weight: 500; }
.auth-card input[type=text],
.auth-card input[type=email],
.auth-card input[type=password] {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 0;
  font: inherit;
  background: #fff;
  color: inherit;
}
.auth-card input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}
.auth-card .error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: 0;
  padding: .65rem .8rem;
  margin: .75rem 0 0;
  font-size: 13px;
}
.auth-card button.primary {
  margin-top: 1.25rem;
  width: 100%;
  padding: .65rem 1rem;
  border: 0;
  border-radius: 0;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.auth-card button.primary:hover { background: var(--brand-2); }

/* === Responsive === */
@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1100px) {
  .grid.three { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid.two   { grid-template-columns: 1fr; }
}
@media (max-width: 900px)  { .pipeline { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Below 1024px — collapse module nav into a right-side drawer */
@media (max-width: 1024px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .global-search { width: 220px; }
  .page-head { padding: 9px 12px; }
  .main { padding: 12px; }

  .menu-toggle { display: inline-flex; color: var(--topbar-text); }
  .menu-toggle:hover { background: var(--topbar-hover); }

  .modules {
    position: fixed;
    top: 44px; right: 0; bottom: 0; left: auto;
    width: 280px; max-width: 85vw;
    flex-direction: column;
    align-items: stretch;
    padding: 6px 0;
    overflow-y: auto;
    overflow-x: hidden;
    transform: translateX(100%);
    transition: transform 240ms ease;
    z-index: 40;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.22);
  }
  .modules.mobile-open { transform: translateX(0); }
  .module {
    padding: 12px 16px;
    font-size: 13.5px;
    border-bottom: 1px solid var(--modules-border);
    gap: 12px;
    white-space: normal;
    border-left: 3px solid transparent;
  }
  .module i.ti { font-size: 16px; width: 18px; text-align: center; }
  .module.active {
    background: rgba(255, 255, 255, 0.08);
    border-left-color: var(--modules-accent);
    padding-left: 13px;
  }
  .module.module-end { margin-left: 0; }
}

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: 1fr; }
  .brand-text { display: none; }
  .topbar-spacer { display: none; }
  .topbar-actions { flex: 1; }
  .global-search { width: auto; flex: 1; padding: 5px 8px; margin-right: 0; }
  .global-search .kbd { display: none; }
  .global-search input { font-size: 12px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; row-gap: 4px; }
  .page-head h1 { font-size: 14px; flex: 0 0 auto; }
  .page-head .meta { flex: 1 0 100%; order: 3; font-size: 11px; margin: 0; }
  .page-head-actions { margin-left: auto; flex: 0 0 auto; }
  .page-head-actions .btn { padding: 5px 8px; }
  .page-head-actions .btn-text { display: none; }
  .page-head-actions .btn i.ti { margin: 0; }
  .subtab { padding: 7px 10px; font-size: 11.5px; }
  .statusbar { flex-wrap: wrap; row-gap: 4px; padding: 7px 12px; }
}

@media (max-width: 480px) {
  .icon-btn { width: 26px; height: 26px; }
  .user-chip .name { display: none; }
  .user-chip { padding: 4px 6px; }
  .page-head h1 i.ti { font-size: 16px; }
  .card-head { background: var(--surface); }
  .kpi-value { font-size: 17px; }
  .kpi-label { font-size: 10px; }
  .quick-add { grid-template-columns: 1fr; }
}

/* === List view === */
.list-toolbar {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.list-search {
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 10px;
  flex: 1; max-width: 380px;
  position: relative;
}
.list-search:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.list-search i.ti { font-size: 14px; color: var(--muted); margin-right: 6px; }
.list-search input {
  border: 0; outline: 0; background: transparent;
  font: inherit; flex: 1; color: var(--text);
}
.list-search-clear {
  position: absolute; right: 8px;
  color: var(--tertiary); display: inline-flex;
  align-items: center; justify-content: center;
  padding: 2px;
}
.list-search-clear:hover { color: var(--muted); text-decoration: none; }
.list-toolbar-right { display: flex; gap: 6px; margin-left: auto; }
.list-toolbar-right .btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.list-card { overflow: hidden; }
.list-table th .sort-link {
  color: var(--muted); text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.list-table th .sort-link:hover { color: var(--text); text-decoration: none; }
.list-table .check-col { width: 32px; text-align: center; }
.list-table .check-col input[type=checkbox] {
  vertical-align: middle; margin: 0;
}
.cell-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 0;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.muted-cell { color: var(--tertiary); }
.rec-link { color: var(--brand); text-decoration: none; }
.rec-link:hover { color: var(--brand-2); text-decoration: underline; }

/* === Pagination === */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 0 4px;
  flex-wrap: wrap;
}
.pagination-meta { color: var(--muted); font-size: 12px; }
.pagination-buttons { display: flex; align-items: center; gap: 8px; }
.pagination-pages { font-size: 12px; color: var(--muted); }
.btn.disabled { opacity: 0.4; pointer-events: none; }

/* === Detail view === */
.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 0;
}
.field-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dotted var(--surface-3);
  font-size: 12.5px;
}
.field-row:last-child { border-bottom: 0; }
.field-label {
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10.5px;
  padding-top: 2px;
}

/* === Forms (M1.2) === */
.form-section { margin-bottom: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}
.form-field { display: flex; flex-direction: column; min-width: 0; }
.form-field-half { grid-column: span 1; }
.form-field-full { grid-column: 1 / -1; }

.form-label {
  display: block;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10.5px;
  margin-bottom: 4px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 10px;
  height: 32px;
  line-height: 1.3;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.form-textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 64px; }
.form-select { padding-right: 28px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}
.form-input.has-error, .form-select.has-error, .form-textarea.has-error {
  border-color: var(--danger);
  background-color: #fff8f8;
}
.form-input.has-error:focus, .form-select.has-error:focus, .form-textarea.has-error:focus {
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.16);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--tertiary); }

.form-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  height: 32px;
}
.form-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}

.form-currency-group {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 8px;
}
.form-currency-select { padding-right: 24px; }
.form-currency-input { text-align: right; }

.form-error {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--danger);
  font-size: 11.5px;
  margin-top: 4px;
}
.form-error .ti { font-size: 13px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 0 4px;
}

/* Flash banners */
.flash-stack {
  padding: 10px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 0;
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-banner .ti { font-size: 16px; }
.flash-success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border-color: #fecaca; }
.flash-warn    { background: var(--warn-bg);    color: var(--warn);    border-color: #fde68a; }
.flash-info    { background: var(--brand-bg);   color: var(--brand-3); border-color: #bfdbfe; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-field-half, .form-field-full { grid-column: 1 / -1; }
  .form-currency-group { grid-template-columns: 70px 1fr; }
  .flash-stack { padding: 10px 14px 0; }
}
.field-value { color: var(--text); word-break: break-word; }

/* Two-column field grid for record General card.
 * Used inside .shell-main on detail views.
 */
.field-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  row-gap: 0;
}
.field-grid-two .field-row { padding: 7px 0; }
@media (max-width: 1024px) {
  .field-grid-two { grid-template-columns: 1fr; }
}

/* Rail-card variants: tighter labels since System lives in 320px column */
.shell-rail .field-row { grid-template-columns: 110px 1fr; }
.shell-rail .field-row .field-value { font-size: 12px; }

/* === M1.5.8 Phase D — inline-edit polish ================================ */
/* Hover hint: subtle background + a pencil glyph at the right edge so the
 * user knows a card's fields are editable. The pencil itself isn't a
 * click target (entering edit mode is via the card-head Edit button),
 * but the visual cue invites the action. */
.card .field-row { position: relative; }
.card .card-head .btn:has(.ti-edit) { opacity: 0.7; transition: opacity .12s; }
.card:hover .card-head .btn:has(.ti-edit) { opacity: 1; }
.card .field-row::after {
  content: '\ea84'; /* ti-edit codepoint */
  font-family: 'tabler-icons';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--brand);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.card .card-body:hover .field-row:hover::after {
  /* Only show when we're hovering an individual row, not the whole body. */
  opacity: 0.55;
}
/* Hide hint while a card is already in edit mode. */
.card-editing .field-row::after,
form.card-editing .field-row::after { display: none; }
/* And on the SYSTEM rail's read-only-ish fields, suppress the hint too. */
.rail-card-system .field-row::after { display: none; }
.rail-card-activity .activity-row::after { display: none; }

/* === M1.5.8 Phase D — concurrent-edit conflict banner ==================== */
.dup-conflict-banner {
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
  color: #7c2d12;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
}

/* === M1.4 — Admin module shell, sidebar, role matrix ===================== */
.admin-with-sidebar {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  min-height: calc(100vh - 44px - 36px - 28px); /* topbar - modules - statusbar */
}
.admin-sidebar {
  background: var(--dark-bg);
  color: var(--dark-text);
  padding: 12px 0;
}
.admin-sidebar-header {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dark-mute);
  padding: 8px 16px 4px;
}
.admin-sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  color: var(--dark-text);
  font-size: 13px;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.admin-sidebar-item i.ti { font-size: 14px; }
.admin-sidebar-item:hover { background: rgba(255,255,255,0.04); color: #ffffff; }
.admin-sidebar-item.is-active {
  background: var(--brand);
  color: #ffffff;
  border-left-color: #60a5fa;
}
.admin-sidebar-item.is-disabled {
  color: #64748b;
  pointer-events: none;
}
.admin-sidebar-tag {
  margin-left: auto;
  font-size: 9.5px;
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 0;
}
.admin-content { min-width: 0; background: var(--bg); }

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 16px;
}
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 0;
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: border-color 120ms, transform 120ms;
}
.admin-card:hover { border-color: var(--border); transform: translateY(-1px); text-decoration: none; }
.admin-card h3 { font-size: 15px; font-weight: 500; margin: 8px 0 4px; color: var(--text); }
.admin-card p  { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.55; }
.admin-card-icon { font-size: 24px; color: var(--brand); }
.admin-card-count { color: var(--muted); font-weight: 400; font-size: 13.5px; margin-left: 4px; }
.admin-card-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  background: var(--surface-3);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 0;
}
.admin-card-disabled { color: var(--muted); cursor: default; }
.admin-card-disabled:hover { transform: none; }
.admin-card-disabled .admin-card-icon { color: var(--tertiary); }

/* === Role matrix table ============================================== */
.acl-matrix th, .acl-matrix td { padding: 6px 10px; }
.acl-matrix .acl-scope {
  font: inherit;
  font-size: 11.5px;
  padding: 3px 22px 3px 8px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  cursor: pointer;
}
.acl-scope-all    { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.acl-scope-team   { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.acl-scope-shared { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.acl-scope-own    { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.acl-scope-none   { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

/* Stream composer (M1.4 Phase B) */
.stream-composer {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-2);
  background: var(--surface-2);
  align-items: start;
}
.composer-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--teal);
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stream-composer textarea {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 6px 10px;
  resize: vertical;
  min-height: 32px;
  outline: none;
}
.stream-composer textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.18);
}

/* Access multi-select page (M1.4 Phase B) */
.access-section { padding: 14px 0; }
.access-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 8px;
}
.access-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 6px;
}
.access-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  font-size: 13px;
  cursor: pointer;
}
.access-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}
.access-check:has(input:checked) {
  background: var(--brand-bg);
  border-color: var(--brand);
}
.access-check .desc {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 1024px) {
  .admin-with-sidebar { grid-template-columns: 1fr; }
  .admin-sidebar {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 6px 0;
  }
  .admin-sidebar-header { display: none; }
  .admin-sidebar-item {
    padding: 8px 14px;
    border-left: 0;
    border-bottom: 3px solid transparent;
    flex-shrink: 0;
  }
  .admin-sidebar-item.is-active {
    border-left: 0;
    border-bottom-color: #60a5fa;
  }
  .admin-grid { grid-template-columns: 1fr 1fr; }
}

/* === M1.3.5 — list view filter panel + chips ============================= */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 0;
  margin-bottom: 10px;
  font-size: 12.5px;
}
.filter-chips i.ti { color: var(--brand-3); font-size: 14px; }
.filter-chips-label { color: var(--muted); font-size: 11.5px; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--brand-bg);
  color: var(--brand-3);
  padding: 3px 4px 3px 10px;
  border-radius: 0;
  font-size: 11.5px;
}
.filter-chip .chip-field { font-weight: 500; }
.filter-chip .chip-op    { font-style: italic; color: var(--brand-3); opacity: 0.85; }
.filter-chip .chip-val   { font-weight: 500; }
.filter-chip .chip-rm    { color: var(--brand-3); padding: 2px 4px; border-radius: 0; display: inline-flex; }
.filter-chip .chip-rm:hover { background: rgba(30, 64, 175, 0.16); text-decoration: none; }
.filter-chips-match { margin-left: auto; color: var(--muted); font-size: 11.5px; }
.filter-chips-clear { font-size: 11.5px; color: var(--muted); padding-left: 8px; border-left: 1px solid var(--border); }
.filter-chips-clear:hover { color: var(--danger); }

.subtab-view { color: var(--muted); }
.subtab-view i.ti { color: var(--muted); }
.subtab-view.active i.ti { color: var(--brand); }

.list-with-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: start;
}
.list-with-panel.panel-open {
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
}
.list-area { min-width: 0; }
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 14px 16px;
  min-width: 0;
  display: none;
}
.list-with-panel.panel-open .filter-panel { display: block; }

.filter-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 13px;
}
.filter-panel-head i.ti { color: var(--brand); font-size: 16px; }
.filter-panel-title { font-weight: 600; color: var(--text); font-size: 13px; }
.filter-panel-count {
  background: var(--brand-bg);
  color: var(--brand-3);
  font-size: 10.5px;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 0;
}
.filter-panel-close {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 2px;
  border-radius: 0;
}
.filter-panel-close:hover { background: var(--surface-3); color: var(--text); }

.filter-form { display: flex; flex-direction: column; gap: 8px; }
.filter-label {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === Entity Manager — new entity form (M1.5 B.2a) === */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.form-row input[type=text], .form-row input[type=number], .form-row select, .form-row textarea {
  padding: 6px 9px; border: 1px solid var(--border); border-radius: 0; font: inherit; background: #fff; color: var(--text);
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  border-color: var(--brand); outline: 0; box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-row .hint { font-size: 11px; color: var(--tertiary); }
.form-row .field-error { font-size: 11px; color: var(--danger); margin-top: 1px; }
.form-row.has-error input, .form-row.has-error select, .form-row.has-error textarea { border-color: var(--danger); }
.form-row-check { flex-direction: row; align-items: center; gap: 8px; }
.form-row-check input { width: auto; }
.form-row-check label { font-size: 13px; color: var(--text); margin: 0; }

.icon-selected-pill {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 0;
}
.icon-selected-pill .icon-preview {
  width: 36px; height: 36px; border-radius: 0;
  background: var(--brand-bg); color: var(--brand-3);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-selected-pill .icon-preview i { font-size: 20px; }
.icon-selected-pill .meta { display: flex; flex-direction: column; line-height: 1.2; }
.icon-selected-pill .meta .code { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--muted); }
.icon-selected-pill .meta .name { font-size: 13px; color: var(--text); }

.color-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.color-picker .color-chip {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
  cursor: pointer; padding: 0;
}
.color-picker .color-chip.is-on { box-shadow: 0 0 0 2px var(--brand); }

/* === Token input (multi-select with chip pills + autocomplete) === */
.token-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 8px; min-height: 36px;
  background: #fff; border: 1px solid var(--border); border-radius: 0;
  cursor: text;
}
.token-input:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.token-input.has-error { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.10); }
.token {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--brand-bg); color: var(--brand-3);
  padding: 2px 4px 2px 8px; border-radius: 0;
  font-size: 12px; font-weight: 500;
}
.token .ttype {
  color: var(--brand); opacity: .7; font-weight: 400;
  font-size: 10.5px; margin-left: 3px;
}
.token .token-remove {
  background: transparent; border: 0; color: var(--brand-3);
  cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1;
  border-radius: 0;
}
.token .token-remove:hover { background: rgba(37,99,235,.18); }
.token-input input {
  flex: 1; min-width: 120px;
  border: 0; outline: 0; background: transparent; font: inherit; color: var(--text);
  padding: 2px 0;
}
.token-suggest {
  margin-top: 2px; background: #fff;
  border: 1px solid var(--border); border-radius: 0;
  box-shadow: 0 8px 24px rgba(15,23,42,.08);
  max-height: 200px; overflow-y: auto;
}
.token-suggest .opt {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 12.5px;
}
.token-suggest .opt:hover, .token-suggest .opt.active { background: var(--surface-2); }
.token-suggest .opt code { font-size: 11px; color: var(--muted); }
.token-suggest .opt .ttype { color: var(--tertiary); font-size: 11px; margin-left: auto; }

/* === Icon picker modal (native <dialog>) === */
.modal-pick-dialog {
  width: 680px; max-width: 92vw; padding: 0;
  border: 1px solid var(--border); border-radius: 0;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
  background: #fff; color: var(--text);
}
.modal-pick-dialog::backdrop { background: rgba(15,23,42,.55); }
.modal-pick-dialog .modal-pick-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-pick-dialog .modal-pick-head h3 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; }
.modal-pick-dialog .modal-pick-head h3 i { color: var(--muted); margin-right: 4px; }
.modal-pick-dialog .modal-pick-head .close {
  background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: 18px;
}
.modal-pick-dialog .modal-pick-search {
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.modal-pick-dialog .modal-pick-search input {
  width: 100%; padding: 7px 12px; border: 1px solid var(--border); border-radius: 0;
  font: inherit; background: #fff;
}
.modal-pick-dialog .modal-pick-body { padding: 14px 16px; max-height: 380px; overflow-y: auto; }
.modal-pick-dialog .modal-pick-group {
  font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  margin: 0 0 8px; font-weight: 600;
}
.modal-pick-dialog .icon-picker {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px;
}
.modal-pick-dialog .icon-cell {
  aspect-ratio: 1; border: 1px solid var(--border); border-radius: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); background: #fff; cursor: pointer;
}
.modal-pick-dialog .icon-cell:hover { background: var(--surface-2); }
.modal-pick-dialog .icon-cell.selected {
  background: var(--brand-bg); border-color: var(--brand); color: var(--brand-3);
  box-shadow: 0 0 0 1px var(--brand);
}
.modal-pick-dialog .icon-cell i { font-size: 18px; }
.modal-pick-dialog .modal-pick-foot {
  padding: 10px 16px; border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; gap: 6px; justify-content: flex-end;
}

.filter-quick {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--surface-2);
  border-radius: 0;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.filter-quick-list {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.filter-quick-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 2px 9px;
  font-size: 11.5px; font-weight: 500;
  color: var(--text);
  text-decoration: none;
}
.filter-quick-chip:hover { background: var(--surface-3); text-decoration: none; }
.filter-quick-chip.is-on {
  background: var(--brand-bg);
  border-color: var(--brand);
  color: var(--brand-3);
}
.filter-quick-chip-view { color: var(--brand); border-style: dashed; }

.filter-match {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border-radius: 0;
  padding: 8px 10px;
}
.filter-match-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 1px;
}
.filter-match-btn {
  background: transparent;
  border: 0;
  padding: 3px 11px;
  font-size: 12px;
  color: var(--muted);
  border-radius: 0;
  cursor: pointer;
}
.filter-match-btn.is-on { background: var(--brand); color: #ffffff; }
.filter-match-hint { font-size: 11px; color: var(--tertiary); }

.filter-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.filter-rule-empty {
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 0;
  padding: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--tertiary);
}
.filter-rule {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}
.filter-rule-head {
  display: flex;
  align-items: center;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}
.filter-rule-head .filter-rule-remove {
  margin-left: auto;
  background: transparent;
  border: 0;
  padding: 2px 4px;
  color: var(--tertiary);
  cursor: pointer;
  border-radius: 0;
}
.filter-rule-head .filter-rule-remove:hover { background: var(--danger-bg); color: var(--danger); }
.filter-rule select,
.filter-rule input[type="text"],
.filter-rule input[type="number"],
.filter-rule input[type="date"] {
  width: 100%;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 5px 8px;
  height: 28px;
  box-sizing: border-box;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.filter-rule select:focus,
.filter-rule input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.18);
}

.filter-rule-twoval { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }

.filter-add-row { padding: 4px 0; }
.filter-add {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--brand-3);
  font-size: 12px;
  width: 100%;
  padding: 6px;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.filter-add:hover { background: var(--brand-bg); border-style: solid; border-color: var(--brand-bg); }

.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 6px;
}

.filter-save-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dotted var(--border-2);
}
.filter-save-form { display: flex; flex-direction: column; gap: 6px; }
.filter-save-form input[type="text"] {
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 5px 8px;
  height: 28px;
}

.filter-saved-views {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dotted var(--border-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-view-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.filter-view-link {
  flex: 1;
  padding: 5px 8px;
  border-radius: 0;
  font-size: 12.5px;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.filter-view-link i.ti { color: var(--muted); font-size: 13px; }
.filter-view-link:hover { background: var(--surface-3); text-decoration: none; }
.filter-view-link.is-active { background: var(--brand-bg); color: var(--brand-3); }
.filter-view-link.is-active i.ti { color: var(--brand-3); }
.filter-view-delete button {
  background: transparent;
  border: 0;
  color: var(--tertiary);
  cursor: pointer;
  padding: 4px;
  border-radius: 0;
}
.filter-view-delete button:hover { color: var(--danger); background: var(--danger-bg); }

@media (max-width: 1024px) {
  .list-with-panel.panel-open {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .filter-panel { order: -1; }
}