/* Same design tokens as the Sales Portal dashboard (salesPortal/index.html) and the
   training guides (training/guide.css), so this app reads as part of the same
   product rather than a bolted-on tool. */
:root {
  --color-fg-primary: #0a0a0a;
  --color-fg-secondary: #737373;
  --color-fg-third: #a3a3a3;
  --color-surface: #ffffff;
  --color-bg-page: #f5f5f5;
  --color-bg-subtle: #f5f5f5;
  --color-bg-brand: #eaf4ff;
  --color-bg-brand-vibrant: #cfe6ff;
  --color-bg-success: #eaf8f3;
  --color-bg-warning: #fff6e9;
  --color-bg-danger: #fdecee;
  --color-line: #e5e5e5;
  --color-border: #e5e5e5;
  --color-interactive: #0a77ff;
  --color-interactive-hover: #086ae6;
  --color-interactive-active: #075ccc;
  --color-text-success: #228864;
  --color-text-warning: #d48e29;
  --color-text-danger: #c22525;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-full: 9999px;

  --shadow-2xs: 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-sm: 0 1px 3px rgba(10, 10, 10, 0.06), 0 1px 2px rgba(10, 10, 10, 0.04);
  --shadow-md: 0 4px 12px rgba(10, 10, 10, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-bg-page);
  color: var(--color-fg-primary);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex; flex-direction: column;
}
.topbar-brand-row {
  height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 24px;
  border-bottom: 1px solid var(--color-border);
}
.topbar-nav-row {
  height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.nav-row-right { display: flex; align-items: center; gap: 20px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius-md);
  background: var(--color-interactive);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
}
.brand-name { font-weight: 600; font-size: 15px; }
.brand-name span { color: var(--color-fg-secondary); font-weight: 500; }

/* Nav links used in the second toolbar row (Back to Opportunities / Back to Dashboard) */
.nav-link {
  display: flex; align-items: center; gap: 6px; border: none; background: none; padding: 0;
  font-size: 13px; font-weight: 500; color: var(--color-fg-secondary); text-decoration: none;
  font-family: inherit; cursor: pointer;
}
.nav-link:hover { color: var(--color-interactive); }

/* User menu (avatar + name, click to reveal Sign out) */
.user-menu { position: relative; margin-left: auto; }
.user-menu-trigger {
  display: flex; align-items: center; gap: 8px; border: none; background: none; padding: 4px 6px;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
}
.user-menu-trigger:hover { background: var(--color-bg-subtle); }
.user-menu-trigger .chevron { color: var(--color-fg-third); }
.avatar {
  width: 28px; height: 28px; border-radius: var(--radius-full);
  background: var(--color-bg-brand-vibrant); color: var(--color-interactive-active);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11px;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--color-fg-primary); }
.user-menu-dropdown {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; min-width: 140px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 6px;
}
.user-menu-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 8px 10px; border-radius: var(--radius-sm); font-family: inherit;
  font-size: 13px; font-weight: 500; color: var(--color-fg-secondary); cursor: pointer;
}
.user-menu-item:hover { background: var(--color-bg-subtle); color: var(--color-fg-primary); }

.wrap { margin: 0 auto; padding: 32px 24px 80px; }
.view { max-width: 760px; margin: 0 auto; }
/* Search (My Opportunities grid) and the opportunity detail/questionnaire view
   both use the full page width rather than the narrower centered column. */
#view-search, #view-questionnaire { max-width: none; }

.view[hidden] { display: none; }

h1 { font-size: 22px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 6px; }
.subtitle { color: var(--color-fg-secondary); font-size: 14px; margin-bottom: 24px; }

