/* Scope — scope and budget by milestone. Layout & app-specific components.
   Оболочка повторяет Codex, чтобы два инструмента студии читались как один. */

/* ---------- shell ---------- */
.shell{display:grid;grid-template-columns:auto minmax(0,1fr);min-height:100vh}
.side{width:264px;border-right:1px solid var(--hair);display:flex;flex-direction:column;
  height:100vh;position:sticky;top:0;background:var(--bg);z-index:20}
.main{min-width:0;display:flex;flex-direction:column}
.topbar{height:56px;border-bottom:1px solid var(--hair);display:flex;align-items:center;gap:12px;padding:0 22px;
  position:sticky;top:0;background:var(--bg);z-index:30}
.topbar .sp{margin-left:auto}
@media(max-width:940px){
  .shell{grid-template-columns:minmax(0,1fr)}
  .side{position:fixed;left:0;top:0;bottom:0;width:min(264px,82vw);transform:translateX(-100%);transition:transform .22s cubic-bezier(.4,0,.2,1);box-shadow:var(--shadow-s)}
  .side.open{transform:none}
}
.burger{display:none}
@media(max-width:940px){.burger{display:inline-flex}}
.side-scrim{position:fixed;inset:0;background:var(--scrim);z-index:19;animation:fadeIn .18s ease}
@media(min-width:941px){.side-scrim{display:none}}
@media(max-width:640px){
  .topbar{gap:8px;padding:0 12px}
  .topbar .filt-in{width:120px}
}

/* ---------- project switcher ---------- */
.proj{display:flex;align-items:center;gap:9px;padding:0 16px;height:56px;border-bottom:1px solid var(--hair);
  width:100%;text-align:left;transition:background .15s}
.proj:hover{background:var(--tint)}
.pop{position:fixed;background:var(--bg);border:1px solid var(--hair2);border-radius:6px;box-shadow:var(--shadow-s);
  padding:6px;z-index:70;min-width:220px;display:flex;flex-direction:column;gap:1px;animation:riseIn .14s cubic-bezier(.4,0,.2,1)}
.pop-i{display:flex;align-items:center;gap:9px;padding:8px 10px;border-radius:4px;text-align:left;width:100%;font-size:13px;transition:background .12s}
.pop-i:hover,.pop-i.cur{background:var(--tint)}
.pop-i.danger{color:var(--red)}
.pop-sep{height:1px;background:var(--hair);margin:5px 2px}
.pop-h{font-size:10px;letter-spacing:.08em;color:var(--mut2);text-transform:uppercase;padding:8px 10px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}

/* ---------- tree (milestones + departments) ---------- */
.tree{flex:1;overflow-y:auto;padding:10px 8px 24px}
.tree::-webkit-scrollbar{width:9px}
.tree::-webkit-scrollbar-thumb{background:var(--hair2);border-radius:9px;border:3px solid var(--bg)}
.t-h{font-size:10px;letter-spacing:.08em;color:var(--mut2);text-transform:uppercase;padding:10px 10px 6px;
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.t-row{display:flex;align-items:center;gap:8px;width:100%;text-align:left;border-radius:6px;padding:6px 10px;
  font-size:13.5px;line-height:1.45;color:var(--mut2);transition:background .12s,color .12s;position:relative}
.t-row:hover{background:var(--tint);color:var(--ink)}
.t-row.on{background:var(--tint2);color:var(--ink)}
.t-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;flex:1}
.t-num{font-size:11px;color:var(--mut);font-variant-numeric:tabular-nums;flex:none;letter-spacing:.01em}
.t-row.on .t-num,.t-row:hover .t-num{color:var(--mut2)}
.t-sub{font-size:11px;color:var(--mut);display:block;margin-top:-1px}
.t-ms{align-items:flex-start;padding:7px 10px}
.t-ms .t-name{display:flex;flex-direction:column;line-height:1.35}
.t-kids{display:grid;grid-template-rows:1fr;margin:2px 0 4px 16px;padding-left:10px;border-left:1px solid var(--hair);
  transition:grid-template-rows .2s cubic-bezier(.4,0,.2,1)}
.t-kids.closed{grid-template-rows:0fr}
.t-kids-in{min-height:0;overflow:hidden}
.t-kids .t-row{font-size:12.5px;padding:4px 8px}
.t-ghost{color:var(--mut);font-size:12.5px}
.t-ghost:hover{color:var(--ink)}
.side-foot{border-top:1px solid var(--hair);padding:10px 14px;display:flex;align-items:center;gap:10px}
.t-row:focus-visible{outline:2px solid var(--ink);outline-offset:-2px;background:var(--tint)}

