/* ==========================================================================
 * AgentDesk — design system v2 (preview).
 *
 * Loaded after styles.css, so it is the look and it wins: the portal takes the same system
 * as the TextBot and GPS Track portals. Inter for everything that is interface, six-to-eight
 * pixel controls and twelve-to-sixteen pixel surfaces, solid surfaces with one-pixel borders
 * and a barely-there shadow, sentence case at ordinary weight, teal spent on the primary
 * action and on what is selected. The side menu is a light panel floating on the page.
 *
 * AgentDesk's own tokens (--canvas, --surface, --ink …) are remapped below, so the many
 * screens styled through them follow without per-screen rules; components with their own
 * colours are restyled after that. Rules for new markup: no capsules on anything with text
 * in it, no uppercase, no letter tracking, no gradients on controls.
 * ======================================================================== */

:root {
  color-scheme: light;

  --ds-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ds-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ds-r-xs: 4px;
  --ds-r-sm: 6px;
  --ds-r-md: 8px;
  --ds-r-lg: 12px;
  --ds-r-xl: 14px;

  --ds-surface: #ffffff;
  --ds-surface-2: #f6f7f9;
  --ds-surface-3: #eef0f3;
  --ds-border: rgba(15, 23, 42, 0.08);
  --ds-border-strong: rgba(15, 23, 42, 0.14);
  --ds-text: #0f172a;
  --ds-text-2: #475569;
  --ds-text-3: #64748b;

  --ds-accent: #0f766e;
  --ds-accent-hover: #115e59;
  --ds-accent-soft: rgba(15, 118, 110, 0.09);
  --ds-accent-line: rgba(15, 118, 110, 0.32);
  --ds-accent-text: #0f766e;

  --ds-ok-bg: rgba(5, 150, 105, 0.1);
  --ds-ok-text: #047857;
  --ds-warn-bg: rgba(217, 119, 6, 0.12);
  --ds-warn-text: #b45309;
  --ds-danger-bg: rgba(225, 29, 72, 0.1);
  --ds-danger-text: #be123c;
  --ds-danger-line: rgba(225, 29, 72, 0.3);

  --ds-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --ds-shadow-md: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px -8px rgba(15, 23, 42, 0.1);
  --ds-shadow-lg: 0 20px 48px -16px rgba(15, 23, 42, 0.28);
  --ds-ring: 0 0 0 3px rgba(20, 184, 166, 0.2);

  --ds-bg-0: #f7faf8;
  --ds-bg-1: #eff6f2;
  --ds-bg-2: #e6f0eb;
  --ds-glow-1: rgba(15, 118, 110, 0.1);
  --ds-glow-2: rgba(20, 184, 166, 0.08);
  --ds-rail-bg: #ffffff;
  --ds-backdrop: rgba(2, 6, 23, 0.55);
  --ds-toast-bg: #0f172a;
  --ds-toast-text: #f8fafc;

  --rail-w: 296px;
  --rail-w-collapsed: 76px;
  --shell-pad: 20px;
  --page-pad: 16px;

  /* AgentDesk's tokens, on the shared palette. */
  --canvas: var(--ds-bg-0);
  --canvas-2: var(--ds-bg-1);
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef0f3;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: rgba(15, 23, 42, 0.08);
  --line-strong: rgba(15, 23, 42, 0.14);
  --line-soft: rgba(15, 23, 42, 0.05);
  --rail: #ffffff;
  --rail-2: #ffffff;
  --rail-text: #475569;
  --rail-muted: #64748b;
  --accent: #0f766e;
  --accent-2: #115e59;
  --accent-soft: rgba(15, 118, 110, 0.09);
  --accent-ring: rgba(20, 184, 166, 0.2);
  --blue: #0f766e;
  --blue-soft: rgba(15, 118, 110, 0.09);
  --amber: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --green: #047857;
  --green-soft: rgba(5, 150, 105, 0.1);
  --red: #be123c;
  --red-soft: rgba(225, 29, 72, 0.1);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px -8px rgba(15, 23, 42, 0.1);
  --shadow-strong: 0 20px 48px -16px rgba(15, 23, 42, 0.28);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 14px;
  --font-body: var(--ds-font);
  --font-display: var(--ds-font);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --ds-surface: #16191e;
  --ds-surface-2: rgba(255, 255, 255, 0.03);
  --ds-surface-3: rgba(255, 255, 255, 0.06);
  --ds-border: rgba(255, 255, 255, 0.07);
  --ds-border-strong: rgba(255, 255, 255, 0.12);
  --ds-text: #e8ebef;
  --ds-text-2: #a6afbb;
  --ds-text-3: #7f8995;

  --ds-accent: #0d9488;
  --ds-accent-hover: #0fa396;
  --ds-accent-soft: rgba(45, 212, 191, 0.1);
  --ds-accent-line: rgba(45, 212, 191, 0.3);
  --ds-accent-text: #5eead4;

  --ds-ok-bg: rgba(16, 185, 129, 0.14);
  --ds-ok-text: #34d399;
  --ds-warn-bg: rgba(245, 158, 11, 0.14);
  --ds-warn-text: #fbbf24;
  --ds-danger-bg: rgba(244, 63, 94, 0.14);
  --ds-danger-text: #fb7185;
  --ds-danger-line: rgba(251, 113, 133, 0.3);

  --ds-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --ds-shadow-md: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px -12px rgba(0, 0, 0, 0.45);
  --ds-shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, 0.65);
  --ds-ring: 0 0 0 3px rgba(45, 212, 191, 0.22);

  --ds-bg-0: #0e1114;
  --ds-bg-1: #15191e;
  --ds-bg-2: #1d2329;
  --ds-glow-1: rgba(112, 128, 144, 0.14);
  --ds-glow-2: rgba(52, 63, 73, 0.18);
  /* The rail keeps a slate of its own: the near-black of a surface was hard on the eyes there. */
  --ds-rail-bg: linear-gradient(180deg, rgba(27, 32, 38, 0.97), rgba(20, 24, 29, 0.95));
  --ds-backdrop: rgba(0, 0, 0, 0.62);
  --ds-toast-bg: #262b32;
  --ds-toast-text: #e8ebef;

  /* Solid steps for AgentDesk's tokens: its screens stack these, so no transparency here. */
  --canvas: var(--ds-bg-0);
  --canvas-2: var(--ds-bg-1);
  --surface: #16191e;
  --surface-2: #1c2025;
  --surface-3: #23272d;
  --ink: #e8ebef;
  --ink-2: #a6afbb;
  --muted: #7f8995;
  --muted-2: #5f6873;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --line-soft: rgba(255, 255, 255, 0.04);
  --rail: #1b2026;
  --rail-2: #1b2026;
  --rail-text: #a6afbb;
  --rail-muted: #7f8995;
  --accent: #0d9488;
  --accent-2: #0fa396;
  --accent-soft: rgba(45, 212, 191, 0.1);
  --accent-ring: rgba(45, 212, 191, 0.22);
  --blue: #5eead4;
  --blue-soft: rgba(45, 212, 191, 0.1);
  --amber: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --green: #34d399;
  --green-soft: rgba(16, 185, 129, 0.14);
  --red: #fb7185;
  --red-soft: rgba(244, 63, 94, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px -12px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 24px 60px -18px rgba(0, 0, 0, 0.65);
}

