:root {
  --bg: #f6f1e8;
  --surface: #ffffff;
  --surface-2: #efe8dc;
  --surface-3: #faf7f2;
  --border: #e6ddcf;
  --border-strong: #d6cbbb;
  --text: #1c1917;
  --text-2: #44403c;
  --muted: #6b645d;
  --primary: #c2410c;
  --primary-hover: #9a3412;
  --primary-soft: #ffedd5;
  --primary-softer: #fff7ed;
  --green: #137a37;
  --green-dot: #22a447;
  --green-soft: #e5f6ea;
  --orange: #b9450c;
  --orange-dot: #f47b20;
  --orange-soft: #fff0e3;
  --red: #c21f2a;
  --red-soft: #fdebec;
  --slate: #57534e;
  --slate-soft: #ede9e3;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .05);
  --shadow: 0 1px 2px rgba(28, 25, 23, .04), 0 8px 24px rgba(28, 25, 23, .06);
  --shadow-lg: 0 24px 64px rgba(28, 25, 23, .22);
  --radius: 16px;
  --radius-sm: 12px;
  --font: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 68px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid rgba(194, 65, 12, .45); outline-offset: 2px; border-radius: 8px; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.fill { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------ shell */
.shell { display: block; min-height: 100vh; }
.sidebar, .rail { display: none; }
.main { min-width: 0; padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }

.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.page-head .titles { flex: 1; min-width: 0; }
.page-head h1 { margin: 0; font-size: 34px; line-height: 1.1; letter-spacing: -.02em; font-weight: 800; }
.page-head .subtitle { margin: 6px 0 0; font-size: 18px; color: var(--text-2); }
.sync { margin: 6px 0 0; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.sync.is-error { color: var(--red); }
.sync .changed { flex-basis: 100%; }
@media (min-width: 768px) { .sync .changed { flex-basis: auto; } .sync .changed::before { content: '·'; margin-right: 8px; } }
.sync .retry { border: 0; background: none; color: var(--primary); padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.head-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-sm);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.is-spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.refresh-btn-label { display: none; }

/* ------------------------------------------------------------ segmented tabs */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
}
.segmented button {
  min-height: 46px; border: 0; border-radius: 11px; background: transparent; font-size: 17px; font-weight: 500; color: var(--text-2);
}
.segmented button[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 650; }

/* ------------------------------------------------------------ search + filters */
.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%; height: 52px; padding: 0 44px 0 48px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface); font-size: 16px; box-shadow: var(--shadow-sm);
}
.search input::placeholder { color: #8a8178; }
.search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(194, 65, 12, .15); }
.search .clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; display: grid; place-items: center; }

