/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--app-background);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; color: var(--brand-navy); font-weight: 650; }
h1 { font-size: 20px; letter-spacing: -0.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ==========================================================================
   Layout shell
   ========================================================================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: var(--sidebar-width);
  display: flex; flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text-secondary);
}
.sidebar__brand { padding: 22px 22px 26px; }
.sidebar__logo { display: block; width: 118px; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; flex: 1; }
.nav__link {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-secondary);
  font-weight: 500;
  text-decoration: none;
}
.nav__link .icon { width: 18px; height: 18px; }
.nav__link:hover { color: var(--sidebar-text); background: rgba(255, 255, 255, 0.04); text-decoration: none; }
.nav__link.is-active { color: var(--sidebar-text); background: var(--sidebar-active-bg); }
.nav__link.is-active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--sidebar-indicator);
}
.nav__section { margin: 14px 12px 6px; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #6F7D89; }
.sidebar__user {
  display: flex; align-items: center; gap: 8px;
  margin: 8px; padding: 10px 4px 6px 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar__user-info { min-width: 0; flex: 1; }
.sidebar__user-name, .sidebar__user-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user-name { color: var(--sidebar-text); font-weight: 600; font-size: 13px; }
.sidebar__user-role { font-size: 11.5px; }
.sidebar__user .sidebar__icon-btn { width: 26px; height: 26px; }
.sidebar__icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--sidebar-text-secondary); cursor: pointer;
}
.sidebar__icon-btn:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text); }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-width); display: flex; flex-direction: column; }
.topbar { display: none; }
.view { flex: 1; min-width: 0; padding: 22px 28px 32px; }
.view--flush { padding: 0; display: flex; flex-direction: column; min-height: 0; }
/* The pipeline fills the viewport so columns scroll on their own. */
.view--board { height: 100vh; height: 100dvh; overflow: hidden; }
.opp-content { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.view--board .opp-content { overflow: hidden; }

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-lg); }
  .app.is-nav-open .sidebar { transform: none; }
  .app.is-nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(19, 26, 33, 0.45); }
  .main { margin-left: 0; }
  .topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 30;
    height: 52px; padding: 0 16px;
    background: var(--sidebar-bg);
  }
  .topbar img { width: 96px; height: auto; }
  .topbar .sidebar__icon-btn { color: var(--sidebar-text); }
  .view { padding: 16px; }
  .view--flush { padding: 0; }
  .view--board { height: calc(100vh - 52px); height: calc(100dvh - 52px); }
  .list-pad { padding: 12px 16px 20px !important; }
  .segmented button span { display: none; }
}

/* ==========================================================================
   Page header & toolbar
   ========================================================================== */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-header__title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-header__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.breadcrumb a { color: var(--text-secondary); }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.toolbar__spacer { flex: 1; }
