/* Dense admin UI. 13px base, near-black on white, sharp edges, hairline
   borders instead of cards. Colour is reserved for status and money — if a
   thing is coloured here, the colour means something. */

:root {
  --bg: #ffffff;
  --sunk: #fafafa;
  --panel: #ffffff;
  --line: #e7e7ea;
  --line-soft: #f0f0f2;
  --ink: #16161a;
  --ink-2: #55555f;
  --muted: #8b8b95;
  --accent: #5b5bd6;
  --accent-soft: #eeeefc;
  --hover: #f6f6f8;
  --sel: #eef0fd;

  --grey: #9a9aa4;
  --blue: #3b6fd4;
  --amber: #b57314;
  --green: #17855a;
  --red: #c0392f;

  --r: 5px;
  --row: 34px;

  /* Type scale. Every size in this file comes from here — change --fs and the
     rest follows, rather than hunting 20 hard-coded pixel values. */
  --fs: 15px;      /* body */
  --fs-sm: 13px;   /* meta lines, legends, hints, code */
  --fs-xs: 12px;   /* section headers, labels, table headers, tags */
  --fs-lg: 20px;   /* rail figures */
  --fs-h1: 21px;   /* page title */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d10;
    --sunk: #121216;
    --panel: #131317;
    --line: #26262c;
    --line-soft: #1d1d22;
    --ink: #e9e9ec;
    --ink-2: #a8a8b2;
    --muted: #787883;
    --accent: #8f8ff5;
    --accent-soft: #1e1e33;
    --hover: #17171c;
    --sel: #1c1c2e;

    --grey: #6a6a75;
    --blue: #6f9bf0;
    --amber: #dba13f;
    --green: #3fbc85;
    --red: #ef6f63;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs)/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "tnum" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }
.link-accent { color: var(--accent); }
.link-accent:hover { text-decoration: underline; }

/* --- chrome --------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 44px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.mark {
  width: 15px; height: 15px;
  border-radius: 3px;
  background: var(--accent);
  display: inline-block;
  flex: none;
}
.brand span { color: var(--muted); font-weight: 400; }

.topbar nav { display: flex; gap: 2px; margin-right: auto; }
.topbar nav a {
  padding: 4px 9px;
  border-radius: var(--r);
  color: var(--ink-2);
}
.topbar nav a:hover { background: var(--hover); color: var(--ink); }
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

main { max-width: 1180px; margin: 0 auto; padding: 16px 14px 56px; }

/* --- summary strip -------------------------------------------------------- */
/* Replaces four big stat boxes: same numbers, one line, no chrome. */

.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 6px;
  padding: 9px 12px;
  margin-bottom: 14px;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink-2);
}
.strip .n { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.strip .sep { color: var(--line); padding: 0 3px; }
.strip .warn .n { color: var(--amber); }
.strip .bad .n { color: var(--red); }
.strip a:hover .n { color: var(--accent); }

/* --- pipeline rail -------------------------------------------------------- */

.rail { display: flex; gap: 3px; margin-bottom: 14px; }
.rail a {
  flex: 1;
  padding: 7px 9px;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: var(--r);
  min-width: 0;
}
.rail a:hover { background: var(--hover); border-color: var(--accent); }
.rail .k { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .v { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
.rail a.empty-stage .v { color: var(--muted); font-weight: 400; }

/* --- panels --------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 12px;
}
.panel > h2 {
  margin: 0;
  padding: 8px 12px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel > h2 .count { color: var(--ink-2); font-weight: 500; letter-spacing: 0; }
.panel > h2 .spacer { margin-left: auto; }
.pad { padding: 10px 12px; }

.grid { display: grid; gap: 12px; align-items: start; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .grid.two { grid-template-columns: 1fr; } }

/* --- page head ------------------------------------------------------------ */

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.page-head h1 { font-size: var(--fs-h1); font-weight: 600; margin: 0 0 3px; letter-spacing: -0.015em; }
.page-head .spacer { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.sub { color: var(--muted); margin: 0; }

/* --- dense rows ----------------------------------------------------------- */

.rows { display: flex; flex-direction: column; }
.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  min-height: var(--row);
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--hover); }
.row-item.sel { background: var(--sel); box-shadow: inset 2px 0 0 var(--accent); }
.row-item .main { min-width: 0; flex: 1; }
.row-item .title { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* display:block matters — ellipsis truncation needs a block box, and without
   it a long client/rating/bids line just overflows the viewport. */
.row-item .meta { display: block; color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row-item .done { color: var(--muted); text-decoration: line-through; }

/* --- status dots ---------------------------------------------------------- */
/* A dot plus a word. Cheaper than a pill and reads faster in a dense list. */

.st { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink-2); }
.st::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--dot, var(--grey));
  flex: none;
}
.st.hollow::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--dot, var(--grey)); }
.st-w { min-width: 108px; }

