:root {
  --bg: #f4f6f9; --panel: #fff; --ink: #172033; --ink-2: #3b4559; --muted: #6b7486; --line: #e4e8ee; --line-2: #eef1f5;
  --brand: #0f2a44; --brand-2: #16395c; --accent: #1f6fb2; --accent-soft: #e8f1fa;
  --won: #15803d; --won-soft: #e9f7ef;
  --adv: #1d64b0; --adv-soft: #e8f1fa;
  --none: #b45309; --none-soft: #fdf3e6;
  --back: #c0362c; --back-soft: #fdeeed;
  --new: #6d48c7; --new-soft: #f1ecfc;
  --note-bg: #fffaeb; --note-line: #f2c94c; --note-ink: #7a5b00;
  --bad: #c0362c; --warn-bg: #fff6e8; --warn-ink: #8a4b00;
  --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; margin: 28px 0 12px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.r { text-align: right; }
.zero { color: #c3c9d3; }

/* ---------- Top bar ---------- */
.topbar { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; display: flex; align-items: center; gap: 24px; padding: 0 24px; min-height: 58px; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 8px rgba(15,42,68,.25); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: #2f8be0; display: grid; place-items: center; }
.brand .mark svg { width: 20px; height: 20px; }
.brand .name { display: flex; flex-direction: column; line-height: 1.1; }
.brand .name small { font-size: 10px; letter-spacing: .14em; color: #9fbbd4; text-transform: uppercase; }
.brand .name b { font-size: 15px; letter-spacing: .01em; }
.topbar nav { display: flex; gap: 2px; align-items: center; flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { color: #c9d9e8; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.topbar nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.topbar nav .sep { width: 1px; height: 20px; background: rgba(255,255,255,.15); margin: 0 6px; flex: none; }
.usermenu { display: flex; align-items: center; gap: 4px; margin-left: auto; white-space: nowrap; }
.usermenu .who { display: flex; align-items: center; gap: 8px; color: #dbe7f2; padding: 4px 8px; border-radius: 8px; }
.usermenu .who:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #2f8be0; color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.usermenu .link { color: #9fbbd4; background: none; border: 0; font: inherit; font-weight: 500; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.usermenu .link:hover { color: #fff; background: rgba(255,255,255,.08); }
form.inline { display: inline; }

.refresh { display: flex; align-items: center; gap: 8px; background: #fff; color: var(--ink-2); padding: 8px 24px; font-size: 13px; border-bottom: 1px solid var(--line); }
.refresh .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--won); box-shadow: 0 0 0 3px var(--won-soft); flex: none; }
.refresh.stale { background: var(--warn-bg); color: var(--warn-ink); }
.refresh.stale .dot { background: #e08a00; box-shadow: 0 0 0 3px #fde7c2; }

main { padding: 24px 24px 72px; max-width: 1480px; margin: 0 auto; }
.msg { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; background: var(--won-soft); color: #14532d; border: 1px solid #c8ebd5; }
.msg.error { background: var(--back-soft); color: #8a1c14; border-color: #f6cfcb; }
.warn { background: var(--warn-bg); color: var(--warn-ink); padding: 8px 12px; border-radius: 8px; margin: 8px 0; font-size: 13px; }

/* ---------- Page header & controls ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.week-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; box-shadow: var(--shadow); }
.week-picker label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.week-picker select { border: 0; background: var(--line-2); font-weight: 600; color: var(--ink); }
.week-picker .muted { font-size: 12px; padding-right: 6px; }
select, input, textarea, button { font: inherit; }
select, input { padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
select:focus, input:focus, textarea:focus { outline: 2px solid #b9d6f2; outline-offset: 0; border-color: var(--accent); }
button, .button { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 7px 16px; cursor: pointer; font-weight: 600; }
button:hover, .button:hover { background: #185d97; text-decoration: none; }
button.secondary { background: #fff; color: var(--accent); border: 1px solid #b9d6f2; }
button.secondary:hover { background: var(--accent-soft); }
.count { color: var(--muted); font-weight: 500; }
.badge { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 11px; font-size: 12px; font-weight: 700; text-align: center; background: var(--line-2); color: var(--ink-2); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; }

/* ---------- Home ---------- */
.headline { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--ink); display: grid; grid-template-columns: 1fr auto; align-items: center; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.tile:hover { text-decoration: none; border-color: #b9d6f2; transform: translateY(-1px); }
.tile .label { color: var(--muted); font-weight: 600; font-size: 13px; }
.tile .num { font-size: 40px; font-weight: 750; line-height: 1.1; letter-spacing: -.02em; }
.tile .sub { font-size: 12px; color: var(--muted); }
.tile .sub b { color: var(--bad); }
.tile .icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); grid-row: 1 / 4; grid-column: 2; }
.tile.won .num { color: var(--won); } .tile.won .icon { background: var(--won-soft); }
.tile.closing .icon { background: var(--none-soft); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: flex; flex-direction: column; gap: 2px; border: 1px solid transparent; transition: transform .15s; }
.kpi:hover { text-decoration: none; transform: translateY(-1px); }
.kpi .num { font-size: 30px; font-weight: 750; line-height: 1.15; }
.kpi .label { font-size: 13px; font-weight: 600; }
.kpi.s-won { background: var(--won-soft); border-color: #cdeedb; } .kpi.s-won .num, .kpi.s-won .label { color: var(--won); }
.kpi.s-advanced { background: var(--adv-soft); border-color: #cfe2f5; } .kpi.s-advanced .num, .kpi.s-advanced .label { color: var(--adv); }
.kpi.s-none { background: var(--none-soft); border-color: #f6e0c2; } .kpi.s-none .num, .kpi.s-none .label { color: var(--none); }
.kpi.s-lost, .kpi.s-backwards { background: var(--back-soft); border-color: #f6d3d0; }
.kpi.s-lost .num, .kpi.s-lost .label, .kpi.s-backwards .num, .kpi.s-backwards .label { color: var(--back); }
.kpi.s-new { background: var(--new-soft); border-color: #e1d7f8; } .kpi.s-new .num, .kpi.s-new .label { color: var(--new); }

.two-col { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

.attention { list-style: none; padding: 0; margin: 0; }
.attention li a { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 18px; color: var(--ink); border-top: 1px solid var(--line-2); }
.attention li:first-child a { border-top: 0; }
.attention li a:hover { background: #fafbfc; text-decoration: none; }
.attention .n { font-weight: 700; font-size: 16px; }
.attention .none { padding: 14px 18px; margin: 0; }
details.report-notes { border-top: 1px solid var(--line); }
details.report-notes summary { padding: 11px 18px; cursor: pointer; color: var(--muted); font-size: 13px; }
details.report-notes .warn { margin: 0 18px 10px; }
.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; display: flex; min-width: 80px; }
.bar span { display: block; height: 100%; }
.bar .b-won { background: var(--won); } .bar .b-adv { background: var(--adv); } .bar .b-new { background: var(--new); } .bar .b-lost { background: var(--back); }

/* ---------- Tables ---------- */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); }
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
.card > .table-wrap:first-child { border-radius: var(--radius); }
.grid th { text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8f9fb; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th.r { text-align: right; }
.grid th[data-sort] { cursor: pointer; user-select: none; }
.grid th[data-sort]:hover { color: var(--ink); }
.grid th.asc::after { content: " ▲"; font-size: 9px; } .grid th.desc::after { content: " ▼"; font-size: 9px; }
.grid td { padding: 9px 12px; border-top: 1px solid var(--line-2); vertical-align: top; }
.grid tbody.item:first-of-type tr:first-child td { border-top: 0; }
.grid tbody.item:hover td { background: #fafcff; }
.grid td.bad { color: var(--bad); font-weight: 600; }
.grid td.next { max-width: 340px; color: var(--ink-2); }
.acct { font-weight: 600; }
.opp { color: var(--ink-2); }
.opp a { color: var(--ink-2); text-decoration: underline; text-decoration-color: #c3cfdd; text-underline-offset: 2px; }
.sfid { color: var(--muted); font-size: 11px; font-family: ui-monospace, Consolas, monospace; }
.stage { display: inline-block; padding: 2px 9px; border-radius: 10px; background: var(--line-2); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.arrow { color: var(--muted); margin: 0 3px; }
.blank { color: #a0a8b6; font-style: italic; font-size: 12px; }
.tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 8px; margin-left: 4px; }
.tag.new { background: var(--new-soft); color: var(--new); } .tag.back { background: var(--back-soft); color: var(--back); }
.tag.role { background: var(--accent-soft); color: var(--brand); margin-left: 0; }

.flags { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 4px; }
.flag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 8px; background: var(--back-soft); color: #9b2219; white-space: nowrap; }
.flag.f-long, .flag.f-no_next_step, .flag.f-no_supplier, .flag.f-no_category { background: var(--warn-bg); color: var(--warn-ink); }
.flag.f-no_id { background: var(--line-2); color: var(--muted); }

/* ---------- Weekly WIP ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips a { padding: 6px 13px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.chips a:hover { text-decoration: none; border-color: #b9d6f2; }
.chips a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chips a b { margin-left: 4px; }
.jump { position: sticky; top: 58px; z-index: 5; background: var(--bg); padding: 8px 0; margin-bottom: 0; }
.jump a.s-won b { color: var(--won); } .jump a.s-advanced b { color: var(--adv); } .jump a.s-backwards b { color: var(--back); }
.jump a.s-new b { color: var(--new); } .jump a.s-none b { color: var(--none); }
.wip-section { margin-top: 16px; scroll-margin-top: 120px; overflow: hidden; }
.wip-section .card-head { border-left: 4px solid var(--line); }
.wip-section .card-head h2 { display: flex; align-items: center; gap: 8px; }
.wip-section.s-won .card-head { border-left-color: var(--won); background: linear-gradient(90deg, var(--won-soft), #fff 45%); } .s-won .card-head h2 { color: var(--won); }
.wip-section.s-advanced .card-head { border-left-color: var(--adv); background: linear-gradient(90deg, var(--adv-soft), #fff 45%); } .s-advanced .card-head h2 { color: var(--adv); }
.wip-section.s-none .card-head { border-left-color: var(--none); background: linear-gradient(90deg, var(--none-soft), #fff 45%); } .s-none .card-head h2 { color: var(--none); }
.wip-section.s-backwards .card-head { border-left-color: var(--back); background: linear-gradient(90deg, var(--back-soft), #fff 45%); } .s-backwards .card-head h2 { color: var(--back); }
.wip-section.s-new .card-head { border-left-color: var(--new); background: linear-gradient(90deg, var(--new-soft), #fff 45%); } .s-new .card-head h2 { color: var(--new); }
.wip-section summary { list-style: none; cursor: pointer; }
.wip-section summary::-webkit-details-marker { display: none; }
.wip-section .toggle { font-size: 13px; font-weight: 600; color: var(--accent); }
.wip-section .toggle::after { content: "Show ▾"; }
.wip-section details[open] .toggle::after { content: "Hide ▴"; }
.wip-section details:not([open]) .card-head { border-bottom: 0; }
.wip-section .empty { padding: 14px 18px; color: var(--muted); margin: 0; }

/* WIP commentary is styled differently everywhere so it is never mistaken for Salesforce data. */
.commentary td { background: var(--note-bg) !important; border-top: 0; padding-top: 0; }
.commentary-box { background: var(--note-bg); border-left: 3px solid var(--note-line); padding: 8px 12px; border-radius: 6px; }
.commentary-box p { margin: 3px 0; }
.commentary-box .support { color: #8a1c14; }
.commentary-label { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--note-ink); margin-bottom: 3px; }
.sf-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; background: var(--accent-soft); color: var(--brand); padding: 2px 6px; border-radius: 4px; }

/* ---------- My WIP notes ---------- */
.progress-card { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 14px 18px; margin-bottom: 8px; }
.progress-card .bar { flex: 1; height: 8px; min-width: 160px; }
.progress-card .bar span { background: var(--won); }
.group-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 10px; }
.note-card { margin-bottom: 12px; border-left: 4px solid var(--line); overflow: hidden; scroll-margin-top: 80px; }
.note-card.s-won { border-left-color: var(--won); } .note-card.s-advanced { border-left-color: var(--adv); }
.note-card.s-none { border-left-color: var(--none); } .note-card.s-backwards, .note-card.s-lost { border-left-color: var(--back); }
.note-card.s-new { border-left-color: var(--new); }
.note-card summary { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px; list-style: none; cursor: pointer; }
.note-card summary::-webkit-details-marker { display: none; }
.note-card summary:hover { background: #fafcff; }
.note-card h3 { margin: 2px 0 4px; font-size: 15px; }
.note-card h3 .opp-name { font-weight: 500; color: var(--ink-2); }
.note-card .status { font-size: 12px; font-weight: 600; color: var(--muted); }
.note-card .facts { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.note-state { font-size: 12px; font-weight: 600; white-space: nowrap; padding: 2px 9px; border-radius: 10px; background: var(--line-2); color: var(--muted); }
.note-state.done { background: var(--won-soft); color: var(--won); }
.note-card .prev { background: #f6f7f9; padding: 7px 12px; border-radius: 6px; margin: 0 18px 10px; font-size: 13px; }
.note-form { margin: 0 18px 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; padding: 12px 14px; }
@media (max-width: 1000px) { .note-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .note-form { grid-template-columns: 1fr; } }
.note-form label { display: flex; flex-direction: column; font-size: 12px; font-weight: 700; color: var(--note-ink); gap: 4px; }
.note-form textarea { width: 100%; padding: 7px 9px; border: 1px solid #efdfa6; border-radius: 8px; font-weight: 400; color: var(--ink); resize: vertical; background: #fff; min-height: 58px; }
.note-form textarea:disabled { background: #fdf9ec; color: var(--muted); }
.note-form .actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; }

/* ---------- Pipeline filters ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; padding: 14px 16px; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: var(--muted); gap: 4px; }

/* ---------- Forms & settings ---------- */
.upload, .import { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 12px; box-shadow: var(--shadow); }
.panel-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.panel-form.narrow { max-width: 440px; margin: 32px auto; }
.panel-form h2 { font-size: 15px; margin: 22px 0 12px; padding-top: 16px; border-top: 1px solid var(--line-2); }
.panel-form h2:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; margin-bottom: 5px; }
.field.check > label { display: flex; gap: 8px; align-items: center; }
.field.check input { width: 16px; height: 16px; }
.field input:not([type=checkbox]), .field select { width: 100%; max-width: 440px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.field .help ul { margin: 4px 0; padding-left: 18px; }
.error { color: var(--bad); font-size: 12px; margin-top: 4px; }
.has-error input { border-color: var(--bad); }
.help.saved { color: var(--won); margin: -10px 0 14px; font-size: 12px; }
tr.inactive td { color: var(--muted); }
.grid.stages input, .grid.stages select { padding: 4px 8px; }
.sync-status { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; box-shadow: var(--shadow); }
.sync-status.ok { border-left-color: var(--won); }
.sync-status.failed { border-left-color: var(--bad); background: #fdf5f4; }
.sync-actions { display: flex; gap: 8px; }
.setup-steps { padding-left: 20px; } .setup-steps li { margin-bottom: 8px; }
pre.soql { white-space: pre-wrap; background: #f4f6f9; padding: 10px 12px; border-radius: 8px; font-size: 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 220px); display: grid; place-items: center; }
.login { width: 100%; max-width: 380px; padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login .sub { color: var(--muted); margin: 0 0 18px; }
.login input { width: 100%; }
.login button { width: 100%; justify-content: center; padding: 10px; margin-top: 6px; }

/* ---------- Phones ---------- */
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; gap: 0 12px; padding: 8px 16px 0; position: static; }
  .topbar nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .usermenu .who .name { display: none; }
  main { padding: 16px 16px 60px; }
  .refresh { padding: 8px 16px; }
  .tile .num { font-size: 34px; }
  .jump { top: 0; }
}
.readonly-note { background: var(--won-soft); border: 1px solid #cdeedb; color: #14532d; border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 13px; }
