:root {
  --bg: #F3F5F2; --card: #FFFFFF; --ink: #17201B; --muted: #5B6A61; --line: #DCE3DD;
  --accent: #1E7A58; --accent-ink: #FFFFFF; --soft: #E5F1EB; --warn: #6B4000; --warn-soft: #FFF3DD;
  --blue: #0B4F94; --blue-soft: #E6F0FA; --danger: #A63A1E; --chip: #EEF2EE; --bar: #3D9670;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1411; --card: #161E1A; --ink: #E3EBE6; --muted: #98A89F; --line: #2A352F;
    --accent: #3FB386; --accent-ink: #08130E; --soft: #1C2D25; --warn: #F0B35C; --warn-soft: #2B2416;
    --blue: #8CC2F5; --blue-soft: #17263A; --danger: #F08A6C; --chip: #202A25; --bar: #3FB386;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg);
  color: var(--ink); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.hide { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }

header.bar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
  padding-top: env(safe-area-inset-top); }
header.bar .in { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
nav.top { display: flex; gap: 4px; flex-wrap: wrap; }
nav.top a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
nav.top a.on { background: var(--soft); color: var(--accent); font-weight: 600; }
.who { margin-left: auto; font-size: 13px; color: var(--muted); }

main { max-width: 1240px; margin: 0 auto; padding: 22px 16px 60px; display: flex; flex-direction: column; gap: 18px; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.head .grow { flex: 1 1 320px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.cols .main { flex: 999 1 600px; min-width: 0; }
.cols .side { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

button, .btn { font: inherit; font-weight: 600; line-height: 1.2; padding: 11px 16px; border-radius: 10px; border: 0;
  background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
button.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: var(--card); color: var(--danger); border: 1px solid var(--line); }
button.chip { min-height: 36px; padding: 6px 12px; border-radius: 99px; font-size: 13px; background: var(--card);
  color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.chip.on { background: var(--soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
button:disabled { opacity: 0.55; }
.full { width: 100%; }
input[type=search], input[type=text], input[type=email], textarea, select {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { resize: vertical; min-height: 84px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.funnel { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.funnel .st { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.funnel .nm { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel .well { height: 96px; background: var(--chip); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; }
.funnel .fill { width: 100%; background: var(--bar); border-radius: 8px 8px 0 0; min-height: 3px; }
.funnel b { font-size: 20px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.list { padding: 0; overflow: hidden; }
.scroll { overflow-x: auto; }
table { width: 100%; min-width: 700px; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 10px 12px; }
td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 18px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--chip); }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--accent); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.av.big { width: 54px; height: 54px; font-size: 19px; }
.nm-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.nm-cell a { color: var(--ink); text-decoration: none; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: var(--soft); color: var(--accent); }
.tag.stalled, .tag.due { background: var(--warn-soft); color: var(--warn); }
.tag.you { background: var(--blue-soft); color: var(--blue); }
.tag.side { background: var(--chip); color: var(--muted); font-weight: 500; }
.empty { padding: 30px 18px; text-align: center; color: var(--muted); }

.steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.steps li { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.steps li i { display: block; height: 7px; border-radius: 4px; background: var(--line); }
.steps li.done { color: var(--ink); font-weight: 600; }
.steps li.done i { background: var(--accent); }
ol.tl { list-style: none; margin: 0; padding: 0; }
ol.tl li { display: flex; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
ol.tl li:first-child { border-top: 0; }
ol.tl .when { width: 88px; flex: none; font-size: 13px; color: var(--muted); }
ol.tl .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); margin-top: 6px; flex: none; }
ol.tl .dot.app { background: var(--accent); }
ol.tl .dot.fb { background: var(--blue); }
ol.tl .dot.you { background: var(--warn); }
ol.tl .what { flex: 1 1 auto; min-width: 0; }
ol.tl .src { font-size: 12px; color: var(--muted); white-space: nowrap; }
.sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 8px 0; border-top: 1px solid var(--line); }
ul.plain li:first-child { border-top: 0; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: var(--card); color: var(--ink);
  width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; max-width: 90vw; }

.gate { max-width: 420px; margin: 12vh auto 0; text-align: center; display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.gate img { width: 64px; height: 64px; margin: 0 auto; border-radius: 16px; }
ol.wsteps { text-align: left; margin: 0; padding-left: 20px; color: var(--muted); }
ol.wsteps li.now { color: var(--ink); font-weight: 600; }
ol.wsteps li.done { color: var(--accent); }

@media (max-width: 640px) {
  .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .who { display: none; }
}

.card.helper { padding: 14px; margin-top: 10px; background: var(--bg); }
fieldset.perms { border: 0; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
fieldset.perms label { min-height: 36px; font-size: 14px; }
fieldset.perms input, .card input[type=checkbox] { width: 20px; height: 20px; }