/* Search */
.search-box {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.search-box input {
  flex: 1; height: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 0 14px; font-family: inherit; font-size: 14px; outline: none;
}
.search-box input:focus { border-color: var(--color-interactive); box-shadow: 0 0 0 3px rgba(10,119,255,.15); }
.search-box button {
  height: 40px; padding: 0 18px; border: none; border-radius: var(--radius-sm);
  background: var(--color-interactive); color: #fff; font-weight: 600; font-size: 13.5px; cursor: pointer;
}
.search-box button:hover { background: var(--color-interactive-hover); }

.result-list { display: flex; flex-direction: column; gap: 8px; }
.result-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 12px 14px; cursor: pointer; font-family: inherit;
}
.result-item:hover { border-color: var(--color-interactive); box-shadow: var(--shadow-sm); }
.result-item .name { font-weight: 600; font-size: 14px; }
.result-item .meta { font-size: 12.5px; color: var(--color-fg-secondary); }
.empty-state { color: var(--color-fg-third); font-size: 13.5px; padding: 16px 0; }

.back-to-mine {
  border: none; background: none; color: var(--color-interactive); font-family: inherit;
  font-size: 12.5px; font-weight: 600; cursor: pointer; padding: 0 0 14px; display: block;
}
.back-to-mine:hover { color: var(--color-interactive-hover); }

/* My Opportunities (default landing list) */
.my-opps-header { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.section-title { font-size: 15px; font-weight: 700; }
.sort-control { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--color-fg-secondary); }
.sort-control select {
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 5px 8px;
  font-family: inherit; font-size: 12.5px; background: var(--color-surface); color: var(--color-fg-primary);
}

/* The whole list is one CSS grid so the header, group-divider rows, and each
   opportunity row's cells all share the exact same column tracks (via
   `subgrid`) — real column alignment, not four independently-styled lists
   that happen to look similar. */
#stageGroups {
  display: grid;
  grid-template-columns: 1.6fr 1fr 160px 150px;
  column-gap: 16px; row-gap: 6px;
}

.grid-header {
  display: grid; grid-template-columns: subgrid; grid-column: 1 / -1;
  padding: 0 14px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--color-fg-secondary);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 6px;
}

/* The grouping row: deliberately a solid, high-contrast full-width bar so a
   stage boundary is unmistakable while scanning the grid, not just another
   line of small gray text. */
.stage-group-row {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 8px;
  background: var(--color-interactive); color: #fff;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  margin-top: 12px;
}
.stage-group-row:first-child { margin-top: 0; }
.stage-group-row .count { font-weight: 500; color: rgba(255,255,255,.75); text-transform: none; letter-spacing: 0; }
.stage-group-row.collapsible { cursor: pointer; user-select: none; }
.stage-group-row.collapsible:hover { background: var(--color-interactive-hover); }
.stage-group-row .collapse-icon { display: inline-block; font-size: 9px; transition: transform .15s ease; }
.stage-group-row.expanded .collapse-icon { transform: rotate(90deg); }