.s-lead, .s-pending, .s-closed, .s-archived { --dot: var(--grey); }
.s-applied, .s-submitted { --dot: var(--blue); }
.s-interviewing, .s-funded { --dot: var(--amber); }
.s-won, .s-in_progress, .s-approved { --dot: var(--green); }
.s-delivered, .s-paid { --dot: var(--green); }
.s-lost { --dot: var(--red); }

.tag {
  display: inline-block;
  padding: 1px 6px;
  font-size: var(--fs-xs);
  border-radius: 3px;
  background: var(--sunk);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.good { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }
.tag.bad { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.tag.warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }

.money { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.dim { color: var(--muted); }

/* --- tables --------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 12px; border-bottom: 1px solid var(--line-soft); }
th {
  font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  background: var(--sunk);
}
tbody tr:hover { background: var(--hover); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* --- meter ---------------------------------------------------------------- */

.meter { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; }
.meter .paid { background: var(--green); }
.meter .held { background: var(--amber); }
/* Money agreed with nothing behind it. Must stay visible against the track —
   it is the risk signal, so it is the last thing that should read as empty. */
.meter .open { background: color-mix(in srgb, var(--grey) 45%, transparent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: var(--fs-sm); margin-top: 8px; }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }

/* --- forms ---------------------------------------------------------------- */

label { display: block; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .04em; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=url], input[type=number], input[type=date],
input[type=password], select, textarea {
  width: 100%;
  padding: 5px 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
input::placeholder { color: var(--muted); }
textarea { min-height: 190px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--fs-sm); line-height: 1.5; }
.field { margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 130px; }
.check { display: flex; align-items: center; gap: 7px; }
.check input { width: auto; }
.check label { margin: 0; text-transform: none; letter-spacing: 0; font-size: var(--fs); color: var(--ink); }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--hover); border-color: var(--muted); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.link { border: none; background: none; color: var(--muted); padding: 2px 4px; }
button.link:hover { color: var(--ink); background: var(--hover); }
button.danger { color: var(--red); }
button.tiny, .btn.tiny { padding: 2px 7px; font-size: var(--fs-sm); }
td select, td button { padding: 3px 7px; font-size: var(--fs-sm); }
td select { min-width: 104px; }

.inline { display: inline; }
.actions { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.filters { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input[type=text] { max-width: 280px; }
.filters select { max-width: 160px; }

kbd {
  font: var(--fs-xs) ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--sunk);
  color: var(--muted);
}
.hint { color: var(--muted); font-size: var(--fs-sm); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* --- markdown ------------------------------------------------------------- */

.md { font-size: var(--fs); line-height: 1.65; overflow-x: auto; }
.md > :first-child { margin-top: 0; }
.md table { margin: 10px 0; font-size: var(--fs-sm); border: 1px solid var(--line); }
.md th { position: static; }
.md code { background: var(--sunk); border: 1px solid var(--line-soft); padding: 0 4px; border-radius: 3px; font-size: var(--fs-sm); }
.md pre { background: var(--sunk); border: 1px solid var(--line); padding: 10px; border-radius: var(--r); overflow-x: auto; }
.md pre code { border: none; background: none; padding: 0; }
.md h1, .md h2, .md h3 { text-transform: none; letter-spacing: -0.01em; color: var(--ink); margin: 18px 0 6px; padding: 0; border: none; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: var(--fs); }
.md a { color: var(--accent); }
.md a:hover { text-decoration: underline; }
.md blockquote { margin: 10px 0; padding-left: 12px; border-left: 2px solid var(--line); color: var(--ink-2); }

.empty { color: var(--muted); padding: 14px 12px; text-align: center; }
.empty a { color: var(--accent); }

/* --- login ---------------------------------------------------------------- */

.login-wrap { max-width: 300px; margin: 15vh auto; padding: 0 14px; }
.login-wrap .brand { margin-bottom: 3px; font-size: 17px; }
.error { color: var(--red); margin-bottom: 10px; }

/* --- narrow screens ------------------------------------------------------- */
/* Last in the file on purpose: these override earlier same-specificity rules. */

@media (max-width: 620px) {
  .topbar { height: auto; padding: 8px 12px; flex-wrap: wrap; gap: 10px; }
  .topbar nav { order: 3; width: 100%; margin-right: 0; }
  main { padding: 12px 10px 48px; }
  .rail { flex-wrap: wrap; }
  .rail a { flex: 1 1 30%; }
  .row > * { flex-basis: 100%; }
  .page-head { flex-wrap: wrap; }
}

/* Legend swatch for the not-funded segment: kept in CSS so it cannot drift
   from the .meter .open colour it stands for. */
.swatch-open { background: color-mix(in srgb, var(--grey) 45%, transparent); }

.nowrap { white-space: nowrap; flex: none; }
