/* Workspace design tokens follow BugZero's slate surfaces and purple accent. */
:root {
  --crm-bg: #f8fafc;
  --crm-surface: #fff;
  --crm-border: #e2e8f0;
  --crm-text: #0f172a;
  --crm-muted: #64748b;
  --crm-accent: #9333ea;
  --crm-accent-hover: #7e22ce;
  --crm-tint: #f3e8ff;
}

.crm-app-shell {
  grid-template-columns: 208px minmax(0, 1fr);
  color: var(--crm-text);
  background: var(--crm-bg);
  font-size: 14px;
}

.crm-app-shell :is(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--crm-accent);
  outline-offset: 3px;
}

.crm-app-shell .sidebar {
  padding: 26px 14px 18px;
  gap: 32px;
  color: var(--crm-muted);
  background: var(--crm-surface);
  border-right: 1px solid var(--crm-border);
}

.crm-app-shell .brand { gap: 10px; padding: 0 6px; }
.crm-app-shell .brand > span {
  width: 34px;
  height: 34px;
  color: white;
  background: var(--crm-accent);
  border-radius: 9px;
  font-size: 18px;
  font-weight: 700;
}
.crm-app-shell .brand strong { color: var(--crm-text); font-weight: 650; letter-spacing: -.3px; }
.crm-app-shell .sidebar nav { gap: 5px; }
.crm-app-shell .nav-item { color: #475569; font-size: 13px; font-weight: 500; }
.crm-app-shell .nav-item:hover { background: #f1f5f9; }
.crm-app-shell .nav-item.is-active { background: var(--crm-tint); color: var(--crm-accent-hover); font-weight: 600; }
.crm-app-shell .sidebar-toggle {
  order: 3;
  margin-top: auto;
  width: 34px;
  height: 34px;
  color: var(--crm-muted);
  background: transparent;
  border-color: var(--crm-border);
}
.crm-app-shell.is-sidebar-collapsed { grid-template-columns: 68px minmax(0, 1fr); }
.crm-app-shell.is-sidebar-collapsed .sidebar { padding-inline: 10px; }
.crm-app-shell.is-sidebar-collapsed .sidebar-toggle { align-self: center; }
.crm-app-shell.is-sidebar-collapsed .brand { padding: 0; }

.crm-app-shell .crm-content { padding: 0 32px 32px; }
.crm-app-shell .topbar {
  min-height: 78px;
  gap: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--crm-border);
}
.crm-app-shell .search-box { width: min(400px, 100%); height: 38px; background: transparent; border-color: transparent; padding-left: 0; }
.crm-app-shell .search-box:focus-within { border-color: #c084fc; background: white; padding-left: 10px; }
.crm-app-shell .search-box input { color: var(--crm-text); font-size: 13px; }
.crm-app-shell .search-box input::placeholder { color: var(--crm-muted); }
.crm-app-shell .topbar-actions { gap: 8px; flex-shrink: 0; }
.crm-app-shell :is(.primary-action, .ghost-action, .icon-button) { min-height: 36px; border-radius: 7px; font-size: 12px; font-weight: 600; box-shadow: none; }
.crm-app-shell .primary-action { background: var(--crm-accent); border-color: var(--crm-accent); }
.crm-app-shell .primary-action:hover { background: var(--crm-accent-hover); }
.crm-app-shell :is(.ghost-action, .icon-button) { color: #475569; background: white; border-color: var(--crm-border); }
.crm-app-shell :is(.ghost-action, .icon-button):hover { background: #f8fafc; border-color: #cbd5e1; }
.crm-app-shell .icon-button.is-active { background: var(--crm-tint); border-color: #d8b4fe; color: var(--crm-accent-hover); }
.crm-app-shell .topbar .icon-button { width: 36px; }
.crm-app-shell .notifications-button { width: 36px; padding: 0; }
.crm-app-shell .notifications-badge { position: absolute; right: -5px; top: -5px; min-width: 16px; height: 16px; font-size: 10px; }
.crm-app-shell .topbar-company-menu { min-width: 130px; max-width: 230px; }
.crm-app-shell .tenant-switcher__button { border-color: transparent; background: transparent; font-weight: 500; }

.workspace-disclosure { position: relative; }
.workspace-disclosure__content {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 70;
  width: max-content;
  min-width: 180px;
  max-width: min(300px, calc(100vw - 28px));
  padding: 6px;
  border: 1px solid var(--crm-border);
  border-radius: 10px;
  background: var(--crm-surface);
  box-shadow: 0 8px 24px #0f172a12;
}
.crm-app-shell .workspace-disclosure__content > button {
  display: flex;
  width: 100%;
  min-height: 40px;
  justify-content: flex-start;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 0;
  border-radius: 5px;
  color: #475569;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}
.crm-app-shell .workspace-disclosure__content > button:hover { background: #f1f5f9; }
.crm-app-shell .workspace-disclosure__content > .danger-action { color: #b91c1c; }
.workspace-actions__language { padding: 8px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--crm-border); }
.workspace-actions__language > span { display: block; margin-bottom: 8px; color: var(--crm-muted); font-size: 11px; }
.crm-app-shell .language-switcher { background: #f8fafc; border-color: var(--crm-border); }
.crm-app-shell .language-switcher button { color: #64748b; font-weight: 600; }
.crm-app-shell .language-switcher button.is-selected { background: var(--crm-tint); color: var(--crm-accent-hover); box-shadow: none; }
.workspace-nav-more { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--crm-border); }
.workspace-nav-more .workspace-disclosure__content { position: static; margin-top: 6px; min-width: 0; max-width: none; width: 100%; padding: 0; border: 0; box-shadow: none; }
.crm-app-shell .workspace-nav-more .workspace-disclosure__content > button { font-size: 12px; padding-left: 12px; }
.crm-app-shell.is-sidebar-collapsed .workspace-nav-more .workspace-disclosure__content > button { justify-content: center; padding: 0; }

.crm-app-shell .demo-banner {
  min-height: 32px;
  margin: -12px 0 24px;
  padding: 0;
  color: var(--crm-muted);
  background: transparent;
  border: 0;
  font-size: 11px;
  gap: 7px;
  flex-wrap: nowrap;
}
.crm-app-shell .demo-banner > svg { width: 13px; }
.crm-app-shell .demo-banner button { min-height: 28px; width: auto; margin-left: auto; border: 0; padding: 0; background: transparent; color: var(--crm-accent-hover); font-size: 11px; }
.overview-workspace { display: grid; gap: 24px; max-width: 1360px; margin: 0 auto; }
.overview-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.overview-heading h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.7px; line-height: 1.25; }
.overview-heading p { margin: 7px 0 0; color: var(--crm-muted); font-size: 13px; }
.overview-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--crm-border); background: white; border-radius: 10px; padding: 22px 0; }
.overview-metrics article { padding: 0 24px; }
.overview-metrics article + article { border-left: 1px solid var(--crm-border); }
.overview-metrics span { display: block; color: var(--crm-muted); font-size: 12px; }
.overview-metrics strong { display: block; margin-top: 12px; color: var(--crm-text); font-size: 28px; font-weight: 600; letter-spacing: -.7px; font-variant-numeric: tabular-nums; }
.crm-app-shell :is(.panel, .copilot-panel, .metric-card) { border-color: var(--crm-border); background: white; box-shadow: none; border-radius: 10px; }
.crm-app-shell :is(.panel, .copilot-panel) { padding: 22px; }
.crm-app-shell .panel-header { align-items: center; margin-bottom: 22px; }
.crm-app-shell :is(.panel-header h2, .copilot-header h2) { font-size: 17px; font-weight: 600; color: var(--crm-text); letter-spacing: -.3px; }
.crm-app-shell :is(.panel-header p, .copilot-header p) { color: var(--crm-muted); font-size: 12px; }
.crm-app-shell .overview-pipeline .panel-header h2, .crm-app-shell .overview-workspace .activity-panel h2 { font-size: 14px; letter-spacing: 0; }
.crm-app-shell .stage-overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 20px; }
.crm-app-shell .stage-overview__item { padding: 0; border: 0; background: transparent; text-align: left; border-radius: 3px; }
.crm-app-shell .stage-overview__item:hover { background: #faf5ff; }
.crm-app-shell .stage-overview__item span { color: #475569; font-size: 12px; font-weight: 500; }
.crm-app-shell .stage-overview__item strong { display: block; margin: 14px 0 3px; color: var(--crm-text); font-size: 23px; font-weight: 550; }
.crm-app-shell .stage-overview__item small { color: var(--crm-muted); font-size: 11px; }
.stage-overview__track { display: block; height: 3px; background: #f1f5f9; border-radius: 3px; margin-top: 17px; }
.stage-overview__track i { display: block; height: 100%; background: #c084fc; border-radius: inherit; }
.overview-setup { display: flex; align-items: center; justify-self: start; gap: 8px; padding: 0; background: transparent; border: 0; color: var(--crm-muted); font-size: 12px; }
.crm-app-shell .agenda-buckets { gap: 20px; }
.crm-app-shell .agenda-bucket h3 { font-size: 10px; color: var(--crm-muted); font-weight: 600; letter-spacing: .7px; }
.crm-app-shell .activity-list { gap: 0; }
.crm-app-shell .activity-row { padding: 12px 0; border-radius: 0; background: transparent; border-bottom: 1px solid #f1f5f9; }
.crm-app-shell .activity-row:last-child { border: 0; }
.crm-app-shell .activity-row > span { background: #f8fafc; color: #64748b; border: 1px solid var(--crm-border); }
.crm-app-shell .activity-row strong { color: #334155; font-weight: 500; font-size: 13px; }
.crm-app-shell .activity-row small { color: var(--crm-muted); font-size: 11px; }
.crm-app-shell .activity-row .activity-due { font-weight: 400; }
.crm-app-shell .activity-action { background: transparent; color: #64748b; border: 0; }
.crm-app-shell .activity-action:hover { background: #f3e8ff; color: var(--crm-accent-hover); }
.crm-app-shell .agenda-empty { font-size: 12px; }

/* Records show just enough information to choose the next action. */
.crm-app-shell .kanban-board { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 14px; padding-bottom: 12px; }
.crm-app-shell .pipeline-panel { background: transparent; border: 0; padding: 0; border-radius: 0; }
.crm-app-shell .pipeline-panel .panel-header { margin-bottom: 26px; }
.crm-app-shell .pipeline-panel h2 { font-size: 26px; }
.crm-app-shell .kanban-column { padding: 10px; background: #f1f5f9; min-height: 460px; border-radius: 9px; }
.crm-app-shell .kanban-column.is-drop-target { border-color: var(--crm-accent); background: var(--crm-tint); }
.crm-app-shell .kanban-column__header { min-height: 65px; padding: 5px 2px 16px; display: block; }
.crm-app-shell .kanban-column__header strong { font-size: 12px; font-weight: 600; color: #334155; }
.crm-app-shell .kanban-column__header small { margin-top: 7px; color: var(--crm-muted); font-size: 11px; }
.crm-app-shell .kanban-count { background: #e2e8f0; color: #64748b; padding: 1px 5px; font-size: 10px; }
.crm-app-shell .deal-card { padding: 15px 13px; border: 1px solid var(--crm-border); border-radius: 8px; box-shadow: 0 1px 2px #0f172a04; }
.crm-app-shell .deal-card:hover { border-color: #d8b4fe; transform: translateY(-1px); box-shadow: 0 3px 8px #0f172a08; }
.crm-app-shell .deal-card__top strong { font-size: 12px; font-weight: 600; line-height: 1.45; color: #334155; }
.crm-app-shell .deal-card p { font-size: 11px; color: var(--crm-muted); margin: 7px 0 18px; }
.crm-app-shell .deal-card__meta { margin-bottom: 12px; }
.crm-app-shell .deal-card__value { font-size: 15px; color: var(--crm-text); font-weight: 600; }
.crm-app-shell .deal-card > small { border-top: 1px solid #f1f5f9; padding-top: 10px; color: var(--crm-muted); font-size: 11px; line-height: 1.5; }
.crm-app-shell .kanban-placeholder { border-color: #dbe2eb; min-height: 80px; }
.crm-app-shell .contacts-panel { padding: 0; background: transparent; border: 0; }
.crm-app-shell .contacts-panel h2 { font-size: 26px; }
.crm-app-shell .contact-table { gap: 0; border: 1px solid var(--crm-border); border-radius: 10px; background: white; }
.crm-app-shell .contact-row, .contact-table__labels { display: grid; grid-template-columns: minmax(200px, 1.6fr) minmax(130px, 1fr) 120px 36px; gap: 18px; padding: 18px; align-items: center; }
.contact-table__labels { color: var(--crm-muted); font-size: 11px; border-bottom: 1px solid var(--crm-border); background: #f8fafc; border-radius: 10px 10px 0 0; }
.crm-app-shell .contact-row { border: 0; border-bottom: 1px solid #f1f5f9; border-radius: 0; background: transparent; }
.crm-app-shell .contact-row:last-child { border: 0; }
.crm-app-shell .contact-row:hover { background: #fafbfe; }
.crm-app-shell .contact-row :is(.person-cell, .person-cell > div) { min-width: 0; }
.crm-app-shell .person-cell > span { width: 34px; height: 34px; flex-shrink: 0; border-radius: 50%; background: #f3e8ff; color: #7e22ce; font-size: 12px; font-weight: 600; }
.contact-name { border: 0; background: none; color: #334155; font-size: 13px; font-weight: 600; padding: 0; text-align: left; }
.contact-name:hover { color: var(--crm-accent-hover); text-decoration: underline; }
.crm-app-shell .contact-row strong { font-size: 12px; font-weight: 500; color: #475569; }
.crm-app-shell .contact-row small { color: var(--crm-muted); font-size: 11px; overflow-wrap: anywhere; }
.crm-app-shell .channel-cell { color: #64748b; font-size: 12px; font-weight: 400; }
.crm-app-shell .contact-actions .icon-button { border-color: transparent; background: transparent; }
.crm-app-shell .contact-actions .workspace-disclosure__content { max-width: min(300px, calc(100vw - 60px)); }
.crm-app-shell .empty-state-card { padding: 30px 20px; background: white; border-color: var(--crm-border); color: var(--crm-muted); }
.crm-app-shell .metric-card { border-top-width: 1px; }
.crm-app-shell .conversation-row.is-active { background: #faf5ff; border-color: #d8b4fe; }
.crm-app-shell .channel-avatar { background: var(--crm-accent); }
.crm-app-shell .outgoing { background: #f3e8ff; border-color: #e9d5ff; color: #3b0764; }
.crm-app-shell .bubble { box-shadow: none; }
.crm-app-shell .detail-drawer { box-shadow: -8px 0 32px #0f172a12; }
.crm-app-shell .tag-list span { background: #f1f5f9; color: #475569; font-weight: 500; }

@media (max-width: 1100px) and (min-width: 821px) {
  .crm-app-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .crm-app-shell .crm-content { padding-inline: 22px; }
  .crm-app-shell .contact-row, .contact-table__labels { grid-template-columns: minmax(160px, 1.4fr) minmax(110px, 1fr) 90px 32px; gap: 12px; padding-inline: 14px; }
}

@media (max-width: 820px) {
  .crm-app-shell { display: flex; flex-direction: column; }
  .crm-app-shell .sidebar { flex-shrink: 0; min-height: 66px; max-height: none; height: 66px; padding: 5px 12px; overflow: visible; border: 0; border-bottom: 1px solid var(--crm-border); }
  .crm-app-shell .sidebar .brand, .crm-app-shell .sidebar-toggle { display: none; }
  .crm-app-shell .sidebar nav { min-width: 0; width: 100%; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
  .crm-app-shell .sidebar .nav-item { width: 100%; padding: 7px 2px; min-height: 50px; display: flex; flex-direction: column; justify-content: center; gap: 5px; }
  .crm-app-shell .sidebar .nav-label { display: block; font-size: 10px; line-height: 1.25; }
  .workspace-nav-more { margin: 0; padding: 0; border: 0; }
  .workspace-nav-more .workspace-disclosure__content { position: fixed; top: 72px; right: 12px; left: 12px; max-height: calc(100dvh - 94px); overflow-y: auto; width: auto; margin: 0; border: 1px solid var(--crm-border); padding: 6px; border-radius: 10px; box-shadow: 0 12px 30px #0f172a18; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-app-shell .sidebar .workspace-nav-more .workspace-disclosure__content > button { flex-direction: row; justify-content: flex-start; padding: 12px; gap: 10px; }
  .crm-app-shell .workspace-nav-more .workspace-disclosure__content .nav-label { font-size: 12px; }
  .crm-app-shell .crm-content { flex: 1; min-height: 0; height: auto; padding: 0 18px 24px; }
  .crm-app-shell .topbar { flex-direction: row; align-items: center; min-height: 66px; gap: 8px; margin-bottom: 22px; }
  .crm-app-shell .topbar-actions { display: flex; width: auto; flex-wrap: nowrap; flex-shrink: 1; min-width: 0; }
  .crm-app-shell .topbar-actions > :is(.workspace-actions, .notifications-menu) { flex: 0 0 auto; }
  .crm-app-shell .topbar-actions > button { flex: 0 0 auto; }
  .crm-app-shell .topbar-company-menu { flex: 1 1 150px; min-width: 0; max-width: 170px; }
  .crm-app-shell .topbar-company-menu .company-menu__list { position: fixed; top: 124px; right: 18px; left: 18px; width: auto; }
  .crm-app-shell .search-box { flex: 1; min-width: 80px; }
  .crm-app-shell .search-box input { min-width: 0; }
  .crm-app-shell .workspace-disclosure__content .utility-action span { position: static; width: auto; height: auto; margin: 0; overflow: visible; clip: auto; }
  .crm-app-shell .workspace-actions .language-switcher { width: auto; }
  .crm-app-shell .panel-header { flex-direction: row; align-items: center; gap: 10px; }
  .crm-app-shell .toolbar { width: auto; flex-wrap: nowrap; }
  .crm-app-shell .overview-workspace { gap: 18px; }
  .crm-app-shell .demo-banner { margin: -8px 0 18px; }
  .overview-heading h1, .crm-app-shell .pipeline-panel h2, .crm-app-shell .contacts-panel h2 { font-size: 23px; }
  .overview-metrics { padding: 18px 0; }
  .overview-metrics article { padding: 0 16px; }
  .overview-metrics strong { font-size: 24px; }
  .crm-app-shell .contact-row, .contact-table__labels { grid-template-columns: minmax(160px, 1.4fr) minmax(100px, 1fr) 85px 32px; gap: 12px; padding: 16px 12px; }
  .crm-app-shell .crm-content--inbox { padding-top: 14px; }
}

@media (max-width: 560px) {
  .crm-app-shell .crm-content { padding-inline: 12px; }
  .crm-app-shell :is(.panel, .copilot-panel) { padding: 16px; }
  .crm-app-shell :is(.pipeline-panel, .contacts-panel) { padding: 0; }
  .crm-app-shell .topbar-company-menu { max-width: 145px; }
  .crm-app-shell .topbar-company-menu .tenant-switcher__button { gap: 5px; padding: 0 4px; }
  .crm-app-shell .topbar-company-menu .tenant-switcher__button > svg:first-child { display: none; }
  .crm-app-shell .topbar .search-box { gap: 6px; }
  .crm-app-shell .search-box input { font-size: 12px; }
  .overview-heading p { font-size: 12px; }
  .overview-heading > button { flex-shrink: 0; padding: 0 10px; }
  .overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; }
  .overview-metrics article { padding: 16px; }
  .overview-metrics article:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--crm-border); }
  .overview-metrics article:nth-child(2) { border-left: 0; }
  .overview-metrics strong { margin-top: 8px; font-size: 25px; }
  .overview-metrics article:first-child strong { font-size: 30px; }
  .overview-metrics span { font-size: 11px; }
  .crm-app-shell .stage-overview { grid-template-columns: repeat(5, minmax(95px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 6px; }
  .crm-app-shell .kanban-board { grid-auto-columns: minmax(245px, 82vw); scroll-snap-type: x proximity; }
  .crm-app-shell .kanban-column { scroll-snap-align: start; }
  .crm-app-shell .panel-header { margin-bottom: 18px; flex-wrap: wrap; }
  .crm-app-shell .contact-table__labels { display: none; }
  .crm-app-shell .contact-row { grid-template-columns: minmax(0, 1fr) 36px; gap: 8px 12px; padding: 16px; }
  .crm-app-shell .contact-row > .person-cell { grid-column: 1; }
  .crm-app-shell .contact-row > div:nth-child(2) { grid-column: 1; padding-left: 44px; }
  .crm-app-shell .contact-row > .channel-cell { grid-column: 1; padding-left: 44px; font-size: 11px; }
  .crm-app-shell .contact-row > .contact-actions { grid-column: 2; grid-row: 1; }
  .crm-app-shell .contact-actions .icon-button { min-height: 36px; width: 36px; }
  .crm-app-shell .activity-row { grid-template-columns: 28px minmax(0, 1fr); gap: 8px; }
  .crm-app-shell .activity-row > span { width: 28px; height: 28px; }
  .crm-app-shell .activity-actions { grid-column: 2; justify-content: flex-end; }
  .crm-app-shell .activity-action { width: 36px; height: 36px; }
}
