:root {
  --ink: #1a1d21; --ink-2: #4b5259; --ink-3: #7b838b; --line: #dfe3e7; --line-2: #eef0f2;
  --bg: #f6f7f8; --panel: #ffffff; --accent: #1f3a5f; --accent-2: #e8eef6; --warn: #b4531a; --warn-bg: #fbeee4;
  --amber: #c98a12; --red: #a8261d;
  --ok: #2b7a4b; --ok-bg: #e6f3ea; --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font: 400 26px/1.2 var(--serif); margin: 0 0 4px; overflow-wrap: anywhere; } h2 { font: 400 18px/1.25 var(--serif); margin: 0 0 8px; }
h3 { font: 600 12px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 8px; }
h4 { font: 600 11px/1.3 var(--sans); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 12px 0 4px; }
.muted { color: var(--ink-3); } .small { font-size: 12px; } .mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.overdue, .overdue a, .overdue input { color: var(--warn); }

/* layout */
#app { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: 100vh; }
#app.bare { display: block; }
nav.rail { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
nav.rail .rail-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
nav.rail .brand { font: 600 18px/1.1 var(--serif); color: var(--accent); padding: 4px 10px 14px; white-space: nowrap; }
nav.rail .brand:hover { text-decoration: none; }
nav.rail .links { display: flex; flex-direction: column; gap: 2px; }
nav.rail .links a { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; border-radius: 6px; color: var(--ink-2); }
nav.rail .links a:hover { background: var(--line-2); text-decoration: none; } nav.rail .links a.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
nav.rail .divider { border-top: 1px solid var(--line); margin: 8px 10px; }
nav.rail .spacer { flex: 1; } nav.rail .who { padding: 8px 10px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }
nav.rail .search-hint { margin: 4px 0 12px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink-3); background: var(--bg); display: flex; justify-content: space-between; cursor: text; }
nav.rail kbd { font: 11px var(--mono); color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; background: #fff; }
nav.rail .rail-btns { display: none; gap: 6px; }
main { padding: 22px 28px 60px; min-width: 0; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.head > div:first-child { min-width: 0; }
.head .sub { color: var(--ink-3); }

/* panels & grid */
.grid { display: grid; gap: 14px; } .grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 1fr) 320px; } .grid.main-side.wide { grid-template-columns: minmax(0, 1fr) 380px; }
.grid + .panel, .panel + .grid, .grid + .grid { margin-top: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.panel + .panel { margin-top: 14px; }
.panel h3 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel h3 .act { text-transform: none; letter-spacing: 0; font-weight: 500; }
.panel h3 button.act { border: none; background: none; color: var(--accent); padding: 0; font-size: 12px; }
.note-line { font-size: 12px; color: var(--ink-3); margin-top: 8px; }

/* tables */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
th { font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
th.sort { cursor: pointer; } th.sort:hover { color: var(--ink); }
tr.row { cursor: pointer; } tr.row:hover td { background: #fafbfc; }
td .sub { color: var(--ink-3); font-size: 12px; }
td.c-deal { min-width: 180px; } td.c-next { min-width: 170px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--ink-3); font-size: 12px; flex-wrap: wrap; }

/* stale edges: ink when fresh, amber after 14 days, red after 30 or never touched */
tr.edge-ink td:first-child { box-shadow: inset 3px 0 0 var(--ink-2); }
tr.edge-amber td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
tr.edge-red td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.card.edge-ink { border-left: 3px solid var(--ink-2); } .card.edge-amber { border-left: 3px solid var(--amber); } .card.edge-red { border-left: 3px solid var(--red); }

/* forms & controls */
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
input[type=text], input[type=search], input[type=date], input[type=number], input[type=email], input[type=password], select, textarea { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; max-width: 100%; }
input[type=search] { min-width: 260px; } textarea { width: 100%; min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.btn { padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); display: inline-block; white-space: nowrap; }
.btn:hover { background: var(--line-2); text-decoration: none; } .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: #17304f; }
.btn.small { padding: 3px 8px; font-size: 12px; } .btn.danger { color: var(--warn); border-color: #f0d3c4; } .btn.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; } .form.one { grid-template-columns: minmax(0, 1fr); } .form .full { grid-column: 1 / -1; }
.form label, .form .field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-3); min-width: 0; }
.form label > input, .form label > select, .form label > textarea, .form label > .pick { font-size: 14px; color: var(--ink); width: 100%; }
.form label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); }
.form label.check input { width: auto; }
fieldset { border: none; border-top: 1px solid var(--line); margin: 0 0 6px; padding: 12px 0 8px; min-width: 0; }
fieldset:first-of-type { border-top: none; padding-top: 0; }
legend { font: 400 17px/1.3 var(--serif); color: var(--ink); padding: 0 8px 0 0; }
.hint { font-size: 12px; color: var(--ink-3); }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.picked { font-size: 12px; color: var(--ok); }