/* a save that cannot land must be loud */
.storage-warn{position:sticky;top:56px;z-index:35;display:flex;align-items:center;gap:12px;
  background:color-mix(in srgb,var(--red) 12%,var(--bg));border-bottom:1px solid color-mix(in srgb,var(--red) 40%,transparent);
  padding:11px 22px;font-size:13px}
.storage-warn b{font-weight:500;color:var(--red)}

/* ---------- topbar bits ---------- */
.crumbs{display:flex;align-items:center;gap:6px;font-size:12.5px;color:var(--mut2);white-space:nowrap;min-width:0;overflow:hidden}
.crumbs .sep{color:var(--mut);opacity:.55;display:inline-flex}
.crumbs .sep svg{display:block}
.crumbs button{font:inherit;color:inherit;border-radius:3px;padding:1px 4px;margin:-1px -4px;transition:color .14s,background .14s}
.crumbs button:hover{color:var(--ink);background:var(--tint)}
.crumbs .here{color:var(--ink)}
.filt-in{background:var(--surface);border:1px solid var(--hair2);border-radius:5px;padding:6px 10px 6px 28px;font-size:13px;width:200px;
  transition:border-color .18s,box-shadow .18s,width .2s}
.filt-in:focus{outline:none;box-shadow:0 0 0 3px var(--ring);width:260px}
.filt-wrap{position:relative;display:flex;align-items:center}
.filt-wrap .mag{position:absolute;left:10px;color:var(--mut);font-size:12px;pointer-events:none}
.seg{display:inline-flex;border:1px solid var(--hair2);border-radius:5px;overflow:hidden;flex:none}
.seg button{padding:5px 11px;font-size:12.5px;color:var(--mut2);transition:background .14s,color .14s}
.seg button+button{border-left:1px solid var(--hair)}
.seg button.on{background:var(--tint2);color:var(--ink)}
.badge{font-size:10px;letter-spacing:.05em;color:var(--mut2);border:1px solid var(--hair);border-radius:3px;padding:1px 5px;
  text-transform:uppercase;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;flex:none}
.badge.new{color:var(--ember);border-color:color-mix(in srgb,var(--ember) 40%,transparent)}

/* ---------- views ---------- */
.wrap{max-width:1000px;margin:0 auto;padding:32px 40px 90px}
.wide{max-width:1240px;margin:0 auto;padding:30px 32px 120px;width:100%}
@media(max-width:640px){.wide{padding:20px 14px 100px}.wrap{padding:24px 16px 80px}}
.fadein{animation:riseIn .24s cubic-bezier(.4,0,.2,1)}
.title{font-family:'PT Serif',Georgia,serif;font-size:27px;font-weight:700;line-height:1.26;letter-spacing:-.2px;margin:0}
.title-in{font:inherit;background:none;border:0;padding:2px 8px;margin-left:-8px;border-radius:5px;width:100%;max-width:640px;
  color:inherit;outline:none;transition:background .15s}
.title-in:hover,.title-in:focus{background:var(--tint)}
.ms-meta{display:flex;align-items:center;gap:10px;color:var(--mut2);font-size:12px;margin-top:6px;flex-wrap:wrap}
.ms-note{font-size:13.5px;color:var(--mut2);line-height:1.5;margin:8px 0 0;max-width:720px}
.ms-note-in{font:inherit;color:inherit;background:none;border:0;padding:4px 8px;margin-left:-8px;border-radius:5px;width:100%;
  max-width:720px;resize:none;outline:none;line-height:1.5;transition:background .15s;min-height:28px}
.ms-note-in:hover,.ms-note-in:focus{background:var(--tint)}
.ms-note-in::placeholder{color:var(--mut)}

