:root { --bg:#fff; --fg:#1d2433; --mut:#667085; --line:#e2e6ee; --head:#f3f5f9; --acc:#2a62d9; --warn:#b42318; --warnbg:#fef0ee; --sel:#eaf1ff; --row:34px; --ok:#16794c; --cf:#c2580a; --botbg:#fff6d6; --romut:#8a93a6; }
@media (prefers-color-scheme: dark) { :root { --bg:#15181f; --fg:#e8ebf2; --mut:#9aa3b5; --line:#2b3140; --head:#1d222d; --acc:#6b9cff; --warn:#ff8a80; --warnbg:#3a1e1c; --sel:#1f2b45; --ok:#5fd39b; --cf:#ffa45c; --botbg:#3d3513; --romut:#6e788c; } }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--fg); font:14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--acc); }
.pre { white-space: pre-line; }
.hint { color: var(--mut); font-size: 12px; }
.err { color: var(--warn); background: var(--warnbg); padding: 8px 12px; border-radius: 8px; }
.login { max-width: 460px; margin: 0 auto; padding: 8vh 16px 32px; }
.login h1 { font-size: 24px; margin: 0 0 8px; }
.chk { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0; }
.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; background: var(--acc); color: #fff; text-decoration: none; border: 0; font: inherit; cursor: pointer; min-height: 44px; }
.btn.ghost { background: transparent; color: var(--acc); border: 1px solid var(--acc); }
.link { background: none; border: 0; color: var(--acc); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.top { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--line); }
.top .co { font-weight: 600; }
.top .sp { flex: 1; }
.bar { padding: 6px 16px; background: var(--head); display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.bar.urgent { background: var(--warnbg); color: var(--warn); }
.pop { padding: 8px 16px; background: var(--sel); display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; }
.tab { padding: 6px 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); color: var(--fg); cursor: pointer; font: inherit; white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--acc); color: #fff; border-color: var(--acc); }
.tab .n { opacity: .7; margin-left: 4px; font-size: 12px; }
input[type="search"], select, details > summary { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
input[type="search"] { min-width: 220px; flex: 1 1 220px; max-width: 420px; }
details { position: relative; }
details > summary { cursor: pointer; list-style: none; }
details .menu { position: absolute; z-index: 30; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; max-height: 60vh; overflow: auto; min-width: 200px; box-shadow: 0 6px 24px rgba(0,0,0,.15); }
details .menu label { display: flex; gap: 6px; padding: 3px 0; white-space: nowrap; }
.count { color: var(--mut); padding: 0 16px 4px; }
.grid { position: relative; flex: 1; overflow: auto; border-top: 1px solid var(--line); }
.ghead { position: sticky; top: 0; z-index: 10; display: flex; background: var(--head); height: var(--row); border-bottom: 1px solid var(--line); }
.gbody { position: relative; }
.grow { position: absolute; left: 0; display: flex; height: var(--row); border-bottom: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.grow:hover, .grow.sel { background: var(--sel); }
.gc { flex: none; padding: 0 8px; line-height: calc(var(--row) - 1px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-right: 1px solid var(--line); background: inherit; }
.ghead .gc { background: var(--head); font-weight: 600; cursor: pointer; user-select: none; }
.gc.num { text-align: right; }
.gc.stk { position: sticky; z-index: 5; }
.ghead .gc.stk { z-index: 12; }
.badge { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: var(--head); color: var(--mut); margin-left: 6px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--mut); }
.s0, .s1 { background: #3b82f6; } .s2 { background: #eab308; } .s3, .s4 { background: #8b5cf6; } .s5 { background: #22c55e; } .s6 { background: #ef4444; } .s7 { background: #f97316; }
.empty { padding: 48px 16px; text-align: center; color: var(--mut); }
.totals { padding: 6px 16px; border-top: 1px solid var(--line); background: var(--head); display: flex; flex-wrap: wrap; gap: 4px 16px; }
aside.card { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg); border-left: 1px solid var(--line); z-index: 40; display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(0,0,0,.12); }
aside.card header { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
aside.card header h2 { flex: 1; margin: 0; font-size: 16px; }
aside.card .body { overflow: auto; padding: 12px 16px; flex: 1; }
.ctabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; }
dl.f { display: grid; grid-template-columns: 1fr 2fr; gap: 6px 12px; margin: 0; }
dl.f dt { color: var(--mut); } dl.f dd { margin: 0; word-break: break-word; white-space: pre-line; }
table.t { border-collapse: collapse; width: 100%; } table.t td, table.t th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.msg { margin: 6px 0; padding: 8px 10px; border-radius: 10px; background: var(--head); white-space: pre-wrap; word-break: break-word; max-width: 90%; }
.msg.master { margin-left: auto; background: var(--sel); }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal > div { background: var(--bg); padding: 20px; border-radius: 12px; max-width: 420px; }
@media (max-width: 600px) { .top, .tools { padding: 8px 12px; } input[type="search"] { max-width: none; } .btn, .tab { min-height: 44px; } }

/* ---- этап B1: правка ячеек ---- */
.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; justify-content: space-between; padding-right: 16px; }
.hintline { color: var(--mut); font-size: 12px; min-height: 1em; }
.grid:focus { outline: none; }
.gc.ro { color: var(--romut); }
.gc.cur { outline: 2px solid var(--acc); outline-offset: -2px; z-index: 6; }
.gc.late { color: var(--warn); font-weight: 600; }
.gc .noname { color: var(--mut); font-style: italic; }
.gc.bot { background: var(--botbg); box-shadow: inset 3px 0 0 #e0a800; }
.gc.st-sv::after { content: '…'; color: var(--mut); position: absolute; right: 4px; }
.gc.st-ok::after { content: '✓'; color: var(--ok); position: absolute; right: 4px; font-weight: 700; }
.gc.st-er { box-shadow: inset 0 0 0 2px var(--warn); background: var(--warnbg); }
.gc.st-cf { box-shadow: inset 0 0 0 2px var(--cf); }
.gc.st-sv, .gc.st-ok { position: relative; }
.gc.stk.st-sv, .gc.stk.st-ok { position: sticky; }
.grow.gone { opacity: .5; text-decoration: line-through; }
.gc.editing { position: relative; overflow: visible; padding: 0; z-index: 7; }
.gc.stk.editing { position: sticky; }
.edbox { display: flex; align-items: center; height: calc(var(--row) - 1px); background: var(--bg); }
.edbox input[type="text"], .edbox select, .edbox textarea { font: inherit; color: var(--fg); background: var(--bg); border: 2px solid var(--acc); border-radius: 0; width: 100%; height: 100%; padding: 0 6px; margin: 0; min-width: 0; }
.edbox textarea { position: absolute; left: 0; top: 0; z-index: 20; height: auto; min-height: calc(var(--row) - 1px); min-width: 260px; max-height: 160px; padding: 6px; resize: vertical; line-height: 1.3; }
.edbox .pickbtn { border: 0; background: var(--head); color: var(--fg); height: 100%; padding: 0 8px; cursor: pointer; }
.edbox .dpick { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.save { font-size: 12px; color: var(--mut); padding: 2px 8px; border-radius: 10px; }
.save.busy { color: var(--acc); }
.save.bad { color: var(--warn); background: var(--warnbg); cursor: pointer; font-weight: 600; }
.tab:disabled { opacity: .45; cursor: default; }
.tab.dirty { border-color: var(--cf); box-shadow: 0 0 0 2px var(--cf); }
.newbar { padding: 6px 16px; border-top: 1px solid var(--line); }
.newform { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.newform input { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); min-width: 140px; flex: 1 1 140px; max-width: 280px; }
.newerr { color: var(--warn); }
.toasts { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(560px, calc(100% - 24px)); pointer-events: none; }
.toast { pointer-events: auto; background: #1d2433; color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.toast.err { background: #7a1c13; }
.toast .link { color: #9cc0ff; }
.toast .x { background: none; border: 0; color: inherit; font-size: 18px; cursor: pointer; line-height: 1; opacity: .7; }
.modal.dlg h2 { margin: 0 0 8px; font-size: 17px; }
.modal.dlg .btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bar button.btn { min-height: 32px; padding: 4px 12px; }