.opp-row {
  display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; align-items: center;
  width: 100%; text-align: left; font-family: inherit; cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 11px 14px;
}
.opp-row:hover { border-color: var(--color-interactive); box-shadow: var(--shadow-sm); }
.opp-row .name, .grid-header .name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-row .bu, .grid-header .bu { font-size: 12.5px; color: var(--color-fg-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-row .stage, .grid-header .stage { font-size: 11.5px; color: var(--color-fg-secondary); }
.opp-row .updated, .grid-header .updated { font-size: 11.5px; color: var(--color-fg-third); text-align: right; white-space: nowrap; }
.grid-header .updated { color: inherit; }

@media (max-width: 640px) {
  #stageGroups { grid-template-columns: 1fr; }
  .grid-header { display: none; }
  .opp-row { grid-template-columns: 1fr; gap: 3px; }
  .opp-row .updated { text-align: left; }
}

/* Questionnaire */
.opp-header {
  background: var(--color-bg-brand); border: 1px solid var(--color-bg-brand-vibrant);
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 24px;
}
.opp-header .name { font-weight: 700; font-size: 15px; }

/* Save button, now living in the topbar's nav row rather than the opp-header */
.save-btn-top {
  border: none; border-radius: var(--radius-sm); background: var(--color-interactive); color: #fff;
  font-weight: 700; font-size: 12.5px; padding: 7px 16px; cursor: pointer;
}
.save-btn-top:hover { background: var(--color-interactive-hover); }
.save-btn-top:disabled { background: var(--color-fg-third); cursor: not-allowed; }
.save-btn-top.dirty { background: var(--color-text-warning); }
.save-btn-top.dirty:hover { background: #c17a1f; }

/* Shown next to either Save button whenever anything (gate/category/stage)
   differs from what's actually saved in Twenty. */
.unsaved-indicator { font-size: 12px; font-weight: 600; color: var(--color-text-warning); white-space: nowrap; }

/* Details / Timeline tabs, sitting between the lock banner and whichever panel is active.
   Wrapped in .view-tabs-row together with the Add Note button, which — unlike the tab
   panels themselves — is never hidden by switchTab(), so it stays available on both tabs. */
.view-tabs-row {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; border-bottom: 1px solid var(--color-border);
}
.view-tabs { display: flex; gap: 4px; }
.view-tab {
  border: none; background: none; cursor: pointer; font: inherit; color: var(--color-fg-secondary);
  font-weight: 600; font-size: 13.5px; padding: 9px 4px; margin-right: 20px;
  border-bottom: 2px solid transparent; transition: color .15s ease, border-color .15s ease;
}
.view-tab:hover { color: var(--color-fg-primary); }
.view-tab.active { color: var(--color-interactive); border-bottom-color: var(--color-interactive); }

.add-note-btn {
  border: 1px solid var(--color-interactive); background: var(--color-surface); color: var(--color-interactive);
  border-radius: var(--radius-sm); font-weight: 700; font-size: 12.5px; padding: 7px 14px;
  cursor: pointer; white-space: nowrap; margin-bottom: 10px;
}
.add-note-btn:hover { background: var(--color-bg-brand); }

/* Activity Timeline tab: one chronological feed of Notes/Attachments/Emails
   from the Opportunity, its Company/Business Unit, and its Contacts. Each
   row's left badge marks the item TYPE; the meta line marks which record(s)
   it belongs to — the two things the SDR needs to place an item at a glance. */
.timeline-list { display: flex; flex-direction: column; gap: 10px; }
.timeline-item {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 12px 16px;
}
.timeline-item-header {
  display: flex; gap: 12px; align-items: flex-start; width: 100%;
  border: none; background: none; padding: 0; margin: 0; font: inherit; text-align: left; color: inherit;
}
button.timeline-item-header { cursor: pointer; }
.timeline-type-badge {
  flex-shrink: 0; border-radius: var(--radius-full); padding: 3px 10px; font-size: 10.5px;
  font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #fff; white-space: nowrap;
}
.timeline-type-note { background: var(--color-interactive); }
.timeline-type-attachment { background: #8e4ec6; }
.timeline-type-email { background: #0891b2; }
.timeline-item-body { min-width: 0; flex: 1; }
.timeline-item-title { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.timeline-item-meta { font-size: 12px; color: var(--color-fg-third); margin-top: 3px; }
.timeline-item-chevron {
  flex-shrink: 0; font-size: 9px; color: var(--color-fg-third); margin-top: 3px; transition: transform .15s ease;
}
.timeline-item.expanded .timeline-item-chevron { transform: rotate(90deg); }

/* The expanded detail panel: note/email body as preformatted text (long
   emails scroll rather than blowing out the page), or a list of attachment
   download links. */
.timeline-item-detail { display: none; margin: 12px 0 2px 42px; }
.timeline-item.expanded .timeline-item-detail { display: block; }
.timeline-item-content {
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto; color: var(--color-fg-primary);
  background: var(--color-bg-subtle); border-radius: var(--radius-sm); padding: 10px 12px;
}
.timeline-item-content-empty { color: var(--color-fg-third); font-style: italic; background: none; padding: 0; }
.timeline-file-link {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600;
  color: var(--color-interactive); text-decoration: none; margin-bottom: 6px;
}
.timeline-file-link:hover { text-decoration: underline; }

/* Overview: stage progress + basic Opportunity info in a wide main column,
   Contacts/Company/Business Unit in a narrower sidebar — shown above the
   qualification form. "Related" cards get a visibly distinct pill + border
   tint so it's obvious those fields live on a different Twenty record, not
   on the Opportunity itself. */
#overviewSection { margin-bottom: 4px; }

.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 28px; align-items: start; }

.overview-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 16px 18px; margin-bottom: 14px;
}
.overview-card.related { border-color: var(--color-bg-brand-vibrant); background: var(--color-bg-brand); }
.overview-card-title { font-size: 15px; font-weight: 700; }
.overview-empty { font-size: 12.5px; color: var(--color-fg-third); font-style: italic; }

/* Company/Business Unit cards are collapsible — the header (pill + name) is
   always visible and clickable; only the field grid hides/shows. */
.overview-card-header {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: none; padding: 0; margin: 0; cursor: pointer; font: inherit; text-align: left; color: inherit;
}
.overview-card.expanded .overview-card-header { margin-bottom: 12px; }
.overview-card-header .collapse-icon {
  font-size: 9px; color: var(--color-fg-third); flex-shrink: 0; transition: transform .15s ease;
}
.overview-card.expanded .overview-card-header .collapse-icon { transform: rotate(90deg); }

.related-pill {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  background: var(--color-interactive); color: #fff; border-radius: var(--radius-full);
  padding: 2px 9px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

/* The Details card's named sub-sections (Basic Info, Opportunity Size, Status).
   A grayscale rule separates each section from the next — but not after the
   last one, since there's nothing left to separate it from. */
.detail-subsection { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--color-border); }
.detail-subsection:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.detail-subsection-title {
  display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--color-interactive-active); background: var(--color-bg-brand);
  padding: 5px 12px; border-radius: var(--radius-sm); margin-bottom: 14px;
}

/* Fields as compact label-over-value blocks, several per row — reads like a
   real record detail page rather than a two-column key/value list. */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); row-gap: 16px; column-gap: 16px; }
.field-row {
  display: flex; flex-direction: column; gap: 4px;
  border: none; background: none; padding: 0; margin: 0; font: inherit; text-align: left; color: inherit;
}
.field-label { font-size: 11px; font-weight: 600; color: var(--color-fg-secondary); text-transform: uppercase; letter-spacing: .03em; }
.field-value { font-size: 14px; font-weight: 600; color: var(--color-fg-primary); word-break: break-word; }
/* Editable Details fields (click to open the edit modal) get a dashed
   underline hint even before hovering, since there's nothing else on the
   page distinguishing "clickable" from "just text." */
.field-row.editable { cursor: pointer; }
.field-row.editable .field-value { border-bottom: 1px dashed var(--color-fg-third); padding-bottom: 1px; }
.field-row.editable:hover .field-value { border-bottom-color: var(--color-interactive); color: var(--color-interactive); }
.field-value a { color: var(--color-interactive); text-decoration: none; }
.field-value a:hover { text-decoration: underline; }

/* Stage progress: a linear main track (New Opportunity -> ... -> Closed Won)
   plus a separate "off-track" cluster for Stalled/Nurture/Closed Lost, which
   aren't steps on that line — a deal can jump into one of them from anywhere
   in the main flow and later jump back out. Only the current stage is ever
   marked; there's no cumulative "done" state before it, since stage here
   isn't strictly monotonic. */
.stage-panel { display: flex; gap: 24px; align-items: flex-start; margin: 2px 0 10px; }

/* Wraps the track + gate status badge as one column, so the badge sits right
   below the track's own bottom edge — not below the whole panel, which would
   be taller whenever .stage-side (a vertical stack of chips) is taller than
   the track. */
.stage-track-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage-track { display: flex; min-width: 0; overflow-x: auto; padding: 4px 2px 8px; }
/* Both are real <button>s now (clicking any phase selects it as the pending
   stage to save) — reset button defaults so they still look like the plain
   step/chip they did as <div>s. */
.stage-step {
  flex: 1; min-width: 76px; display: flex; flex-direction: column; align-items: center; text-align: center;
  position: relative; border: none; background: none; padding: 0; font: inherit; cursor: pointer;
}
.stage-step::before {
  content: ''; position: absolute; top: 12px; right: 50%; width: 100%; height: 2px;
  background: var(--color-border); z-index: 0;
}
.stage-step:first-child::before { content: none; }
.stage-dot {
  width: 26px; height: 26px; border-radius: 50%; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-surface); border: 2px solid var(--color-border); color: var(--color-fg-third);
  font-size: 12px; font-weight: 700;
}
.stage-step:hover .stage-dot { border-color: var(--color-interactive); }
.stage-step.current .stage-dot { background: var(--stage-color); border-color: var(--stage-color); color: #fff; }
/* Pending = selected but not yet saved: dashed outline instead of a solid
   fill, so "about to change" reads differently from "confirmed in Twenty." */
.stage-step.current.pending .stage-dot {
  background: var(--color-surface); color: var(--stage-color); border-style: dashed;
}
/* Before-pause = purely informational: the real stage this deal was on right
   before it went Stalled/Nurture. Faded tint + dashed ring, distinct from
   both the solid "confirmed" fill and the empty "pending" outline — it's
   neither the current stage nor a pending choice, just history. */
.stage-step.before-pause .stage-dot {
  background: color-mix(in srgb, var(--stage-color) 35%, var(--color-surface));
  border-style: dashed; border-color: var(--stage-color); color: var(--stage-color);
}
.stage-label { font-size: 11px; margin-top: 7px; color: var(--color-fg-secondary); max-width: 88px; line-height: 1.3; }
.stage-step.current .stage-label { color: var(--color-fg-primary); font-weight: 700; }

.stage-side {
  flex: 0 0 150px; border-left: 1px dashed var(--color-border); padding: 4px 0 4px 16px;
  display: flex; flex-direction: column; gap: 7px;
}
.stage-side-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--color-fg-third); margin-bottom: 1px; }
.stage-chip {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-fg-secondary);
  padding: 6px 10px; border-radius: var(--radius-sm); background: var(--color-bg-subtle);
  border: none; font-family: inherit; cursor: pointer; text-align: left;
}
.stage-chip:hover { background: var(--color-bg-brand-vibrant); }
.stage-chip.current { background: var(--color-bg-brand); color: var(--color-fg-primary); font-weight: 700; }
.stage-chip-dot {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--color-border); background: var(--color-surface);
  display: flex; align-items: center; justify-content: center; font-size: 9px; color: #fff;
}
.stage-chip.current .stage-chip-dot { background: var(--stage-color); border-color: var(--stage-color); }
.stage-chip.current.pending .stage-chip-dot {
  background: var(--color-surface); color: var(--stage-color); border-style: dashed;
}
.stage-chip.current.pending { background: var(--color-bg-subtle); }

