:root {
  --bg: #f3eee6;
  --sidebar-bg: rgba(255, 252, 247, 0.88);
  --header-bg: #14242f;
  --header-text: #f8f2e8;
  --accent: #0d6b4e;
  --accent-hover: #0b8f65;
  --accent-light: rgba(13, 107, 78, 0.08);
  --accent-mid: rgba(13, 107, 78, 0.14);
  --border: rgba(20, 36, 47, 0.12);
  --input-border: rgba(20, 36, 47, 0.16);
  --text: #17242d;
  --text-muted: #526071;
  --danger: #c24133;
  --success: #1a7f53;
  --warning: #b7791f;
  --radius: 10px;
  --radius-lg: 20px;
  --shadow-sm: 0 10px 30px rgba(23, 36, 45, 0.06);
  --shadow-md: 0 24px 60px rgba(23, 36, 45, 0.14);
  --font-heading: "Fraunces", Georgia, serif;
}

body {
  background:
    radial-gradient(circle at top left, rgba(216, 237, 224, 0.78), transparent 32%),
    radial-gradient(circle at top right, rgba(245, 214, 176, 0.28), transparent 28%),
    linear-gradient(180deg, #f7f2eb 0%, #f0ece4 100%);
}

#header {
  position: relative;
  z-index: 3;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.05), transparent 34%),
    linear-gradient(135deg, #14242f 0%, #1d313b 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#app {
  background:
    radial-gradient(circle at top left, rgba(13, 107, 78, 0.05), transparent 24%),
    radial-gradient(circle at top right, rgba(201, 148, 60, 0.08), transparent 24%);
}

#sidebar {
  background: var(--sidebar-bg);
  backdrop-filter: blur(18px);
  box-shadow: inset -1px 0 0 rgba(20, 36, 47, 0.06);
}

#main {
  padding: 12px;
  gap: 10px;
  background: transparent;
}

.workspace-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px 10px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(246, 241, 232, 0.94));
  box-shadow: 0 12px 28px rgba(23, 36, 45, 0.06);
  overflow: hidden;
  position: relative;
}

.workspace-shell::after {
  content: "";
  position: absolute;
  top: -60px;
  right: -24px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 107, 78, 0.1), transparent 68%);
  pointer-events: none;
}

.workspace-hero-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.workspace-kicker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#workspace-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 36, 47, 0.06);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.workspace-context-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(13, 107, 78, 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.workspace-heading-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

#workspace-title {
  font-family: var(--font-heading);
  font-size: clamp(22px, 2.1vw, 30px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 0 0 6px;
  color: #1a2a35;
}

#workspace-subtitle {
  max-width: 720px;
  font-size: 13px;
  line-height: 1.5;
  color: #465667;
}

.workspace-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  align-items: center;
}

.workspace-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  background: rgba(255, 255, 255, 0.94);
  color: #314152;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.workspace-action-btn:hover {
  transform: translateY(-1px);
  background: #fff;
  border-color: rgba(20, 36, 47, 0.18);
  box-shadow: 0 8px 18px rgba(23, 36, 45, 0.08);
}

.workspace-action-btn.primary {
  background: linear-gradient(180deg, #1c2b38 0%, #243746 100%);
  color: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14), 0 12px 24px rgba(15, 23, 42, 0.12);
}

.workspace-nav,
.workspace-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.workspace-btn,
.workspace-subnav .tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: #556475;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.workspace-btn:hover,
.workspace-subnav .tab:hover {
  color: var(--text);
  background: rgba(20, 36, 47, 0.05);
}

.workspace-btn.active,
.workspace-subnav .tab.active {
  background: #17242d;
  color: #f5efe6;
  border-color: rgba(20, 36, 47, 0.08);
  box-shadow: 0 6px 18px rgba(20, 36, 47, 0.1);
}

.workspace-subnav .tab {
  margin-bottom: 0;
  border-bottom: 1px solid transparent;
}

.workspace-subnav .tab.workspace-hidden {
  display: none;
}

.workspace-spotlight {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workspace-spotlight-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
}

.workspace-spotlight-pill.emphasis {
  background: rgba(20, 36, 47, 0.92);
  color: #f5efe6;
}

.workspace-spotlight-label {
  display: inline-flex;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
}

.workspace-spotlight-value {
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

#workspace-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-content {
  min-height: 0;
  border: 1px solid rgba(20, 36, 47, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-sm);
}

/* Table tab — scoped to .active to prevent display:flex overriding display:none on inactive tabs */
#tab-table.active {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.table-modern-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Background gradient for all workspace tabs */
#tab-map,
#tab-table,
#tab-summary,
#tab-pipeline,
#tab-activities,
#tab-users,
#tab-workflows,
#tab-sales,
#tab-planner,
#tab-insights,
#tab-operations {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 243, 236, 0.96));
}

/* Scrollable tabs: content scrolls within the tab */
#tab-today.active,
#tab-summary.active,
#tab-activities.active,
#tab-users.active,
#tab-workflows.active,
#tab-sales.active,
#tab-planner.active,
#tab-insights.active,
#tab-operations.active,
#tab-settings-home.active {
  overflow-y: auto;
}

/* Non-scrollable tabs: internal components manage their own scroll */
/* #tab-pipeline — kanban columns scroll internally, board scrolls horizontally */
/* #tab-table — table wrapper scrolls internally */
/* #tab-map — map fills the viewport, no scroll needed */

#tab-users {
  min-height: 0;
  overflow: hidden;
}

#tab-users.active {
  display: flex;
  flex-direction: column;
}

#users-controls {
  flex: 0 0 auto;
}

#users-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

#users-sub-content {
  min-height: 0;
}

#tab-today {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 246, 240, 0.98));
}

#today-root {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.today-grid {
  display: grid;
  gap: 16px;
}

.today-kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.today-kpi-card,
.today-panel {
  border: 1px solid rgba(20, 36, 47, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-sm);
}

.today-kpi-card {
  padding: 18px;
}

.today-kpi-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.today-kpi-value {
  display: block;
  font-family: var(--font-heading);
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
}

.today-kpi-caption {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.today-main-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
}

.today-side-grid {
  display: grid;
  gap: 16px;
}

.today-panel {
  padding: 18px 18px 14px;
}

.today-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.today-panel-title {
  font-family: var(--font-heading);
  font-size: 22px;
  line-height: 1.1;
  margin: 0 0 4px;
}

.today-panel-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
}

.today-link-btn {
  border: none;
  background: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.today-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.today-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(250, 248, 244, 0.9);
}

.today-item-main {
  min-width: 0;
}

.today-item-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.today-item-meta,
.today-item-reason {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
}

.today-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.today-inline-btn {
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.today-inline-btn.primary {
  background: rgba(13, 107, 78, 0.12);
  border-color: rgba(13, 107, 78, 0.18);
  color: var(--accent);
}

.today-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.today-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(20, 36, 47, 0.05);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}

.today-empty {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(20, 36, 47, 0.14);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.58);
}

.today-route-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(13, 107, 78, 0.08), rgba(255, 255, 255, 0.92));
  border: 1px solid rgba(13, 107, 78, 0.12);
}

.today-route-city {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
}

.today-route-copy {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.today-stage-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--stage-badge-color, var(--accent)) 18%, white);
  border: 1px solid color-mix(in srgb, var(--stage-badge-color, var(--accent)) 32%, white);
  color: #1f2937;
}

.today-agenda-stack {
  display: grid;
  gap: 12px;
}

.today-agenda-group {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(255, 255, 255, 0.74);
}

.today-agenda-group h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.today-agenda-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-agenda-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(20, 36, 47, 0.08);
}

.today-agenda-item:first-child {
  border-top: none;
  padding-top: 0;
}

.today-agenda-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 3px;
}

.today-agenda-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.today-agenda-date {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}

.detail-panel {
  width: min(72vw, 760px);
  max-width: min(92vw, 760px);
  background: linear-gradient(180deg, rgba(255, 251, 245, 0.98), rgba(243, 238, 229, 0.98));
  box-shadow: -18px 0 42px rgba(20, 36, 47, 0.22);
}

.detail-resize-handle::after {
  background: rgba(20, 36, 47, 0.18);
}

.detail-panel-header {
  position: relative;
  padding: 22px 24px 18px;
  background:
    linear-gradient(135deg, #14242f 0%, #21414a 100%);
}

.detail-panel-header::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -70px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), transparent 70%);
  pointer-events: none;
}

.detail-panel-header h2 {
  position: relative;
  z-index: 1;
  font-family: var(--font-heading);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.detail-header-actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: #243746;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  touch-action: manipulation;
  transition: background var(--duration-fast), transform var(--duration-fast), box-shadow var(--duration-fast), border-color var(--duration-fast);
}

.detail-close:hover,
.detail-close:focus-visible {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.18);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.detail-close:active {
  transform: scale(0.96);
}

.detail-panel-tabs {
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(14px);
}

.detail-tab {
  padding: 12px 16px;
  border-radius: 999px;
  margin: 10px 4px 10px 0;
  border-bottom: none;
}

.detail-tab.active {
  background: rgba(20, 36, 47, 0.92);
  color: #f7f1e8;
  border-bottom-color: transparent;
}

.detail-panel-body {
  padding: 20px 22px 28px;
}

.detail-hero {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 20px;
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(13, 107, 78, 0.12), rgba(255, 255, 255, 0.96));
  border: 1px solid rgba(13, 107, 78, 0.14);
}

.detail-hero-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.detail-hero-copy h3 {
  margin: 0 0 6px;
  font-family: var(--font-heading);
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: #17302a;
}

