/*
 * One stylesheet, no build step — what is here is what ships, exactly as in the
 * field app. Colours are tokens so the dark scheme is a redefinition rather
 * than a second set of rules that can drift.
 */

:root {
  --topbar: 57px;
  --bg: #f2f2f0;
  --panel: #fff;
  --ink: #0c0d10;
  --muted: #5f6167;
  --line: #d6d7da;
  --accent: #b3540a;
  --accent-ink: #fff;
  --warn: #b3540a;
  --won: #0ca30c;
  --lost: #d03b3b;
  /* The same green is a fine fill and a poor label: #0ca30c sits at 3.35:1 as
     text on the panel. Fills and text get their own step. */
  --won-ink: #0a7d0a;
  --lost-ink: #d03b3b;
  --chip: #e9eaec;
  --shadow: rgba(0, 0, 0, .09);

  /* Stage ramp: one hue, light -> dark as the deal advances. Validated as an
     ordinal scale against the surface it renders on, not picked by eye. */
  --s1: #e8963a;
  --s2: #cc7317;
  --s3: #a4560c;
  --s4: #6e3a08;

  /* Header ink, per stage. A single value cannot work: the ramp runs from a
     pale amber to a near-brown, and white on the pale end sits at 2.3:1. Each
     of these is the better of the two inks on its own fill, all above 4.5:1. */
  --ink-lead: #0c0d10;
  --ink-qual: #0c0d10;
  --ink-prop: #fbfbfd;
  --ink-neg:  #fbfbfd;
  --ink-won:  #0c0d10;
  --ink-lost: #fbfbfd;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101218;
    --panel: #1a1c22;
    --ink: #fbfbfd;
    --muted: #9195a1;
    --line: #2b2e38;
    --accent: #e8963a;
    --accent-ink: #101218;
    --warn: #f5c07a;
    --won: #6fc46f;
    --lost: #e66767;
    --won-ink: #6fc46f;
    --lost-ink: #e66767;
    --chip: #23262e;
    --shadow: rgba(0, 0, 0, .45);

    --s1: #f5c07a;
    --s2: #e8963a;
    --s3: #c4731e;
    --s4: #94550f;

    --ink-lead: #101218;
    --ink-qual: #101218;
    --ink-prop: #101218;
    --ink-neg:  #fbfbfd;
    --ink-won:  #101218;
    --ink-lost: #101218;
  }
}

* { box-sizing: border-box; }

/*
 * Two scrolls, doing different jobs.
 *
 * The page scrolls, and what it scrolls away is the chrome: the stat tiles and
 * the filter row tuck up under the topbar and the board takes the full height.
 * Past that point the page has nothing left to give, and the stage columns
 * scroll on their own — which is the part that matters, because scrolling to
 * the bottom of 122 leads must not leave the other five columns blank.
 *
 * Column headers sit outside the scrolling list rather than sticking to it.
 * `position: sticky` resolves against the nearest scrolling ancestor, and the
 * board sets `overflow-x` for narrow screens, so it would become that ancestor
 * and the headers would scroll away under the cards.
 */
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 13.5px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: -.004em;
}


button, input, select, textarea {
  font: inherit;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
}

button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.quiet { background: none; border-color: transparent; color: var(--muted); }
button.danger:hover { border-color: var(--lost); color: var(--lost-ink); }
button[disabled] { opacity: .5; cursor: not-allowed; }
textarea { resize: vertical; min-height: 68px; width: 100%; }
label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.field { margin-bottom: 11px; }
.field input, .field select, .field textarea { width: 100%; }

/* ---------- shell ---------- */

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 22px; border-bottom: 1px solid var(--line); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 14.5px; margin: 0; letter-spacing: -.02em; font-weight: 700; }
.topbar .who { margin-left: auto; color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 10px; }
.tabs { display: flex; gap: 2px; }
.tabs button { background: none; border: none; color: var(--muted); padding: 5px 11px; border-radius: 6px; }
.tabs button.on { background: var(--chip); color: var(--ink); font-weight: 700; }

.wrap { max-width: 1680px; margin: 0 auto; padding: 16px 22px 0; width: 100%; }

/* ---------- stats ---------- */

.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1.5px solid var(--line); border-radius: 7px; padding: 10px 14px; min-width: 110px; }
.stat b { display: block; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums;
  letter-spacing: -.03em; line-height: 1.05; }
.stat span { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }

.filters { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters input[type="search"] { min-width: 210px; }

/* ---------- board ---------- */

.board {
  display: grid; grid-template-columns: repeat(6, minmax(196px, 1fr));
  gap: 11px; align-items: stretch;
  /* Sticks once the chrome above has scrolled away, then fills the screen. */
  position: sticky; top: var(--topbar);
  height: calc(100vh - var(--topbar));
  /* `clip` rather than `hidden`: hidden is still a scroll container, so it
     swallows the wheel and the page below it never moves. clip is not. */
  overflow-x: auto; overflow-y: clip;
  padding-bottom: 14px;
}
.col {
  min-width: 196px; min-height: 0;
  display: flex; flex-direction: column;
}
/*
 * The stage header is a solid block rather than a label over a hairline, so the
 * column a deal sits in is legible at a glance — and from across a room, which
 * is the point if this ever goes on a screen in the office.
 */
.colhead { flex: none; border-radius: 7px; overflow: hidden; margin-bottom: 8px; }

/*
 * The lists scroll without showing a bar for it.
 *
 * Six permanent scrollbars is six vertical lines of furniture across a screen
 * whose whole job is to be scanned. The bar appears on hover, so the affordance
 * is there when a hand is actually on the column.
 */
.cards {
  flex: 1; min-height: 0; overflow-y: auto; padding-right: 3px;
  scrollbar-width: none;
}
.cards::-webkit-scrollbar { width: 0; }
.col:hover .cards { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.col:hover .cards::-webkit-scrollbar { width: 7px; }
.col:hover .cards::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.col:hover .cards::-webkit-scrollbar-track { background: transparent; }
.colhead h2 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em; margin: 0;
  font-weight: 700; padding: 8px 10px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 6px;
}
.colhead em { font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.bar { display: none; }

.col[data-stage="Lead"]        .colhead { background: var(--s1); color: var(--ink-lead); }
.col[data-stage="Qualified"]   .colhead { background: var(--s2); color: var(--ink-qual); }
.col[data-stage="Proposal"]    .colhead { background: var(--s3); color: var(--ink-prop); }
.col[data-stage="Negotiation"] .colhead { background: var(--s4); color: var(--ink-neg); }
.col[data-stage="Closed Won"]  .colhead { background: var(--won); color: var(--ink-won); }
.col[data-stage="Closed Lost"] .colhead { background: var(--lost); color: var(--ink-lost); }
.col.drop { outline: 2px dashed var(--accent); outline-offset: 3px; border-radius: 9px; }

.card {
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 7px;
  padding: 10px 11px; margin-bottom: 7px; cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: .45; }
.card h3 { font-size: 13.5px; margin: 0 0 3px; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; }
.meta { color: var(--muted); font-size: 11.5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hl { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.tag { background: var(--chip); border-radius: 5px; padding: 0 5px; font-size: 10px; font-weight: 600; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); display: inline-block; }
.empty { color: var(--muted); font-size: 12px; padding: 8px 2px; font-style: italic; }

/* ---------- panel ---------- */

.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 40; }
.panel {
  position: fixed; top: 0; right: 0; width: min(460px, 100%); height: 100%;
  background: var(--panel); border-left: 1px solid var(--line); padding: 20px;
  overflow: auto; box-shadow: -8px 0 24px var(--shadow); z-index: 41;
}
.panel h2 { margin: 0 0 2px; font-size: 19px; letter-spacing: -.025em; font-weight: 700; padding-right: 30px; }
.panel .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.panel .close { position: absolute; top: 14px; right: 16px; border: none; background: none; font-size: 22px; color: var(--muted); padding: 0; line-height: 1; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.flagbox { border: 1px solid var(--warn); border-radius: 7px; padding: 9px 11px; margin: 0 0 14px; }
.flagbox b { color: var(--warn); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.flagbox ul { margin: 6px 0 0; padding-left: 16px; font-size: 12.5px; }
.flagbox li { margin-bottom: 5px; }
.flagbox button { padding: 1px 7px; font-size: 11px; margin-left: 4px; }
.raw { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11.5px; }

.timeline { list-style: none; margin: 14px 0 0; padding: 0; border-top: 1px solid var(--line); }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.timeline .when { color: var(--muted); font-size: 11px; display: block; }

/* ---------- sign in ---------- */

.signin { max-width: 340px; margin: 12vh auto; padding: 0 20px; }
.signin h1 { font-size: 23px; margin: 0 0 4px; letter-spacing: -.03em; font-weight: 800; }
.signin p.lead { color: var(--muted); margin: 0 0 22px; font-size: 13px; }
.signin button { width: 100%; margin-top: 4px; }
.signin .swap { margin-top: 14px; text-align: center; }
.err { color: var(--lost-ink); font-size: 12.5px; margin: 10px 0 0; }
.ok { color: var(--won-ink); font-size: 12.5px; margin: 10px 0 0; }

/* ---------- people ---------- */

table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1.5px solid var(--line); border-radius: 7px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 700; }
tr:last-child td { border-bottom: none; }
td select { padding: 4px 7px; font-size: 12.5px; }

@media (max-width: 860px) {
  .board { grid-template-columns: repeat(6, 210px); }
  .wrap { padding: 14px 14px 40px; }
  .topbar { padding: 10px 14px; }
}
