/* Contract Radar dashboard. Mobile first; tables turn into cards below 760px. */
:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #52606d;
  --faint: #7b8794;
  --border: #e4e7eb;
  --line: #eef1f4;
  --brand: #12324f;
  --brand-text: #ffffff;
  --primary: #12324f;
  --link: #0b4f8a;
  --accent: #1d6fb8;
  --urgent: #b42318;
  --urgent-bg: #fdecea;
  --warn: #8a5a00;
  --warn-bg: #fff8e6;
  --ok: #1e7b4b;
  --ok-bg: #e6f4ec;
  --chip-bg: #e9eef4;
  --bid: #12324f;
  --bid-bg: #e6edf5;
  --respond: #1e6b52;
  --respond-bg: #e3f2ec;
  --prepare: #5b4a8a;
  --prepare-bg: #efebf8;
  --focus: #1d6fb8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1720;
    --card: #17212b;
    --text: #e6eaef;
    --muted: #a7b2bd;
    --faint: #7f8b97;
    --border: #283543;
    --line: #22303d;
    --brand: #0c2236;
    --primary: #2f78c4;
    --link: #7cb7f0;
    --accent: #5aa3e8;
    --urgent: #ff8a80;
    --urgent-bg: #3a1c1c;
    --warn: #f0c36a;
    --warn-bg: #352a12;
    --ok: #6fd3a0;
    --ok-bg: #12301f;
    --chip-bg: #22303d;
    --bid: #7cb7f0;
    --bid-bg: #16283a;
    --respond: #6fd3a0;
    --respond-bg: #12301f;
    --prepare: #b9a7f0;
    --prepare-bg: #241d3a;
    --focus: #7cb7f0;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
}
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--brand); color: var(--brand-text);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand img { width: 22px; height: 22px; }
.lastrun { flex: 1; min-width: 0; font-size: 13px; opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lastrun .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #6fd3a0; vertical-align: 1px; }
.lastrun.bad .dot { background: #ff8a80; }
.lastrun.partial .dot { background: #f0c36a; }
.topbar .btn-ghost { color: var(--brand-text); border-color: rgba(255, 255, 255, 0.35); }

main { max-width: 1280px; margin: 0 auto; padding: 16px; }

/* ---------- buttons & inputs ---------- */
.btn, .btn-ghost, .btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-ghost { background: transparent; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #ffffff; }
.btn:disabled, .btn-primary:disabled { opacity: 0.55; cursor: default; }
input[type='search'], input[type='email'], input[type='password'], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
}
select { padding-right: 28px; }
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }

/* ---------- summary tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 12px 14px 12px 18px; text-align: left; overflow: hidden;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer;
}
.tile::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--faint); }
.tile.act-bid::before { background: var(--bid); }
.tile.act-respond::before { background: var(--respond); }
.tile.act-prepare::before { background: var(--prepare); }
.tile.urgent::before { background: var(--urgent); }
.tile .n { font-size: 28px; font-weight: 750; line-height: 1.1; }
.tile .l { font-size: 14px; font-weight: 700; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile.urgent .n { color: var(--urgent); }
.tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tab {
  padding: 10px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--muted); font-weight: 600; cursor: pointer;
}
.tab[aria-selected='true'] { color: var(--text); border-bottom-color: var(--accent); }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--chip-bg); font-size: 12px; text-align: center; }
.tab-count:empty { display: none; }

/* ---------- next-step segments ---------- */
.segments { display: flex; gap: 6px; margin: 0 0 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.seg { flex: none; min-height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 650; color: var(--muted); cursor: pointer; }
.seg[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--card); }
.seg.act-bid[aria-pressed='true'] { background: var(--bid); border-color: var(--bid); color: #fff; }
.seg.act-respond[aria-pressed='true'] { background: var(--respond); border-color: var(--respond); color: #fff; }
.seg.act-prepare[aria-pressed='true'] { background: var(--prepare); border-color: var(--prepare); color: #fff; }

/* ---------- filters ---------- */
.filters { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.filters-top { display: flex; gap: 8px; }
.filters-top input[type='search'] { flex: 1; }
.filters-toggle { flex: none; }
.filters-more { display: none; margin-top: 10px; }
.filters.open .filters-more { display: block; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filter-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-top: 10px; }
.filter-checks .spacer { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--chip-bg);
  font-size: 13px; font-weight: 600;
}
.chip button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; }

.resultbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 2px 8px; font-size: 13px; color: var(--muted); }

/* ---------- opportunity cards ---------- */
.cards { display: grid; gap: 10px; }
.card {
  position: relative; display: grid; gap: 6px;
  padding: 14px 16px 12px 20px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer;
}
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; border-radius: var(--radius) 0 0 var(--radius); background: var(--faint); }
.card.act-bid::before { background: var(--bid); }
.card.act-respond::before { background: var(--respond); }
.card.act-prepare::before { background: var(--prepare); }
.card:hover { border-color: var(--accent); }
.card.st-passed { opacity: 0.6; }
.card-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.card-title { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 650; overflow-wrap: anywhere; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-fit { font-size: 13px; color: var(--muted); }
.card-fit strong { color: var(--text); font-weight: 650; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 4px; }
.sam-link { margin-left: auto; font-size: 13px; font-weight: 600; text-decoration: none; }
.badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--chip-bg); color: var(--muted); white-space: nowrap; }
.badge.upd { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--urgent-bg); color: var(--urgent); }
.act-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.act-chip.act-bid { background: var(--bid-bg); color: var(--bid); }
.act-chip.act-respond { background: var(--respond-bg); color: var(--respond); }
.act-chip.act-prepare { background: var(--prepare-bg); color: var(--prepare); }
.due { font-size: 13px; color: var(--muted); white-space: nowrap; }
.due strong { color: var(--text); }
.due.soon, .due.soon strong { color: var(--urgent); }
.due.past, .due.past strong { color: var(--faint); }
.decide { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tri { min-height: 34px; padding: 0 14px; border: 0; border-right: 1px solid var(--border); background: var(--card); font-size: 13px; font-weight: 650; color: var(--muted); cursor: pointer; }
.tri:last-child { border-right: 0; }
.tri:hover { background: var(--bg); color: var(--text); }
.tri-bid[aria-pressed='true'] { background: var(--ok); color: #fff; }
.tri-track[aria-pressed='true'] { background: var(--accent); color: #fff; }
.tri-pass[aria-pressed='true'] { background: var(--faint); color: #fff; }
.status-select { width: auto; min-height: 32px; padding: 4px 26px 4px 8px; font-size: 13px; font-weight: 600; }
.status-select.wide { width: 100%; }
.status-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--chip-bg); }
.st-submitted.status-pill, .st-won.status-pill { background: var(--ok-bg); color: var(--ok); }
.st-lost.status-pill { color: var(--faint); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }

/* ---------- pipeline board ---------- */
.board-hint { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 12px; -webkit-overflow-scrolling: touch; }
.col { display: flex; flex-direction: column; min-height: 200px; background: var(--chip-bg); border-radius: var(--radius); padding: 8px; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 8px; font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.col-count { padding: 0 8px; border-radius: 999px; background: var(--card); color: var(--text); }
.col-cards { display: grid; gap: 8px; align-content: start; }
.col-empty { margin: 8px 6px; font-size: 13px; color: var(--faint); }
.bcard { display: grid; gap: 4px; padding: 10px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); cursor: grab; }
.bcard.dragging { opacity: 0.5; }
.bcard-title { font-size: 14px; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
.bcard-meta { font-size: 12px; color: var(--muted); }
.bcard .status-select { margin-top: 4px; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--border); border-radius: var(--radius); }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0 40px; font-size: 14px; color: var(--muted); }

/* ---------- runs ---------- */
.runs { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 13px; }
.runs th, .runs td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.runs th { font-size: 12px; color: var(--muted); font-weight: 700; background: var(--bg); }
.runs td.num, .runs th.num { text-align: right; font-variant-numeric: tabular-nums; }
.runs .err { color: var(--urgent); max-width: 340px; overflow-wrap: anywhere; }
.runs-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.run-status { font-weight: 700; }
.run-status.success { color: var(--ok); }
.run-status.partial { color: var(--warn); }
.run-status.failed { color: var(--urgent); }

/* ---------- detail panel ---------- */
.backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 32, 0.45); }
.panel {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--card); color: var(--text);
}
.panel-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.panel-head h2 { flex: 1; margin: 0; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.close { flex: none; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-size: 20px; line-height: 1; cursor: pointer; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 32px; -webkit-overflow-scrolling: touch; }
.panel .badges { margin: 0 0 10px; }
.panel-due { margin: 0 0 6px; font-size: 15px; }
.panel-due .due { font-size: 15px; }
.panel-due-label { font-weight: 700; }
.panel-due-full { font-size: 12px; color: var(--muted); margin-top: 2px; }
.panel-fit { margin-bottom: 12px; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 16px; }
.facts { display: grid; grid-template-columns: 1fr; gap: 10px 16px; margin: 0 0 16px; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 700; color: var(--muted); }
.facts dd { margin: 1px 0 0; overflow-wrap: anywhere; }
.section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.section h3 { margin: 0 0 8px; font-size: 14px; }
.work { display: grid; gap: 10px; }
.work label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.work-actions { display: flex; align-items: center; gap: 10px; }
.saved { font-size: 13px; color: var(--ok); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { position: relative; padding: 0 0 12px 18px; border-left: 2px solid var(--line); margin-left: 4px; }
.history li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.history li.orig::before { background: var(--faint); }
.history .when { font-size: 12px; color: var(--muted); font-weight: 600; }
.history .what { font-size: 14px; }
.history .diff { font-size: 13px; color: var(--muted); }
.contacts { display: grid; gap: 8px; }
.contact { font-size: 14px; }
.contact .role { font-size: 12px; color: var(--muted); }

.toast {
  display: flex; align-items: center; gap: 14px;
  position: fixed; left: 50%; bottom: 20px; z-index: 60; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 8px;
  background: #1f2933; color: #fff; font-size: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.toast button { border: 0; background: none; color: #7cb7f0; font-weight: 700; cursor: pointer; padding: 0; }
.loading { opacity: 0.55; transition: opacity 0.15s; }

/* ---------- auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 28px 24px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand img { width: 34px; height: 34px; }
.auth-brand .name { font-weight: 700; font-size: 18px; }
.auth-brand .org { font-size: 13px; color: var(--muted); }
.auth-card h1 { margin: 0 0 6px; font-size: 20px; }
.auth-card p.lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field input { font-size: 16px; } /* 16px stops iOS zooming into the field */
.auth-card .btn-primary { width: 100%; min-height: 44px; font-size: 15px; }
.form-error { margin: 0 0 14px; padding: 9px 12px; border-radius: 8px; background: var(--urgent-bg); color: var(--urgent); font-size: 14px; }
.form-note { margin: 0 0 14px; padding: 9px 12px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); font-size: 14px; }
.auth-links { margin-top: 16px; text-align: center; font-size: 14px; }
.auth-foot { margin-top: 18px; font-size: 12px; color: var(--faint); text-align: center; }

/* ---------- wider screens ---------- */
@media (min-width: 560px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .filter-grid { grid-template-columns: repeat(3, 1fr); }
  .facts { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 760px) {
  .filters-toggle { display: none; }
  .filters-more { display: block; }
  .filter-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }

  .card { padding-right: 190px; }
  .card-top .due { position: absolute; top: 14px; right: 16px; font-size: 14px; }
  .card-actions { margin-right: -174px; }

  .panel { left: auto; width: min(560px, 100%); box-shadow: -8px 0 30px rgba(0, 0, 0, 0.18); }
}

/* ---------- home-screen app (full screen on phones) ---------- */
/* Launched from the home screen, the page runs under the phone's status bar and notch.
   env() is 0 in a normal browser tab, so none of this changes the regular site. */
body::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: env(safe-area-inset-top); background: var(--brand);
}
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.panel-head { padding-top: calc(14px + env(safe-area-inset-top)); }
.panel-body { padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.auth-page { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