@media (max-width: 640px) {
  .stage-panel { flex-direction: column; }
  .stage-side { border-left: none; border-top: 1px dashed var(--color-border); padding: 12px 0 0; flex-direction: row; flex-wrap: wrap; }
}

/* Sidebar */
.sidebar-heading { font-size: 13.5px; font-weight: 700; margin: 20px 0 10px; }
.sidebar-heading:first-child { margin-top: 0; }
.sidebar-heading-row { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.sidebar-heading-row:first-child { margin-top: 0; }
.sidebar-heading-row .sidebar-heading { margin: 0; }
.sidebar-add-btn {
  border: 1px solid var(--color-interactive); background: var(--color-surface); color: var(--color-interactive);
  border-radius: var(--radius-sm); font-weight: 700; font-size: 12px; padding: 4px 10px;
  cursor: pointer; white-space: nowrap;
}
.sidebar-add-btn:hover { background: var(--color-bg-brand); }
.sidebar-empty { font-size: 12.5px; color: var(--color-fg-third); font-style: italic; margin-bottom: 14px; }

.contact-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 14px; margin-bottom: 10px;
}
.contact-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.contact-role-pill, .contact-warning-pill {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius-full);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: #fff;
}
/* Fixed alarming red regardless of Twenty's color token — this one should
   never blend in or shift with theme/status colors like the others do. */