.detail-hero-copy p {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.detail-hero-chip-row,
.detail-hero-actions,
.detail-hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.detail-hero-chip,
.detail-hero-actions a,
.detail-hero-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  text-decoration: none;
}

.detail-hero-actions button {
  cursor: pointer;
}

.detail-hero-fact {
  min-width: 120px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(20, 36, 47, 0.08);
}

.detail-hero-fact-label {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.detail-hero-fact-value {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.detail-section {
  margin-bottom: 16px;
  padding: 18px 18px 16px;
  border-radius: 22px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 26px rgba(20, 36, 47, 0.05);
}

.detail-section h3 {
  margin-bottom: 14px;
  padding-bottom: 0;
  border-bottom: none;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.detail-grid {
  gap: 12px 14px;
}

.detail-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(247, 244, 238, 0.88);
}

.detail-visit-reports-empty {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(247, 244, 238, 0.82);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.detail-visit-report-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 244, 238, 0.9));
  box-shadow: 0 12px 28px rgba(20, 36, 47, 0.06);
}

.detail-visit-report-card + .detail-visit-report-card {
  margin-top: 12px;
}

.detail-visit-report-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.detail-visit-report-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.detail-visit-report-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.detail-visit-report-badges,
.detail-visit-report-actions,
.detail-visit-report-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-visit-report-badge,
.detail-visit-report-action-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.detail-visit-report-badge-warn {
  border-color: rgba(199, 91, 18, 0.2);
  background: rgba(255, 245, 230, 0.95);
  color: #9a5b00;
}

.detail-visit-report-summary {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
}

.detail-visit-report-raw {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(21, 38, 48, 0.04);
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.detail-visit-report-facts {
  row-gap: 6px;
}

.detail-visit-report-facts span {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-visit-report-facts strong,
.detail-visit-report-action-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.detail-visit-report-warning {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 245, 230, 0.95);
  color: #8a4e00;
  font-size: 12px;
  line-height: 1.55;
}

.detail-visit-report-action-block {
  display: grid;
  gap: 8px;
}

.detail-value {
  line-height: 1.55;
}

.field-motion-panel {
  display: grid;
  gap: 14px;
}

.field-motion-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.field-motion-title {
  font-family: var(--font-heading);
  font-size: 18px;
  line-height: 1.1;
  margin-bottom: 4px;
  color: #17302a;
}

.field-motion-subtitle {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 520px;
}

.field-motion-chip-row,
.field-motion-stage-row,
.field-motion-actions,
.field-motion-classify-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.field-motion-btn,
.field-motion-classify-btn {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  background: rgba(247, 244, 238, 0.9);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.field-motion-classify {
  padding-top: 2px;
}

.field-motion-classify-label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@media (max-width: 1320px) {
  .today-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  #main {
    padding: 10px;
  }

  .workspace-shell {
    padding: 12px;
  }

  .workspace-heading-row,
  .today-main-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .workspace-actions { justify-content: flex-start; }
}

@media (max-width: 720px) {
  #main {
    gap: 12px;
  }

  .workspace-shell,
  .tab-content,
  .today-kpi-grid {
    border-radius: 18px;
  }

  .today-item,
  .detail-hero-head,
  .field-motion-summary {
    grid-template-columns: 1fr;
    display: grid;
  }

  .today-item-actions {
    justify-content: flex-start;
  }

  .detail-panel {
    max-width: 100vw;
    width: 100vw;
  }
}

/* Redesign shell overrides */
:root {
  --surface: #fffdf9;
  --surface-raised: #faf7f2;
  --surface-inset: #f4f3f3;
  --border: rgba(51, 28, 46, 0.12);
  --border-subtle: rgba(51, 28, 46, 0.08);
  --text-primary: #023527;
  --text-secondary: #4b4444;
  --text-tertiary: #625b5b;
  --accent: #996958;
  --accent-hover: #6f463a;
  --accent-ink: #6f463a;
  --accent-subtle: rgba(153, 105, 88, 0.16);
  --radius: 12px;
  --radius-lg: 24px;
  --shadow-sm: 0 14px 36px rgba(51, 28, 46, 0.08);
  --font-heading: "Instrument Sans", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

body {
  background:
    radial-gradient(circle at top left, rgba(2, 53, 39, 0.08), transparent 28%),
    linear-gradient(180deg, #fffdf9 0%, #faf7f2 100%);
  color: var(--text-primary);
  font-family: var(--font-body);
}

#header,
#sidebar {
  display: none !important;
}

#app {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  min-height: 100dvh;
  background: transparent;
}

#app.primary-rail-expanded {
  grid-template-columns: 248px minmax(0, 1fr);
}

#main {
  padding: 0;
  gap: 0;
  background: #f8f9fb;
}

.primary-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 14px 12px;
  border-right: none;
  background: #023527;
  color: rgba(255, 255, 255, 0.7);
}

.primary-rail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.primary-rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.primary-rail-brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #996958;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  flex: 0 0 auto;
}

.primary-rail-brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.primary-rail-brand-copy strong {
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.primary-rail-brand-copy span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
}

.primary-rail-toggle {
  width: 36px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}

.primary-rail-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.primary-rail-toggle-icon {
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.primary-rail-toggle-icon svg {
  width: 100%;
  height: 100%;
}

.primary-rail-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.primary-rail-section-label {
  padding: 4px 10px 2px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.primary-rail-btn {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.primary-rail-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: transparent;
}

.primary-rail-btn.active {
  background: rgba(153, 105, 88, 0.25);
  color: #ffffff;
  border-color: transparent;
  box-shadow: inset 3px 0 0 #996958;
}

.primary-rail-btn.active .primary-rail-icon {
  color: #996958;
}

.primary-rail-btn.active .primary-rail-label {
  color: #ffffff;
  font-weight: 700;
}

/* ── Sidebar sub-navigation children ── */
.primary-rail-children {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 4px 46px;
  overflow: hidden;
}

.primary-rail-btn.expanded + .primary-rail-children {
  display: flex;
}

.primary-rail-child {
  width: 100%;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: background 120ms ease-out, color 120ms ease-out;
}

.primary-rail-child:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.primary-rail-child.active {
  color: #ffffff;
  font-weight: 600;
  background: rgba(153, 105, 88, 0.18);
}

/* Hide children when rail is collapsed */
#app.primary-rail-collapsed .primary-rail-children {
  display: none;
}

.primary-rail-signout {
  margin-top: 4px;
  color: rgba(255, 128, 139, 0.8);
}

.primary-rail-signout:hover {
  background: rgba(255, 128, 139, 0.12);
  color: #FF808B;
  border-color: transparent;
}

.primary-rail-icon,
.primary-rail-avatar {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.primary-rail-icon svg {
  width: 20px;
  height: 20px;
}

.primary-rail-label {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: inherit;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}

#app.primary-rail-collapsed .primary-rail {
  padding-inline: 8px;
  align-items: center;
}

#app.primary-rail-collapsed .primary-rail-brand-copy,
#app.primary-rail-collapsed .primary-rail-section-label,
#app.primary-rail-collapsed .primary-rail-label {
  display: none;
}

#app.primary-rail-collapsed .primary-rail-btn {
  justify-content: center;
  padding-inline: 0;
}

#app.primary-rail-collapsed .primary-rail-toggle {
  width: 36px;
}

#app.primary-rail-collapsed .primary-rail-header {
  justify-content: center;
}

#app.primary-rail-collapsed .primary-rail-brand {
  display: none;
}

.primary-rail-spacer {
  flex: 1 1 auto;
}

.workspace-shell {
  display: block;
  padding: 8px 20px 6px;
  border: none;
  border-bottom: 1px solid #E8E4DF;
  border-radius: 0;
  background: #FFFFFF;
  box-shadow: none;
  overflow: visible;
  position: sticky;
  top: 0;
  z-index: 25;
}

.workspace-shell::after,
.workspace-actions,
.workspace-tab-registry {
  display: none !important;
}

.crm-topbar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.crm-topbar-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.crm-topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.crm-eyebrow,
#workspace-eyebrow {
  color: #996958;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: transparent;
  padding: 0;
}

#workspace-title {
  margin: 0;
  color: #023527;
  font-family: var(--font-heading, 'FreightBig Pro', Georgia, serif);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.01em;
}

#workspace-subtitle {
  margin: 2px 0 0;
  color: #5F5F82;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 13px;
  line-height: 1.45;
}