/* ---- base -------------------------------------------------------------------------- */

[hidden] {
  display: none !important;
}

body {
  color: var(--ds-text);
  font-family: var(--ds-font);
  font-size: 13.5px;
  font-feature-settings: "cv11", "ss01", "ss03";
  letter-spacing: -0.003em;
  background:
    radial-gradient(1200px 680px at 12% -5%, var(--ds-glow-1), transparent 58%),
    radial-gradient(860px 580px at 90% 0%, var(--ds-glow-2), transparent 58%),
    linear-gradient(165deg, var(--ds-bg-0), var(--ds-bg-1) 46%, var(--ds-bg-2));
  background-attachment: fixed;
}

h1,
h2,
h3 {
  color: var(--ds-text);
  font-family: var(--ds-font);
  font-weight: 600;
  letter-spacing: -0.012em;
}

p {
  color: var(--ds-text-3);
}

::selection {
  background: rgba(15, 118, 110, 0.22);
}

code {
  color: var(--ds-text);
  background: var(--ds-surface-3);
  border-radius: var(--ds-r-xs);
  font-family: var(--ds-mono);
  font-size: 12px;
}

/* Small words above a heading: the area, quietly, in the accent. */
.eyebrow {
  display: block;
  margin-bottom: 6px;
  color: var(--ds-accent-text);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* A field label names the field, quietly: no capitals, no tracking. */
label,
.workspace-head label,
.wiz-label {
  color: var(--ds-text-2);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.check-line,
.check-grid label,
.inline-check,
.toggle-row {
  color: var(--ds-text);
  font-size: 13.5px;
  font-weight: 450;
}

/* ---- buttons ----------------------------------------------------------------------- */

.primary,
.ghost,
.danger,
.tiny {
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--ds-r-md);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: -0.003em;
  box-shadow: var(--ds-shadow-sm);
}

.primary:hover,
.primary:active,
.ghost:hover,
.tiny:hover,
.danger:hover {
  transform: none;
}

.primary {
  color: #ffffff;
  background: var(--ds-accent);
  box-shadow: var(--ds-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.primary:hover:not(:disabled) {
  background: var(--ds-accent-hover);
  box-shadow: var(--ds-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.ghost,
.tiny {
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
  background: var(--ds-surface);
}

:root[data-theme="dark"] .ghost,
:root[data-theme="dark"] .tiny {
  background: rgba(255, 255, 255, 0.04);
}

.ghost:hover:not(:disabled),
.tiny:hover:not(:disabled) {
  border-color: var(--ds-border-strong);
  background: var(--ds-surface-3);
}

.tiny {
  padding: 4px 10px;
  border-radius: var(--ds-r-sm);
  font-size: 12.5px;
  line-height: 18px;
}

.danger,
.tiny.danger {
  border-color: var(--ds-danger-line);
  color: var(--ds-danger-text);
  background: transparent;
  box-shadow: none;
}

.danger:hover:not(:disabled),
.tiny.danger:hover:not(:disabled) {
  border-color: var(--ds-danger-line);
  background: var(--ds-danger-bg);
}

.primary svg,
.ghost svg,
.danger svg,
.tiny svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.mini-icon,
.icon-button {
  width: 32px;
  height: 32px;
  border: 1px solid transparent;
  border-radius: var(--ds-r-md);
  color: var(--ds-text-3);
  background: transparent;
  box-shadow: none;
}

.mini-icon:hover,
.icon-button:hover {
  border-color: transparent;
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ds-ring);
}

/* ---- fields ------------------------------------------------------------------------ */

input,
select,
textarea,
.toolbar-search,
.conversation-search {
  padding: 7px 10px;
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-r-md);
  color: var(--ds-text);
  background-color: var(--ds-surface);
  font-size: 13.5px;
  line-height: 20px;
  box-shadow: var(--ds-shadow-sm);
}

:root[data-theme="dark"] :is(input, select, textarea, .toolbar-search, .conversation-search) {
  background-color: rgba(255, 255, 255, 0.03);
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ds-border-strong);
}

input:focus,
select:focus,
textarea:focus,
.toolbar-search:focus,
.conversation-search:focus {
  border-color: var(--ds-accent-line);
  box-shadow: var(--ds-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--ds-text-3);
  opacity: 0.8;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  box-shadow: none;
  accent-color: var(--ds-accent);
}

select option,
select optgroup {
  color: #0f172a;
  background-color: #ffffff;
}

:root[data-theme="dark"] select option,
:root[data-theme="dark"] select optgroup {
  color: #e8ebef;
  background-color: #1a1e23;
}

.form-grid {
  gap: 14px 16px;
}

.field {
  gap: 6px;
}

/* ---- badges and chips -------------------------------------------------------------- */

/* A status or category mark. Four pixels: a label, never a capsule. */
.badge,
.status-pill,
.composer-channel,
.media-chip {
  gap: 5px;
  padding: 1px 7px;
  border: 0;
  border-radius: var(--ds-r-xs);
  color: var(--ds-text-2);
  background: var(--ds-surface-3);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 18px;
  text-transform: none;
}

.badge.good,
.badge.ok,
.status-pill {
  color: var(--ds-ok-text);
  background: var(--ds-ok-bg);
}

.badge.warn {
  color: var(--ds-warn-text);
  background: var(--ds-warn-bg);
  border: 0;
}

.badge.bad {
  color: var(--ds-danger-text);
  background: var(--ds-danger-bg);
  border: 0;
}

.badge.blue {
  color: var(--ds-accent-text);
  background: var(--ds-accent-soft);
  border: 0;
}

.status-pill i {
  width: 6px;
  height: 6px;
  background: currentColor;
}

.chip {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-sm);
  color: var(--ds-text-2);
  background: var(--ds-surface);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: none;
}

/* ---- the app shell ----------------------------------------------------------------- */

.app-frame {
  grid-template-columns: calc(var(--rail-w) + var(--shell-pad)) minmax(0, 1fr);
}

.app-frame.menu-collapsed {
  grid-template-columns: calc(var(--rail-w-collapsed) + var(--shell-pad)) minmax(0, 1fr);
}

/* The side menu: a solid panel with a hairline edge, floating on the page. */
.workspace-menu {
  top: var(--shell-pad);
  height: calc(100vh - 2 * var(--shell-pad));
  margin: var(--shell-pad) 0 var(--shell-pad) var(--shell-pad);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-xl);
  color: var(--ds-text);
  background: var(--ds-rail-bg);
  box-shadow: var(--ds-shadow-md);
}

