/* CRUX Workplace · calm visual theme.
   Loaded after app.css. No layout routing, permissions or application state. */
:root {
  --calm-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --calm-space: 24px;
  --calm-radius: 16px;
  --calm-control-radius: 8px;
  --calm-control-height: 40px;
  --calm-duration: 140ms;
  --calm-ease: cubic-bezier(.2, .7, .2, 1);
  --ink: #202735;
  --muted: #596577;
  --line: #dce1e8;
  --bg: #f5f6f8;
  --card: #ffffff;
  --soft: #f1f3f6;
  --accent: #3e57d6;
  --accent2: #3045b4;
  --green: #17764e;
  --red: #bc3343;
  --yellow: #916111;
  --text: var(--ink);
  --border: var(--line);
  --panel: var(--card);
  --surface: var(--card);
  --surface-soft: var(--soft);
  --shadow: 0 2px 8px rgba(32, 39, 53, .045);
  --shadow-sm: 0 1px 3px rgba(32, 39, 53, .035);
  --surface-control: var(--card);
  --surface-control-hover: var(--soft);
  --surface-popover: var(--card);
  --surface-subtle: var(--soft);
  --surface-selected: #edf0ff;
  --border-control: #c4ccd7;
  --text-control: var(--ink);
  --text-muted-control: var(--muted);
  --shadow-popover: 0 8px 28px rgba(25, 35, 55, .12);
  --focus-ring: 0 0 0 3px rgba(62, 87, 214, .18);
  --surface-success: #edf7f1;
  --text-success: #176b48;
  --surface-warning: #fff6e5;
  --text-warning: #80530a;
  --surface-danger: #fff0f2;
  --text-danger: #b22d3e;
  --surface-info: #edf0ff;
  --text-info: #354bbc;
  --v28-gap: var(--calm-space);
  --v28-gutter: var(--calm-space);
  --v28-card-pad: 24px;
  --v28-control-h: var(--calm-control-height);
  --v28-radius: var(--calm-radius);
  --v28-radius-sm: var(--calm-control-radius);
  --v28-font-body: 14px;
  --v28-font-label: 13px;
  --v28-font-meta: 13px;
  --v28-font-h1: 24px;
  --v28-font-h2: 20px;
  --v28-font-h3: 16px;
  --v28-font-h4: 14px;
  --v29-ink: var(--ink);
  --v29-muted: var(--muted);
  --v29-line: var(--line);
  --v29-soft: var(--soft);
  --v29-radius: var(--calm-radius);
  --v29-blue: var(--accent);
  --v29-blue-soft: var(--surface-selected);
  --v29-green: var(--text-success);
  --v29-green-soft: var(--surface-success);
  --v29-red: var(--text-danger);
  --v29-red-soft: var(--surface-danger);
}
html[data-theme="dark"] {
  --ink: #ecedf2;
  --muted: #b3bccb;
  --line: #363e4c;
  --bg: #161a22;
  --card: #202631;
  --soft: #282f3c;
  --accent: #a7b5ff;
  --accent2: #bec8ff;
  --green: #8ed5b0;
  --red: #ffabba;
  --yellow: #f0c576;
  --surface-control: var(--card);
  --surface-control-hover: var(--soft);
  --surface-popover: var(--card);
  --surface-subtle: var(--soft);
  --surface-selected: #303b60;
  --border-control: #657187;
  --text-control: var(--ink);
  --text-muted-control: var(--muted);
  --shadow: 0 2px 8px rgba(0, 0, 0, .08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-popover: 0 8px 28px rgba(0, 0, 0, .28);
  --focus-ring: 0 0 0 3px rgba(167, 181, 255, .24);
  --surface-success: #233e33;
  --text-success: #9fe0bd;
  --surface-warning: #443720;
  --text-warning: #f0ce8e;
  --surface-danger: #452a33;
  --text-danger: #ffb8c3;
  --surface-info: #303b60;
  --text-info: #bdc8ff;
  --v29-ink: var(--ink);
  --v29-muted: var(--muted);
  --v29-line: var(--line);
  --v29-soft: var(--soft);
  --v29-blue-soft: var(--surface-selected);
  --v29-green-soft: var(--surface-success);
  --v29-red-soft: var(--surface-danger);
}

/* Typography: labels and metadata stay readable, even in dense workspaces. */
html:root body, html:root body :is(button, input, select, textarea) { font-family: var(--calm-font); }
html:root body { font-size: 14px; line-height: 1.5; background: var(--bg); color: var(--ink); }
html:root body :is(#content, #modal, #drawer, .login-card, .onboarding-card) :is(p, label, small) { line-height: 1.5; }
html:root body :is(#content, #modal, #drawer) :is(small, .eyebrow, .stat-label) { font-size: 13px; }
html:root body :is(#content, #modal, #drawer) label { font-size: 13px; font-weight: 550; color: var(--ink); }
html:root body #content :is(h1, .page-actions h1) { font-size: 24px; line-height: 1.25; letter-spacing: -.025em; font-weight: 650; }
html:root body #content h2 { font-size: 20px; line-height: 1.3; letter-spacing: -.015em; font-weight: 650; }
html:root body #content h3 { font-size: 16px; line-height: 1.4; letter-spacing: -.01em; font-weight: 600; }
html:root body #content h4 { font-size: 14px; line-height: 1.4; }
html:root body :is(.page-actions, .section-head) p { color: var(--muted); font-size: 14px; }
html:root body :is(.eyebrow, .stat-label) { color: var(--muted); font-weight: 600; letter-spacing: .045em; }

/* Shared frame; preserve the existing navigation and responsive breakpoints. */
html:root body #content { background: var(--bg) !important; padding: 24px 24px 40px !important; }
html:root body .topbar { background: var(--card) !important; border-bottom: 1px solid var(--line); box-shadow: none !important; backdrop-filter: none; }
html:root body .topbar h2 { color: var(--ink); font-size: 20px; font-weight: 650; }
html:root body .topbar p { color: var(--muted); font-size: 13px; }
html:root body .sidebar { background: #19212e; border-right: 1px solid #2b3545; box-shadow: none; }
html:root body .sidebar :is(.company-card, .pricing-sidebar-button) { background: #222c3b; border-color: #3b475a; border-radius: 12px; box-shadow: none; }
html:root body .sidebar :is(.company-card small, .company-card span, .sidebar-footer small, .support-link, .brand span) { color: #b8c3d3; }
html:root body .sidebar #nav button { color: #c6cfdd; font-size: 13px; font-weight: 500; box-shadow: none; }
html:root body .sidebar #nav button.active { color: #fff; background: #2c3951; border-color: transparent; box-shadow: inset 3px 0 #91a3ff; }
html:root body .sidebar #nav button:hover { color: #fff; background-color: #263247; }
html:root body .sidebar #nav .v29-nav-heading { color: #b8c3d3; font-size: 11px; letter-spacing: .045em; font-weight: 600; }
html:root body .sidebar #company-initial { background: #3e57d6; color: #fff; }
html:root body .notification-badge { background: #b22d3e; color: #fff; }
html:root body .v8-global-search { background: var(--soft) !important; border: 1px solid var(--line); border-radius: 8px !important; box-shadow: none; }
html:root body .v8-global-search:focus-within { border-color: var(--accent); box-shadow: var(--focus-ring); }
html:root body .v8-global-search input { background: transparent !important; border-color: transparent !important; box-shadow: none !important; }
html:root body .v44-search-shortcut { color: var(--muted); background: var(--card); border-color: var(--line); }

/* Component surfaces. Explicit families avoid changing charts or status colors. */
html:root body :is(.card, .v29-kpi, .v58-attention, .v58-context, .v43-day-summary, .v23-deal-card, .v23-metric, .v56-start-panel, .v56-team-summary, .v56-analytics-empty, .v29-dashboard-block > .card) {
  background: var(--card) !important; border-color: var(--line) !important;
  border-radius: 16px !important; box-shadow: var(--shadow-sm) !important;
}
html:root body :is(.card, .v58-attention, .v58-context) { padding: 24px; }
html:root body :is(.v29-kpis, .v29-dashboard-grid, .grid, .v58-context) { gap: var(--calm-space); }
html:root body :is(.v29-kpi, .v23-deal-card) { padding: 16px; }
html:root body .v29-kpi::after { display: none; }
html:root body :is(.v29-kpi-label, .v29-kpi-foot, .v29-kpi-change, .v29-kpi-emptytrend) { font-size: 13px; color: var(--muted); }
html:root body .v29-kpi-value strong { font-size: 28px; letter-spacing: -.035em; font-weight: 650; color: var(--ink); }
html:root body :is(.v29-kpi-label, .v29-card-head h2) { color: var(--ink); }
html:root body .v29-card-head h2 { font-size: 16px !important; }
html:root body :is(.v29-period-presets button, .v29-card-head > button) { color: var(--muted); font-size: 13px; }
html:root body .v29-today-all { color: var(--accent); font-size: 13px; }
html:root body .v29-period-presets button.active { background: var(--card); color: var(--ink); }
html:root body :is(.v29-today-list h3, .v29-funnel-stage span, .v29-funnel-stage strong, .v29-funnel-stage b) { font-size: 13px !important; }
html:root body :is(.v29-today-list p, .v29-today-list small, .v29-today-list time, .v29-funnel-layout aside small, .v29-funnel-layout aside span, .v29-goal-values small, .v29-goal-stats small, .v29-goal-stats span) { font-size: 13px; line-height: 1.45; color: var(--muted); }
html:root body .v29-today-list article { min-height: 72px; padding-block: 12px; border-color: var(--line); }
html:root body .v29-today-list article { grid-template-columns: 32px minmax(0, 1fr); grid-template-areas: "icon body" "time body" ". action"; }
html:root body .v29-today-list article > button { justify-self: start; }
html:root body :is(.v29-empty-chart, .v29-empty-compact, .v29-goal-panel, .v29-kpi-emptytrend, .v58-coverage, .v58-attention-empty, .v58-context-grid article) {
  background: var(--soft) !important; color: var(--muted); border-color: var(--line) !important; border-radius: 12px;
}
html:root body :is(.v58-case, .v58-fact) { background: var(--card); border-radius: 12px; box-shadow: none; }
html:root body .v58-case-body h3 { font-size: 15px !important; overflow-wrap: anywhere; }
html:root body .v58-coverage .is-current { color: var(--text-success); }
html:root body .v58-coverage .is-unknown { color: var(--text-warning); }
html:root body .v58-coverage .is-error { color: var(--text-danger); }
html:root body .v49-crm-context { background: var(--soft) !important; border-color: var(--line) !important; box-shadow: none !important; border-radius: 8px; }
html:root body :is(.v49-crm-context-kicker, .v49-control, .v48-task-columns, .v48-task-filter-summary, .v43-refresh-status, .v43-day-summary span, .v43-day-summary small) { font-size: 13px; color: var(--muted); letter-spacing: 0; }
html:root body :is(.v23-priority.medium, .v23-task-count:not(.danger)) { color: var(--muted); background: var(--soft); font-size: 12px; }
html:root body .v43-day-summary article { padding: 16px; }
html:root body .v43-today-page .today-meta { color: var(--muted); font-size: 13px; }
html:root body .today-rank { background: var(--surface-selected); color: var(--accent); }
html:root body .column-empty { color: var(--muted); font-size: 13px; }
html:root body .v39-stage-rail button:not(.active) { background: var(--card); color: var(--muted); border-color: var(--line); }
html:root body .v39-stage-rail button:not(.active) b { background: var(--soft); color: var(--muted); font-size: 12px; }
html:root body .v48-tasks-workspace .task-row { background: var(--card); border-color: var(--line); }
html:root body :is(.v48-task-columns, table th) { background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 550; }
html:root body :is(table td, .task-row) { font-size: 14px; line-height: 1.45; }
html:root body table :is(th, td) { border-color: var(--line); }

/* Controls keep their content, semantics and existing event handlers. */
html:root body :is(.primary, .secondary, .ghost, .danger, .danger-button, .icon-button, .crux-select-trigger) {
  min-height: var(--calm-control-height); border-radius: 8px !important;
  font-size: 14px !important; font-weight: 600; line-height: 1.35;
  transition: background-color 140ms var(--calm-ease), border-color 140ms var(--calm-ease), color 140ms var(--calm-ease), box-shadow 140ms var(--calm-ease);
  transform: none; box-shadow: none;
}
html:root body :is(.primary, .secondary, .ghost, .danger, .danger-button) { padding: 9px 14px; }
html:root body .primary { background: var(--accent) !important; color: #fff !important; border: 1px solid var(--accent) !important; box-shadow: none !important; }
html:root body .primary:hover { background: var(--accent2) !important; border-color: var(--accent2) !important; }
html[data-theme="dark"] body .primary { color: #182343 !important; }
html:root body :is(.secondary, .icon-button, .crux-select-trigger) { background: var(--card) !important; color: var(--ink) !important; border: 1px solid var(--border-control) !important; box-shadow: none !important; }
html:root body .ghost { background: transparent !important; color: var(--ink) !important; border-color: transparent; box-shadow: none !important; }
html:root body :is(.secondary, .ghost, .icon-button, .crux-select-trigger):hover { background: var(--soft) !important; border-color: var(--border-control); }
html:root body :is(.danger, .danger-button) { background: var(--surface-danger) !important; color: var(--text-danger) !important; border: 1px solid var(--border-danger); }
html:root body :is(button, [role="button"]):active:not(:disabled) { filter: brightness(.96); }
html:root body :is(button, input, select, textarea):disabled { opacity: .58; cursor: not-allowed; box-shadow: none !important; }
html:root body button[aria-busy="true"] { cursor: progress; }
html:root body :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible { outline: 2px solid var(--accent) !important; outline-offset: 3px !important; }
html:root body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]), select, textarea) {
  min-height: var(--calm-control-height); padding: 10px 12px; border: 1px solid var(--border-control);
  border-radius: 8px; font-size: 14px; line-height: 1.4;
  background: var(--surface-control); color: var(--ink);
  transition: border-color 140ms var(--calm-ease), box-shadow 140ms var(--calm-ease);
}
html:root body :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
html:root body :is(input, select, textarea):focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
html:root body :is(input, textarea, select):is([aria-invalid="true"], :user-invalid) { border-color: var(--text-danger); }
html:root body :is(.form-error, .field-error, [role="alert"]) { color: var(--text-danger); font-size: 13px; line-height: 1.5; }
html:root body .form-grid { gap: 16px; }
html:root body .form-grid label { gap: 8px; }
html:root body :is(#modal, #drawer, .crux-select-menu, .v8-search-results) { background: var(--card); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-popover); }
html:root body #modal { border-radius: 16px; }
html:root body #drawer { border-radius: 16px 0 0 16px; }
html:root body :is(#modal, #drawer):not(.hidden) { animation: calm-panel-in 180ms var(--calm-ease); }
html:root body :is(.crux-select-menu, .v8-search-results) { border-radius: 12px; }
html:root body .crux-select-option { color: var(--ink); font-size: 14px; }
html:root body .crux-select-option:is(:hover, [aria-selected="true"]) { background: var(--surface-selected); }
@keyframes calm-panel-in { from { opacity: .35; } to { opacity: 1; } }

/* Legacy dark rules include ID selectors and !important; match that scope. */
html:root body :is(#app, #content, #app > main) { background-color: var(--bg) !important; }
html:root body #content :is(.task-row, .v29-today-list article, .v23-deal-card, .v58-case, .v58-context-grid article, .v43-day-summary article) { background: var(--card) !important; border-color: var(--line); }
html:root body #content .v58-case { border-left-color: var(--text-warning); }
html:root body #content .v58-case.is-danger { border-left-color: var(--text-danger); }
html:root body #content .v58-case.is-info { border-left-color: var(--text-info); }
html:root body :is(.v16-dialog-shell, .v16-chat-list, .v16-contact-pane, .v16-list-head, .v16-chat-header, .v16-composer-wrap) { background: var(--card) !important; border-color: var(--line) !important; color: var(--ink) !important; backdrop-filter: none; box-shadow: none; }
html:root body .v16-dialog-shell { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
html:root body :is(.v16-chat-main, .v16-messages) { background: var(--soft) !important; background-image: none !important; }
html:root body .v16-search input { padding-left: 40px; }
html:root body :is(.v16-provider-trigger, .v16-channel-button, .v16-icon-button, .v16-attach) { background: var(--card) !important; color: var(--ink) !important; border: 1px solid var(--border-control) !important; border-radius: 8px; box-shadow: none; }
html:root body .v16-conversation { color: var(--ink); transition: background-color 140ms ease; }
html:root body .v16-conversation:hover { background: var(--soft) !important; box-shadow: none; }
html:root body .v16-conversation.active { background: var(--surface-selected) !important; border-color: var(--line) !important; box-shadow: none; }
html:root body :is(.v16-chat-empty, .v16-chat-empty p, .v16-chat-person small) { color: var(--muted); }
html:root body .v16-list-head small { color: var(--muted); }
html:root body .v16-chat-empty b { color: var(--ink); }

@media (max-width: 1024px) {
  html:root body .v29-dashboard-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
  html:root body .v29-dashboard-tools { align-items: flex-start; }
}

@media (max-width: 768px) {
  :root { --calm-space: 16px; --calm-control-height: 44px; --v28-card-pad: 16px; }
  html:root body #content { padding: 16px 16px 32px !important; }
  html:root body #content :is(h1, .page-actions h1) { font-size: 22px; }
  html:root body #content h2 { font-size: 18px; }
  html:root body :is(.card, .v58-attention, .v58-context) { padding: 16px; }
  html:root body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="hidden"]), select, textarea, .crux-select-trigger) { font-size: 16px !important; }
  html:root body :is(button, [role="button"], summary, .crux-select-option) { min-height: 44px !important; }
  html:root body :is(.icon-button, [data-close], .crux-modal-close, .crux-drawer-close) { min-width: 44px; }
  html:root body :is(.row-actions, .form-actions, .v58-case-actions) { gap: 8px; flex-wrap: wrap; }
  html:root body :is(.v29-period-presets, .v23-tabs) { max-width: 100%; overflow-x: auto; }
  html:root body .v29-today-list article { grid-template-columns: 42px minmax(0, 1fr); gap: 8px; }
  html:root body .v29-today-list article > button { grid-column: 2; justify-self: start; }
  html:root body :is(.v48-task-checkbox, .v48-task-select-all, .v23-bulk-bar label, .v23-select-all) { min-height: 44px; display: inline-flex; align-items: center; }
  html:root body .v37-bulkbar > label { display: inline-flex; align-items: center; min-height: 44px; }
  html:root body .v23-deal-card .v37-row-select { width: 44px; height: 44px; top: 8px; right: 8px; }
  html:root body .v23-deal-card :is(h3, h4) { padding-right: 32px; }
  html:root body #drawer { border-radius: 16px 16px 0 0; }
  html:root body #modal { border-radius: 16px 16px 0 0; }
}
@media (max-width: 600px) {
  html:root body .top-actions [data-action="quick"] { font-size: 0 !important; width: 44px; padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html:root body *, html:root body *::before, html:root body *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}