.toolbar__summary { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.toolbar .search { width: 260px; }
@media (max-width: 900px) {
  .toolbar { padding: 10px 16px; }
  .toolbar .search { width: 100%; order: 10; }
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 28px; background: var(--surface); border-bottom: 1px solid var(--border); }
.filters .input, .filters .select { width: auto; min-width: 140px; height: 32px; font-size: 13px; }
.filters__group { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
@media (max-width: 900px) { .filters { padding: 10px 16px; } .filters .input, .filters .select { flex: 1 1 140px; } }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--input-height); padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--brand-navy);
  font-weight: 600; font-size: 13px; white-space: nowrap;
  cursor: pointer; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--danger { background: var(--surface); border-color: #E9B8B8; color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); }
.btn--danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger-solid:hover { background: var(--danger-hover); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-hover); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn--link { height: auto; padding: 0; border: 0; background: none; color: var(--accent-ink); font-weight: 600; }
.btn--link:hover { background: none; text-decoration: underline; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.icon-btn .icon { width: 18px; height: 18px; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border: 0; background: var(--surface); color: var(--text-secondary); cursor: pointer; font-weight: 600; font-size: 13px; }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button.is-active { background: var(--accent-soft); color: var(--brand-navy); }

/* ==========================================================================
   Form controls
   ========================================================================== */
.input, .select, .textarea {
  display: block; width: 100%;
  height: var(--input-height); padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:hover, .select:hover, .textarea:hover { border-color: #B5C0CA; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
.input:disabled, .select:disabled { background: var(--surface-muted); color: var(--text-secondary); cursor: not-allowed; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2317212B'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.is-invalid .input, .is-invalid .select, .is-invalid .textarea, .input.is-invalid { border-color: var(--danger); }
.is-invalid .input:focus { box-shadow: 0 0 0 3px rgba(200, 70, 70, 0.2); }

.field { margin-bottom: 12px; min-width: 0; }
.field__label { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--brand-navy); }
.field__label .req { color: var(--danger); }
.field__hint { margin-top: 4px; font-size: 12px; color: var(--text-secondary); }
.field__error { margin-top: 4px; font-size: 12px; color: var(--danger); display: flex; gap: 4px; align-items: flex-start; }
.field__error::before { content: "!"; display: inline-grid; place-items: center; flex: none; width: 14px; height: 14px; margin-top: 1px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row--value { grid-template-columns: 1fr 120px; }
.field-row--3 { grid-template-columns: 1fr 1fr 1fr; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.input-icon > .input { padding-left: 34px; }

.section-heading {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0 14px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand-navy);
}
.section-heading::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.method-row { display: grid; grid-template-columns: 1fr 112px 32px; gap: 8px; margin-bottom: 8px; }
.method-row .icon-btn { height: var(--input-height); }
.add-link { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 2px 0; color: var(--brand-navy); font-weight: 600; font-size: 13px; cursor: pointer; }
.add-link:hover { color: var(--accent-ink); }

.disclosure { border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 600; font-size: 13px; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.subpanel { margin: 4px 0 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-muted); }

/* Stage progress selector (Pipedrive-style chevrons) */
.stage-picker { display: flex; gap: 2px; }
.stage-picker__step {
  flex: 1; height: 24px; min-width: 0; padding: 0;
  border: 0; background: #E3E8ED; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%, 8px 50%);
  transition: background 0.12s;
}
.stage-picker__step:first-child { clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%); border-radius: 4px 0 0 4px; }
.stage-picker__step:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 8px 50%); border-radius: 0 4px 4px 0; }
.stage-picker__step:hover { background: #CDEFF4; }
.stage-picker__step.is-filled { background: var(--brand-cyan); }
.stage-picker__step:focus-visible { box-shadow: none; outline: 2px solid var(--brand-navy); outline-offset: 1px; }
.stage-picker__label { margin-top: 6px; font-size: 12px; color: var(--text-secondary); }
.stage-picker__label strong { color: var(--brand-navy); font-weight: 600; }

/* Combobox */
.combo { position: relative; }
.combo__list {
  position: absolute; z-index: 70; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 260px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.combo__option { display: flex; flex-direction: column; padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer; }
.combo__option-sub { font-size: 12px; color: var(--text-secondary); }
.combo__option.is-active { background: var(--accent-soft); }
.combo__option--create { flex-direction: row; align-items: center; gap: 6px; color: var(--accent-ink); font-weight: 600; }
.combo__status { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 12px; color: var(--text-secondary); }

.chip-select { position: relative; }
.chip-select__button { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-height: var(--input-height); height: auto; padding: 4px 30px 4px 8px; text-align: left; }
.chip-select__placeholder { color: var(--text-muted); padding-left: 2px; }
.chip-select__menu { position: absolute; z-index: 70; left: 0; right: 0; top: calc(100% + 4px); max-height: 240px; overflow-y: auto; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.check-option { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.check-option:hover { background: var(--surface-hover); }
.check-option input { accent-color: var(--accent-ink); width: 15px; height: 15px; }

/* ==========================================================================
   Badges, avatars, chips
   ========================================================================== */
.label-chip { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px; background: var(--surface-muted); border: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.stage-badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 11px; background: var(--surface-muted); border: 1px solid var(--border); font-size: 12px; font-weight: 600; white-space: nowrap; color: var(--text-primary); }
.role-badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.role-badge--admin { background: var(--brand-navy); color: #fff; }
.role-badge--rep { background: var(--accent-soft); color: #005F6E; }
.status-badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.status-badge--active { color: var(--success); }
.status-badge--disabled { color: var(--text-secondary); }
.avatar { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; background: #DCE6EE; color: var(--brand-navy); font-size: 10px; font-weight: 700; }
.avatar--lg { width: 32px; height: 32px; font-size: 12px; }
.sidebar .avatar { background: #2B3946; color: var(--sidebar-text); }
.lock-note { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.lock-note .icon { width: 12px; height: 12px; }

/* ==========================================================================
   Cards & panels
   ========================================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--text-secondary); }
.empty__title { color: var(--brand-navy); font-weight: 600; margin-bottom: 4px; }

.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 9px 12px; margin: 0; font-size: 13px; }
.dl dt { color: var(--text-secondary); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; padding: 9px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--surface-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: #F8FBFC; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table__primary { font-weight: 600; color: var(--brand-navy); }
.table__sub { font-size: 12px; color: var(--text-secondary); }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-secondary); }

/* ==========================================================================
   Pipeline board
   ========================================================================== */
.board { flex: 1; display: flex; gap: 10px; padding: 14px 28px 20px; overflow-x: auto; overflow-y: hidden; min-height: 0; align-items: stretch; }
.board__col {
  flex: 0 0 248px; display: flex; flex-direction: column; min-height: 0;
  background: #EEF2F5; border-radius: var(--radius-lg); border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
.board__col-head { padding: 10px 12px 9px; border-top: 3px solid var(--stage-color, var(--border-strong)); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.board__col-name { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: 13px; color: var(--brand-navy); line-height: 1.3; }
.board__col-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--surface); font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.board__col-meta { margin-top: 3px; font-size: 12px; color: var(--text-secondary); display: flex; gap: 8px; align-items: center; }
.board__cards { flex: 1; overflow-y: auto; padding: 2px 8px 10px; display: flex; flex-direction: column; gap: 7px; min-height: 60px; }
.board__col.is-drop-target { border-color: var(--brand-cyan); background: #E5F8FB; }
.board__col.is-drop-blocked { opacity: 0.5; }
.board__more { padding: 6px; text-align: center; font-size: 12px; color: var(--text-secondary); }
.board__divider { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding-top: 12px; width: 18px; }
.board__divider span { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.board__divider::after { content: ""; flex: 1; width: 1px; background: var(--border-strong); }
@media (max-width: 900px) {
  .board { padding: 12px 16px 16px; scroll-snap-type: x mandatory; }
  .board__col { flex-basis: 82vw; max-width: 300px; scroll-snap-align: start; }
}

.opp-card {
  display: block; padding: 10px 11px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  color: var(--text-primary); cursor: pointer; text-decoration: none;
  transition: box-shadow 0.12s, border-color 0.12s;
}
.opp-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.opp-card[draggable="true"] { cursor: grab; }
.opp-card.is-dragging { opacity: 0.45; }
.opp-card.is-saving { opacity: 0.7; }
.opp-card__company { font-weight: 650; color: var(--brand-navy); font-size: 13px; line-height: 1.3; overflow-wrap: anywhere; }
.opp-card__title { font-size: 12px; color: var(--text-secondary); margin-top: 1px; overflow-wrap: anywhere; }
.opp-card__contact { margin-top: 5px; font-size: 12px; color: var(--text-primary); display: flex; gap: 5px; align-items: center; }
.opp-card__contact .icon { width: 13px; height: 13px; color: var(--text-secondary); }
.opp-card__labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.opp-card__meeting { margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #4C3BA0; background: #F0EDFB; padding: 2px 7px; border-radius: 10px; }
.opp-card__meeting .icon { width: 12px; height: 12px; }
.opp-card__foot { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); }
.opp-card__rep { display: flex; align-items: center; gap: 5px; min-width: 0; color: var(--text-primary); }
.opp-card__rep span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-card__value { margin-left: auto; font-weight: 700; color: var(--brand-navy); font-variant-numeric: tabular-nums; }
.opp-card__dates { margin-top: 5px; display: flex; justify-content: space-between; gap: 6px; font-size: 11px; color: var(--text-muted); }

/* ==========================================================================
   Detail pages
   ========================================================================== */
.detail-head { padding: 18px 28px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.detail-head__row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.detail-head__meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 13px; color: var(--text-secondary); }
.detail-head__meta strong { color: var(--text-primary); font-weight: 600; }
.detail-head__meta > span { display: inline-flex; align-items: center; gap: 6px; }
.stage-bar { display: flex; gap: 2px; margin-top: 16px; }
.stage-bar__step {
  flex: 1; min-width: 0; height: 30px; padding: 0 10px 0 16px;
  border: 0; background: #E3E8ED; color: var(--text-secondary);
  font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%, 10px 50%);
  cursor: pointer; transition: background 0.12s;
}
.stage-bar__step:first-child { clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 50%, calc(100% - 10px) 100%, 0 100%); padding-left: 10px; border-radius: 5px 0 0 5px; }
.stage-bar__step:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 10px 50%); border-radius: 0 5px 5px 0; }
.stage-bar__step:hover:not(:disabled) { background: #CDEFF4; color: var(--brand-navy); }
.stage-bar__step.is-done { background: #A9EBF3; color: var(--brand-navy); }
.stage-bar__step.is-current { background: var(--brand-cyan); color: var(--brand-navy); }
.stage-bar__step:disabled { cursor: default; }
.stage-bar__step:focus-visible { box-shadow: none; outline: 2px solid var(--brand-navy); outline-offset: 1px; }
@media (max-width: 900px) {
  .detail-head { padding: 14px 16px; }
  .stage-bar { overflow-x: auto; }
  .stage-bar__step { flex: 0 0 auto; min-width: 120px; }
}

.detail-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; padding: 18px 28px 32px; align-items: start; }
.detail-grid__side { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1100px) { .detail-grid { grid-template-columns: 1fr; padding: 16px; } }

.handoff { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin-top: 12px; border-radius: var(--radius); background: var(--success-soft); color: #165F39; font-size: 13px; }
.handoff .icon { margin-top: 2px; }

.composer { display: flex; flex-direction: column; gap: 8px; }
.composer__actions { display: flex; justify-content: flex-end; gap: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; }
.tabs button { position: relative; height: 40px; padding: 0 10px; border: 0; background: none; color: var(--text-secondary); font-weight: 600; font-size: 13px; cursor: pointer; }
.tabs button.is-active { color: var(--brand-navy); }
.tabs button.is-active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--brand-cyan); }

.timeline { list-style: none; margin: 0; padding: 6px 16px 16px; }
.timeline__item { position: relative; display: flex; gap: 12px; padding: 10px 0; }
.timeline__item + .timeline__item { border-top: 1px solid var(--border); }
.timeline__icon { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--surface-muted); color: var(--text-secondary); }
.timeline__icon .icon { width: 14px; height: 14px; }
.timeline__icon--note { background: #FFF6DA; color: #8A6A00; }
.timeline__icon--stage { background: var(--accent-soft); color: #00788A; }
.timeline__icon--meeting { background: #F0EDFB; color: #4C3BA0; }
.timeline__body { min-width: 0; flex: 1; }
.timeline__text { font-size: 13px; overflow-wrap: anywhere; }
.timeline__note { margin-top: 4px; padding: 10px 12px; border-radius: var(--radius); background: #FFFBEB; border: 1px solid #F3E6B5; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.timeline__meta { margin-top: 2px; font-size: 12px; color: var(--text-secondary); }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  display: block; padding: 14px 16px; color: inherit; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.stat__label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.stat__value { margin-top: 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; color: var(--brand-navy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat__sub { margin-top: 2px; font-size: 12px; color: var(--text-secondary); }
.stat--hero { background: var(--brand-navy); border-color: var(--brand-navy); }
.stat--hero .stat__label { color: var(--sidebar-text-secondary); }
.stat--hero .stat__value { color: #fff; }
.stat--hero .stat__sub { color: var(--brand-cyan); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.bars { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 44px; align-items: center; gap: 10px; font-size: 13px; position: relative; }
.bar-row__label { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--text-primary); }
.bar-row__label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { height: 10px; position: relative; }
.bar-row__fill { position: absolute; left: 0; top: 0; bottom: 0; min-width: 2px; border-radius: 0 4px 4px 0; background: #3E5C76; }
.bar-row__value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.bar-row:hover .bar-row__fill { background: var(--brand-navy); }
.bar-row__hit { position: absolute; inset: -5px 0; }
@media (max-width: 600px) { .bar-row { grid-template-columns: 120px minmax(0, 1fr) 36px; } }

.tooltip {
  position: fixed; z-index: 200; pointer-events: none;
  padding: 7px 10px; border-radius: var(--radius-sm);
  background: var(--brand-navy); color: #fff; font-size: 12px; box-shadow: var(--shadow);
  max-width: 260px;
}
.tooltip strong { display: block; color: #fff; }

.meeting-list { list-style: none; margin: 0; padding: 0; }
.meeting-list li + li { border-top: 1px solid var(--border); }
.meeting-list a { display: flex; gap: 12px; align-items: center; padding: 10px 16px; color: inherit; text-decoration: none; }
.meeting-list a:hover { background: #F8FBFC; }
.date-tile { flex: none; width: 42px; text-align: center; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.date-tile__m { background: var(--brand-navy); color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 0; }
.date-tile__d { font-size: 16px; font-weight: 700; color: var(--brand-navy); padding: 2px 0; }

.mini-bar { height: 6px; background: var(--surface-muted); border-radius: 3px; overflow: hidden; min-width: 60px; }
.mini-bar > span { display: block; height: 100%; background: #3E5C76; border-radius: 0 3px 3px 0; }

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(19, 26, 33, 0.5);
  animation: fade-in 0.12s ease-out;
}
.modal {
  display: flex; flex-direction: column;
  width: 100%; max-width: 520px; max-height: calc(100vh - 48px);
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: pop-in 0.14s ease-out;
}
.modal--wide { max-width: 760px; }
.modal--sm { max-width: 420px; }
.modal__header { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--border); }
.modal__header h2 { font-size: 18px; }
.modal__body { flex: 1; overflow-y: auto; padding: 18px 20px 6px; }
.modal__footer { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 16px 12px 20px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal__footer-left { flex: 1; font-size: 12px; color: var(--text-secondary); }
.form-error { margin-bottom: 14px; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-soft); color: #8E2F2F; font-size: 13px; }
.dup-warning { margin-top: 6px; padding: 9px 11px; border-radius: var(--radius); background: var(--warning-soft); border: 1px solid #F0DDB5; color: #6B4A10; font-size: 12px; }
.dup-warning strong { color: #523707; }
.dup-warning__match { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }

/* Add Opportunity: Pipedrive-style two-column form */
.modal--opp { max-width: 820px; height: min(860px, calc(100vh - 48px)); }
.modal--opp .modal__body { padding: 0; display: grid; grid-template-columns: 1fr 1fr; }
.opp-form__col { padding: 18px 20px 8px; min-width: 0; overflow-y: visible; }
.opp-form__col--left { border-right: 1px solid var(--border); }
@media (max-width: 760px) {
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal--opp { max-width: none; max-height: none; height: 100%; border-radius: 0; }
  .modal__footer { border-radius: 0; }
  .modal--opp .modal__body { grid-template-columns: 1fr; }
  .opp-form__col--left { border-right: 0; border-bottom: 1px solid var(--border); }
  .field-row--3 { grid-template-columns: 1fr; }
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: auto; } }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-root { position: fixed; z-index: 300; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 9px; min-width: 240px; max-width: 380px;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--brand-navy); color: #fff; box-shadow: var(--shadow-lg); font-size: 13px;
  animation: pop-in 0.16s ease-out;
}
.toast .icon { color: var(--brand-cyan); }
.toast--error .icon { color: #FF9C9C; }
@media (max-width: 600px) { .toast-root { left: 16px; right: 16px; } .toast { max-width: none; } }

/* ==========================================================================
   Login
   ========================================================================== */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.login__brand { display: flex; flex-direction: column; justify-content: space-between; padding: 40px; background: var(--brand-navy); color: var(--sidebar-text-secondary); }
.login__brand img { width: 170px; height: auto; }
.login__tagline { max-width: 380px; font-size: 22px; line-height: 1.35; color: #fff; font-weight: 600; letter-spacing: -0.01em; }
.login__tagline span { color: var(--brand-cyan); }
.login__panel { display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--app-background); }
.login__card { width: 100%; max-width: 380px; padding: 28px; }
.login__card h1 { margin-bottom: 4px; }
@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login__brand { padding: 22px 16px; }
  .login__brand img { width: 120px; }
  .login__tagline { display: none; }
}

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 16px; color: var(--text-secondary); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--brand-cyan); animation: spin 0.7s linear infinite; }

.settings-list { list-style: none; margin: 0; padding: 0; }
.settings-list li { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.settings-list li:last-child { border-bottom: 0; }
.settings-list__name { flex: 1; min-width: 0; }
.inline-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.color-swatches { display: flex; gap: 5px; }
.color-swatches label { position: relative; cursor: pointer; }
.color-swatches input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.color-swatches span { display: block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.color-swatches input:checked + span { box-shadow: 0 0 0 2px var(--brand-navy); }
.color-swatches input:focus-visible + span { box-shadow: var(--focus-ring); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