.workspace-head {
  position: relative;
  padding: 26px 16px 14px;
  border-bottom: 1px solid var(--ds-border);
}

.menu-top {
  display: block;
}

.workspace-menu .logo-brand {
  width: auto;
  min-height: 0;
  margin: 0 0 18px;
  padding: 0 36px 0 8px;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.workspace-menu .brand-logo {
  width: auto;
  max-width: 100%;
  height: 42px;
  filter: none;
}

/* One lockup at a time: the light one, the reversed one in dark mode, the mark when collapsed. */
.brand .logo-dark,
.brand .logo-mark {
  display: none;
}

:root[data-theme="dark"] .brand .logo-light {
  display: none;
}

:root[data-theme="dark"] .brand .logo-dark {
  display: block;
}

.menu-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 32px;
  min-width: 32px;
  height: 32px;
  color: var(--ds-text-3);
  border: 1px solid transparent;
  border-radius: var(--ds-r-md);
  background: transparent;
}

.menu-toggle:hover {
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

.menu-toggle svg {
  width: 16px;
  height: 16px;
}

.workspace-picker {
  gap: 6px;
  padding: 0 8px;
}

.workspace-head label {
  color: var(--ds-text-3);
  font-size: 12px;
}

.tenant-select {
  color: var(--ds-text);
  border-color: var(--ds-border-strong);
  background-color: var(--ds-surface);
}

:root[data-theme="dark"] .tenant-select {
  background-color: rgba(255, 255, 255, 0.03);
}

.grouped-nav {
  padding: 10px 12px 12px;
  scrollbar-color: var(--ds-border-strong) transparent;
}

.grouped-nav::-webkit-scrollbar-thumb {
  background: var(--ds-border-strong) border-box;
}

.nav-section {
  display: block;
  margin-bottom: 1px;
}

/* A section header reads like a row of the menu: its icon, its name, a chevron. The section
   holding the page you are on is shown by its name brightening and its icon taking the accent. */
.nav-section-title {
  min-height: 38px;
  gap: 11px;
  padding: 0 10px;
  border-radius: var(--ds-r-md);
  color: var(--ds-text-2);
  background: transparent;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.003em;
  line-height: 1.2;
  text-transform: none;
}

.nav-section-title:hover {
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

.nav-section.has-active .nav-section-title {
  color: var(--ds-text);
  background: transparent;
}

.nav-section.has-active .nav-section-title:hover {
  background: var(--ds-surface-3);
}

.nav-section-title .section-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-section-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--ds-text-3);
}

.nav-section-title:hover .nav-section-icon {
  color: var(--ds-text-2);
}

.nav-section.has-active .nav-section-icon {
  color: var(--ds-accent-text);
}

.nav-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--ds-text-3);
  transition: transform 150ms ease;
}

.nav-section.open .nav-chevron {
  transform: rotate(180deg);
}

/* A section's pages, hung off a guide line rather than floating in an indent. */
.nav-section-body {
  gap: 1px;
  margin: 2px 0 6px 18px;
  padding-left: 9px;
  border-left: 1px solid var(--ds-border);
}

.nav-row {
  min-height: 30px;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ds-r-sm);
  color: var(--ds-text-2);
  background: transparent;
  font-size: 13px;
  font-weight: 450;
  letter-spacing: -0.003em;
}

.nav-row:hover {
  border-color: transparent;
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

.nav-row.active,
.nav-row.active:hover {
  color: var(--ds-text);
  border-color: transparent;
  background: var(--ds-surface-3);
  font-weight: 500;
}

.nav-row.active::before {
  top: 6px;
  bottom: 6px;
  left: -10px;
  width: 2px;
  border-radius: 2px;
  background: var(--ds-accent-text);
}

.nav-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  border-radius: 0;
  color: var(--ds-text-3);
  background: transparent;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}

.nav-row:hover .nav-icon {
  color: var(--ds-text-2);
  background: transparent;
}

.nav-row.active .nav-icon {
  color: var(--ds-accent-text);
  background: transparent;
}

.nav-row b {
  min-width: 0;
  padding: 0 6px;
  border-radius: var(--ds-r-xs);
  color: var(--ds-text-3);
  background: var(--ds-surface-3);
  font-size: 11px;
  font-weight: 500;
  line-height: 18px;
}

.nav-row.active b {
  color: var(--ds-text-2);
  background: var(--ds-surface);
}

.workspace-user {
  gap: 1px;
  padding: 6px 12px 12px;
  border-top: 1px solid var(--ds-border);
}

.workspace-account-row {
  order: 3;
  gap: 10px;
  margin-top: 6px;
  padding: 10px 10px 2px;
  border-top: 1px solid var(--ds-border);
}

.avatar.small {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  color: var(--ds-accent-text);
  background: var(--ds-accent-soft);
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
}