.contact-warning-pill--dnc { background: #e5484d; }
/* Collapsible — name (+ avatar) always visible and clickable; job
   title/email/phone are the part that hides. */
.contact-card-header-row { display: flex; align-items: center; gap: 8px; }
.contact-card-header {
  display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0;
  border: none; background: none; padding: 0; margin: 0; cursor: pointer; font: inherit; text-align: left; color: inherit;
}
.contact-card.expanded .contact-card-header-row { margin-bottom: 10px; }
.contact-edit-btn {
  flex-shrink: 0; border: none; background: none; color: var(--color-fg-third); font-size: 12px;
  padding: 4px 6px; cursor: pointer; border-radius: var(--radius-sm); text-decoration: none;
}
.contact-edit-btn:hover { color: var(--color-interactive); background: var(--color-bg-brand); }
.contact-card-header .collapse-icon {
  font-size: 9px; color: var(--color-fg-third); flex-shrink: 0; transition: transform .15s ease;
}
.contact-card.expanded .contact-card-header .collapse-icon { transform: rotate(90deg); }
.contact-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--color-bg-brand-vibrant); color: var(--color-interactive-active);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11.5px;
}
.contact-name { font-weight: 700; font-size: 13.5px; }
.contact-title { font-size: 11.5px; color: var(--color-fg-secondary); margin-bottom: 8px; }
.contact-detail { font-size: 12px; color: var(--color-fg-secondary); display: flex; align-items: center; gap: 6px; }
.contact-detail + .contact-detail { margin-top: 4px; }
.contact-detail a { color: var(--color-interactive); text-decoration: none; }
.contact-detail a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .field-grid { grid-template-columns: repeat(2, 1fr); }
  .stage-step { min-width: 64px; }
  .stage-label { font-size: 10px; max-width: 68px; }
}