/* pills: stages and grades in ink tones */
.pill { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.kind-loi, .pill.kind-counter { background: var(--ink-2); color: #fff; }
.pill.kind-stage { background: #fff; color: var(--ink-2); border: 1px solid var(--line); }
.pill.kind-call, .pill.kind-meeting, .pill.kind-tour { background: var(--accent-2); color: var(--accent); }
.stage { display: inline-block; padding: 2px 8px; border-radius: 4px; background: var(--line-2); color: var(--ink); font-size: 12px; white-space: nowrap; }
.stage.s-late { background: var(--ink-2); color: #fff; }
.stage.s-closed { background: #fff; color: var(--ink); border: 1px solid var(--ink-3); padding: 1px 7px; }
.stage.s-dead { background: #fff; color: var(--ink-3); border: 1px dashed var(--line); padding: 1px 7px; }
.grade { display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid var(--ink-3); border-radius: 4px; font: 600 11px/17px var(--mono); text-align: center; color: var(--ink); background: #fff; }
.grade.g-C { color: var(--ink-2); border-color: var(--line); }
.grade.g-D, .grade.g-F { color: var(--warn); border-color: #f0d3c4; }
select.stage-sel { font-size: 13px; padding: 3px 6px; background: var(--line-2); border-color: var(--line); color: var(--ink); }

/* multi-chip select */
.mfield .chips { margin-top: 2px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; font-size: 12px; background: #fff; cursor: pointer; color: var(--ink-2); line-height: 1.5; }
.chip:hover { border-color: var(--ink-3); } .chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip-row { margin: -4px 0 12px; }

/* detail */
.dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 4px 10px; margin: 0; } .dl dt { color: var(--ink-3); font-size: 12px; padding-top: 2px; } .dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px 14px; }
.fact span { display: block; font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.fact b { font-weight: 400; font-family: var(--serif); font-size: 16px; overflow-wrap: anywhere; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px 10px; }
.dgrid label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-3); min-width: 0; }
.dgrid input { width: 100%; font-size: 13px; padding: 4px 6px; }
.dgrid label.overdue { color: var(--warn); font-weight: 600; } .dgrid label.overdue input { border-color: var(--warn); }
.timeline .item { padding: 10px 0; border-bottom: 1px solid var(--line-2); } .timeline .item:last-child { border-bottom: none; }
.timeline .meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--ink-3); margin-bottom: 3px; flex-wrap: wrap; }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; } .timeline .subject { font-weight: 600; overflow-wrap: anywhere; }
.timeline .body.clamp { max-height: 6.5em; overflow: hidden; position: relative; } .timeline .more { font-size: 12px; }
.note-box { display: grid; gap: 8px; } .note-box .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note-box input[name=subject] { width: 100%; }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: 6px 0; border-bottom: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: 8px; align-items: baseline; min-width: 0; } .list li:last-child { border-bottom: none; }
.list li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.list .sub { color: var(--ink-3); font-size: 12px; }
.bul { margin: 0; padding-left: 18px; } .bul li { margin: 2px 0; overflow-wrap: anywhere; }
.task.done, .dates li.done { text-decoration: line-through; color: var(--ink-3); } .task input, .dates input { margin-right: 6px; }
.dates { list-style: none; margin: 0; padding: 0; }
.dates li { padding: 6px 0; border-bottom: 1px solid var(--line-2); overflow-wrap: anywhere; } .dates li:last-child { border-bottom: none; }
.dates .dt { font-family: var(--mono); font-size: 12px; display: inline-block; min-width: 52px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--line-2); border-radius: 8px; padding: 8px; min-height: 120px; } .col h4 { margin: 0 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); display: flex; justify-content: space-between; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; overflow-wrap: anywhere; } .card:hover { border-color: var(--accent); }
.card .amt { font-family: var(--mono); font-size: 12px; color: var(--ink-2); margin: 2px 0; }