.crm-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.crm-command-trigger {
  height: 32px;
  min-width: 58px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.crm-command-trigger:hover {
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.crm-view-toggle,
.crm-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.crm-view-chip,
.crm-filter-pill {
  height: 30px;
  padding: 0 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.crm-view-chip.active,
.crm-filter-pill.active {
  background: var(--accent-subtle);
  color: var(--accent-ink);
  border-color: rgba(111, 70, 58, 0.18);
}

.crm-filter-pill.is-clear {
  color: var(--text-tertiary);
}

#workspace-content {
  padding: 0 18px 18px;
}

.tab-content {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.tab-content.active {
  content-visibility: auto;
  contain-intrinsic-size: 900px;
}

.detail-panel {
  width: 420px;
  max-width: 420px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.08);
}

.detail-panel-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.command-palette {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(6px);
}

.command-palette-dialog {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: min(480px, calc(min(100vh, 100dvh) - 80px));
  margin: 64px auto 0;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.command-palette-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

#command-palette-input,
.command-palette-input {
  flex: 1 1 auto;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  background: transparent;
}

#command-palette-close,
.command-palette-close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  cursor: pointer;
}

.command-palette-results {
  overflow: auto;
  padding: 8px;
}

.command-group-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.command-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 10px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}

.command-item:hover,
.command-item.active {
  background: var(--surface-raised);
}

.command-item-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.command-item-meta {
  color: var(--text-secondary);
  font-size: 12px;
}

.command-empty {
  padding: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
}

.command-item-hint {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.crm-floating-popover {
  z-index: 1250;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.crm-popover-search {
  padding: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.crm-popover-search-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
}

.crm-popover-options {
  max-height: 280px;
  overflow: auto;
  padding: 6px;
}

.crm-popover-option,
.crm-profile-action {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}

.crm-popover-option:hover,
.crm-popover-option.active,
.crm-profile-action:hover,
.crm-profile-action.active {
  background: var(--surface-raised);
}

.crm-profile-popover {
  padding: 8px;
}

.crm-profile-email {
  padding: 8px 10px 10px;
  color: var(--text-secondary);
  font-size: 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.crm-profile-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-resize-handle {
  display: none;
}

.detail-panel-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
}

.detail-title-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}

.detail-panel-header h2 {
  color: var(--text-primary);
  margin: 0;
}

.detail-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-header-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.detail-header-actions .btn-detail-map {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text-primary);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: transform 150ms ease-out, background 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out;
}

.detail-header-actions .btn-detail-map:hover,
.detail-header-actions .btn-detail-map:focus-visible {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.18);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.detail-panel-header .detail-close {
  justify-self: start;
  color: var(--text-primary);
}

.detail-hero {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-hero-head {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-hero-copy h3 {
  margin: 0 0 4px;
  color: var(--text-primary);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-hero-copy p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.detail-hero-contact-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.detail-hero-contact {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.detail-hero-contact.is-muted {
  color: var(--text-tertiary);
  font-weight: 500;
}

.detail-hero-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-hero-chip {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.detail-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.detail-hero-actions a,
.detail-hero-actions button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  background: rgba(255, 255, 255, 0.96);
  color: #314152;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: transform 150ms ease-out, background 150ms ease-out, border-color 150ms ease-out, box-shadow 150ms ease-out, color 150ms ease-out;
}

.detail-hero-actions a:hover,
.detail-hero-actions button:hover {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.18);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.detail-hero-actions .is-primary {
  background: linear-gradient(180deg, #1c2b38 0%, #243746 100%);
  border-color: rgba(15, 23, 42, 0.08);
  color: #f8fafc;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.14), 0 12px 24px rgba(15, 23, 42, 0.12);
}

.detail-hero-actions .is-primary:hover,
.detail-hero-actions .is-primary:focus-visible {
  background: linear-gradient(180deg, #223444 0%, #2d4558 100%);
  color: #fff;
}

.detail-hero-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.detail-hero-fact {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-raised);
}

.detail-hero-fact-label {
  display: block;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-hero-fact-value {
  display: block;
  margin-top: 4px;
  color: var(--text-primary);
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  font-weight: 600;
}

/* ── More button: hidden on desktop ── */
.primary-rail-more-btn {
  display: none;
}

/* ── Overflow sheet: hidden by default everywhere ── */
.primary-rail-overflow {
  display: none;
}

.primary-rail-overflow[aria-hidden="false"] {
  display: block;
}

.primary-rail-overflow-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9998;
}

.primary-rail-overflow-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--bg-surface, #fff);
  border-radius: 16px 16px 0 0;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  animation: overflow-slide-up 0.2s ease-out;
}

@keyframes overflow-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.primary-rail-overflow-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 8px 12px;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary, #666);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.primary-rail-overflow-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-secondary, #888);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}

.primary-rail-overflow-close:hover {
  background: var(--bg-hover, rgba(0, 0, 0, 0.06));
}

.primary-rail-overflow-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 48px;
  padding: 12px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 15px;
  color: var(--text-primary, #1a1a1a);
  cursor: pointer;
  text-align: left;
}

.primary-rail-overflow-item:hover,
.primary-rail-overflow-item:focus-visible {
  background: var(--bg-hover, rgba(0, 0, 0, 0.04));
}

.primary-rail-overflow-item .primary-rail-icon,
.primary-rail-overflow-item .primary-rail-avatar {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.primary-rail-overflow-item .primary-rail-icon svg {
  width: 22px;
  height: 22px;
}

/* Sign Out lives at the bottom of the More sheet. Mark it visually
   distinct so users don't miss-tap from Profile → Sign Out in a single
   scroll. */
.primary-rail-overflow-item-danger {
  color: var(--destructive, #b42318);
}

.primary-rail-overflow-item-danger .primary-rail-icon {
  color: var(--destructive, #b42318);
}

/* Landscape phones: viewport height drops to ~390px. Kick in the mobile
   bottom rail so users don't lose navigation after rotating.
   Note: NavigationRail.tsx switches to a mobile-only render path at the
   same 768px breakpoint, so we only need to size the 5 primary tab
   buttons + the overflow sheet here — there is no brand header, section
   labels, children menu, or hidden system cluster to suppress anymore. */
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 72px;
  }

  /* Prevent iOS Safari zoom-on-focus by making every input >= 16px. */
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,
  select,
  [role="combobox"],
  [role="textbox"] {
    font-size: 16px !important;
  }

  /* Eliminate 300ms delay + double-tap zoom on primary controls. */
  button,
  [role="button"],
  a,
  .primary-rail-btn,
  .primary-rail-child {
    touch-action: manipulation;
  }

  .primary-rail-mobile {
    order: 2;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    overflow: hidden;
    border-right: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }

  /* Each of the 5 primary mobile tabs: WCAG 2.5.5 requires a 44x44 min
     target; iOS HIG recommends 44x44. We use 48x48 with room below the
     icon for a tiny label so users know what each pill is without a
     press-and-hold. */
  .primary-rail-mobile .primary-rail-btn {
    flex: 1 1 0;
    min-width: 48px;
    min-height: 48px;
    padding: 4px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 10px;
    background: transparent;
  }

  .primary-rail-mobile .primary-rail-btn.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
  }

  .primary-rail-mobile .primary-rail-icon {
    width: 22px;
    height: 22px;
  }

  .primary-rail-mobile .primary-rail-icon svg {
    width: 22px;
    height: 22px;
  }

  .primary-rail-mobile-label {
    font-family: var(--font-body, 'Arsenal', sans-serif);
    font-size: 10px;
    line-height: 1.1;
    letter-spacing: 0.02em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace-shell {
    padding: 14px 16px 10px;
  }

  #workspace-content {
    padding: 16px;
  }

  .crm-topbar-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .crm-command-trigger,
  .crm-view-chip,
  .crm-filter-pill {
    min-height: 40px;
  }

  .detail-panel {
    width: 100vw;
    max-width: 100vw;
  }

  .detail-panel-header {
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
    padding-right: 18px;
  }

  .detail-header-actions {
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    max-width: calc(100vw - 168px);
  }

  .detail-panel-header h2 {
    min-width: 0;
    font-size: 21px;
  }

  .detail-subtitle {
    white-space: normal;
  }

  .btn-detail-map {
    width: 38px;
    min-width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
    gap: 0;
    border-radius: 12px;
  }

  .btn-detail-map span {
    display: none;
  }

  .btn-detail-map svg {
    margin: 0;
  }

  .detail-close {
    position: absolute;
    top: calc(18px + env(safe-area-inset-top, 0px));
    right: 16px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 24px;
    z-index: 4;
  }
}

.today-redesign,
.perform-shell,
.settings-home-shell {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.today-hero-bar,
.perform-hero,
.settings-home-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border: none;
  border-radius: 12px;
  background: #FAF7F2;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.today-hero-eyebrow,
.perform-eyebrow,
.settings-home-eyebrow {
  margin: 0 0 8px;
  color: #996958;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.today-hero-title,
.perform-hero-copy h3,
.settings-home-hero h3 {
  margin: 0 0 8px;
  color: #023527;
  font-family: var(--font-heading, 'FreightBig Pro', Georgia, serif);
  font-size: 26px;
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.today-hero-copy,
.perform-hero-copy p,
.settings-home-hero p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  max-width: 720px;
}

.perform-hero-note {
  margin-top: 8px !important;
  color: var(--text-tertiary) !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
}

.today-hero-date {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid #E8E4DF;
  border-radius: 20px;
  background: #FFFFFF;
  color: #023527;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.today-kpi-grid,
.perform-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.today-kpi-card,
.sales-kpi-card,
.today-panel,
.perform-card,
.settings-home-card {
  border: 1px solid #E8E4DF;
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.today-kpi-card,
.sales-kpi-card {
  padding: 20px;
}

.today-kpi-label,
.sales-kpi-label {
  display: block;
  margin-bottom: 8px;
  color: #5F5F82;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.today-kpi-value,
.sales-kpi-value {
  display: block;
  margin-bottom: 8px;
  color: #023527;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.today-kpi-caption,
.sales-kpi-delta {
  display: block;
  margin-top: 0;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.today-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.today-side-grid,
.settings-home-grid {
  display: grid;
  gap: 16px;
}

.today-panel,
.perform-card,
.settings-home-card {
  padding: 20px;
}

.today-panel-header,
.perform-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.today-panel-title,
.perform-card-header h4,
.settings-home-card h4 {
  margin: 0 0 6px;
  color: #023527;
  font-family: var(--font-body, 'Arsenal', sans-serif);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.today-panel-subtitle,
.perform-card-header p,
.settings-home-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.today-link-btn,
.settings-home-command {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.today-link-btn:hover,
.settings-home-command:hover {
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--accent-subtle);
}

.today-list,
.today-side-grid,
.today-agenda-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.today-item,
.today-agenda-item,
.today-route-card {
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--surface-raised);
}

.today-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.today-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.today-chip,
.today-stage-badge {
  min-height: 24px;
  padding: 0 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
}

.today-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
}

.today-stage-badge {
  border: none;
  background: color-mix(in srgb, var(--stage-badge-color, var(--accent)) 18%, white);
  color: #1f2937;
}

.today-item-title,
.today-agenda-title {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.today-item-meta,
.today-item-reason,
.today-agenda-meta,
.today-route-copy {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.today-item-meta {
  margin-top: 2px;
}

.today-item-reason {
  margin-top: 6px;
}

.today-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.today-inline-btn {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.today-inline-btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.today-inline-btn:hover {
  background: var(--surface-inset);
}

.today-inline-btn.primary:hover {
  background: var(--accent-hover);
}

.today-agenda-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
}

.today-agenda-date {
  flex-shrink: 0;
  color: var(--accent-ink);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
}

.today-route-card {
  padding: 16px;
}

.today-route-plan {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.06), var(--surface));
}

.today-route-plan-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.today-route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.today-route-stops {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-route-stop {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
}

.today-route-stop-seq {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  font-family: "JetBrains Mono", monospace;
}

.today-route-stop-copy {
  min-width: 0;
}

.today-route-stop-title {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.today-route-stop-meta {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.today-route-city {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.today-empty {
  padding: 20px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.perform-hero {
  align-items: stretch;
  border-color: rgba(15, 23, 42, 0.08);
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 32%),
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 34%),
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(255, 255, 255, 0.92));
}

.perform-filters {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: min(420px, 100%);
}

.perform-periods,
.perform-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.perform-filters-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
}

.perform-period-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.perform-period-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 14px;
  border: 1px solid var(--border, rgba(15, 23, 42, 0.12));
  border-radius: 9999px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground, #14242f);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.perform-period-pill:hover { background: rgba(15, 23, 42, 0.05); }
.perform-period-pill.active {
  background: var(--primary, #0d6b4e);
  border-color: var(--primary, #0d6b4e);
  color: #fff;
}
.perform-period-pill:disabled { opacity: 0.5; cursor: not-allowed; }

.perform-pill-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.perform-date-range {
  display: flex;
  gap: 6px;
}

.perform-date-input {
  max-width: 140px;
  font-size: 12px;
  height: 32px;
}

.perform-rep-select {
  max-width: 180px;
  font-size: 12px;
  height: 32px;
}

.perform-sync-status {
  font-size: 11px;
  color: var(--muted-foreground, #526071);
}

.retention-health-widget {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
}

.retention-health-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 4px 0;
  font-size: 12px;
  color: var(--muted-foreground, #526071);
}

.retention-stat strong {
  font-size: 16px;
  color: var(--foreground, #14242f);
  margin-right: 4px;
}

.retention-stat-warn strong {
  color: #c0443b;
}

.perform-board-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.perform-board-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 18px 20px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.03), rgba(15, 118, 110, 0.06)),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.perform-board-copy h4 {
  margin: 4px 0 6px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.perform-board-copy p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.perform-board-kicker {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.perform-board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.perform-board-actions .btn-reload {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.perform-board-actions .btn-reload.btn-shell-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.perform-board-actions .btn-reload.btn-shell-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, #000 12%);
  border-color: color-mix(in srgb, var(--accent) 88%, #000 12%);
  color: #fff;
}

.perform-board-actions .btn-reload:hover {
  background: var(--accent-subtle);
  border-color: rgba(37, 99, 235, 0.24);
  color: var(--accent);
}

.perform-board-actions .btn-reload.btn-reload-active {
  background: var(--accent-subtle) !important;
  border-color: rgba(37, 99, 235, 0.28) !important;
  color: var(--accent) !important;
}

.perform-board-actions .btn-reload .spinner-sm {
  color: inherit;
}

.perform-board-studio {
  padding: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.02), rgba(255, 255, 255, 0.98));
  box-shadow: var(--shadow-sm);
}

.perform-board-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.perform-preset-pill {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.perform-preset-pill:hover {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--accent-subtle);
  color: var(--accent);
}

.perform-board-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.perform-board-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.perform-board-column-header h5 {
  margin: 0 0 4px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.perform-board-column-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.perform-board-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perform-widget-token {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.perform-widget-token-main {
  flex: 1;
  min-width: 0;
}

.perform-widget-token-topline,
.perform-widget-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.perform-widget-token strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
}

.perform-widget-token p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.perform-widget-token-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.perform-widget-token-meta span {
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
}

.perform-widget-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.perform-widget-control-group > span {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.perform-widget-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.perform-widget-token-actions {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.perform-widget-drag-handle {
  width: 24px;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: grab;
}

.perform-widget-token[draggable="true"],
.perform-widget-card[draggable="true"] {
  cursor: grab;
}

.perform-widget-token.is-dragging,
.perform-widget-card.is-dragging {
  opacity: 0.64;
}

.perform-drop-target {
  border-color: rgba(37, 99, 235, 0.32);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.perform-board-focus {
  animation: performBoardFocusFlash 1.1s ease-out;
}

@keyframes performBoardFocusFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.16);
  }
  40% {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.16);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

.perform-widget-token-actions button,
.perform-widget-segmented button,
.perform-widget-hide {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.perform-widget-token-actions button:hover,
.perform-widget-segmented button:hover,
.perform-widget-hide:hover {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--accent-subtle);
  color: var(--accent);
}

.perform-widget-token-actions button:disabled,
.perform-widget-segmented button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.perform-widget-segmented button.active {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--accent-subtle);
  color: var(--accent);
}

.perform-board-grid .perform-widget-card {
  border-radius: 14px;
  overflow: hidden;
}

.perform-widget-header {
  align-items: center;
}

.perform-widget-hide {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.perform-grid-slot {
  min-width: 0;
}

.perform-empty-slot {
  width: 100%;
  min-height: 100%;
  padding: 22px 18px;
  border: 2px dashed rgba(37, 99, 235, 0.2);
  border-radius: 14px;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.08), transparent 55%),
    rgba(255, 255, 255, 0.72);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 150ms ease-out, background 150ms ease-out, transform 150ms ease-out;
}

.perform-empty-slot:hover {
  border-color: rgba(37, 99, 235, 0.38);
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.12), transparent 55%),
    rgba(239, 246, 255, 0.92);
  transform: translateY(-1px);
}

.perform-empty-slot-static {
  cursor: default;
}

.perform-empty-slot-static:hover {
  border-color: rgba(37, 99, 235, 0.2);
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.08), transparent 55%),
    rgba(255, 255, 255, 0.72);
  transform: none;
}

.perform-empty-slot-icon {
  width: 64px;
  height: 64px;
  border: 2px dashed rgba(37, 99, 235, 0.35);
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 500;
  line-height: 1;
}

.perform-empty-slot-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.perform-empty-slot-copy strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.perform-empty-slot-copy small {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.perform-empty-slot-copy em {
  color: var(--accent);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

body.crm-overlay-open {
  overflow: hidden;
}

.perform-chart-picker-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.perform-chart-picker-modal {
  width: min(1100px, 100%);
  max-height: min(88vh, 920px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
  box-shadow: 0 36px 90px rgba(15, 23, 42, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.perform-chart-picker-header,
.perform-chart-picker-footer {
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.perform-chart-picker-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.perform-chart-picker-header h3 {
  margin: 6px 0 6px;
  color: var(--text-primary);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.perform-chart-picker-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

.perform-chart-picker-kicker {
  color: var(--text-tertiary);
  display: inline-flex;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.perform-chart-picker-close {
  width: 40px;
  min-width: 40px;
  height: 40px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.perform-chart-picker-close:hover {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--accent-subtle);
  color: var(--accent);
}

.perform-chart-picker-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 0;
}

.perform-chart-picker-sidebar {
  min-height: 0;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.78);
  display: flex;
  flex-direction: column;
}

.perform-chart-picker-sidebar-head {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.perform-chart-picker-sidebar-head h4 {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.perform-chart-picker-sidebar-head span {
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 700;
}

.perform-chart-picker-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perform-chart-picker-card {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: inherit;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.perform-chart-picker-card:hover,
.perform-chart-picker-card.active {
  border-color: rgba(37, 99, 235, 0.24);
  box-shadow: 0 18px 34px rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.perform-chart-picker-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.perform-chart-picker-card-badge,
.perform-chart-picker-preview-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.perform-chart-picker-card-state,
.perform-chart-picker-preview-note {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.perform-chart-picker-card strong {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.perform-chart-picker-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.55;
}

.perform-chart-picker-preview-panel {
  min-height: 0;
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.perform-chart-picker-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.perform-chart-picker-preview-card {
  min-height: 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: 0 22px 38px rgba(15, 23, 42, 0.08);
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.perform-chart-picker-preview-card-header h4 {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
}

.perform-chart-picker-preview-card-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.6;
}

.perform-chart-picker-preview-art-wrap {
  flex: 1;
  min-height: 0;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(252, 251, 247, 0.96), rgba(255, 255, 255, 1));
  border: 1px solid var(--border);
  padding: 14px;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.perform-preview-art {
  width: 100%;
  height: 100%;
  min-height: 240px;
  display: block;
}

.perform-chart-picker-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.perform-chart-picker-footer {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  justify-content: flex-end;
}

@media (max-width: 1080px) {
  .perform-chart-picker-body {
    grid-template-columns: 1fr;
  }

  .perform-chart-picker-sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    max-height: 260px;
  }
}

@media (max-width: 720px) {
  .perform-chart-picker-overlay {
    padding: 16px;
  }

  .perform-chart-picker-header,
  .perform-chart-picker-footer,
  .perform-chart-picker-preview-panel {
    padding-left: 18px;
    padding-right: 18px;
  }

  .perform-chart-picker-controls {
    grid-template-columns: 1fr;
  }

  .perform-preview-art {
    min-height: 190px;
  }
}

.sales-period-btn,
.perform-filter-row input,
.perform-filter-row select {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: "Satoshi", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
}

.sales-period-btn {
  cursor: pointer;
}

.sales-period-btn.active,
.sales-period-btn:hover {
  border-color: rgba(111, 70, 58, 0.18);
  background: var(--accent-subtle);
  color: var(--accent-ink);
}

.perform-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.perform-card-wide {
  grid-column: 1 / -1;
}

.perform-chart-wrap {
  min-height: 280px;
}

.perform-widget-body-wrap {
  min-height: 280px;
}

.perform-widget-height-short .perform-chart-wrap,
.perform-widget-height-short .perform-widget-body-wrap {
  min-height: 220px;
}

.perform-widget-height-medium .perform-chart-wrap,
.perform-widget-height-medium .perform-widget-body-wrap {
  min-height: 300px;
}

.perform-widget-height-tall .perform-chart-wrap,
.perform-widget-height-tall .perform-widget-body-wrap {
  min-height: 420px;
}

.perform-alert-banner {
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.08);
  color: #92400e;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.perform-pipeline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
}

.perform-stage-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.perform-stage-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.perform-stage-card strong {
  color: var(--text-primary);
  font-family: "JetBrains Mono", monospace;
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.perform-stage-card span:last-child {
  color: var(--text-secondary);
  font-size: 12px;
}

.perform-stage-label {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.perform-hero-note {
  color: var(--text-secondary);
}

.perform-stale-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.perform-stale-list h5 {
  margin: 0;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
}

.perform-stale-item {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  cursor: pointer;
}

.perform-stale-item:hover {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--accent-subtle);
}

.perform-stale-item small {
  display: block;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.perform-table-wrap {
  overflow: auto;
}

.sales-table {
  width: 100%;
  border-collapse: collapse;
}

.sales-table thead th {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
}

.sales-table tbody td {
  padding: 14px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 13px;
}

.sales-table tbody tr:hover {
  background: var(--surface-raised);
}

.sales-table .right {
  text-align: right;
}

#tab-sales,
#tab-settings-home,
#tab-operations {
  padding: 16px;
  overflow-y: auto;
}

.settings-home-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.settings-home-card {
  cursor: pointer;
  transition: border-color 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}

.settings-home-card:hover {
  transform: translateY(-1px);
  border-color: rgba(37, 99, 235, 0.22);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.settings-home-card-kicker {
  display: inline-flex;
  margin-bottom: 10px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-home-meta {
  margin-top: 16px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

@media (max-width: 1180px) {
  .today-kpi-grid,
  .perform-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .perform-grid,
  .settings-home-grid,
  .perform-pipeline-grid,
  .perform-board-columns {
    grid-template-columns: 1fr;
  }

  .perform-stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .today-main-grid,
  .today-hero-bar,
  .perform-hero,
  .perform-board-toolbar,
  .settings-home-hero {
    grid-template-columns: 1fr;
    display: grid;
  }

  .today-route-plan-header,
  .today-route-stop {
    grid-template-columns: 1fr;
  }

  .today-route-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .today-kpi-grid,
  .perform-kpi-grid,
  .perform-stage-grid {
    grid-template-columns: 1fr;
  }

  .today-item,
  .today-agenda-item {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  #tab-sales,
  #tab-settings-home,
  #today-root {
    padding: 12px;
  }
}

.detail-workspace-rail {
  display: none;
}

.detail-close {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: #243746;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: background 150ms ease-out, border-color 150ms ease-out, transform 150ms ease-out, box-shadow 150ms ease-out;
}

.detail-close:hover,
.detail-close:focus-visible {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.18);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.detail-close-icon {
  font-size: 16px;
  line-height: 1;
}

.detail-close-label {
  font-size: 12px;
  letter-spacing: 0.02em;
}

.detail-workspace-card {
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.06);
  padding: 16px;
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}

.detail-workspace-card-primary {
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.96)),
    rgba(255, 255, 255, 0.96);
}

.detail-workspace-kicker {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-workspace-phase,
.detail-workspace-focus {
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.detail-workspace-copy,
.detail-workspace-note {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.detail-workspace-note {
  margin-top: 8px;
}

.detail-workflow-stepper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-workflow-step {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-subtle, rgba(15, 23, 42, 0.03));
}

.detail-workflow-step.is-complete {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.16);
}

.detail-workflow-step.is-active {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.18);
  box-shadow: inset 3px 0 0 var(--accent);
}

.detail-workflow-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
}

.detail-workflow-step.is-complete .detail-workflow-step-index {
  background: rgba(22, 163, 74, 0.16);
  color: #166534;
}

.detail-workflow-step.is-active .detail-workflow-step-index {
  background: rgba(37, 99, 235, 0.16);
  color: #1d4ed8;
}

.detail-workflow-step-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-workflow-step-copy strong {
  color: var(--text-primary);
  font-size: 13px;
}

.detail-workflow-step-copy span {
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.45;
}

.detail-workspace-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.detail-workspace-quick-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out, transform 150ms ease-out;
}

.detail-workspace-quick-btn:hover,
.detail-workspace-quick-btn:focus-visible {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(37, 99, 235, 0.26);
  transform: translateY(-1px);
}

.detail-workspace-quick-btn.active {
  background: #17242d;
  border-color: #17242d;
  color: #f8fafc;
}

.detail-workspace-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.detail-workspace-stats div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 10px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
}

.detail-workspace-stats div:first-child {
  border-top: none;
  padding-top: 0;
}

.detail-workspace-stats dt {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-workspace-stats dd {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
}

@media (min-width: 980px) {
  .detail-overlay {
    display: none !important;
  }

  .detail-panel.detail-panel-open {
    top: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    left: auto !important;
    width: clamp(460px, 42vw, 760px) !important;
    max-width: calc(100vw - var(--detail-panel-left, 12px) - 24px) !important;
    height: auto !important;
    border-radius: 28px;
    border: 1px solid var(--border-subtle);
    background: rgba(248, 250, 252, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: 0 26px 70px rgba(15, 23, 42, 0.18);
    animation: none !important;
    transform: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden;
  }

  .detail-panel-header {
    padding: 22px 28px 18px;
    background:
      radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 28%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(245, 247, 250, 0.96));
    border-bottom: 1px solid var(--border-subtle);
  }

  .detail-panel-tabs {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px 18px 0;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    background:
      linear-gradient(180deg, rgba(246, 248, 251, 0.95), rgba(240, 244, 248, 0.85));
  }

  .detail-tab {
    width: auto;
    justify-content: center;
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.76);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0;
  }

  .detail-tab:hover,
  .detail-tab:focus-visible {
    background: rgba(255, 255, 255, 0.92);
    color: var(--text-primary);
  }

  .detail-tab.active {
    background: linear-gradient(135deg, #17242d, #243645);
    border-color: transparent;
    color: #f8fafc;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.14);
  }

  .detail-workspace-rail {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 0 0 auto;
    max-height: 240px;
    overflow-y: auto;
    padding: 16px 18px 18px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    background:
      linear-gradient(180deg, rgba(246, 248, 251, 0.95), rgba(240, 244, 248, 0.85));
  }

  .detail-panel-body {
    min-height: 0;
    flex: 1 1 auto;
    padding: 24px 28px 28px;
    background:
      radial-gradient(circle at top right, rgba(37, 99, 235, 0.06), transparent 24%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 249, 252, 0.98));
    overflow-y: auto;
  }

  .detail-hero {
    padding: 0 0 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
  }

  .detail-hero-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .detail-hero-chip-row {
    justify-content: flex-end;
  }

.detail-section {
  margin-bottom: 24px;
  padding: 18px 20px 20px;
  border: 1px solid var(--border-subtle);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.05);
  content-visibility: auto;
  contain-intrinsic-size: 360px;
}
}

@media (max-width: 979px) {
  .detail-close-label {
    display: none;
  }
}

/* 2026-04 speed and workspace polish overrides */
.detail-panel-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  padding: 18px 20px 16px;
}

.detail-close {
  position: relative;
  z-index: 2;
  align-self: start;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.detail-title-stack {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-header-actions {
  gap: 8px;
  align-self: start;
}

.detail-header-actions .btn-detail-map {
  min-height: 40px;
  padding: 0 13px;
  border-radius: 10px;
}

.detail-hero.detail-hero-v2 {
  padding: 0 0 18px;
  margin-bottom: 18px;
}

.detail-hero-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.detail-hero-primary,
.detail-hero-properties {
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.04);
}

.detail-hero-primary {
  padding: 18px 18px 16px;
}

.detail-hero-properties {
  padding: 16px;
}

.detail-hero-kicker-row,
.detail-hero-title-row,
.field-motion-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.detail-hero-kicker,
.detail-hero-properties-kicker {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.detail-hero-help-btn,
.field-motion-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  border-radius: 9px;
  background: rgba(248, 250, 252, 0.92);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.detail-hero-help-btn:hover,
.detail-hero-help-btn:focus-visible,
.field-motion-help-btn:hover,
.field-motion-help-btn:focus-visible {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.18);
  transform: translateY(-1px);
}

.detail-hero-title-row h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(24px, 2vw, 30px);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.detail-hero-stage-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.detail-hero-summary {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  max-width: 62ch;
}

.detail-hero-support,
.detail-hero-location,
.detail-hero-inline-notice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.detail-hero-summary,
.detail-hero-location,
.detail-hero-property-value {
  overflow-wrap: anywhere;
}

.detail-hero-inline-notice {
  margin-top: 12px;
  color: var(--text-tertiary);
}

.detail-hero-inline-sep {
  color: rgba(82, 96, 113, 0.68);
}

.detail-hero-contact-lines {
  gap: 10px;
  margin-top: 12px;
}

.detail-hero-contact {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  border-radius: 9px;
  background: rgba(248, 250, 252, 0.9);
  display: inline-flex;
  align-items: center;
}

.detail-hero-actions {
  gap: 8px;
  margin-top: 14px;
}

.detail-hero-actions a,
.detail-hero-actions button {
  min-height: 38px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.detail-hero-actions a:hover,
.detail-hero-actions button:hover,
.detail-hero-actions a:focus-visible,
.detail-hero-actions button:focus-visible {
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.06);
}

.detail-hero-actions .is-primary {
  background: linear-gradient(180deg, #1b2834 0%, #233341 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), 0 10px 20px rgba(15, 23, 42, 0.08);
}

.detail-hero-properties-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}

.detail-hero-properties-title {
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.detail-hero-property-list {
  display: grid;
  gap: 8px;
}

.detail-hero-property-row {
  display: grid;
  grid-template-columns: minmax(0, 116px) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid rgba(20, 36, 47, 0.08);
}

.detail-hero-property-row:first-child {
  border-top: none;
  padding-top: 0;
}

.detail-hero-property-label {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-hero-property-value {
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.field-motion-title-row {
  margin-bottom: 6px;
}

.field-motion-help-btn {
  flex: 0 0 auto;
}

.help-center-open {
  overflow: hidden;
}

.help-center-overlay {
  position: fixed;
  inset: 0;
  z-index: 12050;
  padding: 28px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(10px);
  isolation: isolate;
}

.help-center-dialog {
  position: relative;
  z-index: 1;
  height: min(86vh, 960px);
  max-width: 1180px;
  margin: 0 auto;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(247, 249, 252, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 34px 80px rgba(15, 23, 42, 0.18);
}

.help-center-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  height: 100%;
}

.help-center-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px 20px;
  border-right: 1px solid rgba(20, 36, 47, 0.08);
  background: linear-gradient(180deg, rgba(241, 245, 249, 0.96), rgba(248, 250, 252, 0.98));
}

.help-center-sidebar-head h2,
.help-center-answer-head h3,
.help-center-article h2 {
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.03em;
}

.help-center-sidebar-head p,
.help-center-article-summary,
.help-center-answer-body,
.help-center-empty p {
  color: var(--text-secondary);
  line-height: 1.6;
}

.help-center-kicker,
.help-center-sidebar-label,
.help-center-answer-kicker,
.help-center-article-kicker {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.help-center-sidebar-list {
  display: grid;
  gap: 8px;
}

.help-center-mobile-list {
  padding: 12px 18px 0;
}

.help-center-sidebar-group.compact {
  padding: 0;
}

.help-center-nav-btn {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.help-center-nav-btn strong {
  color: var(--text-primary);
  font-size: 13px;
}

.help-center-nav-btn span {
  font-size: 12px;
  line-height: 1.45;
}

.help-center-nav-btn:hover,
.help-center-nav-btn:focus-visible,
.help-center-nav-btn.active {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.16);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.help-center-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.help-center-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 20px 22px 16px;
  border-bottom: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(255, 255, 255, 0.74);
}

.help-center-search input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(20, 36, 47, 0.12);
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.96);
  padding: 0 14px;
  color: var(--text-primary);
  font-size: 14px;
}

.help-center-toolbar-btn,
.help-center-close,
.help-center-action-btn,
.help-center-source-chip {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(20, 36, 47, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.help-center-toolbar-btn.primary {
  background: linear-gradient(180deg, #1b2834 0%, #233341 100%);
  color: #f8fafc;
  border-color: rgba(15, 23, 42, 0.08);
}

.help-center-toolbar-btn:hover,
.help-center-toolbar-btn:focus-visible,
.help-center-close:hover,
.help-center-close:focus-visible,
.help-center-action-btn:hover,
.help-center-action-btn:focus-visible,
.help-center-source-chip:hover,
.help-center-source-chip:focus-visible {
  background: #fff;
  border-color: rgba(20, 36, 47, 0.16);
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.help-center-toolbar-btn.primary:hover,
.help-center-toolbar-btn.primary:focus-visible {
  background: linear-gradient(180deg, #223444 0%, #2d4152 100%);
}

.help-center-main-scroll {
  flex: 1;
  overflow: auto;
  padding: 22px;
  display: grid;
  gap: 18px;
}

.help-center-answer-card,
.help-center-article,
.help-center-empty {
  border: 1px solid rgba(20, 36, 47, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  padding: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
  content-visibility: auto;
  contain-intrinsic-size: 280px;
}

.help-center-answer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.help-center-answer-status {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(20, 36, 47, 0.08);
  background: rgba(241, 245, 249, 0.94);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
}

.help-center-answer-sources,
.help-center-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.help-center-article-section {
  margin-top: 18px;
}

.help-center-article-section h3 {
  margin: 0 0 10px;
  color: var(--text-primary);
  font-size: 14px;
}

.help-center-article-section ol,
.help-center-article-section ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .detail-hero-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-hero-properties {
    order: 2;
  }
}

@media (max-width: 979px) {
  .detail-panel-header {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
  }

  .detail-header-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .detail-hero-title-row,
  .detail-hero-kicker-row,
  .field-motion-title-row,
  .help-center-toolbar,
  .help-center-answer-head {
    flex-direction: column;
    align-items: stretch;
  }

  .help-center-overlay {
    padding: 12px;
  }

  .help-center-dialog {
    height: min(92vh, 960px);
    border-radius: 18px;
  }

  .help-center-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .help-center-sidebar {
    border-right: none;
    border-bottom: 1px solid rgba(20, 36, 47, 0.08);
    max-height: 34vh;
    overflow: auto;
  }

  .help-center-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .help-center-mobile-list {
    padding: 12px 16px 0;
  }
}

@media (max-width: 640px) {
  .detail-hero-property-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .detail-hero-actions a,
  .detail-hero-actions button,
  .help-center-toolbar-btn,
  .help-center-close {
    width: 100%;
  }

  .detail-hero-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

.detail-panel,
.detail-panel-body {
  overflow-x: hidden;
}

/* ══════════════════════════════════════════
   A11y + visual polish — QA sweep 2026-04-15
   ══════════════════════════════════════════ */

/* Contrast: bump low-contrast helper labels on Today/Dashboard from 3.74:1
   to 4.5:1+. The nav-rail child already uses rgba(255,255,255,0.55) but on
   the dark rail that's >4.5:1; the failure was on LIGHT-bg labels using
   text-tertiary. Force min-contrast tone. */
.today-hero-eyebrow,
.summary-modern-empty,
.territory-explorer-meta,
.crm-workspace-kicker,
.crm-workspace-description {
  color: var(--text-secondary, #4b4444) !important;
}

/* Give Today's <main> horizontal breathing room (was 0px on Dashboard) */
#main {
  padding-inline: max(env(safe-area-inset-left, 0px), 16px) max(env(safe-area-inset-right, 0px), 16px);
}
@media (min-width: 768px) {
  #main {
    padding-inline: 24px 24px;
  }
}

/* Territory toolbar hover + focus rings (UX v5 flagged these as missing) */
.map-top-btn,
.map-top-btn-secondary {
  transition: background 120ms ease-out, color 120ms ease-out, box-shadow 120ms ease-out;
}
.map-top-btn:hover,
.map-top-btn-secondary:hover {
  background: var(--accent-subtle, rgba(153, 105, 88, 0.16));
}
.map-top-btn:focus-visible,
.map-top-btn-secondary:focus-visible,
.primary-rail-btn:focus-visible,
.primary-rail-child:focus-visible {
  outline: 2px solid var(--accent, #996958);
  outline-offset: 2px;
}

/* Button-height consistency on Perform (was 5 distinct heights).
   Enforce a shared scale for action rows. */
.perform-actions button,
.perform-filter-row button,
.perform-filter-row [role="combobox"],
.perform-filter-row input {
  min-height: 36px;
  box-sizing: border-box;
}

/* Territory loading skeleton — replace bare "Loading map..." text */
.territory-map-loading {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  padding: 24px;
  min-width: 220px;
  background: rgba(255, 253, 249, 0.82);
  border-radius: 12px;
  backdrop-filter: blur(8px);
}
.territory-map-loading::before {
  content: "";
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(153, 105, 88, 0.2);
  border-top-color: var(--accent, #996958);
  animation: territory-spin 800ms linear infinite;
}
@keyframes territory-spin { to { transform: rotate(360deg); } }

/* Touch-target min for mobile buttons that were <44px */
@media (max-width: 767px), (max-height: 500px) and (pointer: coarse) {
  #ctrl-k-button,
  [data-search-show],
  .command-palette-trigger {
    min-height: 44px;
    min-width: 44px;
  }
}

/* Territory toolbar color-mode select (shadcn Select) — match height of
   sibling map-top-btn buttons and ensure the dropdown renders above the
   Leaflet map (z-index 400) and the map-card-container (z-index 1100). */
.map-color-mode-trigger {
  height: 32px;
  min-width: 160px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
}
/* Must render above .map-top-actions (z-index 1208) since Radix portals the
   dropdown content to document.body. Using !important to defeat the inline
   Tailwind `z-50` baked into SelectContent's className. */
.map-color-mode-content {
  z-index: 1300 !important;
}

/* ────────────────────────────────────────────────────────────────────
   Phase B: Region polygon selection (Idealista-style area picker)
   ──────────────────────────────────────────────────────────────── */

/* Select-areas toggle button active state */
.btn-select-areas-toggle.is-active {
  background: #e91e8c;
  color: #fff;
  border-color: #e91e8c;
}
.btn-select-areas-toggle.is-active:hover {
  background: #d1177e;
}

/* Leaflet tooltip for region polygons */
.region-polygon-tooltip {
  background: rgba(30, 30, 40, 0.92);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  white-space: nowrap;
}
.region-polygon-tooltip::before {
  border-top-color: rgba(30, 30, 40, 0.92) !important;
}

/* ── Selected-areas sidebar ── */
.selected-areas-sidebar {
  position: absolute;
  right: 16px;
  top: 56px;
  bottom: 16px;
  width: 300px;
  max-height: calc(100% - 72px);
  background: var(--background, #fff);
  border: 1px solid var(--border, #e2e2e8);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sas-slide-in 0.2s ease-out;
}

@keyframes sas-slide-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

.selected-areas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border, #e2e2e8);
}

.selected-areas-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selected-areas-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground, #111);
}

.selected-areas-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e91e8c;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.selected-areas-actions-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selected-areas-clear-link {
  background: none;
  border: none;
  color: var(--muted-foreground, #888);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.selected-areas-clear-link:hover {
  color: var(--foreground, #111);
}

.selected-areas-close {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--muted-foreground, #888);
  cursor: pointer;
  padding: 0 2px;
}
.selected-areas-close:hover {
  color: var(--foreground, #111);
}

/* Scrollable list */
.selected-areas-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.selected-areas-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  transition: background 0.15s;
}
.selected-areas-item:hover {
  background: var(--muted, #f5f5f5);
}

.selected-areas-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.selected-areas-item-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: #e91e8c;
  flex-shrink: 0;
}

.selected-areas-item-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.selected-areas-item-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground, #111);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.selected-areas-item-meta {
  font-size: 11px;
  color: var(--muted-foreground, #888);
}

.selected-areas-item-remove {
  background: none;
  border: none;
  font-size: 16px;
  line-height: 1;
  color: var(--muted-foreground, #888);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
}
.selected-areas-item-remove:hover {
  background: var(--destructive, #fee);
  color: var(--destructive-foreground, #d00);
}

/* Footer with CTA */
.selected-areas-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border, #e2e2e8);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selected-areas-total {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground, #888);
}

.selected-areas-view-btn {
  width: 100%;
  background: #e91e8c;
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 13px;
}
.selected-areas-view-btn:hover {
  background: #d1177e;
}

/* ── Drawn-area swatch (dashed border distinguishes from province swatches) ── */
.selected-areas-item-swatch.is-drawn {
  border: 2px dashed #e91e8c;
  background: rgba(233, 30, 140, 0.15);
}
.selected-areas-item.is-drawn {
  border-left: 3px solid #e91e8c;
}

/* ── Draw-area toolbar button ── */
.btn-draw-area {
  gap: 4px;
}
.btn-draw-area.is-drawing {
  animation: draw-pulse 1.2s ease-in-out infinite;
}
@keyframes draw-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ── Draw-area instruction tooltip ── */
.draw-area-instructions {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1300;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  animation: draw-instructions-in 0.2s ease-out;
  max-width: 320px;
}
.draw-area-instructions-hint {
  font-size: 11px;
  opacity: 0.7;
}
.draw-area-finish-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 5px 16px;
  background: #e91e8c;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s;
}
.draw-area-finish-btn:hover {
  background: #c7177a;
}
@keyframes draw-instructions-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Draw-area vertex markers ── */
.draw-area-first-vertex {
  cursor: pointer !important;
}

/* Mobile: sidebar full-width at bottom */
@media (max-width: 640px) {
  .selected-areas-sidebar {
    right: 0;
    left: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    max-height: 50vh;
    border-radius: 12px 12px 0 0;
  }
}

/* ── Brand filter dropdown (map toolbar) ── */
.map-brand-filter {
  display: inline-flex;
  align-items: center;
}

/* ── Table: area filter banner ── */
.table-area-filter-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: var(--color-accent-bg, #eff6ff);
  border-bottom: 1px solid var(--color-accent-border, #bfdbfe);
  font-size: 13px;
  color: var(--text-primary, #1e293b);
  flex-shrink: 0;
}
.table-area-filter-banner-text {
  flex: 1;
  font-weight: 500;
}
.table-area-filter-banner-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-primary, #2563eb);
  font-size: 13px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
.table-area-filter-banner-clear:hover {
  background: var(--color-primary-hover-bg, #dbeafe);
}

/* ── Idealista-style polygon filter chip ── */
.table-polygon-filter-chip {
  background: rgba(233, 30, 140, 0.08);
  border-bottom: 1px solid rgba(233, 30, 140, 0.4);
  color: #ad1973;
}
.table-polygon-filter-chip .table-area-filter-banner-text::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #e91e8c;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.table-polygon-filter-chip .table-area-filter-banner-clear {
  color: #ad1973;
  font-size: 18px;
  line-height: 1;
  padding: 2px 8px;
}
.table-polygon-filter-chip .table-area-filter-banner-clear:hover {
  background: rgba(233, 30, 140, 0.18);
}
.territory-polygon-filter-chip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  border-radius: 999px;
  border: 1px solid rgba(233, 30, 140, 0.4);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  padding: 6px 14px;
}

/* ── Table: view toggle (Table / Cards) ── */
.table-view-toggle {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.table-view-toggle-btn {
  border-radius: 6px;
}

/* ── Pharmacy card grid ── */
.pharmacy-card-grid-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  min-height: 0;
  overflow-y: auto;
  flex: 1;
}
.pharmacy-card-grid-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted, #64748b);
}
.pharmacy-card-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.pharmacy-card-grid-info {
  font-size: 13px;
}

.pharmacy-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 1024px) {
  .pharmacy-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .pharmacy-card-grid {
    grid-template-columns: 1fr;
  }
}

.pharmacy-card-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted, #64748b);
  font-size: 14px;
}

.pharmacy-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  background: var(--surface-bg, #fff);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.pharmacy-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--color-primary, #2563eb);
}
.pharmacy-card.is-selected {
  border-color: var(--color-primary, #2563eb);
  background: var(--color-accent-bg, #eff6ff);
}

.pharmacy-card-checkbox-wrap {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
}
.pharmacy-card-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary, #2563eb);
}

.pharmacy-card-photo {
  width: 100%;
  height: 120px;
  background: var(--surface-muted, #f1f5f9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.pharmacy-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pharmacy-card-photo-placeholder {
  background: linear-gradient(135deg, #e0e7ff, #f0fdf4);
}
.pharmacy-card-initials {
  font-size: 36px;
  font-weight: 700;
  color: var(--color-primary, #2563eb);
  opacity: 0.4;
}

.pharmacy-card-body {
  flex: 1;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pharmacy-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  line-height: 1.3;
  /* Reserve the 16px checkbox width + 10px absolute-left offset + 6px gap */
  padding-left: 28px;
}
.pharmacy-card-address {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  line-height: 1.4;
}
.pharmacy-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.pharmacy-card-stage {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
}
.pharmacy-card-score {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  background: var(--surface-muted, #f1f5f9);
  padding: 2px 6px;
  border-radius: 9999px;
}

.pharmacy-card-brands {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.pharmacy-card-brand-tag {
  font-size: 11px;
  padding: 1px 6px;
  background: var(--surface-muted, #f1f5f9);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 4px;
  color: var(--text-secondary, #475569);
}
.pharmacy-card-brand-more {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.pharmacy-card-actions {
  padding: 8px 12px 12px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border-color, #e2e8f0);
  background: var(--surface-subtle, #fafafa);
}
.pharmacy-card-action-btn {
  font-size: 12px;
}

/* ── Bulk action bar ── */
.pharmacy-card-bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-primary, #2563eb);
  border-radius: 8px;
  color: #fff;
}
.pharmacy-card-bulk-count {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}
.pharmacy-card-bulk-actions {
  display: flex;
  gap: 8px;
}
.pharmacy-card-bulk-btn {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}
.pharmacy-card-bulk-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}
.pharmacy-card-bulk-clear {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}
.pharmacy-card-bulk-clear:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ── Card grid pagination ── */
.pharmacy-card-grid-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 8px 0;
  flex-shrink: 0;
}
.pharmacy-card-grid-page-info {
  font-size: 13px;
  color: var(--text-muted, #64748b);
  min-width: 80px;
  text-align: center;
}

/* ── Select-all-results affordance on Cards grid ── */
.pharmacy-card-grid-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pharmacy-card-select-all-results {
  background: transparent;
  border: none;
  color: var(--color-primary, #2563eb);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.pharmacy-card-select-all-results:hover {
  background: var(--color-accent-bg, #eff6ff);
}

.pharmacy-card-contact {
  font-size: 12px;
  color: var(--text-secondary, #475569);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pharmacy-card-subtle {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}
.pharmacy-card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Table selection column (checkbox) ── */
#data-table th.th-select,
#data-table td.td-select {
  width: 36px;
  min-width: 36px;
  padding: 4px 8px;
  text-align: center;
}
.table-row-select-cell,
.table-header-select-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Bulk action bar — floating bottom-center ── */
.pharmacy-bulk-action-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25), 0 2px 8px rgba(15, 23, 42, 0.15);
  z-index: 1300;
  max-width: calc(100vw - 48px);
  flex-wrap: wrap;
  animation: pharmacy-bulk-slide-in 160ms ease-out;
}
@keyframes pharmacy-bulk-slide-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.pharmacy-bulk-action-bar-count {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  padding-right: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}
.pharmacy-bulk-action-bar-count strong {
  font-size: 16px;
  font-weight: 700;
}
.pharmacy-bulk-action-bar-count-label {
  color: rgba(255, 255, 255, 0.85);
}
.pharmacy-bulk-action-bar-status {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 400;
  font-style: italic;
  margin-left: 8px;
}
.pharmacy-bulk-action-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pharmacy-bulk-action-btn {
  background: rgba(255, 255, 255, 0.1) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  color: #fff !important;
  font-size: 12px;
}
.pharmacy-bulk-action-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2) !important;
}
.pharmacy-bulk-action-clear {
  background: transparent !important;
  border-color: transparent !important;
  color: rgba(255, 255, 255, 0.75) !important;
}
.pharmacy-bulk-action-clear:hover:not(:disabled) {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.1) !important;
}
@media (max-width: 768px) {
  .pharmacy-bulk-action-bar {
    bottom: 76px; /* clear the fixed bottom nav rail on mobile */
    left: 12px;
    right: 12px;
    transform: none;
    max-width: calc(100vw - 24px);
  }
  @keyframes pharmacy-bulk-slide-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ── Bulk action popovers ── */
.pharmacy-bulk-popover {
  width: 280px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.pharmacy-bulk-popover-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pharmacy-bulk-popover-input {
  font-size: 13px;
}
.pharmacy-bulk-popover-list {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
  margin: 0 -4px;
}
.pharmacy-bulk-popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-primary, #1e293b);
}
.pharmacy-bulk-popover-item:hover {
  background: var(--surface-muted, #f1f5f9);
}
.pharmacy-bulk-popover-item-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pharmacy-bulk-popover-item-sub {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}
.pharmacy-bulk-popover-item-muted {
  color: var(--text-muted, #64748b);
  border-top: 1px solid var(--border-color, #e2e8f0);
  border-radius: 0;
  margin-top: 4px;
  padding-top: 8px;
}
.pharmacy-bulk-popover-empty {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  padding: 12px 8px;
  text-align: center;
}
.pharmacy-bulk-popover-stage-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.pharmacy-bulk-popover-custom {
  display: flex;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

/* =========================================================================
   MOBILE GLOBAL FIXES — keep this block at the end of the file so it
   overrides earlier rules. Scoped to <= 768px only. Do not add surface
   specific rules here; those belong in the per-surface stylesheets.
   ========================================================================= */
@media (max-width: 768px) {
  /* ── Bug 1: Pin the primary navigation rail to the bottom of the
        viewport so it is reachable on long pages (Today 2989px,
        Operations 8540px, Table 9511px, Workflows 5883px, Detail 4657px).
        The rail is otherwise rendered in normal flow at the end of the
        grid, so long content scrolled it off-screen. ── */
  .primary-rail,
  [data-nav="primary-rail"],
  .navigation-rail {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    background: #023527;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  }

  /* Reserve space at the bottom of the main scroll container so the last
     item of any page isn't hidden behind the now-fixed rail. 56px rail
     + 8px breathing room + iOS home indicator. */
  main,
  #main,
  [data-workspace-main] {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* Bug 2: HIG requires 44x44 minimum tap targets. Tailwind h-8 / h-9
     controls are 32 / 36 — enforce a floor on mobile. Reset on inputs
     that have their own mobile sizing. */
  button,
  [role="button"],
  .btn,
  [type="button"],
  [type="submit"],
  [type="reset"] {
    min-height: 44px;
  }

  button.icon-btn,
  [data-icon-only="true"],
  button[aria-label][data-size="icon"] {
    min-width: 44px;
    min-height: 44px;
  }

  .nav-item,
  [data-nav-item] {
    min-height: 56px;
  }

  /* Bug 3: Typography floor. 14px body / 12px small on mobile so users
     aren't squinting at sub-12px text. Explicit opt-in for truly small
     labels via .micro-text. */
  html {
    font-size: 16px;
  }

  body,
  p,
  li,
  td,
  th {
    font-size: max(14px, 1em);
  }

  .text-xs,
  [class*="text-10"],
  [class*="text-11"] {
    font-size: 12px !important;
  }

  .text-sm {
    font-size: 14px !important;
  }

  /* Explicit opt-out for badges / chip counters that genuinely need to
     be small. Use <span class="micro-text">…</span>. */
  .micro-text {
    font-size: 12px !important;
  }

  /* Bug 5: Safe-area padding for fixed overlays near the bottom-right so
     they don't collide with the iOS home indicator or curved edges. */
  .ai-assistant-bubble,
  .floating-fab,
  .bottom-sheet {
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
  }
}

/* ── Customer BI sub-tab (Perform > Customer Intelligence) ─────────────── */

.perform-subtab-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0 4px;
}
.perform-subtab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 10px 14px;
  font: inherit;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.55);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.perform-subtab-btn:hover {
  color: rgba(0, 0, 0, 0.8);
}
.perform-subtab-btn.active {
  color: var(--color-primary, #0d6b4e);
  border-bottom-color: var(--color-primary, #0d6b4e);
}

.customer-bi-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.customer-bi-picker-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--background, #fff);
  padding: 8px 0;
}

.customer-bi-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.customer-bi-input-wrap {
  position: relative;
  flex: 1;
}
.customer-bi-input {
  width: 100%;
}
.customer-bi-step-btn {
  min-width: 40px;
  font-size: 20px;
  line-height: 1;
}
.customer-bi-picker-meta {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
}

.customer-bi-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
}
.customer-bi-suggestion {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}
.customer-bi-suggestion:last-child { border-bottom: 0; }
.customer-bi-suggestion.active,
.customer-bi-suggestion:hover {
  background: rgba(13, 107, 78, 0.08);
}
.customer-bi-suggestion-meta {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
}
.customer-bi-suggestion-empty {
  padding: 12px;
  color: rgba(0, 0, 0, 0.55);
  font-size: 13px;
}

.customer-bi-header .customer-bi-header-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.customer-bi-header-title { font-size: 20px; }
.customer-bi-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.customer-bi-churn-chip {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.customer-bi-churn-chip.tone-ok        { background: rgba(13, 107, 78, 0.12); color: #0d6b4e; }
.customer-bi-churn-chip.tone-warning   { background: rgba(212, 140, 25, 0.18); color: #8b5d00; }
.customer-bi-churn-chip.tone-critical  { background: rgba(180, 40, 40, 0.18); color: #a62424; }
.customer-bi-header-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 0;
}
.customer-bi-header-grid dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.5);
}
.customer-bi-header-grid dd {
  margin: 2px 0 0;
  font-weight: 500;
}

.customer-bi-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .customer-bi-two-col { grid-template-columns: 1fr; }
}

.customer-bi-chart-wrap svg { width: 100%; height: auto; display: block; }
.customer-bi-chart-empty,
.customer-bi-section-empty {
  padding: 24px;
  color: rgba(0, 0, 0, 0.5);
  text-align: center;
  font-size: 14px;
}

.customer-bi-product-mix {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.customer-bi-product-row {
  display: grid;
  grid-template-columns: 1fr 60px;
  grid-template-areas:
    "label share"
    "bar   bar";
  gap: 4px 8px;
  align-items: center;
}
.customer-bi-product-label {
  grid-area: label;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.customer-bi-product-share {
  grid-area: share;
  text-align: right;
  font-size: 12px;
  color: rgba(0, 0, 0, 0.55);
}
.customer-bi-product-bar-bg {
  grid-area: bar;
  height: 6px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 3px;
  overflow: hidden;
}
.customer-bi-product-bar-fill {
  height: 100%;
  background: var(--color-primary, #0d6b4e);
  border-radius: 3px;
}

.customer-bi-payment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.customer-bi-payment-card {
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.customer-bi-payment-card.tone-warning { background: rgba(212, 140, 25, 0.12); }
.customer-bi-payment-card.tone-critical { background: rgba(180, 40, 40, 0.12); }
.customer-bi-payment-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(0, 0, 0, 0.5);
}
.customer-bi-payment-value { font-size: 20px; font-weight: 600; }

.customer-bi-activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.customer-bi-activity-item {
  padding: 10px 12px;
  border-left: 3px solid rgba(13, 107, 78, 0.4);
  background: rgba(0, 0, 0, 0.02);
  border-radius: 4px;
}
.customer-bi-activity-item.pending { border-left-color: rgba(212, 140, 25, 0.7); }
.customer-bi-activity-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}
.customer-bi-activity-date { color: rgba(0, 0, 0, 0.5); font-size: 12px; }
.customer-bi-activity-meta { font-size: 12px; color: rgba(0, 0, 0, 0.55); }

.customer-bi-nba-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.customer-bi-nba-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.03);
  border-left: 4px solid rgba(0, 0, 0, 0.1);
}
.customer-bi-nba-item.tone-info { border-left-color: rgba(13, 107, 78, 0.6); }
.customer-bi-nba-item.tone-warning {
  border-left-color: rgba(212, 140, 25, 0.8);
  background: rgba(212, 140, 25, 0.08);
}
.customer-bi-nba-item.tone-critical {
  border-left-color: rgba(180, 40, 40, 0.8);
  background: rgba(180, 40, 40, 0.08);
}

.customer-bi-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.05);
}
.customer-bi-status-paid     { background: rgba(13, 107, 78, 0.15); color: #0d6b4e; }
.customer-bi-status-partial  { background: rgba(212, 140, 25, 0.18); color: #8b5d00; }
.customer-bi-status-not_paid { background: rgba(180, 40, 40, 0.15); color: #a62424; }

