:root {
  --paper: #F4F3EE; --card: #FFFFFF; --ink: #17171A; --ink-2: #5D5D66; --ink-3: #8E8E98; --line: #E2E1DA; --rail: #17171A;
  --signal: #FFD23F; --signal-d: #8A6A00; --good: #1F8A55; --warn: #B7791F; --bad: #C2412D;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif; --mono: ui-monospace, "SF Mono", Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(26px, 3vw, 38px); font-weight: 800; font-stretch: 112%; letter-spacing: -.03em; line-height: 1; }
h2 { font-size: 15px; font-weight: 700; }
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: calc(100vh - 32px); }

.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; padding: 18px 12px; background: var(--rail); color: #CFCFD6; }
.rail a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: inherit; text-decoration: none; font-weight: 500; }
.rail a i { display: grid; place-items: center; width: 18px; height: 18px; font-style: normal; }
.rail a i svg { width: 18px; height: 18px; }
.rail a b { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--signal); color: var(--ink); font-size: 11px; text-align: center; }
.rail a b:empty { display: none; }
.rail a:hover { background: #24242A; color: #fff; }
.rail a.on { background: var(--signal); color: var(--ink); }
.rail a.on b { background: var(--ink); color: var(--signal); }
.rail .mark { margin-bottom: 18px; color: #fff; font-weight: 800; font-stretch: 120%; font-size: 17px; letter-spacing: -.02em; }
.rail .mark svg { width: 28px; height: 28px; color: var(--signal); }
.rail .mark:hover { background: none; }
.ws { margin-top: auto; padding: 14px; border: 1px solid #2E2E35; border-radius: 10px; display: flex; flex-direction: column; gap: 2px; }
.ws small { color: #8E8E98; font-size: 11px; }
.ws strong { color: #fff; font-weight: 600; font-size: 13px; }
.ws button { margin-top: 10px; padding: 7px; border: 1px solid #3A3A42; border-radius: 7px; background: none; color: #CFCFD6; font-size: 12px; cursor: pointer; }
.ws button:hover { border-color: var(--signal); color: var(--signal); }

.view { min-width: 0; padding: 24px clamp(16px, 2.6vw, 36px) 60px; outline: none; }
.vh { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
.vh p { margin: 6px 0 0; color: var(--ink-2); }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border: 0; border-radius: 9px; background: var(--ink); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #2E2E35; }
.btn.y { background: var(--signal); color: var(--ink); }
.btn.y:hover { background: #FFDD66; }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.card { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); min-width: 0; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-h a, .lnk { color: var(--ink-2); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; cursor: pointer; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12px; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 12px; }
.kpi h3 { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.kpi strong { display: block; margin: 6px 0 2px; font-size: 30px; font-weight: 800; font-stretch: 110%; letter-spacing: -.03em; }
.kpi span { font-size: 12px; color: var(--ink-3); }
.ov { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.ov > div { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.funnel .row { display: grid; grid-template-columns: 90px 1fr 110px; align-items: center; gap: 10px; padding: 6px 0; }
.funnel .bar { height: 20px; border-radius: 0 4px 4px 0; background: var(--ink); min-width: 3px; transition: width .4s; }
.funnel .row:nth-child(4) .bar { background: var(--signal); }
.funnel .v { text-align: right; font-size: 13px; } .funnel .v small { color: var(--ink-3); }
.agenda li, .runs li { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.agenda, .runs { list-style: none; margin: 0; padding: 0; }
.agenda li:first-child, .runs li:first-child { border-top: 0; }
.agenda time { min-width: 60px; font-family: var(--mono); font-size: 12px; color: var(--ink-2); padding-top: 1px; }
.runs li { flex-direction: column; gap: 2px; }
.runs .rn { font-size: 12px; color: var(--ink-3); }
.runs li.fresh { animation: flash 1.6s; }
@keyframes flash { 0% { background: #FFF3C4; } 100% { background: transparent; } }
.simulate { display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 14px; background: var(--ink); color: #fff; }
.simulate p { margin: 0; color: #B9B9C2; font-size: 13px; }

.tbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tbar input, .tbar select, .field input, .field select, .field textarea { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.tbar input { flex: 1; min-width: 200px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: 10px; text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #FAFAF6; }
.tbl .num { text-align: right; }
.who strong { display: block; font-weight: 600; } .who small { color: var(--ink-3); }
.tag { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px; border-radius: 99px; background: #EFEEE8; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tag.hot { background: var(--signal); }
.tag.risk { background: #FBE3DE; color: var(--bad); }
.stage { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.stage::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--s, var(--ink-3)); }
.score { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; }
.score i { position: relative; width: 44px; height: 6px; border-radius: 3px; background: #EFEEE8; overflow: hidden; }
.score i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--ink); border-radius: 3px; }
.tbl-wrap { overflow-x: auto; }
.mlist { display: none; }

.board { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { display: flex; flex-direction: column; gap: 8px; min-height: 240px; padding: 10px; border-radius: 12px; background: #EAE9E2; transition: background .2s; }
.col.over { background: #FFF1B8; }
.col header { display: flex; justify-content: space-between; align-items: baseline; padding: 2px 4px 6px; }
.col header strong { font-size: 13px; }
.col header span { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); }
.deal { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: grab; user-select: none; }
.deal:active { cursor: grabbing; }
.deal.dragging { opacity: .4; }
.deal h3 { font-size: 13.5px; font-weight: 600; }
.deal p { margin: 2px 0 8px; font-size: 12px; color: var(--ink-2); }
.deal footer { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.deal footer b { font-family: var(--mono); font-weight: 600; }
.av { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 10px; font-weight: 700; }
.hint { margin: 0 0 12px; color: var(--ink-2); font-size: 13px; }

.tasks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: start; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.task:first-of-type { border-top: 0; }
.task input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--ink); }
.task p { margin: 0; font-weight: 500; }
.task small { display: block; color: var(--ink-3); font-size: 12px; }
.task.done p { text-decoration: line-through; color: var(--ink-3); }
.task .auto { color: var(--signal-d); font-weight: 600; }
.over-h { color: var(--bad); }

.week { display: grid; grid-template-columns: 54px repeat(7, 1fr); border: 1px solid var(--line); border-radius: 14px; background: var(--card); overflow: hidden; }
.week .dh { padding: 10px 8px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); font-size: 12px; font-weight: 600; }
.week .dh small { display: block; color: var(--ink-3); font-weight: 400; }
.week .dh.today { background: var(--signal); }
.week .hours { position: relative; }
.week .hours span { position: absolute; right: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); transform: translateY(-6px); }
.week .day { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 48px; }
.ev { position: absolute; left: 4px; right: 4px; padding: 5px 7px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 11.5px; line-height: 1.3; overflow: hidden; cursor: pointer; }
.ev.sv { background: var(--signal); color: var(--ink); }
.ev small { display: block; opacity: .75; }

.rules { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; align-items: start; }
.rule { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); margin-bottom: 10px; }
.rule.off { opacity: .6; }
.rule h3 { font-size: 15px; font-weight: 700; }
.rule .flow { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.rule .flow span { padding: 5px 10px; border-radius: 8px; background: #F1F0EA; }
.rule .flow span.then { background: #FFF3C4; }
.rule .flow b { color: var(--ink-3); font-weight: 400; }
.rule .meta { grid-column: 1 / -1; font-size: 12px; color: var(--ink-3); }
.switch { position: relative; width: 44px; height: 26px; border: 0; border-radius: 99px; background: #D4D3CC; cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--signal); }
.builder .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12.5px; font-weight: 600; }
.builder .field input, .builder .field select { width: 100%; font-weight: 400; }
.builder .step { margin: 4px 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(460px, 100vw); overflow: auto; padding: 20px; background: var(--card); box-shadow: -20px 0 60px rgba(0,0,0,.15); transform: translateX(100%); visibility: hidden; transition: transform .35s cubic-bezier(.2,.7,.1,1), visibility .35s; }
.drawer.open { transform: none; visibility: visible; }
.drawer .x { float: right; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #F1F0EA; font-size: 20px; cursor: pointer; }
.drawer h2 { font-size: 24px; font-weight: 800; font-stretch: 110%; margin: 4px 0 2px; }
.drawer section { padding: 14px 0; border-top: 1px solid var(--line); }
.drawer section h3 { margin-bottom: 8px; font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.drawer dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; margin: 0; font-size: 13.5px; }
.drawer dt { color: var(--ink-3); } .drawer dd { margin: 0; }
.drawer select { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.drawer textarea { width: 100%; min-height: 70px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { position: relative; padding: 0 0 12px 18px; border-left: 1px solid var(--line); margin-left: 4px; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--ink); }
.timeline li.a::before { background: var(--signal); box-shadow: 0 0 0 1px var(--signal-d); }
.timeline small { display: block; color: var(--ink-3); }
.scoreparts { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.scoreparts span { padding: 3px 8px; border-radius: 6px; background: #F1F0EA; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(23,23,26,.35); }

dialog { width: min(520px, calc(100vw - 32px)); padding: 22px; border: 0; border-radius: 16px; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(23,23,26,.45); }
dialog h2 { font-size: 22px; font-weight: 800; font-stretch: 110%; margin-bottom: 14px; }
dialog .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12.5px; font-weight: 600; }
dialog .field input, dialog .field select { width: 100%; font-weight: 400; }
dialog .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
dialog .err { color: var(--bad); font-size: 12.5px; min-height: 18px; margin: 0; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: tin .35s cubic-bezier(.2,.7,.1,1); }
.toast i { color: var(--signal); font-style: normal; font-weight: 800; }
@keyframes tin { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, 1fr); } .ov, .rules { grid-template-columns: 1fr; } .tasks { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 30; height: auto; flex-direction: row; justify-content: space-around; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; }
  .rail a { flex-direction: column; gap: 2px; padding: 6px 6px; font-size: 10px; min-width: 52px; }
  .rail a b { position: absolute; margin: -4px 0 0 18px; min-width: 16px; font-size: 9px; padding: 0 4px; }
  .rail a { position: relative; }
  .rail .mark, .ws { display: none; }
  .view { padding-bottom: 100px; }
  .tbl-wrap { display: none; }
  .mlist { display: flex; flex-direction: column; gap: 8px; }
  .mlist button { display: flex; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); text-align: left; cursor: pointer; }
  .mlist .r { text-align: right; flex-shrink: 0; }
  .board { grid-template-columns: repeat(6, 78vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .tasks { grid-template-columns: 1fr; }
  .week { grid-template-columns: 40px repeat(7, minmax(84px, 1fr)); overflow-x: auto; }
  .week-wrap { overflow-x: auto; }
  .toasts { bottom: 84px; }
  .funnel .row { grid-template-columns: 76px 1fr 92px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