/* palette & modal */
#palette { position: fixed; inset: 0; background: rgba(20, 24, 30, .35); display: flex; align-items: flex-start; justify-content: center; padding: 10vh 0; overflow-y: auto; z-index: 50; }
#palette .box { width: min(720px, 92vw); max-height: 84vh; overflow: auto; background: #fff; border-radius: 10px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); flex-shrink: 0; }
/* A modal form is not clipped, so a picker menu near its bottom edge shows in full; a tall modal scrolls the overlay instead. */
#palette .box.pad { padding: 16px; max-height: none; overflow: visible; }
#palette .box > input { width: 100%; padding: 14px 16px; border: none; border-bottom: 1px solid var(--line); font-size: 16px; outline: none; }
#palette .results { max-height: 60vh; overflow: auto; padding: 6px 0; }
#palette .group { padding: 6px 16px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
#palette .hit { padding: 7px 16px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; } #palette .hit.sel, #palette .hit:hover { background: var(--accent-2); }
#palette .hit .sub { color: var(--ink-3); font-size: 12px; }
#palette .hit.quiet { color: var(--ink-3); border-top: 1px solid var(--line-2); margin-top: 4px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 6px; font-size: 13px; z-index: 60; max-width: 90vw; }
.login { max-width: 360px; margin: 14vh auto; padding: 0 16px; } .login .panel { padding: 24px; }
.login input[type=password] { width: 100%; }
.err { color: var(--warn); font-size: 13px; min-height: 18px; }
.empty { color: var(--ink-3); padding: 10px 0; }
.pick { position: relative; display: block; } .pick input[type=text] { width: 100%; }
.pick .menu { position: absolute; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 20; max-height: 240px; overflow: auto; font-size: 14px; color: var(--ink); }
.pick .menu div { padding: 6px 10px; cursor: pointer; } .pick .menu div:hover, .pick .menu div.sel { background: var(--accent-2); }
.pick .menu div.none { cursor: default; background: none; }

@media (max-width: 1000px) {
  .grid.two, .grid.three, .grid.main-side, .grid.main-side.wide { grid-template-columns: minmax(0, 1fr); }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  nav.rail { position: sticky; top: 0; z-index: 30; height: auto; max-height: 100vh; padding: 8px 16px; border-right: none; border-bottom: 1px solid var(--line); }
  nav.rail .brand { padding: 4px 0; }
  nav.rail .rail-btns { display: flex; }
  nav.rail .links, nav.rail .search-hint, nav.rail .spacer, nav.rail .who { display: none; }
  nav.rail.open .links { display: flex; padding: 6px 0 4px; }
  main { padding: 16px 16px 60px; }
}
@media (max-width: 600px) {
  .form { grid-template-columns: minmax(0, 1fr); }
  input[type=search] { min-width: 0; flex: 1 1 100%; }
  .bar select { max-width: 100%; }
  .dl { grid-template-columns: 100px minmax(0, 1fr); }
  #palette { padding-top: 8px; } #palette .box { width: calc(100vw - 16px); max-height: 92vh; }
  h1 { font-size: 22px; }
}

[hidden] { display: none !important; }