.filters {
  display: flex; gap: 8px; margin: 0 -16px 12px; padding: 2px 16px 4px; overflow-x: auto; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
          mask-image: linear-gradient(90deg, #000 calc(100% - 24px), transparent);
}
.filters::-webkit-scrollbar { display: none; }
.pill {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 15px; white-space: nowrap; box-shadow: var(--shadow-sm);
}
.pill .chev { width: 16px; height: 16px; color: var(--muted); }
.pill.is-active { background: var(--primary-softer); border-color: #fdba74; color: var(--primary); font-weight: 600; }
.pill.is-active .chev { color: var(--primary); }
.pill .pill-value { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

.summary {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); font-size: 15px;
}
.summary strong { color: var(--text); font-size: 17px; margin-right: 4px; }
.summary .week { display: inline-flex; align-items: center; gap: 8px; }
.summary .reset { border: 0; background: none; color: var(--primary); font-weight: 600; padding: 4px 0; }

/* ------------------------------------------------------------ cards */
.cards { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, border-color .2s;
}
.card:hover { box-shadow: var(--shadow); }
.card.is-archived { background: var(--surface-3); }
.card.is-archived .card-title { color: var(--text-2); }
.card.flash { animation: flash 2.4s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px rgba(194, 65, 12, .45); } 100% { box-shadow: var(--shadow-sm); } }
.card-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-meta { flex: 1; min-width: 0; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta .country { color: var(--text-2); }
.badges { display: flex; gap: 6px; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 8px; font-size: 14px; font-weight: 600; line-height: 1.5; }
.badge.new { background: var(--primary-soft); color: var(--primary); }
.badge.archived { background: var(--slate-soft); color: var(--slate); }
.badge svg { width: 14px; height: 14px; }
.fav {
  flex: none; width: 40px; height: 40px; margin: -8px -8px -8px 0; display: grid; place-items: center;
  border: 0; border-radius: 10px; background: none; color: #8a8178;
}
.fav:hover { background: var(--surface-2); }
.fav[aria-pressed="true"] { color: var(--red); }
.fav[aria-pressed="true"] svg { fill: currentColor; }
.card-title { margin: 2px 0 0; font-size: 22px; line-height: 1.22; font-weight: 750; letter-spacing: -.01em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-funding { margin: 0; font-size: 17px; color: var(--text); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-funding.unknown, .muted { color: var(--muted); }
.card-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; font-size: 15px; }
.card-note { margin: 0; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-stage { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.steps { display: inline-flex; gap: 3px; }
.steps i { width: 10px; height: 4px; border-radius: 2px; background: var(--border-strong); }
.steps i.on { background: var(--primary); }

.status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.status svg { width: 18px; height: 18px; }
.status.open { color: var(--green); }
.status.upcoming { color: var(--orange); }
.status.closed { color: var(--slate); }
.status.unclear { color: var(--slate); }
.deadline { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); font-weight: 500; }
.deadline svg { width: 18px; height: 18px; color: var(--muted); }
.deadline.urgent { color: var(--red); background: var(--red-soft); padding: 4px 10px; border-radius: 8px; font-weight: 650; }
.deadline.urgent svg { color: var(--red); }
.deadline.past { color: var(--muted); }

.more-btn {
  margin-top: 6px; min-height: 44px; display: flex; align-items: center; justify-content: center; position: relative;
  border: 1px solid #fed7aa; border-radius: 12px; background: var(--primary-softer); color: var(--primary); font-weight: 600; font-size: 16px; width: 100%;
}
.more-btn:hover { background: var(--primary-soft); }
.more-btn svg { position: absolute; right: 14px; width: 18px; height: 18px; }

/* ------------------------------------------------------------ states */
.state { text-align: center; padding: 40px 20px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--muted); }
.state .state-icon { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--primary); }
.state .state-icon svg { width: 26px; height: 26px; }
.state h3 { margin: 0 0 6px; color: var(--text); font-size: 19px; }
.state p { margin: 0 auto 14px; max-width: 380px; }
.btn { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid #fdba74; background: var(--primary-softer); color: var(--primary); font-weight: 600; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.state.error .state-icon { color: var(--red); background: var(--red-soft); }

.skeleton { pointer-events: none; }
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, #efe8dc 25%, #f8f4ee 50%, #efe8dc 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk, .card.flash, .icon-btn.is-spinning svg { animation: none; } }

/* ------------------------------------------------------------ funnel */
.stage-picker {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 14px; padding: 2px 16px 6px; scrollbar-width: none; scroll-snap-type: x proximity;
}
.stage-picker::-webkit-scrollbar { display: none; }
.stage-chip {
  flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 15px; white-space: nowrap;
}
.stage-chip .num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-size: 12px; font-weight: 700; }
.stage-chip .count { color: var(--muted); font-variant-numeric: tabular-nums; }
.stage-chip[aria-selected="true"] { background: var(--primary-softer); border-color: #fdba74; color: var(--primary); font-weight: 600; }
.stage-chip[aria-selected="true"] .num { background: var(--primary); color: #fff; }
.stage-chip.empty:not([aria-selected="true"]) { color: var(--muted); }
.stage-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 4px 2px 12px; }
.stage-heading h2 { margin: 0; font-size: 20px; }
.stage-heading span { color: var(--muted); font-size: 14px; }

.board { display: none; }
.stage-list { display: grid; gap: 12px; }
.fcard {
  display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.fcard:hover { border-color: #fdba74; box-shadow: var(--shadow); }
.fcard.is-archived { background: var(--surface-3); }
.fcard-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; min-width: 0; }
.fcard-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard-title { font-size: 17px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fcard dl { margin: 0; display: grid; gap: 2px; font-size: 14px; }
.fcard dt { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; margin-top: 6px; }
.fcard dd { margin: 0; color: var(--text-2); overflow-wrap: break-word; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.fcard dd.unset { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------ flags */
.flag { flex: none; width: 34px; height: 24px; border-radius: 5px; overflow: hidden; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); display: block; }
.flag.globe { display: grid; place-items: center; background: var(--primary-softer); color: var(--primary); box-shadow: none; }
.flag.globe svg { width: 16px; height: 16px; }
.fcard .flag { width: 24px; height: 17px; border-radius: 3px; }

/* ------------------------------------------------------------ tabbar (mobile) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border); backdrop-filter: blur(12px);
}
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 13px; color: var(--muted); }
.tabbar button svg { width: 26px; height: 26px; }
.tabbar button[aria-current="page"] { color: var(--primary); font-weight: 650; }
.tabbar button[aria-current="page"] svg.nav-home { fill: currentColor; }

/* ------------------------------------------------------------ sheets / drawers */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(28, 25, 23, .4); animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-lg); animation: up .2s ease-out;
  padding-bottom: env(safe-area-inset-bottom);
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px 20px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 8px 12px 16px; }
.option {
  width: 100%; min-height: 48px; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 0; border-radius: 12px; background: none; text-align: left; font-size: 16px;
}
.option:hover { background: var(--surface-2); }
.option .check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.option[aria-checked="true"] { color: var(--primary); font-weight: 600; }
.option[aria-checked="true"] .check { border-color: var(--primary); background: var(--primary); color: #fff; }
.option .check svg { width: 14px; height: 14px; stroke-width: 3; }
.option .opt-count { margin-left: auto; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }

.detail .sheet-body { padding: 4px 20px 28px; }
.detail { max-height: 94vh; }
.detail-hero { padding: 16px 0 6px; }
.detail-hero .card-top { margin-bottom: 8px; }
.detail-hero h2 { margin: 0 0 10px; font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
.archive-note { margin: 10px 0 4px; padding: 12px 14px; border-radius: 12px; background: var(--slate-soft); color: var(--text-2); font-size: 15px; display: flex; gap: 10px; }
.archive-note svg { color: var(--slate); margin-top: 2px; }
.dsec { padding: 16px 0; border-top: 1px solid var(--border); }
.dsec:first-of-type { border-top: 0; }
.dsec h3 { margin: 0 0 8px; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.dsec p { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-size: 15px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd.unset { color: var(--muted); font-style: italic; }
.links { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.links a {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-3); text-decoration: none; color: var(--primary); font-weight: 500; overflow-wrap: anywhere; word-break: break-word;
}
.links a span { min-width: 0; }
.links a:hover { background: var(--primary-softer); }
.links a svg { width: 18px; height: 18px; flex: none; }
.hist { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; font-size: 15px; }
.hist li { display: flex; gap: 10px; color: var(--text-2); }
.hist time { color: var(--muted); min-width: 130px; font-variant-numeric: tabular-nums; }
.stagebar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 4px 0 12px; }
.stagebar i { height: 6px; border-radius: 3px; background: var(--border); }
.stagebar i.on { background: var(--primary); }

.menu-pop { position: absolute; z-index: 51; min-width: 260px; max-width: 340px; max-height: 60vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu-pop .sheet-head { display: none; }
.menu-pop .sheet-body { padding: 0; }
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: #1c1917; color: #fff; font-size: 15px; box-shadow: var(--shadow-lg);
}

/* ------------------------------------------------------------ rail */
.rail-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.rail-card + .rail-card { margin-top: 20px; }
.rail-card h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 17px; }
.rail-card h2 .all { margin-left: auto; border: 0; background: none; color: var(--primary); font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; gap: 2px; padding: 6px 0; }
.rail-card h2 .all svg { width: 16px; height: 16px; }
.dl-list { list-style: none; margin: 0; padding: 0; }
.dl-list li + li { border-top: 1px solid var(--border); }
.dl-item { width: 100%; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 14px 0; border: 0; background: none; text-align: left; }
.dl-item .d { font-weight: 650; color: var(--text); }
.dl-item .d.urgent { color: var(--red); }
.dl-item .t { font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.dl-item .c { display: block; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-item:hover .t { color: var(--primary); }
.rail-card p { margin: 6px 0 12px; color: var(--text-2); }
.legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; font-size: 15px; }
.rail .exports { display: grid; gap: 8px; margin-top: 4px; }
.dl-link { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--surface-3); border: 1px solid var(--border); text-decoration: none; font-weight: 500; }
.dl-link:hover { background: var(--primary-softer); }

/* ------------------------------------------------------------ tablet / desktop */
@media (min-width: 768px) {
  .tabbar { display: none; }
  .toast { bottom: 24px; }
  .shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 36px 16px 24px;
    background: rgba(255, 255, 255, .55); border-right: 1px solid var(--border);
  }
  .brand { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin: 0 14px 34px; }
  .nav { display: grid; gap: 6px; }
  .nav button { display: flex; align-items: center; gap: 14px; min-height: 50px; padding: 0 16px; border: 0; border-radius: 12px; background: none; font-size: 17px; color: var(--text-2); text-align: left; }
  .nav button svg { width: 24px; height: 24px; }
  .nav button:hover { background: var(--surface-2); }
  .nav button[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
  .nav button[aria-current="page"] svg.nav-home { fill: currentColor; }
  .side-foot { margin-top: auto; display: grid; gap: 4px; }
  .side-foot a, .side-foot button { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px; background: none; color: var(--text-2); font-size: 15px; text-decoration: none; text-align: left; }
  .side-foot a:hover, .side-foot button:hover { background: var(--surface-2); }
  .side-foot .who { padding: 8px 16px; color: var(--muted); font-size: 14px; }
  .main { padding: 36px 32px 48px; }
  .page-head h1 { font-size: 44px; }
  .page-head .subtitle { font-size: 22px; }
  .sync { font-size: 15px; }
  .refresh-btn { width: auto; padding: 0 16px; gap: 8px; display: inline-flex; }
  .refresh-btn-label { display: inline; font-weight: 500; }
  .account-btn { display: none; }
  .segmented { max-width: 540px; }
  .filters { flex-wrap: wrap; overflow: visible; margin: 0 0 14px; padding: 0; -webkit-mask-image: none; mask-image: none; }
  .stage-picker { display: none; }
  .stage-heading { display: none; }
  .stage-list { display: none; }
  .board {
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(232px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px;
    scroll-snap-type: x proximity; overscroll-behavior-x: contain;
  }
  .column { scroll-snap-align: start; min-width: 0; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); border-radius: 16px; padding: 12px; min-height: 260px; }
  .column-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 4px; font-weight: 650; font-size: 15px; }
  .column-head .num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); font-size: 12px; font-weight: 700; flex: none; }
  .column-head .name { flex: 1; min-width: 0; line-height: 1.25; }
  .column-head .count { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
  .column-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 6px; border: 1px dashed var(--border-strong); border-radius: 12px; }
  .column.has-items .column-head .num { background: var(--primary); border-color: var(--primary); color: #fff; }
  .sheet.detail { left: auto; top: 0; bottom: 0; width: min(600px, 92vw); max-height: none; border-radius: 20px 0 0 20px; animation: slide .2s ease-out; }
  @keyframes slide { from { transform: translateX(32px); opacity: .6; } }
  .detail .sheet-body { padding: 4px 28px 32px; }
}
@media (min-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 1320px) {
  .shell { grid-template-columns: 256px minmax(0, 1fr) 380px; }
  .main { padding: 40px 28px 48px 44px; }
  .rail { display: block; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 104px 28px 32px 4px; }
}
@media (min-width: 1320px) {
  .shell.is-funnel { grid-template-columns: 256px minmax(0, 1fr); }
  .shell.is-funnel .rail { display: none; }
}
@media (min-width: 768px) {
  .board { grid-auto-columns: minmax(228px, 1fr); }
}

/* ------------------------------------------------------------ timeline (all widths) */
.timeline { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 8px 0 4px; }
.timeline::before { content: ""; position: absolute; left: 77px; top: 18px; bottom: 0; width: 2px; background: var(--border-strong); }
.tl-row { position: relative; display: grid; grid-template-columns: 64px 26px minmax(0, 1fr); align-items: start; }
.tl-count { display: flex; flex-direction: column; align-items: flex-end; padding-top: 12px; padding-right: 2px; }
.tl-count .num { font-family: "Unbounded", var(--font); font-size: 27px; font-weight: 800; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.tl-count .unit { margin-top: 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: right; }
.tl-row.urgent .num { color: #c2410c; }
.tl-row.far .num, .tl-row.nodate .num, .tl-row.past .num { color: #a8a29e; }
.tl-dot { justify-self: center; position: relative; z-index: 1; width: 14px; height: 14px; margin-top: 18px; border-radius: 50%; background: #57534e; box-shadow: 0 0 0 4px var(--bg); }
.tl-row.urgent .tl-dot, .tl-dot.now { background: #ea580c; }
.tl-row.far .tl-dot, .tl-row.nodate .tl-dot, .tl-row.past .tl-dot { background: #a8a29e; }
.tl-dot.hollow { background: var(--bg); border: 2px dashed #a8a29e; box-shadow: 0 0 0 3px var(--bg); }
.tl-card {
  display: flex; flex-direction: column; gap: 4px; min-width: 0; width: 100%; text-align: left; padding: 14px 16px; border: 0;
  border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(28, 25, 23, .07);
}
.tl-card:active { transform: scale(.99); }
.tl-card.is-archived { background: var(--surface-3); }
.tl-row.past .tl-card { background: transparent; box-shadow: none; border: 1px solid var(--border); }
.tl-when { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.tl-row.urgent .tl-when { color: #c2410c; }
.tl-when .fav-mark { width: 15px; height: 15px; margin-left: auto; color: #e11d48; fill: currentColor; }
.tl-title { font-size: 18px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.tl-sub { font-size: 15px; color: var(--text-2); line-height: 1.35; overflow-wrap: anywhere; }
.tl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tl-tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; }
.tl-tag svg { width: 15px; height: 15px; stroke-width: 2.2; }
.tl-tag.open { background: #dcfce7; color: #166534; }
.tl-tag.upcoming { background: #fef3c7; color: #92400e; }
.tl-tag.unclear { background: #ede9e3; color: #44403c; }
.tl-tag.closed { background: #ede9e3; color: #57534e; }
.tl-tag.archived { background: #e7e5e4; color: #44403c; }
.tl-today, .tl-group { position: relative; display: grid; grid-template-columns: 64px 26px minmax(0, 1fr); align-items: center; min-height: 32px; font-size: 14px; color: var(--muted); }
.tl-group { margin-top: 8px; }
.tl-today .tl-dot, .tl-group .tl-dot { margin-top: 0; }
.tl-label { text-align: right; padding-right: 2px; font-size: 12px; font-weight: 800; letter-spacing: .04em; color: #a8a29e; }
.tl-today .tl-label { color: #c2410c; }
.tl-today > span:last-child, .tl-group > span:last-child { padding-left: 4px; }
.tl-toggle { justify-self: start; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--primary); font-size: 15px; font-weight: 600; }
.tl-toggle svg { width: 18px; height: 18px; }
.tl-empty { margin: 0 0 0 90px; color: var(--muted); }
.timeline .tl-row.flash .tl-card { animation: flash 2.4s ease-out; }


/* ============================================================ fonts (self-hosted, OFL) */
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/onest-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Onest"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("fonts/onest-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("fonts/unbounded-cyrillic-wght-normal.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("fonts/unbounded-latin-wght-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ============================================================ mobile: "Лента времени" */
.m-kicker, .m-only, .dock, .m-search-btn { display: none; }
@media (max-width: 767px) {
  :root {
    --dock-h: 88px;
  }
  body { background: var(--bg); }
  .d-only, .subtitle, .segmented, #view-opps .search, #view-opps .filters, #view-opps .summary, .refresh-btn, .stage-picker, #funnel-filters { display: none !important; }
  .m-only { display: inline; }
  .m-kicker { display: block; margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
  .m-search-btn { display: inline-grid; }
  .shell.is-funnel .m-search-btn { display: none; }
  .main { padding: 18px 16px calc(var(--dock-h) + 28px + env(safe-area-inset-bottom)); }
  .page-head { margin-bottom: 8px; align-items: center; }
  .page-head h1 { font-family: "Unbounded", var(--font); font-size: 25px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
  .sync { font-size: 13px; margin-top: 6px; }
  .icon-btn { border-radius: 50%; border: 0; box-shadow: 0 1px 3px rgba(28, 25, 23, .1); }

  /* dock */
  .dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; gap: 10px; padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
    background: linear-gradient(rgba(246, 241, 232, 0), var(--bg) 30%);
  }
  .dock button { min-height: 56px; border: 0; border-radius: 999px; display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; }
  .dock-main { flex: 1; min-width: 0; justify-content: center; padding: 0 20px; background: #1c1917; color: #fff; box-shadow: 0 6px 18px rgba(28, 25, 23, .25); }
  .dock-main.is-active { justify-content: flex-start; background: #c2410c; }
  .dock-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dock-count { margin-left: auto; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: rgba(255, 255, 255, .22); display: grid; place-items: center; font-size: 14px; }
  .dock-side { flex: none; padding: 0 16px; background: #fff; color: var(--text); box-shadow: 0 2px 8px rgba(28, 25, 23, .14); }
  .dock-side svg, .dock-main svg { width: 20px; height: 20px; }
  .toast { bottom: calc(var(--dock-h) + 12px + env(safe-area-inset-bottom)); }

  /* bottom sheets */
  .sheet { border-radius: 26px 26px 0 0; }
  .sheet .grabber { align-self: center; width: 44px; height: 5px; border-radius: 3px; background: #d6d3d1; margin-top: 8px; }
  .sheet-head { border-bottom: 0; padding: 8px 12px 4px 20px; }
  .sheet-head h2 { font-family: "Unbounded", var(--font); font-size: 21px; font-weight: 800; }
  .filter-sheet { max-height: 92vh; }
  .freset { min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--primary); font-weight: 600; font-size: 15px; }
  .fsheet { padding: 4px 20px 12px; }
  .fsearch { width: 100%; height: 52px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface-3); font-size: 16px; }
  .fsearch:focus { outline: none; border-color: var(--primary); }
  .fsections section { margin-top: 18px; }
  .fsections h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--muted); }
  .fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fwrap { display: flex; flex-wrap: wrap; gap: 8px; }
  .fchip {
    min-height: 48px; padding: 0 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: 14px; border: 2px solid var(--border); background: #fff; font-size: 15px; font-weight: 600; color: var(--text);
  }
  .fwrap .fchip { border-radius: 999px; min-height: 44px; }
  .fchip svg { width: 16px; height: 16px; stroke-width: 3; }
  .fchip.on { background: #1c1917; border-color: #1c1917; color: #fff; }
  .fchip-count { color: var(--muted); font-weight: 500; }
  .fchip.on .fchip-count { color: #d6d3d1; }
  .fsheet-foot { padding: 10px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
  .fshow { width: 100%; min-height: 56px; border-radius: 999px; font-size: 17px; background: #ea580c; border-color: #ea580c; }
  .fshow:hover { background: #c2410c; }

  /* funnel + detail in warm theme */
  .stage-heading h2 { font-family: "Unbounded", var(--font); font-size: 19px; }
  .fcard { border: 0; border-radius: 18px; box-shadow: 0 1px 2px rgba(28, 25, 23, .07); }
  .detail-hero h2 { font-family: "Unbounded", var(--font); font-size: 22px; line-height: 1.25; }
  .state { border-style: solid; border-color: var(--border); }
}
@media (max-width: 400px) {
  .dock { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .dock button { font-size: 15px; gap: 8px; }
  .dock-main { padding: 0 16px; }
  .dock-side { padding: 0 14px; }
}

/* ============================================================ desktop: style E */
.page-head h1, .brand { font-family: "Unbounded", var(--font); }
@media (min-width: 768px) {
  .page-head h1 { font-size: 38px; font-weight: 800; letter-spacing: -.03em; }
  .brand { font-size: 22px; letter-spacing: -.03em; }
  .sidebar { background: transparent; }
  .nav button[aria-current="page"] { background: #1c1917; color: #fff; }
  .nav button:hover:not([aria-current="page"]) { background: var(--surface-2); }
  .segmented { background: var(--surface-2); border-color: transparent; }
  .segmented button[aria-selected="true"] { background: #1c1917; color: #fff; }
  .pill, .search input, .icon-btn { border-color: var(--border); }
  .pill.is-active { background: #1c1917; border-color: #1c1917; color: #fff; }
  .pill.is-active .chev { color: #d6d3d1; }
  .card, .fcard, .rail-card { border: 0; box-shadow: 0 1px 2px rgba(28, 25, 23, .07); border-radius: 18px; }
  .column { background: var(--surface-2); border-radius: 20px; }
  .column.has-items .column-head .num { background: #1c1917; border-color: #1c1917; }
  .timeline { max-width: 920px; gap: 16px; }
  .timeline::before { left: 111px; }
  .tl-row, .tl-today, .tl-group { grid-template-columns: 96px 30px minmax(0, 1fr); }
  .tl-count .num { font-size: 34px; }
  .tl-count .unit { font-size: 13px; }
  .tl-dot { margin-top: 22px; }
  .tl-card { padding: 18px 22px; transition: box-shadow .15s, transform .15s; }
  .tl-card:hover { box-shadow: 0 6px 20px rgba(28, 25, 23, .1); transform: translateY(-1px); }
  .tl-title { font-size: 20px; }
  .tl-empty { margin-left: 126px; }
}

/* ============================================================ readable text + overview */
.bullets { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.bullets li { position: relative; padding-left: 18px; line-height: 1.45; overflow-wrap: anywhere; }
.bullets li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.bullets.compact { gap: 4px; }
.bullets.compact li { padding-left: 14px; }
.bullets.compact li::before { width: 5px; height: 5px; background: var(--muted); }
.bullets.muted li { color: var(--text-2); }
.bullets.muted li::before { background: #a8a29e; }
.bullets a, .dsec p a { color: var(--primary); font-weight: 600; text-underline-offset: 3px; }
.rich { display: grid; gap: 14px; }
.unknowns { padding: 12px 14px; border-radius: 14px; background: var(--surface-2); display: grid; gap: 8px; font-size: 15px; }
.unknowns-h { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.unknowns-h svg { width: 16px; height: 16px; }
.kv dd .bullets.compact { gap: 2px; }
.fcard dd.steps-dd { display: block; -webkit-line-clamp: unset; }

.dfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; margin: 6px 0 4px; }
.dfact { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); min-width: 0; }
.dfact-k { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dfact-v { font-family: "Unbounded", var(--font); font-size: 19px; font-weight: 700; line-height: 1.2; }
.dfact-v.muted { font-family: var(--font); font-size: 17px; font-weight: 600; color: var(--muted); }
.dfact-c { font-weight: 700; color: var(--text-2); }
.dfact.urgent { background: #fff1e6; }
.dfact.urgent .dfact-c, .dfact.urgent .dfact-v { color: #c2410c; }
.dfact-n { font-size: 14px; color: var(--muted); line-height: 1.35; }
.dfact .status { font-size: 17px; }

.overview { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 16px; min-width: 0; }
.overview > * { min-width: 0; }
.hero {
  display: flex; flex-direction: column; gap: 6px; width: 100%; padding: 18px 20px; border: 0; border-radius: 22px; text-align: left;
  background: #1c1917; color: #fff; box-shadow: 0 8px 22px rgba(28, 25, 23, .18);
}
.hero-k { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #fdba74; }
.hero-t { font-family: "Unbounded", var(--font); font-size: 20px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.hero-s { min-width: 0; font-size: 15px; color: #e7e5e4; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.hero-p { flex: none; padding: 7px 12px; border-radius: 999px; background: #fff; color: #1c1917; font-weight: 800; font-size: 14px; }
.hero.urgent .hero-p { background: #ea580c; color: #fff; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 76px; padding: 12px 14px; border: 2px solid transparent;
  border-radius: 18px; background: var(--surface); text-align: left; box-shadow: 0 1px 2px rgba(28, 25, 23, .07);
}
.tile-n { font-family: "Unbounded", var(--font); font-size: 24px; font-weight: 800; line-height: 1.1; }
.tile-l { font-size: 14px; font-weight: 600; color: var(--text-2); line-height: 1.25; }
.tile.open .tile-n { color: #15803d; }
.tile.upcoming .tile-n { color: #b45309; }
.tile.funnel .tile-n { color: var(--text); }
.tile.open.on { border-color: #15803d; background: #f0fdf4; }
.tile.upcoming.on { border-color: #b45309; background: #fffbeb; }
.tile:hover { box-shadow: 0 4px 14px rgba(28, 25, 23, .1); }
@media (min-width: 768px) {
  .overview { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: stretch; max-width: 920px; }
  .overview .tiles { grid-template-columns: 1fr; grid-template-rows: repeat(3, 1fr); gap: 8px; }
  .overview .tile { flex-direction: row; align-items: center; gap: 12px; min-height: 0; padding: 8px 14px; }
  .overview .tile-n { font-size: 20px; min-width: 28px; }
  .hero { justify-content: center; padding: 22px 24px; }
  .hero-t { font-size: 24px; }
}
@media (max-width: 767px) {
  .overview { margin: 6px 0 14px; }
}
@media (max-width: 370px) {
  .tile { padding: 10px; }
  .tile-l { font-size: 13px; }
}
.link-t { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.link-t strong { font-weight: 700; }
.link-t small { font-size: 13px; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) {
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dt { font-size: 13px; margin-top: 10px; }
  .kv dt:first-child { margin-top: 0; }
}
