:root {
  --ink: #141414; --paper: #fff; --mist: #f4f4f4; --line: #e2e2e2; --dim: #6e6e6e;
  --brand-font: "Century Gothic", Futura, Montserrat, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--mist); color: var(--ink); font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; display: flex; min-height: 100vh; flex-direction: column; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; width: 100%; }
a { color: inherit; }

.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 28px; padding-top: 10px; padding-bottom: 10px; }
.brand img { height: 42px; display: block; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .12em; font-size: 11px; color: var(--dim); text-decoration: none; padding: 7px 11px; border-radius: 6px; }
.topbar nav a:hover { color: var(--ink); background: var(--mist); }
.who { text-align: right; font-size: 13px; }
.who .signout { display: block; font-size: 11px; color: var(--dim); }

main { flex: 1; padding: 32px 0 48px; }
.botbar { background: var(--ink); color: rgba(255,255,255,.65); font-family: var(--brand-font); font-size: 10.5px; letter-spacing: .12em; }
.botbar .wrap { padding: 12px 20px; }

h1.h1 { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .2em; font-size: 19px; margin: 0 0 22px; }
h2.h2 { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .12em; font-size: 12.5px; margin: 0 0 14px; }

.grid { display: grid; grid-template-columns: 2fr 1fr; gap: 22px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
a.card { text-decoration: none; display: block; }
a.card:hover { border-color: var(--ink); }
.stat { font-family: var(--brand-font); font-size: 30px; font-weight: 700; }
.statlabel { color: var(--dim); font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--dim); font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
@media (hover: hover) { tr:hover td { background: var(--mist); } }
td a { text-decoration: underline; text-underline-offset: 2px; }

.label { display: block; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px; margin: 0 0 4px; }
.input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit; background: var(--paper); }
.input:focus, select:focus, textarea:focus { outline: 1px solid var(--ink); }
.field { margin-bottom: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn { display: inline-block; background: var(--ink); color: #fff; border: 0; border-radius: 6px; padding: 9px 16px; font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.btn:hover { opacity: .85; }
.btn[disabled] { opacity: .4; cursor: default; }
.btn-ghost { display: inline-block; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 9px 16px; font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.btn-ghost:hover { background: var(--mist); }
.wfull { width: 100%; }

.badge { display: inline-block; border: 1px solid var(--line); border-radius: 4px; color: var(--dim); font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; padding: 2px 7px; }
.dim { color: var(--dim); }
.err { color: #b42318; font-size: 13px; }
.ok { color: #1a7f37; font-size: 13px; }

.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 56px 20px; min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; cursor: pointer; transition: .15s; }
.drop:hover, .drop.over { border-color: var(--ink); background: var(--mist); }
.drop.over { box-shadow: inset 0 0 0 2px var(--ink); }
.drop .t { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .12em; font-size: 13px; }
.drop .t::before { content: "⬇"; display: block; font-size: 22px; margin-bottom: 8px; color: var(--dim); }
.drop .s { color: var(--dim); font-size: 12px; margin-top: 6px; max-width: 340px; }

.fieldsgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-height: 420px; overflow: auto; padding-right: 4px; margin: 14px 0; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.space > * + * { margin-top: 22px; }
.login-card { max-width: 380px; margin: 10vh auto; }
.login-logo { display: block; margin: 6px auto 18px; height: 64px; }
.login-sub { text-align: center; color: var(--dim); font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .15em; font-size: 11px; margin-bottom: 20px; }

.badge-edited { border-color: #b45309; color: #b45309; }
tr.gen-old td { background: #fafafa; font-size: 12.5px; }
.linklike { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* ---- deal checklist ---- */
.checklist { list-style: none; margin: 0 0 12px; padding: 0; }
.checklist li { display: flex; align-items: baseline; gap: 9px; padding: 6px 2px; border-bottom: 1px solid var(--mist); font-size: 13.5px; }
.checklist li:last-child { border-bottom: 0; }
.checklist input[type="checkbox"] { transform: translateY(2px); accent-color: var(--ink); cursor: pointer; flex: none; }
.chk-main { flex: 1; min-width: 0; }
.checklist li.sub { margin-left: 26px; font-size: 13px; }
.chk-count { color: var(--dim); font-size: 11px; margin-left: 7px; }
.chk-docs { font-size: 11.5px; margin-top: 1px; color: var(--dim); }
.chk-docs a { color: inherit; }
.kind-saved { color: #1a7f37; font-size: 11px; white-space: nowrap; }
.checklist li.done .chk-label { color: var(--dim); text-decoration: line-through; }
.chk-meta { color: var(--dim); font-size: 11px; white-space: nowrap; }
.chk-del { color: var(--dim); text-decoration: none; padding: 0 4px; visibility: hidden; }
.checklist li:hover .chk-del { visibility: visible; }
.chk-del:hover { color: #b42318; }
.chk-add { display: flex; gap: 8px; }
.chk-add .input { flex: 1; }

/* ---- document type editing + staged uploads ---- */
.kind-sel { width: auto; max-width: 190px; font-size: 11px; padding: 3px 6px; color: var(--dim); border: 1px solid var(--line); border-radius: 4px; background: var(--paper); font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .06em; }
.flash-ok { outline: 2px solid #1a7f37; }
.staged-panel { border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.staged-panel .t { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .1em; font-size: 12px; margin: 0 0 12px; word-break: break-word; }

/* ================= v2: dates, pipeline, tabs, timeline, mobile ================= */

/* toast */
.pt-toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 16px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; }
.pt-toast.show { opacity: 1; transform: translate(-50%, 0); }
.pt-toast.err { background: #b42318; }
.pt-toast.ok { background: #1a7f37; }

/* urgency pills */
.due-pill { display: inline-block; border-radius: 4px; font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; padding: 2px 7px; white-space: nowrap; border: 1px solid transparent; }
.due-overdue, .due-today { background: #fbe9e5; color: #a02c18; border-color: #eecfc7; }
.due-soon { background: #fdf1df; color: #99551b; border-color: #f0dcbc; }
.due-week { background: #faf6e0; color: #7d6a1a; border-color: #ece2b8; }
.due-later { background: var(--mist); color: var(--dim); border-color: var(--line); }
.due-done { background: #e8f2e9; color: #1a7f37; border-color: #cfe5d3; }

/* status badges */
.badge.st-prospect { border-color: var(--line); color: var(--dim); }
.badge.st-active { border-color: #b7d9bd; color: #1a7f37; background: #f0f7f1; }
.badge.st-under_contract { border-color: #ecd4ab; color: #99551b; background: #fdf6ea; }
.badge.st-closed { border-color: var(--ink); color: var(--ink); }
.badge.st-dead { border-color: var(--line); color: var(--dim); text-decoration: line-through; }

/* progress bars */
.pbar { width: 100%; max-width: 110px; height: 6px; background: var(--mist); border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.pbar span { display: block; height: 100%; background: var(--ink); border-radius: 99px; }

/* tabs on list pages */
.tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin: 0 0 18px; }
.tab { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .1em; font-size: 11px; color: var(--dim); text-decoration: none; padding: 7px 12px; border-radius: 99px; border: 1px solid transparent; }
.tab:hover { color: var(--ink); background: var(--paper); }
.tab.on { color: var(--ink); background: var(--paper); border-color: var(--line); font-weight: 700; }
.tab-n { opacity: .55; font-weight: 400; margin-left: 2px; }
.tab-search { margin-left: auto; max-width: 260px; border-radius: 99px; padding: 7px 14px; }

/* dashboard */
.statcard { text-decoration: none; color: inherit; display: block; }
.statcard:hover { border-color: var(--ink); }
.statsub { color: var(--dim); font-size: 12px; margin-top: 6px; }
.card.attn { border-left: 3px solid #a02c18; }
.duelist { list-style: none; margin: 0; padding: 0; }
.duelist li { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--mist); font-size: 14px; }
.duelist li:last-child { border-bottom: 0; }
.duelist .due-what { flex: 1; min-width: 0; }
.duelist .due-deal { color: var(--dim); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

/* critical dates card */
.datelist { list-style: none; margin: 0 0 12px; padding: 0; }
.datelist li { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--mist); font-size: 13.5px; }
.datelist li:last-child { border-bottom: 0; }
.datelist li.empty { border: 0; font-size: 13px; }
.datelist li.done .dt-label { color: var(--dim); text-decoration: line-through; }
.datelist input[type="checkbox"] { accent-color: var(--ink); cursor: pointer; flex: none; }
.datelist .dt-label { flex: 1; min-width: 0; cursor: pointer; }
.datelist .dt-label:hover { text-decoration: underline; text-underline-offset: 2px; text-decoration-style: dotted; }
.datelist li.editing { gap: 6px; }
.datelist li.editing .input { padding: 5px 8px; font-size: 13px; }
.datelist li.editing input[type="date"] { max-width: 150px; }
.date-add { display: grid; grid-template-columns: 1fr; gap: 8px; }
.date-add .daterow { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chiplet { border: 1px solid var(--line); background: var(--paper); color: var(--dim); border-radius: 99px; padding: 3px 10px; font-size: 11px; font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .06em; cursor: pointer; }
.chiplet:hover { color: var(--ink); border-color: var(--ink); }

/* checklist v2 */
.chk-row1 { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chk-row1 .chk-label { flex: 0 1 auto; }
.chk-caret { border: 0; background: none; cursor: pointer; padding: 0 2px; width: 14px; flex: none; position: relative; top: 1px; }
.chk-caret::before { content: "▾"; color: var(--dim); font-size: 11px; }
.chk-caret.closed::before { content: "▸"; }
.chk-assignee { background: var(--ink); color: #fff; border-radius: 99px; font-size: 9.5px; font-weight: 700; padding: 2px 6px; letter-spacing: .05em; }
.chk-plan { display: flex; gap: 6px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.chk-plan[hidden] { display: none; }
.chk-plan .input { padding: 5px 8px; font-size: 12.5px; width: auto; }
.chk-plan select { max-width: 160px; }
.chk-planbtn { font-size: 12px; text-decoration: none; }

/* deal terms card */
.termstable { width: 100%; }
.termstable td { padding: 5px 6px 5px 0; vertical-align: top; font-size: 13px; border-bottom: 1px solid var(--mist); }
.termstable tr:last-child td { border-bottom: 0; }
.termstable .tk { color: var(--dim); width: 42%; }
.termstable .tv { word-break: break-word; }
.termstable .ta { white-space: nowrap; text-align: right; font-size: 11.5px; }
.termstable .ta a { color: var(--dim); }
.termstable .term-clear { text-decoration: none; padding: 0 3px; }
.termstable .term-clear:hover { color: #b42318; }
.termstable .input { padding: 4px 7px; font-size: 13px; }

/* working group */
.wg-row { margin: 0 0 12px; line-height: 1.55; }
.wg-row .badge { margin-right: 4px; }

/* activity timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--mist); font-size: 13.5px; }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { flex: none; width: 18px; text-align: center; color: var(--dim); font-size: 12px; }
.tl-text { flex: 1; min-width: 0; }
.tl-meta { color: var(--dim); font-size: 11.5px; white-space: nowrap; }

/* extraction humanized */
.kv td { padding: 4px 8px 4px 0; font-size: 13.5px; border-bottom: 1px solid var(--mist); vertical-align: top; }
.kv tr:last-child td { border-bottom: 0; }

/* header meta strip on deal page */
.dealmeta { line-height: 2; }

/* ---- responsive: phones & small tablets ---- */
@media (max-width: 860px) {
  .grid, .grid3 { grid-template-columns: 1fr; }
  .grid > *, .grid3 > *, .space > * { min-width: 0; }
  .wrap { padding: 0 14px; }
  .topbar .wrap { flex-wrap: wrap; gap: 10px 16px; padding-top: 12px; padding-bottom: 8px; }
  .topbar nav { order: 3; flex-basis: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .checklist li, .datelist li { flex-wrap: wrap; }
  .chk-meta, .tl-meta { white-space: normal; }
  .chk-main, .chk-label, .tl-text, .dt-label { min-width: 0; overflow-wrap: anywhere; }
  .chk-docs a { overflow-wrap: anywhere; }
  .kind-sel { max-width: 140px; }
  .topbar nav a { padding: 7px 9px; white-space: nowrap; }
  .who { margin-left: auto; }
  .card { padding: 16px; }
  .card > table { display: block; overflow-x: auto; }
  .row2 { grid-template-columns: 1fr; }
  .tab-search { margin-left: 0; flex-basis: 100%; max-width: none; }
  .date-add { grid-template-columns: 1fr; }
  .date-add input[type="date"] { max-width: none; }
  .duelist li { flex-wrap: wrap; }
  .duelist .due-deal { max-width: none; }
  .btn, .btn-ghost { padding: 11px 16px; }
  .drop { padding: 36px 14px; min-height: 120px; }
  h1.h1 { font-size: 22px; }
}

/* ================= v3: council polish ================= */
.quiet { color: inherit; }
.prep-cta { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.prep-cta .btn { flex: none; white-space: nowrap; }
.chk-sect { font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; font-weight: 700; }
.checklist li:has(.chk-sect) { background: var(--mist); margin: 4px -8px 0; padding: 7px 8px; border-radius: 6px; border-bottom: 0; }
.auto-badge { display: inline-block; border: 1px solid var(--line); border-radius: 3px; color: var(--dim); font-family: var(--brand-font); text-transform: uppercase; letter-spacing: .08em; font-size: 8.5px; padding: 0 4px; vertical-align: 1px; }
.chk-donebar { border-bottom: 1px solid var(--mist); padding: 6px 0; font-size: 12px; }
.chk-donebar a { color: var(--dim); text-decoration: none; }
.chk-donebar a:hover { color: var(--ink); }
.staged-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.staged-row { display: grid; grid-template-columns: 1fr 200px; gap: 10px; align-items: center; }
.staged-row .staged-name { font-size: 13px; overflow-wrap: anywhere; }
.staged-row .input { padding: 6px 8px; font-size: 12.5px; }
.docrow-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.relrow { margin-top: 6px; }
.ics-link { font-size: 11px; font-weight: normal; text-transform: none; letter-spacing: 0; margin-left: auto; }

/* dashboard statcards align even when empty */
.statsub:empty::before { content: "—"; color: var(--dim); }

@media (max-width: 860px) {
  .staged-row { grid-template-columns: 1fr; }
  .prep-cta { flex-direction: column; align-items: stretch; }
  /* transactions table becomes cards */
  #txn-table { display: block; }
  #txn-table tbody, #txn-table tr { display: block; }
  #txn-table tr:first-child { display: none; } /* header row */
  #txn-table tr.txn-row { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
  #txn-table td { display: inline-block; border: 0; padding: 2px 10px 2px 0; vertical-align: top; background: transparent !important; }
  #txn-table td:first-child { display: block; padding-bottom: 4px; }
  #txn-table .pbar { max-width: 90px; display: inline-block; vertical-align: middle; }
}