/* email capture: rail count, in/out marker, mailbox tag, set-up steps, inbox */
nav.rail .links a .count { font-size: 11px; line-height: 16px; color: var(--accent); background: var(--accent-2); border-radius: 10px; padding: 0 7px; font-weight: 600; }
nav.rail .links a.active .count { background: #fff; }
.mk { display: inline-block; font: 600 10px/15px var(--mono); text-transform: uppercase; letter-spacing: .04em; padding: 0 5px; border: 1px solid var(--ink-3); border-radius: 4px; color: var(--ink-2); background: #fff; }
.mk.out { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }
.mbox { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 10px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.timeline .att { font-size: 12px; color: var(--ink-3); margin-top: 4px; overflow-wrap: anywhere; }
.panel.alert { border-color: #f0d3c4; background: var(--warn-bg); color: var(--warn); padding: 10px 16px; }
.ok-text { color: var(--ok); }
.list.mailboxes li { align-items: flex-start; padding: 10px 0; flex-wrap: wrap; }
.list.mailboxes li > span:first-child { flex: 1 1 240px; }
.list.mailboxes li > span:first-child > div { margin-top: 2px; }
.list.sugs li { align-items: center; }
ol.steps { margin: 12px 0; padding-left: 22px; display: grid; gap: 10px; }
ol.steps li { padding-left: 4px; overflow-wrap: anywhere; }
ol.steps .btn { white-space: normal; max-width: 100%; }
ol.steps .hint { margin-top: 3px; }
ol.steps details { margin-top: 6px; }
ol.steps details summary { cursor: pointer; color: var(--accent); }
ol.steps textarea { min-height: 180px; margin-top: 6px; font-size: 11px; white-space: pre; overflow-wrap: normal; }
.mail-wait { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; background: var(--bg); font-size: 13px; color: var(--ink-2); }
.mail-wait.ok { border-color: #cfe5d7; background: var(--ok-bg); color: var(--ok); }
.mail-wait.warn { border-color: #f0d3c4; background: var(--warn-bg); color: var(--warn); }
.mail-wait:empty { display: none; }
td.c-mail { min-width: 200px; max-width: 460px; } td.c-why { min-width: 150px; }
td.c-mail .subject { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.snip { color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  table.inbox, table.inbox tbody, table.inbox tr, table.inbox td { display: block; }
  table.inbox tr:first-child { display: none; }
  table.inbox tr { padding: 10px 0; border-bottom: 1px solid var(--line-2); }
  table.inbox tr:last-child { border-bottom: none; }
  table.inbox td { border: none; padding: 2px 0; min-width: 0; max-width: none; }
  table.inbox td.right { text-align: left; padding-top: 8px; }
}

/* Updates from email (suggested deal updates) */
.upd-panel { border-left: 3px solid var(--accent); }
.upd-panel .list li.upd { align-items: flex-start; }
.upd-panel .sub b { color: var(--ink); font-weight: 600; }
.upd-panel .ev { font-style: normal; margin-top: 2px; }
.upd-panel .acts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 600px) { .upd-panel .list li.upd { flex-direction: column; } .upd-panel .acts { justify-content: flex-start; margin-top: 6px; } }

/* Person types (docs/TYPES.md): one colour per group, the same on chips, the People page groups and the Type picker. */
.tchip { display: inline-block; padding: 0 7px; border-radius: 10px; font-size: 11px; line-height: 18px; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.tchip.t-deal { background: var(--accent-2); color: var(--accent); }
.tchip.t-capital { background: var(--ok-bg); color: var(--ok); }
.tchip.t-service { background: #efeaf6; color: #563d7c; }
.tchip.t-trade { background: #f7eedf; color: #7a4f0f; }
.typebar { display: grid; gap: 6px; margin: -4px 0 12px; }
.typebar .tg, .tpick .tg { display: flex; gap: 10px; align-items: baseline; }
.typebar .tg-l, .tpick .tg-l { flex: 0 0 72px; font-size: 11px; color: var(--ink-3); }
.tpick .tg { margin-top: 4px; }
.chip .n { color: var(--ink-3); font-size: 11px; margin-left: 2px; } .chip.on .n { color: #dbe4ef; }
@media (max-width: 600px) {
  .typebar .tg, .tpick .tg { flex-direction: column; gap: 3px; }
  .typebar .tg-l, .tpick .tg-l { flex-basis: auto; }
}

/* Inbox: one card per company (inboxCard). */
.igroup .ig-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-bottom: 4px; }
.igroup .ig-head label { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--ink-3); }
.igroup .ig-co input { width: 240px; } .igroup .ig-type { width: 190px; }
.igroup .ig-n { flex: 1; min-width: 140px; padding-bottom: 6px; }
.igroup .list li .acts { display: flex; gap: 4px; align-items: flex-start; }
@media (max-width: 600px) {
  .igroup .ig-head label { flex: 1 1 100%; } .igroup .ig-co input, .igroup .ig-type { width: 100%; }
  .igroup .list li { flex-direction: column; gap: 6px; }
}
