/* =====================================================================
   Iron Mountain Relationship Manager (FMV Tracker + Buyer Directory)
   Navy sidebar, cool paper workspace, IRM blues. One bold element per
   screen; everything else quiet. No inline styles (strict CSP).
   ===================================================================== */

:root {
  --navy-950: #081E36;
  --navy-900: #0C2A4A;
  --navy-800: #123760;
  --navy-700: #1A4675;
  --irm: #13487D;
  --irm-hover: #0F3B68;
  --irm-mid: #1C75BC;
  --sky: #6DCFF6;

  --paper: #F2F5F8;
  --surface: #FFFFFF;
  --surface-2: #F7F9FB;
  --line: #DDE3EA;
  --line-soft: #EAEEF3;

  --ink: #13202E;
  --ink-2: #44546A;
  --ink-3: #5E6E82;
  --ink-4: #606E80;
  --ink-5: #8A98A9; /* icons and dividers only, never text */

  --st-draft-bg: #EEF1F5;   --st-draft: #4A5A6E;
  --st-getting-bg: #E4EFFB; --st-getting: #16589A;
  --st-awaiting-bg: #FDF1DC; --st-awaiting: #8A5205;
  --st-won-bg: #E2F4E8;     --st-won: #16693A;
  --st-lost-bg: #FBE8E7;    --st-lost: #A42A21;
  --st-valued-bg: #EEE8FB;  --st-valued: #5B3BA6;
  --st-internal-bg: #E2F3F0; --st-internal: #1D6B5E;

  --danger: #B42318;
  --danger-bg: #FEF0EE;
  --warn: #8A5205;
  --warn-bg: #FDF1DC;
  --ok: #16693A;

  --f-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-code: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;
  --shadow-float: 0 18px 50px rgba(8, 30, 54, .22), 0 2px 8px rgba(8, 30, 54, .08);
  --focus: 0 0 0 3px rgba(28, 117, 188, .35);
  --sidebar-w: 244px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 14px/1.5 var(--f-body);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--f-display); color: var(--ink); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 600; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 600; line-height: 1.3; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
a { color: var(--irm-mid); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.noscript { padding: 40px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--irm-mid);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================================
   Shell: sidebar + main
   ===================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  /* dvh = the height actually visible (iPad / phone browser bars excluded), so the account
     row with Sign out at the bottom is never hidden under the browser's toolbar */
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  background: var(--navy-900);
  color: #C9D6E6;
  display: flex; flex-direction: column;
  padding: 18px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: auto; display: block; }