/* summary strip: the numbers that matter, once, above the table */
.strip{display:flex;gap:0;flex-wrap:wrap;margin:22px 0 30px;border:1px solid var(--hair);border-radius:6px;background:var(--surface);overflow:hidden}
.strip .st{display:flex;flex-direction:column;gap:3px;padding:14px 20px;border-right:1px solid var(--hair);min-width:130px;flex:1}
.strip .st:last-child{border-right:0}
.strip .st .v{font-size:22px;letter-spacing:-.4px;line-height:1.1;font-variant-numeric:tabular-nums}
.strip .st .v.dim{color:var(--mut2)}
.strip .st .k{font-size:10px;letter-spacing:.08em;color:var(--mut2);text-transform:uppercase;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.strip .st .d{font-size:11px;color:var(--mut);font-variant-numeric:tabular-nums}
/* рост скоупа между версиями — норма, а не тревога: акцент, не красный */
.up{color:var(--ember)}
.down{color:var(--green)}

/* ---------- department block ---------- */
.dept{margin:0 0 40px;scroll-margin-top:72px}
.dept-head{display:flex;align-items:baseline;gap:12px;padding:0 0 8px;border-bottom:1px solid var(--hair2);margin-bottom:2px}
.dept-head h2{font-size:15px;font-weight:500;margin:0;letter-spacing:-.1px}
.dept-head .hint{font-size:12px}
.dept-head .tot{margin-left:auto;display:flex;gap:16px;font-size:12px;color:var(--mut2);font-variant-numeric:tabular-nums;white-space:nowrap}
.dept-head .tot b{font-weight:500;color:var(--ink)}
.dept.empty .dept-head{border-bottom-color:var(--hair)}
.dept.empty .dept-head h2{color:var(--mut2);font-weight:400}

/* ---------- the grid ----------
   Таблица с настоящими <input> в клетках: Tab ходит по ней как по листу
   Excel, Enter — вниз по колонке, а сумма пересчитывается по мере набора. */
.grid-wrap{overflow-x:auto;margin:0 -8px;padding:0 8px}
.grid{width:100%;border-collapse:collapse;font-size:13px;min-width:780px}
.grid th{text-align:left;font-size:10px;letter-spacing:.08em;color:var(--mut2);text-transform:uppercase;font-weight:400;
  padding:8px 8px 7px;border-bottom:1px solid var(--hair);white-space:nowrap;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}
.grid th.num,.grid td.num{text-align:right}
.grid td{padding:0 8px;border-bottom:1px solid var(--hair);vertical-align:middle;height:34px;font-variant-numeric:tabular-nums}
.grid td.name{padding-left:2px}
.grid tr.it:hover td{background:var(--tint)}
.grid td.calc{color:var(--mut2)}
.grid td.calc.strong{color:var(--ink)}
.grid tr.it.dragging td{opacity:.35}
.grid tr.drop-before td{box-shadow:inset 0 2px 0 var(--ember)}
.grid tr.drop-after td{box-shadow:inset 0 -2px 0 var(--ember)}
.grid col.c-h{width:22px}
.grid col.c-count{width:70px}
.grid col.c-unit{width:78px}
.grid col.c-role{width:172px}
.grid col.c-tot{width:84px}
.grid col.c-days{width:66px}
.grid col.c-cost{width:96px}
.grid col.c-m{width:30px}
/* section header row: name is a real input; totals on the right */
.grid tr.sec td{background:var(--surface);height:36px;border-bottom:1px solid var(--hair);border-top:1px solid var(--hair)}
.grid tr.sec .sec-name{font-weight:500;font-size:13px}
.grid tr.sec td.calc{color:var(--mut2);font-size:12px}
.grid tr.sec:hover .r-menu,.grid tr.it:hover .r-menu{opacity:.55}
.grid tr.sub td{height:28px;border-bottom-color:transparent;font-size:12.5px}
.grid tr.sub + tr.it td,.grid tr.sub + tr.sub td{border-top:0}
.grid tr.it.has-sub td{border-bottom-color:transparent}
.grid tr.sub:last-of-type td,.grid tr.sub.last td{border-bottom-color:var(--hair)}
.grid tr.sub .and{color:var(--mut);font-size:11px;padding-left:24px;letter-spacing:.02em}
/* ghost rows: how you add things — always there, never in the way */
.grid tr.ghost td{height:30px;border-bottom:0}
.grid tr.ghost button{color:var(--mut);font-size:12.5px;padding:3px 6px;border-radius:4px;display:inline-flex;align-items:center;gap:6px}
.grid tr.ghost button:hover{color:var(--ink);background:var(--tint)}
.grid tr.ghost.secg td{height:38px;padding-top:4px}
.grid tr.match-hide{display:none}

/* cells */
.cell{width:100%;background:none;border:0;padding:6px 6px;border-radius:4px;font:inherit;color:inherit;outline:none;
  transition:background .12s,box-shadow .12s;min-width:0}
.cell:hover{background:var(--tint)}
.cell:focus{background:var(--bg);box-shadow:0 0 0 1px var(--hair2),0 0 0 3px var(--ring)}
[data-theme=dark] .cell:focus{background:var(--surface)}
.cell.num{text-align:right;font-variant-numeric:tabular-nums}
.cell::placeholder{color:var(--mut)}
.cell.name{font-size:13.5px}
.cell.sec-name{font-weight:500}
.cell[readonly]{cursor:default}
.cell[readonly]:hover{background:none}
/* value from the previous milestone, greyed under the live one */
.was{display:block;font-size:10px;color:var(--mut);line-height:1;margin:-3px 0 4px;text-align:right;padding-right:6px;font-variant-numeric:tabular-nums;white-space:nowrap}
.was.l{text-align:left;padding:0 0 0 8px}
.cellwrap{display:flex;flex-direction:column;justify-content:center;min-height:34px}
.cellwrap .cell{padding-top:4px;padding-bottom:4px}
/* role chip: reads like text, opens the picker */
.role-chip{display:inline-flex;align-items:center;gap:6px;max-width:100%;padding:4px 8px;border-radius:4px;font-size:12.5px;color:var(--mut2);
  border:1px solid transparent;transition:border-color .14s,color .14s,background .14s;text-align:left}
.role-chip:hover{border-color:var(--hair2);color:var(--ink)}
.role-chip .who{color:var(--ink)}
.role-chip .r{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.role-chip.none{color:var(--mut);font-style:normal}
.r-menu{width:24px;height:24px;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;color:var(--mut2);
  opacity:0;transition:opacity .15s,background .15s}
.r-menu:hover{background:var(--hair);color:var(--ink);opacity:1!important}
.r-menu.on{opacity:1}
.drag{width:16px;height:24px;display:inline-flex;align-items:center;justify-content:center;color:var(--mut);opacity:0;cursor:grab;transition:opacity .15s}
tr:hover .drag{opacity:.5}
.drag:hover{opacity:1!important}
.note-dot{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:3px;color:var(--mut);
  flex:none;transition:color .14s,background .14s}
.note-dot:hover{color:var(--ink);background:var(--hair)}
.note-dot.has{color:var(--mut2)}
.namecell{display:flex;align-items:center;gap:2px;min-width:0}
.namecell .cell{flex:1}
.cost-src{font-size:10px;color:var(--mut);margin-left:3px;letter-spacing:.03em;font-family:ui-monospace,SFMono-Regular,Menlo,monospace}

/* role picker popover */
.rp{width:300px;padding:8px}
.rp .inp{padding:7px 10px;font-size:13px}
.rp-list{max-height:260px;overflow-y:auto;margin-top:6px;display:flex;flex-direction:column;gap:1px}
.rp-list .pop-i{padding:6px 9px}
.rp-list .rate{margin-left:auto;font-size:11px;color:var(--mut);font-variant-numeric:tabular-nums}
.rp-people{border-top:1px solid var(--hair);margin-top:6px;padding-top:4px}

/* note popover */
.np{width:340px;padding:10px}
.np textarea{min-height:90px;font-size:13px;line-height:1.5}

/* ---------- budget ---------- */
.tbl{width:100%;border-collapse:collapse;font-size:13.5px}
.tbl th{text-align:left;font-size:10px;letter-spacing:.08em;color:var(--mut2);text-transform:uppercase;font-weight:400;
  padding:0 12px 9px;border-bottom:1px solid var(--hair);font-family:ui-monospace,SFMono-Regular,Menlo,monospace;white-space:nowrap}
.tbl td{padding:10px 12px;border-bottom:1px solid var(--hair);vertical-align:middle;font-variant-numeric:tabular-nums}
.tbl th.num,.tbl td.num{text-align:right}
.tbl tr:hover td{background:var(--tint)}
.tbl tr.total td{border-top:1px solid var(--hair2);border-bottom:0;font-weight:500}
.tbl td.dim{color:var(--mut2)}
.tbl .cell{padding:5px 8px}
.bar{height:5px;background:var(--hair);border-radius:3px;overflow:hidden;min-width:80px}
.bar i{display:block;height:100%;background:var(--ink);opacity:.75;border-radius:3px}
.loadbar{display:flex;align-items:center;gap:10px}
.loadbar .bar{flex:1}
.stack{display:flex;height:8px;border-radius:4px;overflow:hidden;background:var(--hair);margin:14px 0 8px}
.stack i{display:block;height:100%}
.legend{display:flex;flex-wrap:wrap;gap:6px 16px;font-size:12px;color:var(--mut2)}
.legend a:hover{color:var(--ink);text-decoration:none}
.legend .sw{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px;vertical-align:baseline}
.sec-h{font-size:10px;letter-spacing:.08em;color:var(--mut2);text-transform:uppercase;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  margin:40px 0 12px;display:flex;align-items:baseline;gap:12px}
.sec-h:first-of-type{margin-top:0}
.sec-h .hint{text-transform:none;letter-spacing:0;font-family:'Inter',system-ui,sans-serif;font-size:12px}
.callout{background:var(--surface);border:1px solid var(--hair);border-radius:6px;padding:12px 16px;font-size:13px;color:var(--mut2);line-height:1.5;
  display:flex;align-items:center;gap:14px;flex-wrap:wrap}
.callout b{color:var(--ink);font-weight:500}

/* ---------- settings / auth ---------- */
.gate{min-height:100vh;display:grid;place-items:center;padding:24px}
.gate-box{width:min(400px,100%);display:flex;flex-direction:column;gap:20px;text-align:center;animation:riseIn .3s cubic-bezier(.4,0,.2,1)}
.slackbtn{display:flex;align-items:center;justify-content:center;gap:10px;background:var(--ink);color:var(--bg);
  border-radius:5px;padding:12px 18px;width:100%;transition:filter .15s}
.slackbtn:hover{filter:brightness(1.4)}
[data-theme=dark] .slackbtn:hover{filter:brightness(.86)}
.tog{width:34px;height:19px;border-radius:19px;background:var(--hair2);position:relative;transition:background .18s;flex:none}
.tog:after{content:'';position:absolute;top:2px;left:2px;width:15px;height:15px;border-radius:50%;background:var(--bg);
  transition:transform .18s cubic-bezier(.4,0,.2,1)}
.tog.on{background:var(--ember)}
.tog.on:after{transform:translateX(15px)}
.setrow{display:flex;align-items:center;gap:14px;padding:10px 0;border-bottom:1px solid var(--hair);font-size:13.5px}
.setrow:last-child{border-bottom:0}
.setrow .lbl{flex:1;display:flex;flex-direction:column;gap:2px}
.setrow .lbl .hint{font-size:12px}
.setrow .inp{max-width:120px;padding:6px 9px;font-size:13px}
.rates{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:10px}
.rates label{display:flex;flex-direction:column;gap:4px}
.rates .inp{padding:6px 9px;font-size:13px}

/* ---------- misc ---------- */
.toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);background:var(--ink);color:var(--bg);
  border-radius:5px;padding:9px 14px 9px 16px;font-size:13px;z-index:100;box-shadow:var(--shadow-s);display:flex;align-items:center;gap:14px;
  animation:riseIn .18s cubic-bezier(.4,0,.2,1);white-space:nowrap}