/* Gate status: the second item in .stage-track-col, so it sits directly below
   the track's own content (right in the gap that's already there) regardless
   of how tall the Off-track column next to it is — and right-aligns itself
   within the track's own width via align-self, never affecting anything's
   width or position. */
.gate-status-badge {
  align-self: flex-end; margin-top: 6px;
  display: inline-flex; align-items: center; white-space: nowrap;
  padding: 5px 12px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; background: var(--color-bg-subtle); color: var(--color-fg-secondary);
}
.gate-status-badge.qualified { background: var(--color-bg-success); color: var(--color-text-success); }
.gate-status-badge.not-qualified { background: var(--color-bg-danger); color: var(--color-text-danger); }
.gate-status-badge.unknown { background: var(--color-bg-subtle); color: var(--color-fg-secondary); }

.lock-banner {
  border-radius: var(--radius-lg); padding: 12px 16px; margin-bottom: 20px;
  font-size: 13.5px; font-weight: 600; display: none;
  background: var(--color-bg-warning); color: var(--color-text-warning); border: 1px solid #f6e2bf;
}
.lock-banner.show { display: block; }

.view.read-only select,
.view.read-only input,
.view.read-only textarea,
.view.read-only .toggle button,
.view.read-only .submit-btn {
  pointer-events: none; opacity: .6;
}