.brand-name { font-family: var(--f-display); font-weight: 600; font-size: 15px; line-height: 1.15; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.brand, .me { flex-shrink: 0; }
.nav-group { margin-top: 14px; padding: 0 10px 6px; font-size: 12px; color: #8FA6C2; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: #C9D6E6; font-weight: 500; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav a:hover { background: var(--navy-800); color: #fff; }
.nav a[aria-current="page"] { background: var(--navy-800); color: #fff; }
.nav a[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--sky);
}
.nav a[aria-current="page"] svg { opacity: 1; color: var(--sky); }
.nav-count {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 10px;
  background: var(--sky); color: var(--navy-950); font-size: 11.5px; font-weight: 600; text-align: center;
}

.me {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; margin-top: 10px; border-top: 1px solid var(--navy-800);
}
.me-text { min-width: 0; flex: 1; }
.me-name { color: #fff; font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 12px; color: #8FA6C2; }
.me .icon-btn { color: #8FA6C2; }
.me .icon-btn:hover { color: #fff; background: var(--navy-800); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.view { padding: 28px 36px 60px; max-width: 1400px; width: 100%; }
.view-narrow { max-width: 920px; }

/* =====================================================================
   Page header
   ===================================================================== */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .grow { flex: 1; min-width: 220px; }
.page-sub { margin-top: 5px; color: var(--ink-3); }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-weight: 500; margin-bottom: 10px; }
.back svg { width: 15px; height: 15px; }
.back:hover { color: var(--ink); text-decoration: none; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* =====================================================================
   Buttons
   ===================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #C9D2DD; text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--irm); border-color: var(--irm); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--irm-hover); border-color: var(--irm-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { background: #971C13; border-color: #971C13; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-soft); border-color: transparent; }
.btn-quiet-danger { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger).is-busy::after { border-color: var(--line); border-top-color: var(--irm-mid); }

.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-3); cursor: pointer;
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }

/* =====================================================================
   Forms
   ===================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-weight: 500; color: var(--ink-2); font-size: 13px; }
.field .hint { font-size: 12px; color: var(--ink-3); }
.req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.select { padding-right: 32px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235E6E82' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.input:hover, .select:hover, .textarea:hover { border-color: #C3CCD8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--irm-mid); box-shadow: var(--focus); }
.input-sm, .select-sm { height: 34px; font-size: 13px; }
.input[readonly] { background: var(--surface-2); color: var(--ink-2); }
.input-money { position: relative; }
.input-money::before { content: "$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.input-money .input { padding-left: 24px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-section { padding: 22px 24px; border-bottom: 1px solid var(--line-soft); }
.form-section:last-child { border-bottom: 0; }
.form-section > h2 { margin-bottom: 4px; }
.form-section > .page-sub { margin: 0 0 16px; }
.form-foot { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 16px 24px; background: var(--surface-2); border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.form-foot .grow { flex: 1; }
.form-error { color: var(--danger); background: var(--danger-bg); border-radius: var(--r-sm); padding: 9px 12px; font-size: 13px; margin: 0 24px 0; }

/* Segmented control (region, status tabs, ranges) */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--line-soft); border-radius: 9px; flex-wrap: wrap; }
.seg button, .seg label {
  height: 32px; padding: 0 13px; border: 0; border-radius: 7px; background: transparent;
  color: var(--ink-2); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg button:hover, .seg label:hover { color: var(--ink); }
.seg [aria-pressed="true"], .seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(8,30,54,.12); }
.seg label { padding: 0; }
.seg label span { height: 32px; padding: 0 13px; display: inline-flex; align-items: center; border-radius: 7px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { box-shadow: var(--focus); }
.seg .count { font-size: 12px; color: var(--ink-3); font-weight: 500; }

/* Chips (reminder days, salespeople) */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 10px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer;
  font-weight: 500; color: var(--ink-2);
}
.chip:hover { border-color: #BFC9D5; }
.chip[aria-pressed="true"] { border-color: var(--irm-mid); background: #EAF3FC; color: var(--irm); }
.chip .avatar { width: 22px; height: 22px; font-size: 10px; }
.chip-static { cursor: default; }

/* Switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track {
  flex-shrink: 0; width: 38px; height: 22px; border-radius: 11px; background: #C5CFDA; position: relative; transition: background .15s; margin-top: 1px;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s;
}
.switch input:checked + .track { background: var(--irm-mid); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }
.switch-text strong { display: block; font-weight: 500; color: var(--ink); }
.switch-text span { font-size: 12.5px; color: var(--ink-3); }

.dropzone {
  display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 64px; padding: 14px;
  border: 1.5px dashed #BFCAD6; border-radius: var(--r); background: var(--surface-2); color: var(--ink-3);
  cursor: pointer; text-align: center; transition: border-color .12s, background .12s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--irm-mid); background: #EEF5FC; color: var(--irm); }
.dropzone svg { width: 18px; height: 18px; }
.dropzone input { display: none; }

/* =====================================================================
   Surfaces
   ===================================================================== */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { flex: 1; }
/* A panel that folds: the whole header is the toggle. */
.panel-fold > summary { list-style: none; cursor: pointer; border-bottom: 0; }
.panel-fold > summary::-webkit-details-marker { display: none; }
.panel-fold > summary::after { content: ''; width: 8px; height: 8px; border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(45deg); margin: -4px 4px 0 0; transition: transform .15s; }
.panel-fold[open] > summary { border-bottom: 1px solid var(--line-soft); }
.panel-fold[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.panel-body { padding: 18px 20px; }
.panel + .panel { margin-top: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* KPI strip: one continuous band, divided — not separate tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; margin-bottom: 20px; }
.kpi { padding: 16px 20px; border-left: 1px solid var(--line-soft); text-decoration: none; color: inherit; display: block; }
.kpi:first-child { border-left: 0; }
a.kpi:hover { background: var(--surface-2); text-decoration: none; }
.kpi-value { font-family: var(--f-display); font-size: 26px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; }
.kpi-label { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.kpi-note { font-size: 12px; margin-top: 2px; color: var(--ink-4); }
.kpi-note.is-danger { color: var(--danger); }
.kpi-note.is-warn { color: var(--warn); }

/* =====================================================================
   Tables
   ===================================================================== */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.toolbar .grow { flex: 1; }
.search-box { position: relative; min-width: 220px; flex: 1; max-width: 340px; }
.search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-5); pointer-events: none; }
.search-box .input { padding-left: 34px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2);
}
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-link { cursor: pointer; }
.table tr.is-link:hover td { background: #F5F8FB; }
.table tr.is-link:focus-visible { outline: none; box-shadow: inset 3px 0 0 var(--irm-mid); }
.table .num { text-align: right; white-space: nowrap; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--ink); }
.table th[aria-sort="ascending"]::after { content: " ↑"; }
.table th[aria-sort="descending"]::after { content: " ↓"; }
.cell-main { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.job-no { font-family: var(--f-code); font-weight: 500; font-size: 13px; color: var(--irm); white-space: nowrap; }
.table-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line-soft); color: var(--ink-3); font-size: 13px; }
.table-foot .grow { flex: 1; }

.bar { display: block; height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar-fill { display: block; height: 100%; background: var(--irm-mid); border-radius: 3px; width: 0; }
.bar-cell { display: flex; align-items: center; gap: 10px; }
.bar-cell .bar { flex: 1; }

/* =====================================================================
   Badges, avatars
   ===================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--st-draft-bg); color: var(--st-draft);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-plain::before { display: none; }
.st-draft { background: var(--st-draft-bg); color: var(--st-draft); }
.st-getting_offers { background: var(--st-getting-bg); color: var(--st-getting); }
.st-awaiting_results { background: var(--st-awaiting-bg); color: var(--st-awaiting); }
.st-won { background: var(--st-won-bg); color: var(--st-won); }
.st-lost { background: var(--st-lost-bg); color: var(--st-lost); }
.st-valued { background: var(--st-valued-bg); color: var(--st-valued); }
.st-internal { background: var(--st-internal-bg); color: var(--st-internal); }
.tag { display: inline-block; padding: 1px 7px; border: 1px solid var(--line); border-radius: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); background: var(--surface); }
.tag.region-US   { background: #EAEAFB; color: #4338A6; border-color: transparent; }
.tag.region-EMEA { background: #E1F3EF; color: #0D7A66; border-color: transparent; }
.tag.region-APAC { background: #F1E9FA; color: #6B3FA0; border-color: transparent; }
.tag.region-AUS  { background: #FBEAE3; color: #A0522D; border-color: transparent; }
.due { font-size: 12.5px; font-weight: 500; }
.due-danger { color: var(--danger); }
.due-warn { color: var(--warn); }
.due-muted { color: var(--ink-3); font-weight: 400; }
.role-badge { display: inline-block; padding: 2px 9px; border-radius: 5px; font-size: 12px; font-weight: 500; background: var(--line-soft); color: var(--ink-2); }
.role-admin { background: #E5ECF6; color: var(--irm); }
.role-super_editor { background: #E4F3FB; color: #0F5E86; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex-shrink: 0;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: #fff; background: var(--irm);
}
.av-0 { background: #13487D; } .av-1 { background: #1C75BC; } .av-2 { background: #2E7D6B; }
.av-3 { background: #7A5B9C; } .av-4 { background: #A2623A; } .av-5 { background: #3E5A74; }
.avatars { display: inline-flex; }
.avatars .avatar { width: 26px; height: 26px; font-size: 10px; border: 2px solid var(--surface); margin-left: -7px; }
.avatars .avatar:first-child { margin-left: 0; }
.avatars .more { background: var(--line); color: var(--ink-2); }
.unassigned { font-size: 12.5px; color: var(--warn); }

/* =====================================================================
   Job detail
   ===================================================================== */
.job-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 20px; }
.job-head .grow { flex: 1; min-width: 280px; }
.job-id { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.job-id .job-no { font-size: 15px; }
.job-title { font-size: 25px; line-height: 1.25; }

/* The pipeline: the one bold element on this screen */
.pipeline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.stage {
  position: relative; padding: 15px 18px 15px 44px; border: 0; background: transparent; text-align: left;
  color: var(--ink-3); font-weight: 500; display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.stage + .stage { border-left: 1px solid var(--line-soft); }
.stage::before {
  content: ""; position: absolute; left: 17px; top: 19px; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #C3CDD8; background: var(--surface);
}
.stage-name { font-family: var(--f-display); font-size: 15px; font-weight: 600; color: var(--ink-3); }
.stage-note { font-size: 12.5px; font-weight: 400; color: var(--ink-4); }
.stage.is-done::before { background: var(--irm-mid); border-color: var(--irm-mid); }
.stage.is-done .stage-name { color: var(--ink-2); }
.stage.is-current { background: var(--navy-900); }
.stage.is-current::before { border-color: var(--sky); background: var(--sky); box-shadow: 0 0 0 4px rgba(109, 207, 246, .22); }
.stage.is-current .stage-name { color: #fff; }
.stage.is-current .stage-note { color: #9FB6D0; }
.stage.is-won.is-current { background: #0F4D2D; }
.stage.is-lost.is-current { background: #6E1D17; }
.stage.is-won.is-current::before { border-color: #7FE0A6; background: #7FE0A6; box-shadow: 0 0 0 4px rgba(127,224,166,.22); }
.stage.is-lost.is-current::before { border-color: #F5A39C; background: #F5A39C; box-shadow: 0 0 0 4px rgba(245,163,156,.22); }
.stage.is-valued.is-current { background: #3E2A78; }
.stage.is-valued.is-current::before { border-color: #C9B8F5; background: #C9B8F5; box-shadow: 0 0 0 4px rgba(201,184,245,.22); }
button.stage { cursor: pointer; font: inherit; }
button.stage:hover:not(.is-current) { background: var(--surface-2); }
button.stage:hover:not(.is-current) .stage-name { color: var(--ink); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.facts { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 10px 12px; font-size: 13.5px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
.people { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line-soft); }
.people-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.people-list { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.person { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; }
.li-more .facts { margin-top: 8px; }
.notes { white-space: pre-wrap; color: var(--ink-2); font-size: 13.5px; }

.banner { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-radius: var(--r); margin-bottom: 18px; flex-wrap: wrap; }
.banner svg { width: 18px; height: 18px; flex-shrink: 0; }
.banner .grow { flex: 1; min-width: 200px; }
.banner-info { background: #E9F2FB; color: #164A7A; }
.banner-won { background: var(--st-won-bg); color: var(--st-won); }
.banner-lost { background: var(--st-lost-bg); color: var(--st-lost); }
.banner-valued { background: var(--st-valued-bg); color: var(--st-valued); }
.banner-internal { background: var(--st-internal-bg); color: var(--st-internal); }
.stage.is-internal.is-current { background: #164F46; }
.banner-warn { background: var(--warn-bg); color: var(--warn); }
.banner-orange { background: #FDE9DA; color: #9A3E0C; }
.banner a:not(.btn) { color: inherit; font-weight: 600; text-decoration: underline; }

.offer-price { font-family: var(--f-display); font-weight: 600; font-size: 15px; }
.offer-row.is-winner td { background: #F1FAF4; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.pill-top { background: #E4EFFB; color: var(--st-getting); }
.pill-ok { background: var(--st-won-bg); color: var(--st-won); }
.pill-match { background: var(--warn-bg); color: var(--warn); }
.pill-count { background: var(--warn-bg); color: var(--warn); margin-top: 3px; }
.pill-win { background: var(--st-won-bg); color: var(--st-won); }
.pill-valued { background: var(--st-valued-bg); color: var(--st-valued); }
.offer-summary { display: flex; gap: 22px; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2); font-size: 13px; color: var(--ink-3); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.offer-summary strong { color: var(--ink); font-weight: 600; }
.add-offer { padding: 16px 20px; border-top: 1px solid var(--line-soft); }
.add-offer > .field { margin-bottom: 12px; }
.add-offer-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr) minmax(0, .8fr) minmax(0, .8fr); gap: 12px; align-items: end; }
.hint-inline { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.add-offer .form-error { margin: 4px 0 0; }

.file-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 4px 9px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--ink-2); text-decoration: none;
}
.file-chip svg { width: 13px; height: 13px; flex-shrink: 0; color: var(--ink-5); }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.file-chip:hover { border-color: var(--irm-mid); color: var(--irm); text-decoration: none; }
.file-row { display: flex; align-items: center; gap: 8px; }
.file-row .file-chip { flex: 1; min-width: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: #B7C3D0; }
.timeline li::after { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 1px; background: var(--line-soft); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--ink-4); font-size: 12px; }

/* =====================================================================
   Stats
   ===================================================================== */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px var(--f-body); fill: var(--ink-3); }
.chart .grid { stroke: var(--line-soft); }
.chart .b-jobs { fill: #C9DBEE; }
.chart .b-won { fill: var(--irm); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .l-jobs { background: #C9DBEE; } .legend .l-won { background: var(--irm); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.reason-list { display: flex; flex-direction: column; gap: 12px; }
.reason-list .row { display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 4px 10px; font-size: 13px; }
.reason-list .row .bar { grid-column: 1 / -1; }

/* =====================================================================
   Search
   ===================================================================== */
.search-hero { display: flex; gap: 10px; margin-bottom: 8px; }
.search-hero .search-box { max-width: none; }
.search-hero .input { height: 48px; font-size: 16px; }
.search-hero .search-box svg { width: 19px; height: 19px; left: 14px; }
.search-hero .search-box .input { padding-left: 42px; }
.result { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.result:last-child { border-bottom: 0; }
.result-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.result-lines { display: flex; flex-direction: column; gap: 4px; }
.result-line {
  font-size: 13px; padding: 6px 10px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2);
  overflow-wrap: anywhere;
}
mark { background: #FFE9A8; color: var(--ink); border-radius: 2px; padding: 0 1px; }

/* =====================================================================
   Inbox
   ===================================================================== */
.inbox-item { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.inbox-item:last-child { border-bottom: 0; }
.inbox-meta { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.inbox-subject { font-weight: 500; margin-top: 2px; overflow-wrap: anywhere; }
.inbox-jobs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.inbox-jobs .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.inbox-reason { margin-top: 8px; font-size: 13px; padding: 8px 11px; border-radius: 7px; background: var(--warn-bg); color: var(--warn); }
.inbox-reason.is-ok { background: #EEF6F1; color: var(--ok); }
.inbox-reason.is-bad { background: var(--danger-bg); color: var(--danger); }
.inbox-parsed { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--ink-2); }
.inbox-parsed b { font-weight: 500; color: var(--ink-3); margin-right: 5px; }
.inbox-actions { display: flex; gap: 8px; align-items: flex-start; }
.mailbox-line { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); display: inline-block; }
.dot-ok { background: #2DA160; } .dot-bad { background: var(--danger); }

/* =====================================================================
   Help / code blocks
   ===================================================================== */
.howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.codebox { position: relative; margin-top: 12px; border-radius: var(--r); background: var(--navy-900); color: #DCE7F3; padding: 14px 16px; font-family: var(--f-code); font-size: 12.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.codebox .k { color: var(--sky); }
.codebox .c { color: #7F97B3; }
.codebox .icon-btn { position: absolute; top: 8px; right: 8px; color: #8FA6C2; }
.codebox .icon-btn:hover { background: var(--navy-800); color: #fff; }
.steps { margin: 12px 0 0; padding-left: 20px; color: var(--ink-2); }
.steps li + li { margin-top: 6px; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.yes { color: var(--ok); font-weight: 600; }
.no { color: var(--ink-4); }
.kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; font: 500 12px var(--f-code); text-align: center; background: var(--surface); }

/* =====================================================================
   Empty / error / skeleton
   ===================================================================== */
.empty { padding: 48px 24px; text-align: center; color: var(--ink-3); }
.empty h2 { margin-bottom: 6px; color: var(--ink); }
.empty p { max-width: 420px; margin: 0 auto 16px; }
.empty svg { width: 30px; height: 30px; color: var(--ink-5); margin-bottom: 10px; }
.error-state { padding: 40px 24px; text-align: center; }
.error-state p { color: var(--danger); margin-bottom: 14px; }
.skeleton { display: block; height: 14px; border-radius: 4px; background: var(--line-soft); animation: pulse 1.1s ease-in-out infinite alternate; }
.skeleton + .skeleton { margin-top: 12px; }
.skel-block { padding: 22px; }
@keyframes pulse { from { opacity: 1; } to { opacity: .45; } }

/* =====================================================================
   Dialog + toasts
   ===================================================================== */
dialog.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0;
  border-radius: var(--r-lg); box-shadow: var(--shadow-float); color: var(--ink); overflow: visible;
}
dialog.dialog-wide { width: min(720px, calc(100vw - 32px)); }
dialog.dialog::backdrop { background: rgba(8, 30, 54, .45); }
dialog.dialog[open] { animation: pop .12s ease-out; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }

/* While fresh data loads, keep the current content visible but dimmed,
   instead of blanking the page to a loading screen. Feels much faster. */
.is-refreshing { opacity: .55; pointer-events: none; transition: opacity .12s; }

/* Shown if a page fails to load: never a blank screen */
.failure { padding: 28px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--ink-2); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.dialog-head h2 { flex: 1; font-size: 18px; }
.dialog-body { padding: 4px 20px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog-text { color: var(--ink-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.dialog .form-error { margin: 0 20px 14px; }
.secret-box { display: flex; gap: 8px; align-items: center; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px dashed #BFCAD6; }
.secret-box code { flex: 1; font-family: var(--f-code); font-size: 17px; letter-spacing: .04em; overflow-wrap: anywhere; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 380px; padding: 12px 16px; border-radius: var(--r); background: var(--navy-900); color: #fff;
  box-shadow: var(--shadow-float); font-size: 13.5px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: #7A1B14; }
.toast-success { background: #0F4D2D; }

/* =====================================================================
   Login
   ===================================================================== */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.login-art {
  position: relative; overflow: hidden; background: var(--navy-900); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; padding: 44px 52px;
}
.login-art::after {
  content: ""; position: absolute; left: -6%; right: -6%; bottom: -2%; height: 62%;
  background: url("/assets/img/mark.svg") no-repeat center bottom / contain; opacity: .95; pointer-events: none;
}
.login-brand { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; margin-top: 10%; }
.login-brand img { width: 52px; }
.login-brand strong { font-family: var(--f-display); font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; max-width: 360px; }
.login-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.login-form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 24px; }
.login-form .btn { height: 44px; }
.login-form .form-error { margin: 0; }
.login-foot { font-size: 12.5px; color: var(--ink-3); }

/* =====================================================================
   Responsive
   ===================================================================== */
/* iPad landscape and smaller: the job page is one column (offers first, details below). */
@media (max-width: 1280px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .add-offer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; height: 100vh; height: 100dvh; width: min(280px, 84vw); transform: translateX(-102%);
    transition: transform .2s ease; box-shadow: var(--shadow-float);
  }
  .shell.nav-open .sidebar { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(8,30,54,.4); z-index: 25; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    height: 56px; padding: 0 12px; background: var(--navy-900); color: #fff;
  }
  .topbar .icon-btn { color: #fff; }
  .topbar .icon-btn:hover { background: var(--navy-800); }
  .topbar img { width: 26px; }
  .topbar strong { font-family: var(--f-display); font-weight: 600; }
  .view { padding: 20px 16px 48px; }
  h1 { font-size: 22px; }
  .job-title { font-size: 21px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .pipeline { grid-template-columns: minmax(0, 1fr); }
  .stage + .stage { border-left: 0; border-top: 1px solid var(--line-soft); }
  .login { grid-template-columns: minmax(0, 1fr); }
  .login-art { min-height: 220px; padding: 28px 24px; }
  .login-brand { margin-top: 0; }
  .login-brand img { width: 40px; }
  .login-brand strong { font-size: 21px; }
  .login-art::after { height: 55%; opacity: .5; }

  /* Tables become stacked rows on phones */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
  .table-stack td { padding: 3px 0 !important; border: 0; }
  .table-stack td[data-label]::before { content: attr(data-label) " "; color: var(--ink-4); font-size: 12px; }
  .table-stack .num { text-align: left; }
  .table-stack .hide-sm { display: none; }
  .inbox-item { grid-template-columns: minmax(0, 1fr); }
  .inbox-item > .avatar { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

/* Standalone toolbar (statistics filters) */
.toolbar.panel { margin-bottom: 18px; border-bottom: 1px solid var(--line); }

/* =====================================================================
   Jobs page
   ===================================================================== */
.kpis-compact .kpi { padding: 13px 18px; }
.kpis-compact .kpi-value { font-size: 22px; }
.kpis-compact .kpi-label { font-size: 12.5px; margin-top: 1px; }

.jobs-toolbar { gap: 12px; }
.jobs-toolbar .search-box { flex: 1; max-width: none; min-width: 200px; }
.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--irm); color: #fff;
  font-size: 11px; font-weight: 600; display: inline-grid; place-items: center;
}

.filter-panel {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 22px;
  padding: 16px 18px; background: var(--surface-2); border-bottom: 1px solid var(--line-soft);
}
.filter-panel .field { min-width: 170px; }
.filter-panel .seg button { height: 30px; padding: 0 12px; }
.seg .region-opt[aria-pressed="true"].region-US   { color: #4338A6; }
.seg .region-opt[aria-pressed="true"].region-EMEA { color: #0D7A66; }
.seg .region-opt[aria-pressed="true"].region-APAC { color: #6B3FA0; }
.seg .region-opt[aria-pressed="true"].region-AUS  { color: #A0522D; }

.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--line-soft); }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px 0 12px; border: 0; border-radius: 14px;
  background: #EAF3FC; color: var(--irm); font-size: 13px; font-weight: 500; cursor: pointer;
}
.filter-chip svg { width: 13px; height: 13px; opacity: .7; }
.filter-chip:hover { background: #DCEBFA; }
.filter-chip:hover svg { opacity: 1; }
.link-btn { border: 0; background: none; padding: 4px 6px; color: var(--irm-mid); font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

.jobs-table td { padding-top: 15px; padding-bottom: 15px; }
.job-cell .job-no { display: inline-block; font-size: 12px; margin-bottom: 3px; }
.job-subject { font-weight: 500; color: var(--ink); max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vendor-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-cell { width: 1%; white-space: nowrap; }

/* ⋯ menu */
.menu-wrap { position: relative; }
.btn.icon-only { width: 38px; padding: 0; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-float);
}
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 6px;
  background: none; color: var(--ink); font-weight: 500; text-align: left; cursor: pointer; text-decoration: none;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu svg { width: 16px; height: 16px; color: var(--ink-3); }

@media (max-width: 900px) {
  .jobs-toolbar .seg { width: 100%; }
  .jobs-toolbar .seg button { flex: 1; justify-content: center; }
  .job-subject { white-space: normal; max-width: none; }
  .filter-panel .field { min-width: 0; flex: 1 1 100%; }
}

/* Help page step numbers */
.step-no { font-size: 12px; font-weight: 600; color: var(--irm-mid); margin-bottom: 4px; }
.howto > .panel { margin-top: 0; }
.howto .codebox { padding-right: 44px; }
.howto-sub { font-size: 13.5px; font-weight: 600; margin: 18px 0 0; }
.howto-sub + .codebox { margin-top: 8px; }


/* =====================================================================
   Touch screens (iPad, phones): finger-sized targets, ~40-44 px.
   Mouse users keep the compact sizes above.
   ===================================================================== */
@media (pointer: coarse) {
  .btn { height: 44px; }
  .btn-sm { height: 38px; padding: 0 13px; }
  .icon-btn { width: 40px; height: 40px; }
  .chip { height: 38px; }
  .seg button, .seg label span { height: 38px; }
  .filter-panel .seg button { height: 36px; }
  .filter-chip { height: 34px; }
  .input, .select { height: 44px; font-size: 16px; } /* 16px stops iOS zooming into fields */
  .input-sm, .select-sm { height: 40px; font-size: 16px; }
  .textarea { font-size: 16px; }
  .nav a { padding: 11px 10px; }
  .menu a, .menu button { padding: 12px 10px; }
  .table td { padding-top: 14px; padding-bottom: 14px; }
}


/* =====================================================================
   Job categories: solid pills, white text (all >= 5:1 contrast)
   ===================================================================== */
.cat {
  display: inline-block; padding: 2px 9px; border-radius: 11px; color: #fff;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap; vertical-align: middle;
}
.cat-blue { background: #1F5FB0; }   .cat-green { background: #1E7A45; }
.cat-orange { background: #B25409; } .cat-red { background: #B42318; }
.cat-purple { background: #6D3FB0; } .cat-teal { background: #0E7470; }
.cat-pink { background: #AE2E6B; }   .cat-slate { background: #4A5A6E; }
.poc-line { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 3px; }
.poc-line .cell-sub { margin-top: 0; }

/* color picker in the category dialog */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch span { display: block; width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); }
.swatch input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.swatch input:focus-visible + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--irm-mid); }

/* =====================================================================
   Buyers (ERM)
   ===================================================================== */
/* Buyer sourcing regions: same hues as the old ERM, all >= 4.8:1 contrast */
.tag.br-NA   { background: #E3EEFB; color: #1A5CB5; border-color: transparent; }
.tag.br-EU   { background: #E0F2FE; color: #0369A1; border-color: transparent; }
.tag.br-MENA { background: #DDF4F0; color: #0F766E; border-color: transparent; }
.tag.br-APAC { background: #EEE8FC; color: #6D28D9; border-color: transparent; }
.tag.br-AUS  { background: #FCE7F1; color: #BE185D; border-color: transparent; }
.seg .br-text-NA[aria-pressed="true"]   { color: #1A5CB5; }
.seg .br-text-EU[aria-pressed="true"]   { color: #0369A1; }
.seg .br-text-MENA[aria-pressed="true"] { color: #0F766E; }
.seg .br-text-APAC[aria-pressed="true"] { color: #6D28D9; }
.seg .br-text-AUS[aria-pressed="true"]  { color: #BE185D; }

.tag-row { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.pchip {
  display: inline-block; padding: 2px 8px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; text-decoration: none;
}
a.pchip:hover { border-color: var(--irm-mid); color: var(--irm); text-decoration: none; }
.pchip-more { background: transparent; color: var(--ink-3); }
.prewrap { white-space: pre-wrap; }

.buyers-toolbar { gap: 10px; }
.buyers-toolbar .search-box { flex: 1; max-width: none; min-width: 220px; }
.buyers-table td { padding-top: 13px; padding-bottom: 13px; }

/* checkbox chips (regions, products, owners) */
.chip-check { cursor: pointer; gap: 6px; }
.chip-check input { margin: 0; accent-color: var(--irm); }
.chip-check:has(input:checked) { background: #EAF3FC; border-color: var(--irm-mid); color: var(--irm); }

.product-picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; margin-top: 8px; background: var(--surface); }
.pp-group + .pp-group { margin-top: 12px; }
.pp-title { font-size: 12px; font-weight: 600; color: var(--ink-3); margin-bottom: 6px; text-transform: none; }

/* Team page: access per product */
.access-grid { align-items: start; }
.access-badges { display: inline-grid; grid-template-columns: auto auto; gap: 4px 8px; align-items: center; }
.role-badge.role-none, .role-badge.role-crm-none { background: var(--surface-2); color: var(--ink-3); }
.role-badge.role-crm-viewer { background: #EEF1F5; color: #44546A; }
.role-badge.role-crm-contributor { background: #E4EFFB; color: #16589A; }
.role-badge.role-crm-manager { background: #E2F4E8; color: #16693A; }

@media (max-width: 900px) {
  .buyers-toolbar .seg { width: 100%; }
  .buyers-toolbar .seg button { flex: 1; justify-content: center; }
  .buyers-toolbar .select { flex: 1 1 45%; }
}

/* Products & categories */
.toolbar-plain { border: 0; padding: 0 0 14px; background: none; }
.toolbar-plain .search-box { max-width: 420px; }
.cat-section { margin-bottom: 14px; }
.cat-section .panel-head h2 .small { font-weight: 400; margin-left: 6px; }
.cat-section .table td { padding-top: 11px; padding-bottom: 11px; }
.email-add { margin-top: 10px; }
.email-add .input { max-width: 300px; }

/* Category chips (what someone covers) */
.cchip {
  display: inline-block; padding: 2px 9px; border-radius: 10px; background: #EAF3FC; color: #16589A;
  font-size: 12px; font-weight: 600; white-space: nowrap; border: 0; text-decoration: none; cursor: default; font-family: inherit;
}
a.cchip, button.cchip { cursor: pointer; }
a.cchip:hover, button.cchip:hover { background: #DCEBFA; text-decoration: none; }

/* Company page: main column + side column */
.company-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.company-main, .company-side { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.company-main .panel, .company-side .panel { margin-bottom: 0; }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-card { padding: 14px 18px; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 8px; }
.contact-card:first-child { border-top: 0; }
.contact-top { display: flex; align-items: center; gap: 12px; }
.contact-covers { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.company-side .pp-group + .pp-group { margin-top: 12px; }
@media (max-width: 1000px) {
  .company-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Buyer tags: ★ preferred and Bidder (on our bid portal) */
.tags-col { width: 1%; white-space: nowrap; }
.buyer-tags { display: inline-flex; align-items: center; gap: 6px; }
.star-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: #7A8899; cursor: pointer;
}
.star-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; }
.star-btn:hover { background: #FBF3E0; color: #C98500; }
.star-btn.is-on { color: #C98500; }
.star-btn.is-on svg { fill: currentColor; }
.star-btn.is-static { cursor: default; }
.star-btn.is-static:hover { background: none; }
.bidder-tag {
  display: inline-block; padding: 2px 9px; border-radius: 10px; background: #E2F4E8; color: #16693A;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
/* quick on/off filters (★ Preferred, Bidders) */
.qf {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 500; font-size: 13px; cursor: pointer;
}
.qf svg { width: 14px; height: 14px; }
.qf[aria-pressed="true"] { background: #EAF3FC; border-color: var(--irm-mid); color: #16589A; }
.qf[aria-pressed="true"] svg { fill: #C98500; stroke: #C98500; }
@media (pointer: coarse) { .star-btn { width: 40px; height: 40px; } .qf { height: 38px; } }

/* Form submissions + connection key */
.form-list { list-style: none; margin: 0; padding: 0; }
.form-card { padding: 14px 18px; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 10px; }
.form-card:first-child { border-top: 0; }
.form-top { display: flex; align-items: flex-start; gap: 12px; }
.form-details { display: flex; flex-direction: column; gap: 8px; }
.key-box { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); word-break: break-all; margin: 8px 0; }
.match-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin: 4px 0 2px; font-size: 12.5px; color: var(--ink-2); }
@media (min-width: 761px) { .offer-row > td:first-child { min-width: 220px; } }
.cell-sub.is-warn { color: var(--warn); }
.pill-take { background: #EFE7FB; color: #5B3A9A; }
.pill-lip { background: #E6F4EA; color: #1E6B3A; }
.kind-slot:empty { display: none; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }

/* Line items summary (job page) */
.li-box { margin: 0 20px 16px; padding: 14px 16px; border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--surface-2); transition: opacity .15s; }
.li-box.is-refreshing { opacity: .6; }
.li-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.li-head h3 { margin: 0; font-size: 15px; }
.li-note { margin: 4px 0 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.li-note svg { width: 16px; height: 16px; }
.li-note > .grow { flex: 1; min-width: 0; }
.li-note a { color: inherit; font-weight: 600; text-decoration: underline; }
.li-note.is-warn, .li-notes .is-warn { color: var(--warn); }
.li-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.li-cards-one { grid-template-columns: minmax(0, 1fr); }
.li-card { background: var(--surface, #fff); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 12px 14px; }
.li-act { margin-top: 10px; }
.li-award { display: flex; gap: 10px; align-items: flex-start; background: var(--st-won-bg); color: var(--st-won); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; font-size: 13.5px; }
.li-award svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.li-award .li-sub { color: inherit; opacity: .85; margin-top: 2px; }
.li-card.is-best { border-color: var(--st-won); box-shadow: inset 3px 0 0 var(--st-won); }
.li-label { font-size: 12.5px; color: var(--ink-3); }
.li-value { font-family: var(--f-display); font-size: 22px; font-weight: 600; letter-spacing: -.02em; margin: 2px 0; }
.li-sub { font-size: 12.5px; color: var(--ink-3); }
.li-outcome { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 0; font-size: 13.5px; }
.li-outcome svg { width: 16px; height: 16px; color: var(--st-won); flex-shrink: 0; margin-top: 2px; }
.li-notes { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-3); }
.li-notes li { margin: 2px 0; }
.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
@media (max-width: 760px) { .li-box { margin: 0 12px 14px; } .li-cards { grid-template-columns: 1fr; } }
/* Currency + line prices */
.pill-eur { background: #E8F0FE; color: #1E4FA8; }
.price-cur { display: flex; gap: 6px; }
.price-cur .input { flex: 1; min-width: 0; }
.price-cur .select { width: auto; flex: 0 0 auto; }
.lp-pending { display: grid; gap: 10px; margin-bottom: 14px; }
.lp-item { border: 1px solid var(--warn); background: var(--warn-bg); border-radius: var(--r); padding: 10px 12px; display: grid; gap: 6px; font-size: 13px; }
.lp-cands { display: grid; gap: 4px; max-height: 180px; overflow: auto; }
.lp-table { max-height: 55vh; overflow: auto; }
.lp-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.lp-input { width: 110px; text-align: right; }
.lp-table .li-desc { max-width: 260px; }
.show-md { display: none; }
@media (max-width: 1500px) { .table .hide-md { display: none; } .table .show-md { display: block; } }
.offer-btns { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
@media (max-width: 640px) {
  .lp-table .li-desc { max-width: none; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
  .lp-input { width: 86px; }
  .offer-btns { flex-direction: row; align-items: center; justify-content: flex-start; }
}
.li-desc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Split award window */
.aw-totals { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.aw-totals td { padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.aw-totals td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.aw-totals tr.is-total td { font-weight: 600; border-bottom: 0; }
.aw-totals .is-up { color: var(--st-won); } .aw-totals .is-down { color: var(--st-lost); }
.aw-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.aw-tools .input { flex: 1; min-width: 160px; }
.aw-list { max-height: 42vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
.aw-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 46%); gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.aw-row:last-child { border-bottom: 0; }
.aw-row.is-changed { background: var(--warn-bg); }
.aw-line { min-width: 0; }
.aw-line .li-desc { max-width: none; }
.aw-row .select { width: 100%; }
.aw-more { padding: 8px 10px; font-size: 12px; color: var(--ink-5); }
@media (max-width: 640px) { .aw-row { grid-template-columns: 1fr; gap: 6px; } }
/* Status tabs on a phone: one row, five equal tabs */
@media (max-width: 480px) {
  .toolbar > .seg[aria-label="Status"] { display: grid; grid-template-columns: repeat(5, auto); width: 100%; flex-wrap: nowrap; }
  .toolbar > .seg[aria-label="Status"] button { padding: 0 6px; font-size: 13px; justify-content: center; }
}

/* How sheets are read (AI / corrected / automatic) */
.pill-ai { background: #E8E4FB; color: #4B32A8; }
.pill-auto { background: var(--line-soft); color: var(--ink-3); }
.li-reading { margin-top: 10px; font-size: 13px; }
/* Collapsible "More details" blocks: the specifics most people don't need every time. */
.li-more { margin-top: 10px; font-size: 13px; }
.li-more > summary { cursor: pointer; color: var(--ink-3); font-weight: 500; list-style: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; min-height: 32px; }
.li-more > summary::-webkit-details-marker { display: none; }
.li-more > summary::before { content: ''; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.li-more[open] > summary::before { transform: rotate(45deg); }
.li-more > summary:hover { color: var(--ink); }
.li-more > .actions, .li-more > .cell-sub { margin-top: 6px; }
.li-reading ul { margin: 8px 0 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.li-reading li { line-height: 1.5; }
.li-reading .cell-sub { display: block; }
.rfq-reading { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r); font-size: 13px; display: grid; gap: 6px; }
.lf-tab { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 12px; margin: 0 0 12px; min-width: 0; }
.lf-tab legend { padding: 0 6px; }
.lf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 12px; margin-bottom: 8px; }
.lf-grid .field { margin: 0; }
.lf-grid label { font-size: 12px; }
.lf-others { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; }
.lf-preview { max-height: 220px; overflow: auto; margin-top: 8px; border: 1px solid var(--line-soft); border-radius: var(--r); }
.lf-preview table { font-size: 11.5px; }
.lf-preview td, .lf-preview th { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; padding: 4px 8px; }
.pill-fixed { background: #DFF3F1; color: #13665E; }

/* Offers table: always fits its panel, so the row buttons (Mark winner, edit, delete) never
   end up out of view. Long names and file names wrap or get cut with an ellipsis. */
.offers-wrap { container-type: inline-size; }
.offers-table { table-layout: fixed; width: 100%; }
.offers-table .oc-price { width: 17%; }
.offers-table .oc-date { width: 13%; }
.offers-table .oc-files { width: 28%; }
.offers-table .oc-act { width: 140px; }
.offers-table td { overflow-wrap: anywhere; }
.offers-table td[data-label="Files"] { overflow: hidden; }
.offers-table .file-row { max-width: 100%; }
.offers-table .file-chip { max-width: 100%; }
.offers-table .offer-price { white-space: nowrap; }
@container (max-width: 640px) {
  .offers-table .oc-act { width: 64px; }
  .offers-table .oc-lbl { display: none; }
  .offers-table .oc-files { width: 32%; }
}
@media (max-width: 640px) {
  .offers-table { table-layout: auto; }
  .offers-table .oc-lbl { display: inline; }
}
.ai-spend { margin: 6px 0 0; }

/* Line items of an offer (check / correct against their sheet) */
.lp-list { display: grid; gap: 2px; }
.lp-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 110px 116px 34px; gap: 8px; align-items: center; padding: 8px 6px; border-radius: var(--r-sm); }
.lp-row + .lp-row { border-top: 1px solid var(--line-soft); }
.lp-head { font-size: 12px; color: var(--ink-3); font-weight: 600; padding-top: 0; }
.lp-row.is-edited { background: var(--surface-2); }
.lp-row.is-changed { background: var(--warn-bg); }
.lp-line { min-width: 0; font-size: 13px; }
.lp-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lp-cell { display: block; margin: 0; }
.lp-cell .input { width: 100%; text-align: right; }
.lp-cell .input[readonly] { background: var(--surface-2); color: var(--ink-3); }
.lp-lbl { display: none; }
.lp-sum { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 12px; margin: 4px 0 10px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 13px; position: sticky; top: 0; z-index: 1; }
.lp-sum b { font-weight: 600; color: var(--ink-3); margin-right: 4px; }
.lp-ok { color: var(--ok); }
.lp-bad { color: var(--warn); }
.lp-tools { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; }
.lp-tools .input { max-width: 260px; }
@media (max-width: 640px) {
  .lp-head { display: none; }
  .lp-row { grid-template-columns: repeat(3, minmax(0, 1fr)) 34px; }
  .lp-line { grid-column: 1 / -1; }
  .lp-lbl { display: block; font-size: 11.5px; color: var(--ink-3); margin-bottom: 2px; }
  .lp-reset { align-self: end; }
}

/* Job page: small info buttons (hover on desktop, tap on phone), to-do banner, header menu */
.tip { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; padding: 0; margin-left: 2px; border: 0; background: none; color: var(--ink-4); border-radius: 50%; cursor: help; vertical-align: middle; }
.tip svg { width: 15px; height: 15px; }
.tip:hover, .tip:focus-visible { color: var(--irm-mid); background: var(--surface-2); }
@media (pointer: coarse) { .tip { width: 30px; height: 30px; } }
.banner.todo ul { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 2px; }
.banner.todo li { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.banner.todo .tip { color: inherit; opacity: .75; }
.menu-danger { color: var(--danger) !important; }
.menu-danger svg { color: var(--danger) !important; }
.job-head .menu { right: 0; left: auto; min-width: 210px; }
.details-sum { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
/* Add offer: price per line */
.add-lines { margin: 4px 0 12px; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--surface); }
.add-lines-list { max-height: 420px; overflow-y: auto; }
.add-find { max-width: 320px; margin-bottom: 8px; }
.lp-qty { display: block; text-align: right; padding-right: 10px; color: var(--ink-3); font-size: 13px; }
.lp-total-chip { display: inline-flex; align-items: center; padding: 0 12px; min-height: 40px; border-radius: var(--r-sm); background: var(--surface-2); font-weight: 600; font-size: 14px; white-space: nowrap; flex: 1; }

/* Phones: the job's progress as one compact row (current stage name, no notes) */
@media (max-width: 640px) {
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; margin-bottom: 16px; }
  .stage + .stage { border-left: 1px solid var(--line-soft) !important; border-top: 0 !important; }
  .stage { padding: 10px 10px 10px 30px !important; min-height: 0; }
  .stage::before { left: 10px !important; top: 12px !important; width: 12px; height: 12px; }
  .stage-name { font-size: 12.5px; line-height: 1.25; }
  .stage-note { display: none; }
}

/* Jobs list on tablets and phones: each job as a compact card (job on top, then vendor / due /
   offers / status side by side) instead of one tall column. */
@media (max-width: 900px) {
  .jobs-table.table-stack tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px 16px; align-items: start; }
  .jobs-table.table-stack td:first-child { grid-column: 1 / -1; }
  .jobs-table.table-stack td { width: auto; }
  .jobs-table.table-stack td[data-label]::before { display: block; }
}
@media (max-width: 560px) {
  .jobs-table.table-stack tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Home figures: even rows (3 + 3 on tablets, 2 per row on phones) */
@media (max-width: 1100px) {
  .kpis-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis-compact .kpi { border-left: 0; box-shadow: inset -1px -1px 0 var(--line-soft); }
}
@media (max-width: 560px) { .kpis-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