.workspace-user strong {
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 500;
}

.workspace-user span {
  max-width: 190px;
  color: var(--ds-text-3);
  font-size: 12px;
}

/* The foot of the menu: rows like the pages above them. */
.logout-button {
  justify-content: flex-start;
  min-height: 38px;
  gap: 11px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ds-r-md);
  color: var(--ds-text-2);
  background: transparent;
  font-size: 14.5px;
  font-weight: 500;
  letter-spacing: -0.003em;
}

.logout-button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--ds-text-3);
  stroke-width: 1.8;
}

.logout-button:hover {
  transform: none;
  color: var(--ds-text);
  border-color: transparent;
  background: var(--ds-surface-3);
}

.logout-button:hover svg {
  color: var(--ds-text-2);
}

.logout-button span {
  color: inherit;
  font-size: inherit;
}

.rail-theme {
  order: 1;
}

.workspace-user > .logout-button:not(.rail-theme) {
  order: 2;
}

.app-version {
  order: 4;
  padding: 4px 10px 0;
  color: var(--ds-text-3);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-align: left;
}

/* Collapsed: icons only, centred. */
.menu-collapsed .workspace-head {
  padding: 52px 8px 14px;
}

.menu-collapsed .menu-toggle {
  right: 50%;
  transform: translateX(50%);
}

.menu-collapsed .logo-brand {
  width: auto;
  min-height: 0;
  justify-content: center;
  margin: 0;
  padding: 0;
  border-radius: 0;
}

.menu-collapsed .brand-logo {
  width: auto;
  height: 32px;
}

:root .menu-collapsed .brand .logo-light,
:root .menu-collapsed .brand .logo-dark,
:root[data-theme="dark"] .menu-collapsed .brand .logo-dark {
  display: none;
}

:root .menu-collapsed .brand .logo-mark {
  display: block;
}

.menu-collapsed .grouped-nav {
  padding: 8px 10px 12px;
}

.menu-collapsed .nav-section-title {
  min-height: 0;
  height: 9px;
  margin: 4px 6px;
  padding: 0;
}

.menu-collapsed .nav-section-title::before {
  width: 100%;
  background: var(--ds-border);
}

.menu-collapsed .nav-section-icon,
.menu-collapsed .nav-chevron {
  display: none;
}

.menu-collapsed .nav-section-body {
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

.menu-collapsed .nav-row {
  width: 100%;
  height: 34px;
  min-height: 34px;
  margin: 0;
  border-radius: var(--ds-r-md);
}

.menu-collapsed .nav-row.active::before {
  left: 0;
  top: 8px;
  bottom: 8px;
}

.menu-collapsed .nav-icon {
  width: 17px;
  height: 17px;
}

.menu-collapsed .workspace-user {
  justify-items: stretch;
  padding: 6px 10px 12px;
}

.menu-collapsed .logout-button {
  width: 100%;
  height: 36px;
  justify-content: center;
  padding: 0;
}

.menu-collapsed .logout-button span,
.menu-collapsed .app-version {
  display: none;
}

.menu-collapsed .workspace-account-row {
  justify-content: center;
  padding: 10px 0 0;
}

/* ---- the page --------------------------------------------------------------------- */

.main {
  padding: calc(var(--shell-pad) + var(--page-pad)) calc(var(--shell-pad) + var(--page-pad)) calc(var(--shell-pad) + var(--page-pad)) calc(var(--shell-pad) + var(--page-pad));
}

/* The page header: the workspace as the eyebrow, the page as the title, its actions right. */
.topbar {
  min-height: 0;
  margin-bottom: 20px;
  padding: 22px 24px;
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
}

.topbar > div:first-child {
  display: flex;
  flex-direction: column-reverse;
  min-width: 0;
}

.topbar h1 {
  color: var(--ds-text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.022em;
}

.topbar p {
  margin: 0 0 6px;
  color: var(--ds-accent-text);
  font-size: 12px;
  font-weight: 500;
}

.topbar-actions {
  gap: 8px;
}

.theme-toggle,
.notif-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-r-md);
  color: var(--ds-text-2);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-sm);
}

:root[data-theme="dark"] .theme-toggle,
:root[data-theme="dark"] .notif-btn {
  background: rgba(255, 255, 255, 0.04);
}

.theme-toggle:hover,
.notif-btn:hover {
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

.theme-toggle svg,
.notif-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- surfaces ---------------------------------------------------------------------- */

/* Solid, bordered, barely raised. No lift on hover. */
.card,
.panel,
.module-card,
.stack-card,
.subpanel,
.note,
.step-chip,
.stage-row,
.profile-list.wide {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-xl);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
}

.panel:hover,
.card:hover {
  border-color: var(--ds-border);
}

.panel {
  margin-bottom: 20px;
  padding: 20px;
}

.panel.compact {
  padding: 12px 14px;
}

.toolbar {
  gap: 10px 14px;
  margin-bottom: 16px;
}

.toolbar h2 {
  color: var(--ds-text);
  font-size: 14.8px;
  font-weight: 600;
}

.toolbar p {
  margin: 2px 0 0;
  font-size: 13px;
}

/* A panel's title sits on the panel over a hairline, not in a band of colour. */
.panel:not(.compact) > .toolbar:first-child {
  min-height: 56px;
  margin: -20px -20px 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--ds-border);
}

/* A table that is a panel's only content runs edge to edge; so does one under a title band. */
.panel > .table-wrap:only-child {
  margin: -20px;
  border: 0;
  border-radius: var(--ds-r-xl);
}

.panel:not(.compact) > .toolbar:first-child + .table-wrap:last-child {
  margin: -16px -20px -20px;
  border: 0;
  border-radius: 0 0 var(--ds-r-xl) var(--ds-r-xl);
}

/* A toolbar's search sits beside its buttons at a set width, not above them. */
.button-row > .toolbar-search:not(.grow) {
  width: 260px;
  flex: 0 1 260px;
}

.check-grid {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-lg);
  background: var(--ds-surface-2);
  box-shadow: none;
}

/* The page's opening card: eyebrow, title, and a strip of figures. */
.hero-panel {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--ds-border);
  border-radius: 16px;
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
}