/* The gate modal moves #gateGrid/the Vertical card OUT of .view — the rule
   above can't reach them there, so read-only gets applied directly instead
   (see openGateModal in app.js). */
.modal-body.read-only select,
.modal-body.read-only .toggle button {
  pointer-events: none; opacity: .6;
}

.derived-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
}
.derived-badge.fit { background: var(--color-bg-success); color: var(--color-text-success); }
.derived-badge.no-fit { background: var(--color-bg-danger); color: var(--color-text-danger); }
.unclassified-note {
  font-size: 11.5px; color: var(--color-text-warning); margin-top: 6px; font-weight: 500;
}

.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--color-fg-secondary); margin: 24px 0 10px;
}
.section-label:first-child { margin-top: 0; }

.gate-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
/* The 5 gate toggles (No Vertical Fit, EDI Dependency, Feature-based RFP,
   Existing WMS, Existing Satisfactory ERP) now live only in the gate-edit
   modal (opened from the Gate Status badge) — hidden in their normal inline
   spot, and shown again once openGateModal() moves #gateGrid into the modal. */
#gateGrid { display: none; }
.modal-body #gateGrid { display: flex; }

/* All 7 questionnaire categories now live only via the Details card's
   click-to-edit fields (each opens the real category card in a modal — see
   openCategoryFieldModal in app.js). Only the LIST container is hidden —
   once a single .category-card is reparented out of it into the modal, it's
   no longer a descendant of this hidden container and renders normally with
   its own default block display, so no override is needed for the card itself. */
#categoryList { display: none; }
.gate-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 12px 16px;
}
.gate-row .label { font-size: 13.5px; font-weight: 500; }
.toggle { display: flex; gap: 4px; background: var(--color-bg-subtle); border-radius: var(--radius-sm); padding: 3px; }
.toggle button {
  border: none; background: transparent; padding: 5px 12px; border-radius: 5px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--color-fg-secondary); font-family: inherit;
}
.toggle button.active.no { background: var(--color-surface); color: var(--color-text-success); box-shadow: var(--shadow-2xs); }
.toggle button.active.yes { background: var(--color-surface); color: var(--color-text-danger); box-shadow: var(--shadow-2xs); }

.category-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 14px 16px; margin-bottom: 10px;
}
.category-card .label { font-size: 13.5px; font-weight: 600; margin-bottom: 8px; display: block; }
.category-card select {
  width: 100%; height: 38px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 0 10px; font-family: inherit; font-size: 13.5px; background: var(--color-surface); color: var(--color-fg-primary);
}
.category-card select:focus { border-color: var(--color-interactive); outline: none; }
.category-card .note-input {
  width: 100%; margin-top: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-family: inherit; font-size: 13px; resize: vertical; min-height: 44px;
  display: none;
}
.category-card .note-input.show { display: block; }

.checkbox-list { display: flex; flex-direction: column; gap: 8px; }
.checkbox-row {
  display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer;
  padding: 6px 2px;
}
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-interactive); cursor: pointer; }

.submit-btn {
  width: 100%; height: 46px; border: none; border-radius: var(--radius-md);
  background: var(--color-interactive); color: #fff; font-weight: 700; font-size: 14.5px; cursor: pointer;
}
.submit-btn:hover { background: var(--color-interactive-hover); }
.submit-btn:disabled { background: var(--color-fg-third); cursor: not-allowed; }
.submit-btn.dirty { background: var(--color-text-warning); }
.submit-btn.dirty:hover { background: #c17a1f; }

/* Gate status is clickable — opens the gate-edit modal below. */
.gate-status-badge { cursor: pointer; }
.gate-status-badge:hover { filter: brightness(0.95); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 10, 10, .5);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
/* `.modal-overlay`'s own `display: flex` has the same specificity as the
   browser's built-in `[hidden] { display: none }` rule, so without this it
   silently wins and the `hidden` attribute gets ignored — the modal shows
   permanently regardless of JS toggling it. */
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  width: 100%; max-width: 480px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--color-border); flex-shrink: 0;
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-close-btn {
  border: none; background: none; font-size: 22px; line-height: 1; color: var(--color-fg-secondary);
  cursor: pointer; padding: 2px 4px;
}
.modal-close-btn:hover { color: var(--color-fg-primary); }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--color-border); flex-shrink: 0; }

