:root {
  --ink: #1d2733; --muted: #5f6b7a; --faint: #8a95a3; --line: #e2e6ea; --line-2: #d3d9df;
  --bg: #f6f7f9; --surface: #ffffff; --accent: #1f5f8b; --accent-ink: #ffffff; --accent-soft: #e8f0f7;
  --warn-bg: #fff6e0; --warn-line: #f0d48a; --warn-ink: #6b4d00;
  --err-bg: #fdecec; --err-line: #f1b5b5; --err-ink: #8a1f1f;
  --ok-bg: #e9f6ee; --ok-line: #b5dcc3; --ok-ink: #1d5b35;
  --lock: #7a4e9c; --radius: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); font-size: 15px; line-height: 1.45;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; font-weight: 650; }
h3 { font-size: .95rem; margin: 1rem 0 .4rem; font-weight: 650; }
p { margin: .3rem 0 .7rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }

/* top bar */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 1.2rem; min-height: 54px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--ink); letter-spacing: .01em; }
.nav { display: flex; gap: .2rem; flex-wrap: wrap; }
.nav a { padding: .45rem .7rem; border-radius: var(--radius); color: var(--muted); font-weight: 550; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a:hover { text-decoration: none; color: var(--ink); }
.who { margin-left: auto; display: flex; gap: .8rem; align-items: center; font-size: .9rem; color: var(--muted); }
.who form { display: inline; }
.devbar { background: #3b2b00; color: #ffe8a3; text-align: center; font-size: .82rem; padding: .3rem 16px; }

main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head .sub { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card.tight { padding: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid2, .grid3 { grid-template-columns: 1fr; } }

/* flash */
.flash { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: .6rem; border: 1px solid var(--ok-line); background: var(--ok-bg); color: var(--ok-ink); }
.flash.error { border-color: var(--err-line); background: var(--err-bg); color: var(--err-ink); }
.flash.warn, .notice { border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn-ink); }
.notice { padding: .65rem .9rem; border-radius: var(--radius); margin: .5rem 0; }
.policy { border: 1px solid #d8c8e6; background: #f6f0fb; color: #4a2d63; padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: .88rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.overdue { color: var(--err-ink); font-weight: 600; }

/* forms */
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink); margin: .55rem 0 .2rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 500; margin: .2rem .9rem .2rem 0; }
input[type=text], input[type=email], input[type=url], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line-2); border-radius: var(--radius); font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc3e4; border-color: var(--accent); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0 12px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: .2rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .9rem .8rem; margin: .8rem 0; }
legend { font-weight: 650; font-size: .9rem; padding: 0 .3rem; }

.btn, button { display: inline-block; padding: .5rem .95rem; border-radius: var(--radius); border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.small, button.small { padding: .25rem .6rem; font-size: .85rem; font-weight: 550; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 550; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.actions-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .8rem; }

/* filters */
.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 8px; }
.filters .more { display: contents; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } .filters .q { grid-column: 1 / -1; } }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .2rem 0 .8rem; }
.chip { padding: .25rem .65rem; border: 1px solid var(--line-2); border-radius: 999px; font-size: .85rem; color: var(--muted); background: #fff; }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.pill { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef1f4; color: #3e4a57; white-space: nowrap; }
.pill.s-ready-to-approach { background: #e6f0fa; color: #1f4f7a; }
.pill.s-contacted, .pill.s-in-conversation { background: #e7f5ef; color: #1d5b35; }
.pill.s-ready-for-handover { background: #fff1d6; color: #6b4d00; }
.pill.s-handed-over { background: #ece7f6; color: #4a2d63; }
.pill.s-archived { background: #f0f0f0; color: #777; }
.lock { color: var(--lock); font-size: .78rem; font-weight: 650; white-space: nowrap; }
.tag { display: inline-block; font-size: .78rem; padding: .05rem .4rem; border-radius: 4px; background: #f1f3f5; color: #4b5563; margin: 0 .2rem .2rem 0; }

dl.kv { display: grid; grid-template-columns: 170px 1fr; gap: .35rem .8rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; }
@media (max-width: 600px) { dl.kv { grid-template-columns: 1fr; } dl.kv dt { margin-top: .4rem; } }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line-2); padding: .1rem 0 .9rem 1rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .45rem; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline .meta { font-size: .85rem; color: var(--muted); }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: .6rem; }
pre.md { white-space: pre-wrap; background: #fafbfc; border: 1px solid var(--line); padding: 12px; border-radius: var(--radius); font-size: .88rem; }
.pager { display: flex; gap: .4rem; align-items: center; justify-content: flex-end; padding: .6rem .8rem; }
.empty { color: var(--muted); padding: .6rem 0; }
.stat { font-size: 1.6rem; font-weight: 650; }

/* compact list → cards on small screens */
@media (max-width: 760px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: .5rem .2rem; }
  table.stack td { border: 0; padding: .15rem .6rem; }
  table.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .who { margin-left: 0; width: 100%; justify-content: space-between; padding-bottom: .4rem; }
}
.hide { display: none !important; }
.narrow { max-width: 460px; margin: 60px auto; }
.inline-form { display: inline; }
.overdue, td[data-label="Due"] { white-space: nowrap; }
.small-link { font-size: .82rem; color: var(--accent); font-weight: 550; }
.inline-details { text-align: left; margin-top: .3rem; }
.inline-details form { display: grid; gap: .3rem; margin-top: .3rem; }
@media (max-width: 760px) { table.stack td[data-label].blank { display: none; } }
@media (min-width: 901px) { .grid2.coord-first { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); } .grid2.coord-first > :first-child { order: 2; } }
details.more { margin: .8rem 0; }