.hero-panel h2 {
  color: var(--ds-text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.metric-strip {
  gap: 8px;
}

.metric-strip div {
  padding: 10px 12px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-lg);
  background: var(--ds-surface);
}

:root[data-theme="dark"] .metric-strip div {
  background: rgba(255, 255, 255, 0.025);
}

.metric-strip span {
  color: var(--ds-text-3);
  font-size: 12px;
}

.metric-strip strong {
  color: var(--ds-text);
  font-size: 20px;
  font-weight: 600;
}

/* Figures: a label on the left, the number on the right, as on the tracking portal. */
.grid {
  gap: 16px;
  margin-bottom: 16px;
}

.grid > .card {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--ds-r-lg);
  box-shadow: none;
}

:root[data-theme="dark"] .grid > .card {
  background: rgba(255, 255, 255, 0.025);
}

.grid > .card span {
  color: var(--ds-text-2);
  font-size: 12.5px;
  font-weight: 500;
}

.grid > .card strong {
  margin: 0;
  color: var(--ds-text);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.module-grid {
  gap: 12px;
}

.module-card {
  min-height: 0;
  padding: 16px;
  border-radius: var(--ds-r-lg);
  box-shadow: none;
}

.module-card:hover {
  transform: none;
  border-color: var(--ds-border-strong);
  box-shadow: none;
}

.module-card span {
  color: var(--ds-accent-text);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.module-card strong {
  margin: 6px 0 4px;
  color: var(--ds-text);
  font-size: 15px;
  font-weight: 600;
}

.module-card p {
  margin: 0;
  font-size: 13px;
}

.empty-state,
.widget-empty,
.doc-empty {
  border: 1px dashed var(--ds-border-strong);
  border-radius: var(--ds-r-lg);
  color: var(--ds-text-3);
  background: transparent;
  box-shadow: none;
}

/* ---- tables ------------------------------------------------------------------------ */

.table-wrap {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-lg);
  background: var(--ds-surface);
}

/* Column heads are labels, not a banner: the muted text colour on the faintest of tints. */
th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--ds-border);
  color: var(--ds-text-3);
  background: var(--ds-surface-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--ds-border);
  color: var(--ds-text-2);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

table th {
  color: var(--ds-text-3);
  font-weight: 500;
  letter-spacing: 0;
}

tbody tr:hover,
table tbody tr:hover {
  background: var(--ds-surface-2);
}

/* ---- dashboards: the tracking portal's analytics page -------------------------------
   Both dashboards (the workspace overview and the CRM dashboard) follow its DashboardV2:
   a greeting on the page, a period picker, six figures, dashboards as underline tabs, and a
   grid of widget windows with a quiet header. */

.main.dash-mode,
:root[data-theme="dark"] .main.dash-mode {
  padding-top: calc(var(--shell-pad) + var(--page-pad));
  background: transparent;
}

.crm-dash {
  gap: 20px;
  padding: 0;
}