/* #fieldModalBody's own controls — plain select/number inputs, and the
   Owner/SDR Owner/AE Owner person picker. */
#fieldModalBody select,
#fieldModalBody input[type="number"],
#fieldModalBody input[type="text"] {
  width: 100%; height: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 0 12px; font-family: inherit; font-size: 14px; background: var(--color-surface); color: var(--color-fg-primary);
}
#fieldModalBody select:focus,
#fieldModalBody input:focus { border-color: var(--color-interactive); outline: none; }

/* Add Note modal (#noteModalBody has no id — it's the modal-body's direct
   children — labeled field groups, since this one has three controls rather
   than the single bare control every other modal-body renders). */
.modal-field { display: flex; flex-direction: column; gap: 6px; }
.modal-field label { font-size: 13.5px; font-weight: 600; }
.modal-field .field-optional { font-weight: 400; color: var(--color-fg-secondary); }
.modal-field select,
.modal-field input[type="text"],
.modal-field input[type="email"],
.modal-field input[type="url"],
.modal-field input[type="date"],
.modal-field textarea {
  width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: inherit; font-size: 14px; background: var(--color-surface); color: var(--color-fg-primary);
}
.modal-field select { height: 40px; padding: 0 12px; }
.modal-field textarea { resize: vertical; min-height: 110px; }
.modal-field select:focus,
.modal-field input:focus,
.modal-field textarea:focus { border-color: var(--color-interactive); outline: none; }

.field-modal-picker-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow-y: auto; }
.field-modal-picker-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; border: 1px solid var(--color-border); background: var(--color-surface);
  border-radius: var(--radius-sm); padding: 10px 12px; font-family: inherit; cursor: pointer;
}
.field-modal-picker-row:hover { border-color: var(--color-interactive); }
.field-modal-picker-row.selected { border-color: var(--color-interactive); background: var(--color-bg-brand); }
.field-modal-picker-name { font-size: 13.5px; font-weight: 600; }
.field-modal-picker-email,
.field-modal-picker-detail { font-size: 12px; color: var(--color-fg-secondary); }
.field-modal-picker-row.create-new { border-style: dashed; color: var(--color-interactive); font-weight: 600; }

.modal-back-btn {
  border: none; background: none; color: var(--color-interactive); font-size: 12.5px; font-weight: 600;
  cursor: pointer; padding: 0; align-self: flex-start;
}
.modal-back-btn:hover { text-decoration: underline; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--color-fg-primary); color: #fff; padding: 12px 20px; border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-md); display: none;
}
.toast.show { display: block; }
.toast.error { background: var(--color-text-danger); }

.login-card {
  max-width: 380px; margin: 80px auto 0; text-align: center;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: 36px 28px; box-shadow: var(--shadow-sm);
}
.login-card .brand-mark { margin: 0 auto 16px; width: 40px; height: 40px; font-size: 20px; }
.login-card h1 { font-size: 18px; margin-bottom: 8px; }
.login-card p { color: var(--color-fg-secondary); font-size: 13.5px; margin-bottom: 22px; }
.login-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 44px; border: none; border-radius: var(--radius-md);
  background: var(--color-interactive); color: #fff; font-weight: 700; font-size: 14px;
  text-decoration: none; cursor: pointer;
}
.login-btn:hover { background: var(--color-interactive-hover); }
