:root {
  --crm-primary: #335cff;
  --crm-primary-dark: #2446d8;
  --crm-ink: #172033;
}

body {
  color: var(--crm-ink);
  min-height: 100vh;
}

.btn-primary {
  --bs-btn-bg: var(--crm-primary);
  --bs-btn-border-color: var(--crm-primary);
  --bs-btn-hover-bg: var(--crm-primary-dark);
  --bs-btn-hover-border-color: var(--crm-primary-dark);
}

.text-primary {
  color: var(--crm-primary) !important;
}

.login-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(51, 92, 255, .16), transparent 28rem),
    radial-gradient(circle at 90% 85%, rgba(22, 181, 160, .12), transparent 25rem),
    #f6f8fc;
}

.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--crm-primary), #763bff);
  border-radius: 1rem;
  box-shadow: 0 .75rem 2rem rgba(51, 92, 255, .22);
  color: #fff;
  display: flex;
  font-size: .78rem;
  font-weight: 800;
  height: 3.5rem;
  justify-content: center;
  letter-spacing: .08em;
  width: 3.5rem;
}

.form-control:focus {
  border-color: rgba(51, 92, 255, .65);
  box-shadow: 0 0 0 .25rem rgba(51, 92, 255, .14);
}

.welcome-panel {
  background: linear-gradient(135deg, #fff, #eef2ff);
  border: 1px solid rgba(51, 92, 255, .1);
  min-height: 18rem;
}

.welcome-panel::after {
  background: linear-gradient(135deg, rgba(51, 92, 255, .2), rgba(118, 59, 255, .06));
  border-radius: 50%;
  content: "";
  height: 24rem;
  position: absolute;
  right: -8rem;
  top: -10rem;
  width: 24rem;
}

.welcome-content {
  max-width: 48rem;
  z-index: 1;
}

main { max-width: 1440px; margin-inline: auto; }
.form-page { max-width: 960px; }
.narrow-page { max-width: 640px; }
.card { border-radius: .85rem; }
.table thead th { background: #f8f9fc; color: #5c667a; font-size: .78rem; font-weight: 650; letter-spacing: .02em; white-space: nowrap; }
.table td { padding-block: 1rem; }
.form-control, .form-select { min-height: 2.75rem; }
select[multiple].form-select { min-height: 8.5rem; }
.base-location-select { min-width: 0; width: 100%; }
.base-location-summary {
  align-items: center;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .375rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  min-height: 44px;
  overflow-wrap: anywhere;
  padding: .6rem 2.5rem .6rem .75rem;
  position: relative;
  width: 100%;
}
.base-location-summary::-webkit-details-marker { display: none; }
.base-location-summary::marker { content: ""; }
.base-location-summary:focus-visible {
  border-color: rgba(51, 92, 255, .65);
  box-shadow: 0 0 0 .25rem rgba(51, 92, 255, .14);
  outline: 0;
}
.base-location-chevron {
  border-bottom: 2px solid #677185;
  border-right: 2px solid #677185;
  height: .55rem;
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-65%) rotate(45deg);
  transition: transform .15s ease;
  width: .55rem;
}
.base-location-select[open] .base-location-chevron { transform: translateY(-35%) rotate(225deg); }
.base-location-options {
  background: #fff;
  border: 1px solid #dfe3eb;
  border-radius: .55rem;
  box-shadow: 0 .6rem 1.4rem rgba(27, 39, 70, .08);
  margin-top: .35rem;
  max-height: 19rem;
  overflow: auto;
  padding: .45rem;
  width: 100%;
}
.base-location-instruction { color: #6b7486; font-size: .78rem; margin: .25rem .45rem .45rem; }
.base-location-option {
  align-items: center;
  border: 1px solid transparent;
  border-radius: .45rem;
  cursor: pointer;
  display: flex;
  gap: .65rem;
  min-height: 44px;
  overflow-wrap: anywhere;
  padding: .55rem .65rem;
  width: 100%;
}
.base-location-option:hover { background: #f6f8fc; }
.base-location-option.is-selected { background: #eef2ff; border-color: rgba(51, 92, 255, .22); }
.base-location-option.is-inactive { background: #f8f9fa; color: #596376; }
.base-location-option input {
  flex: 0 0 auto;
  height: 1.15rem;
  margin: 0;
  width: 1.15rem;
}
.base-location-option input:focus-visible { outline: 3px solid rgba(51, 92, 255, .32); outline-offset: 3px; }
.base-location-option-label { flex: 1 1 auto; min-width: 0; }
.base-location-option .badge { flex: 0 0 auto; max-width: 100%; white-space: normal; }
.base-location-empty { color: #6b7486; min-height: 44px; padding: .65rem; }
.quick-create { background: #f8f9fc; border-color: #e4e8f0 !important; }
.sticky-actions { background: rgba(255,255,255,.94); bottom: 0; padding: 1rem 0; position: sticky; z-index: 10; }
.contact-card { border-bottom: 1px solid #edf0f5; display: block; padding: 1rem; }
.contact-card:last-child { border-bottom: 0; }
.detail-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-grid div { min-width: 0; }
.detail-grid span { color: #6b7486; display: block; font-size: .8rem; margin-bottom: .3rem; }
.detail-grid strong { overflow-wrap: anywhere; }
.system-meta { display: grid; grid-template-columns: 5rem 1fr; row-gap: .9rem; }
.system-meta dt { color: #6b7486; font-size: .82rem; font-weight: 500; }
.system-meta dd { margin: 0; }
.timeline { padding-left: 1.1rem; }
.timeline li { margin-bottom: .8rem; }
.timeline-cards { border-left: 2px solid #e5e9f2; margin-left: .35rem; padding-left: 1.25rem; }
.timeline-card { border-bottom: 1px solid #edf0f5; padding: .2rem 0 1rem; position: relative; }
.timeline-card::before { background: var(--crm-primary); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #d9deea; content: ""; height: .75rem; left: -1.68rem; position: absolute; top: .35rem; width: .75rem; }
.summary-cards { display: grid; gap: .75rem; grid-template-columns: repeat(4, 1fr); }
.summary-cards div { background: #f7f8fc; border-radius: .65rem; padding: 1rem; }
.summary-cards strong { display: block; font-size: 1.5rem; }
.summary-cards span { color: #6b7486; font-size: .78rem; }

.workspace-header { align-items: flex-end; display: flex; gap: 1.5rem; justify-content: space-between; }
.workspace-summary { display: grid; gap: .85rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.summary-action { background: #fff; border: 1px solid #e5e9f2; border-radius: .9rem; color: inherit; display: grid; min-width: 0; padding: 1rem 1.1rem; text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.summary-action:hover { border-color: rgba(51, 92, 255, .38); box-shadow: 0 .55rem 1.5rem rgba(27, 39, 70, .07); color: inherit; transform: translateY(-1px); }
.summary-action span { color: #626d80; font-size: .8rem; font-weight: 650; }
.summary-action strong { font-size: 1.8rem; line-height: 1.2; margin-block: .15rem; }
.summary-action small { color: #858ea0; }
.summary-action.summary-danger { border-color: rgba(202, 48, 61, .28); }
.summary-action.summary-danger strong { color: #b42332; }
.section-heading { align-items: flex-end; display: flex; gap: 1rem; justify-content: space-between; margin-bottom: 1rem; }
.section-heading a { font-size: .875rem; text-decoration: none; white-space: nowrap; }
.section-kicker { color: #6b7486; font-size: .75rem; font-weight: 700; letter-spacing: .08em; margin-bottom: .2rem; text-transform: uppercase; }
.workspace-card-stack { display: grid; gap: .8rem; }
.workspace-card { background: #fff; border: 1px solid #e7eaf1; border-left: 4px solid #aeb7c6; border-radius: .85rem; box-shadow: 0 .25rem .8rem rgba(27, 39, 70, .035); display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) auto; padding: 1rem; }
.workspace-card-p0 { border-left-color: #c5303d; }
.workspace-card-p1 { border-left-color: #d59b17; }
.workspace-card-body { min-width: 0; }
.workspace-card-actions { align-items: flex-start; display: flex; flex-wrap: wrap; gap: .45rem; justify-content: flex-end; }
.workspace-card-actions .btn { align-items: center; display: inline-flex; justify-content: center; }
.priority-label { border-radius: 999px; display: inline-block; font-size: .7rem; font-weight: 750; margin-right: .35rem; padding: .18rem .5rem; }
.priority-p0 { background: #fff0f1; color: #a51f2c; }
.priority-p1 { background: #fff6dc; color: #805d00; }
.priority-p2 { background: #eef1f6; color: #5e687a; }
.reason-label { background: #f0f2f7; border-radius: 999px; color: #5d6678; display: inline-block; font-size: .72rem; line-height: 1.25; padding: .25rem .55rem; }
.workspace-note { color: #4f596c; font-size: .875rem; overflow-wrap: anywhere; }
.workspace-empty { align-items: center; background: #fff; border: 1px dashed #d8deea; border-radius: .85rem; color: #727c8f; display: flex; flex-direction: column; gap: .25rem; justify-content: center; min-height: 7rem; padding: 1.5rem; text-align: center; }
.workspace-empty strong { color: #3f495b; }
.workspace-project-grid { display: grid; gap: .9rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workspace-project-card { background: #fff; border: 1px solid #e7eaf1; border-radius: .85rem; min-width: 0; padding: 1rem; }
.workspace-grid-empty { grid-column: 1 / -1; }
.project-facts { display: grid; gap: .7rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.project-facts div { background: #f8f9fc; border-radius: .55rem; min-width: 0; padding: .6rem; }
.project-facts span { color: #747e90; display: block; font-size: .7rem; }
.project-facts strong { display: block; font-size: .78rem; margin-top: .15rem; overflow-wrap: anywhere; }
.recent-activity-list { background: #fff; border: 1px solid #e7eaf1; border-radius: .85rem; overflow: hidden; }
.recent-activity-item { border-bottom: 1px solid #edf0f5; color: inherit; display: grid; gap: .2rem; padding: .9rem 1rem; text-decoration: none; }
.recent-activity-item:last-child { border-bottom: 0; }
.recent-activity-item:hover { background: #f8f9fc; color: inherit; }
.recent-activity-item > span:last-child { color: #5f697b; font-size: .82rem; overflow-wrap: anywhere; }
.quick-context-list { display: grid; gap: .7rem; }
.quick-context-item { align-items: center; background: #fff; border: 1px solid #e7eaf1; border-radius: .75rem; color: inherit; display: grid; gap: .35rem .7rem; grid-template-columns: auto minmax(0, 1fr); padding: .9rem 1rem; text-decoration: none; }
.quick-context-item > span:last-child { grid-column: 2; }
.quick-context-item:hover { border-color: rgba(51, 92, 255, .4); color: inherit; }
.workspace-mobile-actions { background: rgba(255, 255, 255, .97); border-top: 1px solid #e2e6ee; bottom: 0; display: grid; gap: .55rem; grid-template-columns: repeat(2, minmax(0, 1fr)); left: 0; padding: .7rem max(.8rem, env(safe-area-inset-left)) calc(.7rem + env(safe-area-inset-bottom)) max(.8rem, env(safe-area-inset-right)); position: fixed; right: 0; z-index: 1030; }
.workspace-mobile-actions .btn:only-child { grid-column: 1 / -1; }

.manager-priority-summary { display: grid; gap: .9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 50rem; }
.manager-workspace .workspace-header { flex-wrap: wrap; }
.manager-priority-item { background: #fff; border: 1px solid #e5e9f2; border-radius: .9rem; color: inherit; display: grid; padding: 1rem 1.1rem; text-decoration: none; }
.manager-priority-item:hover { border-color: rgba(51, 92, 255, .38); color: inherit; }
.manager-priority-item span { color: #626d80; font-size: .8rem; font-weight: 700; }
.manager-priority-item strong { font-size: 1.9rem; line-height: 1.2; }
.manager-priority-item small { color: #858ea0; }
.manager-priority-p0 { border-color: rgba(202, 48, 61, .28); }
.manager-priority-p0 strong { color: #b42332; }
.manager-risk-stack { display: grid; gap: 1rem; }
.manager-risk-card { align-items: start; background: #fff; border: 1px solid #e5e9f2; border-left: 5px solid #aeb7c6; border-radius: 1rem; display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) auto; padding: 1.15rem; }
.manager-risk-p0 { border-left-color: #c5303d; box-shadow: 0 .4rem 1.3rem rgba(151, 31, 44, .07); }
.manager-risk-p1 { border-left-color: #d59b17; }
.manager-risk-main { min-width: 0; }
.manager-risk-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; max-width: 17rem; }
.manager-risk-actions .btn { align-items: center; display: inline-flex; justify-content: center; }
.manager-risk-facts { display: grid; gap: .65rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.manager-risk-facts div, .manager-context-row > div { background: #f8f9fc; border-radius: .6rem; min-width: 0; padding: .65rem .75rem; }
.manager-risk-facts span, .manager-context-row span { color: #747e90; display: block; font-size: .7rem; }
.manager-risk-facts strong, .manager-context-row strong { display: block; font-size: .82rem; margin-top: .15rem; overflow-wrap: anywhere; }
.manager-context-row { display: grid; gap: .65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.manager-context-row small { color: #677185; display: block; margin-top: .2rem; overflow-wrap: anywhere; }
.manager-state-grid { display: grid; gap: .85rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.manager-state-grid a, .manager-entry-grid a { background: #fff; border: 1px solid #e5e9f2; border-radius: .85rem; color: inherit; display: grid; padding: 1rem; text-decoration: none; }
.manager-state-grid a:hover, .manager-entry-grid a:hover { border-color: rgba(51, 92, 255, .38); color: inherit; }
.manager-state-grid span { color: #626d80; font-size: .78rem; font-weight: 650; }
.manager-state-grid strong { font-size: 1.55rem; }
.manager-state-grid small, .manager-entry-grid span { color: #7a8496; font-size: .78rem; }
.manager-entry-grid { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.manager-entry-grid strong { margin-bottom: .25rem; }
.manager-filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; }
.team-mobile-facts { display: grid; gap: .65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.team-mobile-facts div { background: #f8f9fc; border-radius: .6rem; min-width: 0; padding: .65rem .75rem; }
.team-mobile-facts dt { color: #747e90; font-size: .7rem; font-weight: 500; }
.team-mobile-facts dd { font-size: .82rem; font-weight: 650; margin: .15rem 0 0; overflow-wrap: anywhere; }
.team-description { grid-column: 1 / -1; }
.team-person-heading, .team-history-title { align-items: center; display: flex; flex-wrap: wrap; gap: .55rem; }
.team-person-heading strong { font-size: 1.15rem; }
.team-history-list { display: grid; gap: .85rem; }
.team-history-card { border: 1px solid #e7eaf1; border-radius: .75rem; padding: 1rem; }
.team-history-facts { display: grid; gap: .7rem; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: .85rem; }
.team-history-facts div { background: #f8f9fc; border-radius: .55rem; min-width: 0; padding: .65rem .75rem; }
.team-history-facts span { color: #747e90; display: block; font-size: .7rem; }
.team-history-facts strong { display: block; font-size: .8rem; margin-top: .15rem; overflow-wrap: anywhere; }

.team-page { min-width: 0; }
.team-page h1, .team-page h2, .team-page p, .team-page dd, .team-page strong { overflow-wrap: anywhere; }
.team-page :focus-visible { outline: 3px solid #0b5ed7; outline-offset: 3px; }
.team-touch-target { align-items: center; display: inline-flex; justify-content: center; min-height: 44px; }
.team-back-link { align-items: center; display: inline-flex; min-height: 44px; text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .2em; }
.team-filter-nav .nav-link { align-items: center; display: inline-flex; justify-content: center; min-height: 44px; }
.team-filter-nav .nav-link:not(.active) { color: #0a58ca; }
.team-list-table { table-layout: fixed; width: 100%; }
.team-list-table th:nth-child(1) { width: 16%; }
.team-list-table th:nth-child(2) { width: 8%; }
.team-list-table th:nth-child(3) { width: 11%; }
.team-list-table th:nth-child(4) { width: 14%; }
.team-list-table th:nth-child(5) { width: 11%; }
.team-list-table th:nth-child(6) { width: 28%; }
.team-list-table th:nth-child(7) { width: 12%; }
.team-list-table td { min-width: 0; overflow-wrap: anywhere; vertical-align: top; }
.team-list-table .badge { max-width: 100%; white-space: normal; }
.team-summary-cell { line-height: 1.45; }
.team-list-card { min-width: 0; }
.team-list-card > * { min-width: 0; }
.team-list-card .badge { flex: 0 0 auto; white-space: normal; }
.team-danger-action { margin-left: 1rem; }
.team-member-section-header > * { min-width: 0; }
#current-members { scroll-margin-top: 5rem; }
.team-confirm-page { max-width: 860px; }
.team-impact-grid { display: grid; gap: .75rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.team-impact-grid div { background: #f8f9fc; border: 1px solid #dfe3eb; border-radius: .65rem; min-width: 0; padding: 1rem; }
.team-impact-grid dt { color: #596376; font-size: .8rem; font-weight: 600; }
.team-impact-grid dd { font-size: 1.5rem; font-weight: 700; line-height: 1.2; margin: .3rem 0 0; }
.team-risk-alert { border-width: 2px; }
.team-status-form textarea { max-width: 100%; resize: vertical; }
.team-status-actions { display: flex; gap: .75rem; }
.team-status-actions .btn { min-height: 44px; }
.team-status-form [aria-invalid="true"] { border-color: #b02a37; }
.team-status-form [aria-invalid="true"]:focus { box-shadow: 0 0 0 .25rem rgba(176, 42, 55, .18); }

@media (max-width: 991.98px) {
  .workspace-project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manager-risk-facts, .manager-state-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-history-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-impact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .sales-workspace { padding-bottom: 5rem; }
  .workspace-card { grid-template-columns: 1fr; }
  .workspace-card-actions { justify-content: flex-start; }
  .workspace-card-actions .btn { flex: 1 1 auto; min-height: 2.75rem; }
  .manager-risk-card { grid-template-columns: 1fr; }
  .manager-risk-actions { justify-content: flex-start; max-width: none; }
  .manager-risk-actions .btn { flex: 1 1 8rem; min-height: 2.75rem; }
  .manager-entry-grid { grid-template-columns: 1fr; }
}

@media (max-width: 575.98px) {
  .team-page-header { align-items: stretch !important; flex-direction: column; }
  .team-page-header > div { min-width: 0; width: 100%; }
  .detail-actions { display:grid !important; gap: .75rem !important; grid-template-columns:1fr; width:100%; }
  .detail-actions .btn { display:flex; align-items:center; justify-content:center; width:auto; min-height:44px; height:auto; white-space:normal; }
  .team-danger-action { margin-left: 0; margin-top: .5rem; }
  .team-filter-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-filter-nav .nav-link { width: 100%; }
  .team-list-card { padding: 1rem; }
  .team-list-card > .d-flex:first-child { align-items: flex-start; flex-direction: column; }
  .team-member-section-header { align-items: flex-start !important; flex-direction: column; }
  .team-member-section-header .text-end { text-align: left !important; }
  .team-status-actions { display: grid; gap: .75rem; grid-template-columns: 1fr; }
  .team-status-actions .btn { width: 100%; }
  .team-risk-alert, .team-status-form .card-body, .team-status-page .card-body { padding: 1rem !important; }
  .login-shell {
    align-items: flex-start !important;
    padding-top: 2.5rem !important;
  }

  .welcome-panel {
    min-height: 15rem;
  }
  main { padding-top: 1.25rem !important; }
  .detail-grid { grid-template-columns: 1fr; gap: 1rem; }
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .sticky-actions .btn { min-height: 2.8rem; flex: 1; }
  .narrow-page button[type="submit"], .form-page button[type="submit"] { min-height: 2.75rem; }
  main > .d-flex.justify-content-between { flex-direction: column; }
  main > .d-flex.justify-content-between > .d-flex { width: 100%; }
  main > .d-flex.justify-content-between > .d-flex .btn { flex: 0 0 auto; min-height: 2.75rem; white-space: normal; }
  main > .d-flex.justify-content-between > .d-flex { align-items: stretch !important; }
  main > .position-fixed.bottom-0 { margin-top: 1rem; position: static !important; }
  .lead-pools .btn { min-height: 2.75rem; }
  .btn { min-height: 2.75rem; }
  .navbar-toggler { min-height: 44px; min-width: 44px; }
  .workspace-header { align-items: flex-start; }
  .workspace-header h1 { font-size: 1.55rem; }
  .workspace-summary { display: flex; margin-inline: -.75rem; overflow-x: auto; padding: 0 .75rem .35rem; scroll-snap-type: x proximity; }
  .summary-action { flex: 0 0 8.6rem; scroll-snap-align: start; }
  .workspace-secondary-action { display: none !important; }
  .workspace-project-grid { grid-template-columns: 1fr; }
  .project-facts { grid-template-columns: 1fr 1fr; }
  .section-heading { align-items: center; }
  .manager-workspace { padding-bottom: 1.5rem; }
  .manager-workspace .workspace-header { flex-direction: column; }
  .manager-priority-summary { grid-template-columns: 1fr 1fr; }
  .manager-priority-item { min-width: 0; padding: .85rem; }
  .manager-priority-item strong { font-size: 1.55rem; }
  .manager-risk-card { padding: 1rem; }
  .manager-risk-facts, .manager-context-row, .manager-state-grid { grid-template-columns: 1fr; }
  .manager-risk-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .manager-risk-actions .btn:first-child { grid-column: 1 / -1; }
  .manager-filter-bar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manager-filter-bar .btn { min-height: 2.75rem; width: 100%; }
  .team-history-facts { grid-template-columns: 1fr; }
  .team-current-members .list-group-item { align-items: stretch !important; flex-direction: column; }
  .team-current-members .btn { width: 100%; }
  .team-page .team-touch-target { min-height: 44px; }
}