/* The greeting sits on the page, not in a card. */
.crm-top {
  align-items: flex-start;
  gap: 16px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

.crm-top-lead .eyebrow {
  margin: 0 0 4px;
  color: var(--ds-accent-text);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
}

.crm-top-lead h1 {
  margin: 0;
  color: var(--ds-text);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.crm-top-lead p {
  margin: 2px 0 0;
  color: var(--ds-text-3);
  font-size: 14px;
}

.crm-top-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.crm-top-actions .ghost,
.crm-top-actions .primary {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
}

.crm-top-actions .notif-btn {
  width: 36px;
  height: 36px;
}

/* The period: a segmented control. */
.range-pills {
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-md);
  background: var(--ds-surface-2);
  box-shadow: none;
}

.range-pills .rp {
  padding: 4px 12px;
  border-radius: var(--ds-r-sm);
  color: var(--ds-text-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
}

.range-pills .rp:hover {
  color: var(--ds-text);
}

.range-pills .rp.active {
  color: var(--ds-text);
  background: var(--ds-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 0 0 1px var(--ds-border);
}

:root[data-theme="dark"] .range-pills .rp.active {
  background: rgba(255, 255, 255, 0.1);
}

/* Figures: the name and a small icon on one line, the number, a line under it. */
.stat-row {
  gap: 12px;
}

.stat-tile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "label ico" "value value" "sub sub";
  align-items: center;
  gap: 0;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-xl);
  color: var(--ds-text);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
  font: inherit;
  text-align: left;
}

:root[data-theme="dark"] .stat-tile {
  background: var(--ds-surface);
}

button.stat-tile {
  cursor: pointer;
  transition: border-color 150ms ease;
}

.stat-tile:hover,
button.stat-tile:hover {
  transform: none;
  border-color: var(--ds-border-strong);
  box-shadow: var(--ds-shadow-md);
}

.stat-tile .st-ico,
.stat-tile.green .st-ico,
.stat-tile.blue .st-ico,
.stat-tile.amber .st-ico,
.stat-tile.red .st-ico {
  grid-area: ico;
  width: auto;
  height: auto;
  margin: 0;
  border-radius: 0;
  color: var(--ds-text-3);
  background: none;
}

.stat-tile .st-ico svg {
  width: 16px;
  height: 16px;
}

.stat-tile.green .st-ico { color: #059669; }
.stat-tile.blue .st-ico { color: var(--ds-accent-text); }
.stat-tile.amber .st-ico { color: #d97706; }
.stat-tile.red .st-ico { color: #e11d48; }
:root[data-theme="dark"] .stat-tile.green .st-ico { color: #6ee7b7; }
:root[data-theme="dark"] .stat-tile.amber .st-ico { color: #fcd34d; }
:root[data-theme="dark"] .stat-tile.red .st-ico { color: #fda4af; }

.stat-tile .st-label {
  grid-area: label;
  overflow: hidden;
  color: var(--ds-text-2);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

.stat-tile .st-value,
.stat-tile.green .st-value,
.stat-tile.blue .st-value,
.stat-tile.amber .st-value,
.stat-tile.red .st-value {
  grid-area: value;
  margin-top: 10px;
  color: var(--ds-text);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat-tile .st-sub {
  grid-area: sub;
  margin-top: 8px;
  overflow: hidden;
  color: var(--ds-text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dashboards are tabs with an underline; "Dashboard" adds to them. */
.crm-tabs {
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  width: auto;
  max-width: none;
  padding: 0;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid var(--ds-border);
  border-radius: 0;
  background: none;
}

.crm-tabs button {
  position: relative;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 0;
  color: var(--ds-text-3);
  background: none;
  box-shadow: none;
  font-size: 13.5px;
  font-weight: 500;
}

.crm-tabs button:hover {
  color: var(--ds-text);
  background: none;
}

.crm-tabs button.active,
:root[data-theme="dark"] .crm-tabs button.active {
  color: var(--ds-text);
  background: none;
  box-shadow: none;
  font-weight: 500;
}

.crm-tabs button.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  background: var(--ds-accent);
}

.crm-tab-add {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  margin: 0 0 0 4px !important;
  padding: 4px 8px !important;
  border: 0 !important;
  border-radius: var(--ds-r-sm) !important;
  color: var(--ds-text-3) !important;
  font-size: 13px !important;
}

.crm-tab-add:hover {
  color: var(--ds-text) !important;
  background: var(--ds-surface-3) !important;
}

.crm-tab-add svg {
  width: 14px;
  height: 14px;
}

/* Widgets: windows of one height per row, a quiet header, the content filling the rest. */
.widget-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 440px;
  align-items: stretch;
  gap: 16px;
}

.widget {
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-xl);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
}

.widget.editing {
  border-style: dashed;
  border-color: var(--ds-border-strong);
}

.widget-head {
  flex-shrink: 0;
  gap: 8px;
  padding: 14px 20px 10px;
  border-bottom: 0;
}

.widget-grip {
  opacity: 0.4;
}

.widget-ico,
.widget-ico svg {
  color: var(--ds-text-3);
}

.widget-ico svg {
  width: 16px;
  height: 16px;
}

.widget-head h3 {
  min-width: 0;
  overflow: hidden;
  color: var(--ds-text);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.widget-tools {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.widget-more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 4px 8px;
  border-radius: var(--ds-r-sm);
  color: var(--ds-text-2);
  background: none;
  font-size: 12.5px;
  font-weight: 500;
}

.widget-more:hover {
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

.widget-more svg {
  width: 12px;
  height: 12px;
}

.widget-badge {
  padding: 1px 6px;
  border-radius: var(--ds-r-xs);
  color: var(--ds-text-2);
  background: var(--ds-surface-3);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 18px;
}

.widget-remove {
  margin: 0;
}

.widget-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 20px 16px;
}

.widget .widget-empty {
  padding: 24px 0;
  border: 0;
  color: var(--ds-text-3);
  font-size: 13px;
  text-align: center;
}

/* Short content sits in the middle of its window, as on the tracking portal. */
.widget-body > .dash-stats:only-child {
  height: 100%;
  align-content: center;
}

.widget-body:has(> .dash-figure),
.widget-body:has(> .mini-bars) {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.widget-body > .widget-empty:only-child {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-add {
  border-radius: var(--ds-r-xl);
}

.dash-empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 80px 24px;
  border: 1px dashed var(--ds-border-strong);
  border-radius: var(--ds-r-lg);
  text-align: center;
}

.dash-empty p {
  margin: 0;
  color: var(--ds-text-3);
}

/* A donut: a thin ring, the total in its middle, a two-column key under it. */
.donut-wrap {
  height: 100%;
  justify-content: center;
  gap: 16px;
  padding: 0;
}

.donut {
  width: 152px;
  height: 152px;
}

.donut-hole {
  inset: 18px;
  background: var(--ds-surface);
}

.donut-hole span {
  color: var(--ds-text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
}

.donut-hole strong {
  color: var(--ds-text);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
}

.donut-legend {
  width: 100%;
  max-width: 330px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 20px;
}

.dleg {
  gap: 8px;
  min-width: 0;
  font-size: 12px;
}

.dl-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.dl-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ds-text-3);
  text-overflow: ellipsis;
  text-transform: none;
  white-space: nowrap;
}

/* Stage names arrive as keys ("qualified"): sentence case, not Title Case. */
.dl-name::first-letter {
  text-transform: uppercase;
}

.dl-pct {
  margin-left: auto;
  color: var(--ds-text-2);
  font-weight: 600;
}

/* A feed: a tinted square with an icon, a coloured title, the subject, a time. */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.feed-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px;
  border: 0;
  border-radius: var(--ds-r-lg);
  color: inherit;
  background: none;
  font: inherit;
  text-align: left;
}

.feed-row[data-action] {
  cursor: pointer;
}

.feed-row:hover {
  background: var(--ds-surface-2);
}

.feed-ico {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  margin-top: 2px;
  border-radius: var(--ds-r-md);
}

.feed-ico svg {
  width: 14px;
  height: 14px;
}

.feed-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.feed-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.feed-title {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-time {
  flex-shrink: 0;
  color: var(--ds-text-3);
  font-family: var(--ds-mono);
  font-size: 10px;
}

.feed-sub {
  overflow: hidden;
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Small figures on a faint tint: a label over a value. */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dash-stat {
  min-width: 0;
  padding: 12px;
  border-radius: var(--ds-r-md);
  background: rgba(2, 6, 23, 0.035);
}

:root[data-theme="dark"] .dash-stat {
  background: rgba(255, 255, 255, 0.05);
}

.dash-stat span,
.dash-stat small {
  display: block;
  overflow: hidden;
  color: var(--ds-text-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-stat span {
  font-size: 11px;
  font-weight: 700;
}

.dash-stat strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--ds-text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-stat strong.bad {
  color: #e11d48;
}

:root[data-theme="dark"] .dash-stat strong.bad {
  color: #fda4af;
}

.dash-stat small {
  margin-top: 2px;
  font-size: 11px;
}

.dash-stats + .mini-bars {
  margin-top: 20px;
}

/* One figure, large, when a widget is about a single number. */
.dash-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 24px;
  text-align: center;
}

.dash-figure strong {
  color: var(--ds-text);
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.dash-figure span {
  margin-top: 8px;
  color: var(--ds-text-3);
  font-size: 12.5px;
}

/* Ranked rows, a bar behind each in proportion to the leader. */
.rank-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rank-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  padding: 10px 12px;
  border-radius: var(--ds-r-lg);
}

.rank-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  border-radius: var(--ds-r-lg);
}

.rank-no,
.rank-name,
.rank-value {
  position: relative;
  z-index: 1;
}

.rank-no {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--ds-r-md);
  color: var(--ds-text-3);
  background: var(--ds-surface-3);
  font-size: 11px;
  font-weight: 700;
}

.rank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-name small {
  margin-left: 8px;
  color: var(--ds-text-3);
  font-size: 11px;
  font-weight: 400;
}

.rank-value {
  flex-shrink: 0;
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rank-value small {
  color: var(--ds-text-3);
  font-size: 10px;
  font-weight: 500;
}

/* Horizontal bars: a label, the bar, the figure. */
.mini-bars {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}

.mb-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mb-label {
  flex-shrink: 0;
  width: 96px;
  overflow: hidden;
  color: var(--ds-text-3);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mb-track {
  flex: 1;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--ds-surface-3);
}

.mb-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.mb-value {
  flex-shrink: 0;
  width: 44px;
  color: var(--ds-text);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Tinted status tiles, as the tracking portal's service schedule. */
.dash-tiles {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sched-boxes {
  gap: 12px;
}

.sched-box {
  padding: 16px 10px;
  border-radius: var(--ds-r-lg);
}

.sched-box span {
  font-size: 11px;
  font-weight: 600;
}

.sched-box strong {
  margin-top: 4px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.sched-box small {
  margin-top: 4px;
  color: inherit;
  font-size: 10px;
  opacity: 0.8;
}

.sched-box.up { background: #f0f9ff; }
.sched-box.up span, .sched-box.up strong, .sched-box.up small { color: #0369a1; }
.sched-box.due { background: #fffbeb; }
.sched-box.due span, .sched-box.due strong, .sched-box.due small { color: #b45309; }
.sched-box.over { background: #fff1f2; }
.sched-box.over span, .sched-box.over strong, .sched-box.over small { color: #be123c; }
:root[data-theme="dark"] .sched-box.up { background: rgba(14, 165, 233, 0.1); }
:root[data-theme="dark"] .sched-box.up span, :root[data-theme="dark"] .sched-box.up strong, :root[data-theme="dark"] .sched-box.up small { color: #7dd3fc; }
:root[data-theme="dark"] .sched-box.due { background: rgba(245, 158, 11, 0.1); }
:root[data-theme="dark"] .sched-box.due span, :root[data-theme="dark"] .sched-box.due strong, :root[data-theme="dark"] .sched-box.due small { color: #fcd34d; }
:root[data-theme="dark"] .sched-box.over { background: rgba(244, 63, 94, 0.1); }
:root[data-theme="dark"] .sched-box.over span, :root[data-theme="dark"] .sched-box.over strong, :root[data-theme="dark"] .sched-box.over small { color: #fda4af; }

.dash-foot {
  margin: 12px 0 0;
  color: var(--ds-text-3);
  font-size: 11px;
  text-align: center;
}

.wp-card {
  border-radius: var(--ds-r-lg);
}

@media (max-width: 1280px) {
  .stat-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .widget-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .widget-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(360px, auto);
  }
}

/* ---- leftovers of the old look -------------------------------------------------------- */

/* Code on the neutral palette: the light block of the tracking portal. */
.code {
  padding: 10px 12px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-lg);
  color: var(--ds-text);
  background: var(--ds-surface-2);
  font-family: var(--ds-mono);
  font-size: 12.5px;
  word-break: break-all;
}

.code:empty {
  display: none;
}

/* Decorative gradients become the flat accent. */
.pipeline-column::before,
.crm-view .pipeline-column::before {
  background: var(--ds-accent-line);
}

.crm-view .pipeline-column {
  background: var(--ds-surface-2);
}

.crm-view .stage-dot,
.media-chip span,
.report-bar i,
.funnel-track i,
.trx-bar i {
  background: var(--ds-accent);
}

.conversation-card.active::before {
  background: var(--ds-accent-text);
}

.cl-avatar {
  color: var(--ds-accent-text);
  background: var(--ds-accent-soft);
}

.crm-view .hero-panel.crm-hero {
  color: var(--ds-text);
  background: var(--ds-surface);
}

.transcription-log {
  border-color: var(--ds-border);
  border-radius: var(--ds-r-lg);
}

.transcription-log.failed {
  border-color: var(--ds-danger-line);
  background: var(--ds-surface);
}

/* The document search is one field with a magnifier, not a field inside a field. */
.doc-search {
  padding: 7px 10px;
  border-color: var(--ds-border-strong);
  border-radius: var(--ds-r-md);
  box-shadow: var(--ds-shadow-sm);
}

.doc-search:focus-within {
  border-color: var(--ds-accent-line);
  box-shadow: var(--ds-ring);
}

.doc-search input,
.doc-search input:focus {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

/* Labels still set in capitals by the old stylesheet. */
.doc-stat-strip .dss span,
.bulk-phead,
.drp-status {
  letter-spacing: 0;
  text-transform: none;
}

.drp-status {
  border-radius: var(--ds-r-xs);
}

.note-strip code {
  border-radius: var(--ds-r-xs);
}

/* ---- inbox ------------------------------------------------------------------------- */

/* The inbox fills the page beside the menu, lined up with its top and foot. */
.inbox-frame .main {
  gap: 12px;
  padding: var(--shell-pad);
}

.respond-inbox {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-xl);
  box-shadow: var(--ds-shadow-md);
  backdrop-filter: none;
}

.inbox-filter-group h3 {
  color: var(--ds-text-3);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.avatar,
.avatar.whatsapp,
.avatar.website_chat {
  color: var(--ds-accent-text);
  background: var(--ds-accent-soft);
  box-shadow: none;
  font-weight: 600;
}

/* The contact's avatar keeps its size; only the name block beside it stretches. */
.thread-person > .avatar {
  flex: 0 0 auto;
}

/* ---- dialogs ----------------------------------------------------------------------- */

.modal-backdrop {
  background: var(--ds-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-panel {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-xl);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-lg);
  animation: ds-modal-in 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ds-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--ds-border);
  background: var(--ds-surface);
}

.modal-head h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.modal-body {
  padding: 20px;
}

.toast {
  padding: 10px 14px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-md);
  color: var(--ds-toast-text);
  background: var(--ds-toast-bg);
  box-shadow: var(--ds-shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
}

/* ---- sign in: one window, two panes ------------------------------------------------ */

.auth-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px 64px;
}

.auth-window {
  width: min(1180px, 100%);
  min-height: min(680px, calc(100vh - 96px));
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  overflow: hidden;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-r-lg);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-md);
}

.auth-brand {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 56px;
  overflow: hidden;
  color: #ffffff;
  background: #12365b;
}

.auth-brand::after {
  content: "";
  position: absolute;
  top: 40px;
  right: 40px;
  width: 160px;
  height: 160px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  pointer-events: none;
}

.auth-brand-body {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-brand-logo {
  display: block;
  width: 300px;
  max-width: 100%;
  height: auto;
  margin-bottom: 44px;
}

.auth-brand h1 {
  max-width: 460px;
  margin-bottom: 18px;
  color: #ffffff;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.auth-brand p {
  max-width: 440px;
  margin: 0 0 36px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 16px;
  line-height: 1.6;
}

.auth-features {
  display: grid;
  gap: 10px;
  max-width: 440px;
}

.auth-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--ds-r-md);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: 14px;
  font-weight: 500;
}

.auth-feature::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ffffff;
}

.auth-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 480px;
  margin-top: 44px;
}

.auth-metrics div {
  padding: 12px 16px;
  border-radius: var(--ds-r-md);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.auth-metrics span {
  display: block;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11.5px;
}

.auth-metrics strong {
  display: block;
  margin-top: 2px;
  color: #ffffff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-brand-foot {
  position: relative;
  z-index: 1;
  margin-top: 28px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11.5px;
}

.auth-form-pane {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 56px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
}

.auth-mobile-logo {
  display: none;
  justify-content: center;
  margin-bottom: 28px;
}

.auth-mobile-logo img {
  width: 220px;
  height: auto;
}

.auth-mobile-logo .logo-dark {
  display: none;
}

:root[data-theme="dark"] .auth-mobile-logo .logo-light {
  display: none;
}

:root[data-theme="dark"] .auth-mobile-logo .logo-dark {
  display: block;
}

.auth-heading {
  margin-bottom: 28px;
}

.auth-heading .eyebrow {
  margin-bottom: 8px;
}

.auth-heading h2 {
  color: var(--ds-text);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.022em;
}

.auth-heading p {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.55;
}

.auth-card form {
  display: grid;
  gap: 16px;
}

.auth-card form input {
  min-height: 40px;
  padding: 9px 12px;
}

.auth-card form .primary {
  width: 100%;
  min-height: 42px;
  margin-top: 2px;
}

.auth-message {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--ds-danger-line);
  border-radius: var(--ds-r-md);
  color: var(--ds-danger-text);
  background: var(--ds-danger-bg);
  font-size: 13px;
  font-weight: 500;
}

.auth-message.info {
  border-color: var(--ds-accent-line);
  color: var(--ds-accent-text);
  background: var(--ds-accent-soft);
}

.auth-footer {
  position: absolute;
  right: 0;
  bottom: 18px;
  left: 0;
  margin: 0;
  color: var(--ds-text-3);
  font-size: 11.5px;
  text-align: center;
}

.auth-theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-r-md);
  color: var(--ds-text-2);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-sm);
}

.auth-theme-toggle:hover {
  color: var(--ds-text);
  background: var(--ds-surface-3);
}

.auth-theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* ---- laptop screens ------------------------------------------------------------------
   A MacBook shows the portal about 1,470 px wide; a desktop monitor, 1,920. From 1,600 px
   down the menu narrows and the rows and headings tighten, as on the tracking portal. */
@media (max-width: 1600px) {
  :root {
    --rail-w: 256px;
  }

  .workspace-head {
    padding-top: 24px;
  }

  .workspace-menu .brand-logo {
    height: 38px;
  }

  .nav-section-title,
  .logout-button {
    min-height: 34px;
    gap: 10px;
    font-size: 14px;
  }

  .nav-section-icon,
  .logout-button svg {
    width: 17px;
    height: 17px;
  }

  .nav-row {
    min-height: 28px;
    font-size: 12.5px;
  }
}

@media (min-width: 1024px) and (max-width: 1600px) and (-webkit-min-device-pixel-ratio: 2) and (hover: hover) and (pointer: fine),
       (min-width: 1024px) and (max-width: 1600px) and (min-resolution: 2dppx) and (hover: hover) and (pointer: fine) {
  :root {
    --rail-w: 232px;
    --shell-pad: 16px;
    --page-pad: 12px;
  }

  .nav-section-title,
  .logout-button {
    min-height: 31px;
    font-size: 13px;
  }

  .nav-row {
    min-height: 26px;
    font-size: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }
}

@media (max-width: 1180px) {
  :root {
    --rail-w: 240px;
  }
}

@media (max-width: 1023px) {
  .auth-brand {
    display: none;
  }

  .auth-mobile-logo {
    display: flex;
  }

  .auth-window {
    width: min(480px, 100%);
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .auth-form-pane {
    padding: 36px 28px;
  }
}

.mobile-nav-button,
.rail-backdrop {
  display: none;
}

/* Phones: the menu is a drawer behind a menu button, as on the TextBot portal. */
@media (max-width: 860px) {
  .app-frame,
  .app-frame.menu-collapsed {
    display: block;
  }

  .workspace-menu {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: 284px;
    height: 100vh;
    margin: 0;
    border-width: 0 1px 0 0;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }

  .mobile-nav-open .workspace-menu {
    transform: none;
  }

  .mobile-nav-open .rail-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: block;
    background: var(--ds-backdrop);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .mobile-nav-button {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 40;
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-r-md);
    color: var(--ds-text);
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-sm);
  }

  .mobile-nav-button svg {
    width: 20px;
    height: 20px;
  }

  .menu-toggle {
    display: none;
  }

  .main,
  .main.dash-mode {
    height: auto;
    min-height: 100vh;
    padding: 64px 12px 16px;
  }

  .inbox-frame .main {
    padding: 64px 0 0;
  }

  .topbar {
    padding: 18px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .auth-form-pane {
    padding: 28px 20px;
  }
}