.toast-act{color:var(--bg);font-weight:500;text-decoration:underline;text-underline-offset:3px;font-size:13px}
.brand{flex:none;display:block}
.proj:hover .brand circle[fill]:not([fill="none"]){filter:brightness(1.12)}
.upd-bar{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:80;
  display:flex;align-items:center;gap:12px;flex-wrap:wrap;max-width:min(680px,calc(100vw - 32px));
  padding:10px 14px;border-radius:7px;font-size:13px;
  background:var(--bg);border:1px solid var(--hair2);box-shadow:var(--shadow-s);animation:riseIn .16s cubic-bezier(.4,0,.2,1)}
.upd-bar b{font-weight:600;flex:none}
.upd-bar span{color:var(--mut2);flex:1;min-width:180px}
.empty-state{max-width:520px;margin:80px auto;text-align:center;display:flex;flex-direction:column;gap:14px;align-items:center;animation:riseIn .3s cubic-bezier(.4,0,.2,1)}
.empty-state h2{font-family:'PT Serif',Georgia,serif;font-size:24px;font-weight:700;margin:0}
mark.f{background:none;color:var(--ember);font-weight:500}
.kbd{border:1px solid var(--hair2);border-radius:3px;padding:1px 4px;font-size:10px;color:var(--mut2)}
