/* ============================================================
   Excel AI (ArisCell) — web spreadsheet UI.
   Golos Text (RU) · emerald accent · light office theme.
   ============================================================ */
@font-face{font-family:'Golos Text';font-weight:400 700;font-display:swap;
  src:url(fonts/golos-cyrillic.woff2) format('woff2');
  unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;}
@font-face{font-family:'Golos Text';font-weight:400 700;font-display:swap;
  src:url(fonts/golos-latin-ext.woff2) format('woff2');
  unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+1E00-1E9F,U+2020,U+20A0-20AB,U+2C60-2C7F,U+A720-A7FF;}
@font-face{font-family:'Golos Text';font-weight:400 700;font-display:swap;
  src:url(fonts/golos-latin.woff2) format('woff2');
  unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+2000-206F,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;}

:root{
  --paper:#F4F3EE; --surface:#FFFFFF; --canvas:#E9E8E2;
  --ink:#1D232B; --muted:#6A7280; --faint:#9AA1AB;
  --line:#E4E2D9; --line-2:#D7D4C9; --grid:#D9DCE1;
  --accent:#157A57; --accent-press:#0F5E43; --accent-weak:#157A571A; --accent-weak-2:#157A570F;
  --amber:#C9892B; --danger:#C2483B;
  --hdr:#F2F4F3; --hdr-active:#D7EBE2;
  --r-sm:6px; --r:9px; --r-lg:13px; --r-pill:999px;
  --sh-1:0 1px 2px rgba(29,35,43,.06); --sh-2:0 6px 18px rgba(29,35,43,.10); --sh-3:0 24px 60px rgba(29,35,43,.18);
  --ui:'Golos Text',system-ui,-apple-system,'Segoe UI',sans-serif;
  --mono:'SF Mono',ui-monospace,'Cascadia Code',Consolas,monospace;
  --t:140ms cubic-bezier(.2,.8,.2,1);
  --cellw:96px; --cellh:26px; --rowhdr:46px;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{font-family:var(--ui);color:var(--ink);background:var(--paper);font-size:14px;
  -webkit-font-smoothing:antialiased;overflow:hidden;display:flex;flex-direction:column}
button{font-family:inherit}
::selection{background:var(--accent-weak)}

/* ---------- Title bar ---------- */
.titlebar{display:flex;align-items:center;gap:14px;height:48px;padding:0 14px;
  background:var(--surface);border-bottom:1px solid var(--line);flex:none;z-index:30}
.brand{display:flex;align-items:center;gap:10px;text-decoration:none;color:var(--ink)}
.brand .logo{width:30px;height:30px;border-radius:8px;background:linear-gradient(140deg,#1E9A6E,#0F5E43);
  display:grid;place-items:center;color:#fff;box-shadow:var(--sh-1)}
.brand .logo svg{width:18px;height:18px}
.brand b{font-size:15.5px;font-weight:700;letter-spacing:-.01em}
.brand b span{color:var(--accent)}
.doc-title{display:flex;align-items:center;gap:8px;margin-left:8px;min-width:0}
.doc-title input{border:1px solid transparent;background:transparent;font:600 14px/1 var(--ui);
  color:var(--ink);padding:6px 8px;border-radius:7px;width:200px;max-width:30vw;transition:var(--t)}
.doc-title input:hover{background:var(--paper)}
.doc-title input:focus{background:var(--paper);border-color:var(--line-2);outline:none}
.saved{font-size:11.5px;color:var(--faint);white-space:nowrap}
.tb-spacer{flex:1}
.tb-actions{display:flex;align-items:center;gap:8px}
.icon-btn{width:34px;height:34px;border:1px solid transparent;background:transparent;border-radius:8px;
  cursor:pointer;font-size:15px;color:var(--muted);transition:var(--t)}
.icon-btn:hover{background:var(--paper);color:var(--ink)}
.btn{height:34px;padding:0 14px;border:1px solid var(--line-2);background:var(--surface);border-radius:8px;
  cursor:pointer;font:600 13px var(--ui);color:var(--ink);transition:var(--t)}
.btn:hover{border-color:var(--accent);color:var(--accent)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff}
.btn.primary:hover{background:var(--accent-press);color:#fff}
.avatar{width:32px;height:32px;border-radius:50%;background:linear-gradient(140deg,#C9892B,#9A6418);
  color:#fff;display:grid;place-items:center;font-size:12px;font-weight:700}

/* ---------- Tabs + ribbon ---------- */
.tabs{display:flex;gap:2px;padding:0 12px;background:var(--surface);border-bottom:1px solid var(--line);flex:none;z-index:20}
.tab{border:0;background:transparent;padding:9px 15px;font:600 13px var(--ui);color:var(--muted);cursor:pointer;
  border-radius:8px 8px 0 0;border-bottom:2px solid transparent;transition:var(--t)}
.tab:hover{color:var(--ink);background:var(--paper)}
.tab.active{color:var(--accent);border-bottom-color:var(--accent)}
.ribbon{display:flex;gap:6px;padding:7px 12px;background:var(--surface);border-bottom:1px solid var(--line);
  flex:none;overflow-x:auto;min-height:64px;align-items:stretch;z-index:10}
.rgroup{display:flex;flex-direction:column;gap:4px;padding:0 8px;border-right:1px solid var(--line)}
.rgroup:last-child{border-right:0}
.rg-body{display:flex;gap:4px;align-items:center;flex:1}
.rg-name{font-size:10px;color:var(--faint);text-align:center;letter-spacing:.02em}
.rcol{display:flex;flex-direction:column;gap:3px}
.rrow{display:flex;gap:3px;align-items:center}
.tool{height:28px;min-width:28px;padding:0 7px;border:1px solid transparent;background:transparent;border-radius:7px;
  cursor:pointer;font:500 13px var(--ui);color:var(--ink);display:inline-flex;align-items:center;justify-content:center;gap:5px;transition:var(--t)}
.tool:hover{background:var(--paper);border-color:var(--line-2)}
.tool.active{background:var(--accent-weak);color:var(--accent)}
.tool.big{height:56px;flex-direction:column;gap:3px;min-width:62px;font-size:11.5px;padding:4px 8px}
.tool.big .ic{font-size:18px}
.tool .ic{font-size:14px}
.tool.bold{font-weight:800}.tool.italic{font-style:italic}.tool.under{text-decoration:underline}
.field{height:28px;border:1px solid var(--line-2);background:var(--surface);border-radius:7px;padding:0 8px;
  font:500 13px var(--ui);color:var(--ink);outline:none}
.field:focus{border-color:var(--accent)}
.color-tool{position:relative;display:inline-flex;flex-direction:column;align-items:center;justify-content:center;
  height:28px;min-width:30px;border-radius:7px;cursor:pointer;border:1px solid transparent}
.color-tool:hover{background:var(--paper);border-color:var(--line-2)}
.color-tool .bar{width:18px;height:3px;border-radius:2px;margin-top:1px}
.color-tool input{position:absolute;inset:0;opacity:0;cursor:pointer}

/* ---------- Formula bar ---------- */
.fxbar{display:flex;align-items:center;gap:0;height:34px;background:var(--surface);border-bottom:1px solid var(--line);
  padding:0 10px;flex:none;z-index:9}
.namebox{width:84px;height:24px;border:1px solid var(--line-2);border-radius:6px;display:flex;align-items:center;
  justify-content:center;font:600 12.5px var(--mono);color:var(--ink);background:var(--paper)}
.fx-sep{width:1px;height:20px;background:var(--line);margin:0 10px}
.fx-ic{font:italic 700 13px Georgia,serif;color:var(--muted);margin-right:8px}
.fx-input{flex:1;height:26px;border:1px solid transparent;background:transparent;font:500 13.5px var(--mono);
  color:var(--ink);outline:none;padding:0 4px}
.fx-input:focus{border-bottom:1px solid var(--accent)}

/* ---------- Workspace ---------- */
.workspace{flex:1;display:flex;min-height:0;background:var(--canvas)}
.sheet-wrap{flex:1;overflow:auto;position:relative;background:#fff}

/* ---------- Grid ---------- */
.grid{position:relative;font-size:13px;width:max-content}
.grid table{border-collapse:collapse;table-layout:fixed}
.grid th,.grid td{border:1px solid var(--grid);height:var(--cellh);padding:0;margin:0}
.grid thead th{position:sticky;top:0;z-index:6;background:var(--hdr);color:var(--muted);font-weight:600;
  font-size:11.5px;text-align:center;height:22px;user-select:none}
.grid tbody th{position:sticky;left:0;z-index:5;background:var(--hdr);color:var(--muted);font-weight:600;
  font-size:11px;text-align:center;width:var(--rowhdr);min-width:var(--rowhdr);user-select:none}
.grid thead th.corner{position:sticky;left:0;top:0;z-index:7;width:var(--rowhdr);min-width:var(--rowhdr);background:var(--hdr)}
.grid thead th.hl,.grid tbody th.hl{background:var(--hdr-active);color:var(--accent)}
.grid td{overflow:hidden;white-space:nowrap;
  padding:0 5px;cursor:cell;color:var(--ink);background:#fff;text-overflow:ellipsis;line-height:var(--cellh)}
/* resize handles */
.grid thead th .col-rz{position:absolute;top:0;right:-3px;width:6px;height:100%;cursor:col-resize;z-index:8}
.grid tbody th .row-rz{position:absolute;left:0;bottom:-3px;height:6px;width:100%;cursor:row-resize;z-index:8}
.grid .col-rz:hover,.grid .row-rz:hover{background:var(--accent)}
body.col-resizing,body.col-resizing *{cursor:col-resize!important;user-select:none!important}
body.row-resizing,body.row-resizing *{cursor:row-resize!important;user-select:none!important}
.grid td.num{text-align:right}
.grid td.sel{box-shadow:inset 0 0 0 2px var(--accent);z-index:2;position:relative}
.grid td.inrange{background:var(--accent-weak-2)}
.grid td.err{color:var(--danger)}
.grid td.b{font-weight:700}.grid td.i{font-style:italic}.grid td.u{text-decoration:underline}
.grid td.al{text-align:left}.grid td.ac{text-align:center}.grid td.ar{text-align:right}
.cell-editor{position:absolute;z-index:20;border:2px solid var(--accent);background:#fff;font:500 13px var(--ui);
  padding:0 4px;outline:none;box-shadow:var(--sh-2)}

/* ---------- AI panel (same as Word) ---------- */
.ai{width:330px;flex:none;background:var(--surface);border-left:1px solid var(--line);display:flex;flex-direction:column;transition:var(--t)}
.ai.hidden{width:0;overflow:hidden;border-left:0}
.ai-h{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--line)}
.ai-h .spark{width:30px;height:30px;border-radius:8px;background:var(--accent-weak);color:var(--accent);display:grid;place-items:center;font-size:15px}
.ai-h b{font-size:14px}.ai-h .note{font-size:10.5px;color:var(--faint)}
.ai-quick{display:flex;flex-wrap:wrap;gap:6px;padding:12px 16px;border-bottom:1px solid var(--line)}
.chip{border:1px solid var(--line-2);background:var(--surface);border-radius:var(--r-pill);padding:6px 11px;
  font:500 12px var(--ui);color:var(--ink);cursor:pointer;transition:var(--t)}
.chip:hover{border-color:var(--accent);color:var(--accent)}
.ai-thread{flex:1;overflow-y:auto;padding:14px 16px;display:flex;flex-direction:column;gap:12px}
.ai-msg{font-size:13px;line-height:1.5}
.ai-msg.u{align-self:flex-end;background:var(--accent-weak);padding:8px 12px;border-radius:12px 12px 2px 12px;max-width:85%}
.ai-msg.a{color:var(--ink)}
.ai-msg.a .mono{font-family:var(--mono);background:var(--paper);border-radius:5px;padding:1px 5px}
.ai-input{display:flex;gap:8px;padding:12px 16px;border-top:1px solid var(--line);align-items:flex-end}
.ai-input textarea{flex:1;border:1px solid var(--line-2);border-radius:10px;padding:9px 11px;font:500 13px var(--ui);
  color:var(--ink);resize:none;max-height:120px;outline:none}
.ai-input textarea:focus{border-color:var(--accent)}
.send{width:36px;height:36px;border:0;border-radius:9px;background:var(--accent);color:#fff;cursor:pointer;font-size:14px}
.send:hover{background:var(--accent-press)}

/* ---------- Status bar ---------- */
.statusbar{display:flex;align-items:center;gap:14px;height:30px;padding:0 14px;background:var(--surface);
  border-top:1px solid var(--line);font-size:12px;color:var(--muted);flex:none}
.sheet-tabs{display:flex;align-items:center;gap:3px}
.sheet-tab{border:1px solid transparent;background:transparent;padding:3px 12px;border-radius:6px 6px 0 0;
  font:600 12px var(--ui);color:var(--muted);cursor:pointer}
.sheet-tab.active{background:var(--accent-weak);color:var(--accent)}
.sheet-add{border:0;background:transparent;font-size:15px;color:var(--muted);cursor:pointer;width:24px;height:22px;border-radius:6px}
.sheet-add:hover{background:var(--paper);color:var(--accent)}
.sb-spacer{flex:1}
.sb-stat{white-space:nowrap;font-variant-numeric:tabular-nums}
.zoom{display:flex;align-items:center;gap:6px}
.zoom input{width:90px}

/* ---------- toast ---------- */
.toast{position:fixed;bottom:46px;left:50%;transform:translateX(-50%);background:var(--ink);color:#fff;
  padding:9px 16px;border-radius:10px;font-size:13px;box-shadow:var(--sh-2);z-index:9999;opacity:0;
  transition:opacity .2s,transform .2s;pointer-events:none}
.toast.show{opacity:1;transform:translateX(-50%) translateY(-4px)}

/* ---------- modal (shared) ---------- */
.aris-modal-ov{position:fixed;inset:0;background:rgba(28,34,42,.42);display:grid;place-items:center;z-index:9000}
.aris-modal{background:#fff;border-radius:14px;box-shadow:var(--sh-3);width:440px;max-width:92vw;max-height:90vh;overflow:auto;border:1px solid var(--line)}
.aris-modal .am-h{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--line)}
.aris-modal .am-h b{font-size:15px}
.aris-modal .am-x{border:0;background:transparent;cursor:pointer;font-size:15px;color:var(--faint);width:28px;height:28px;border-radius:8px}
.aris-modal .am-x:hover{background:var(--paper)}
.aris-modal .am-body{padding:16px 18px}
.aris-modal .am-foot{display:flex;justify-content:flex-end;gap:8px;padding:12px 18px;border-top:1px solid var(--line)}
.aris-modal .md-row{display:flex;align-items:center;gap:10px;margin-bottom:12px}
.aris-modal .md-row>span{width:120px;flex:none;font-size:12.5px;color:var(--muted)}
.aris-modal .md-row .field{flex:1}

/* ── Диаграммы (плавающие блоки) ── */
#sheet-wrap{ position:relative }
.chart-box{ position:absolute; z-index:50; background:#fff; border:1px solid var(--line,#e0ddd2); border-radius:10px;
  box-shadow:0 8px 28px rgba(0,0,0,.16); overflow:hidden; display:flex; flex-direction:column }
.chart-box .chart-bar{ display:flex; align-items:center; justify-content:space-between; padding:5px 8px;
  background:#F6F8F7; border-bottom:1px solid var(--line,#eee); cursor:move; font-size:12px; color:#1D232B; user-select:none }
.chart-box .chart-grip{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.chart-box .chart-x{ border:0; background:transparent; cursor:pointer; color:#8a8478; font-size:12px; width:20px; height:20px; border-radius:5px; flex:none }
.chart-box .chart-x:hover{ background:#FBECE9; color:#B5562E }
.chart-box canvas{ flex:1; display:block; margin:8px }
/* модальное окно (если ещё не описано) */
.aris-modal-ov{ position:fixed; inset:0; background:rgba(28,34,42,.42); display:grid; place-items:center; z-index:9000 }
.aris-modal{ background:#fff; border-radius:14px; box-shadow:0 24px 64px rgba(0,0,0,.28); width:440px; max-width:92vw; max-height:90vh; overflow:auto }
.aris-modal .am-h{ display:flex; align-items:center; justify-content:space-between; padding:14px 18px; border-bottom:1px solid var(--line,#eee); font-size:15px }
.aris-modal .am-x{ border:0; background:transparent; cursor:pointer; font-size:15px; color:#8a8478; width:28px; height:28px; border-radius:8px }
.aris-modal .am-body{ padding:16px 18px }
.aris-modal .am-foot{ display:flex; justify-content:flex-end; gap:8px; padding:12px 18px; border-top:1px solid var(--line,#eee) }
.aris-modal .md-row{ display:flex; align-items:center; gap:10px; margin-bottom:12px }
.aris-modal .md-row>span{ width:90px; flex:none; font-size:12.5px; color:#6A7280 }
.aris-modal .field{ flex:1; border:1px solid var(--line,#d8d3c5); border-radius:8px; padding:7px 9px; font:inherit; font-size:13px }

/* ── Автофильтр / закрепление ── */
.grid tr.flt-hidden{ display:none }
.grid thead th.flt-col{ background:var(--accent-weak-2,#157A571a); color:var(--accent,#157A57) }
.grid thead th.flt-col::after{ content:" ▼"; font-size:9px }
.grid .frz{ background:#fff }
.grid thead th.frz{ background:var(--hdr) }
.grid tbody th.frz{ background:var(--hdr) }

/* ── ИИ: действия под ответом + квота ── */
.ai{width:360px}
.ai-acts{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
.ai-act{border:1px solid var(--line,#e0ddd2);background:#fff;border-radius:7px;padding:3px 9px;font-size:11.5px;
  cursor:pointer;color:var(--accent,#157A57);text-decoration:none;display:inline-block}
.ai-act:hover{background:var(--accent-weak-2,#157A571a)}
.ai-msg .mono{font-family:ui-monospace,Menlo,Consolas,monospace;background:#f2efe6;border-radius:4px;padding:0 4px;font-size:12px}

/* проверка данных — выпадающая стрелка */
.grid td.has-dv{ padding-right:16px }
.grid .dv-arrow{ position:absolute; right:1px; top:0; bottom:0; width:14px; display:flex; align-items:center; justify-content:center;
  font-size:9px; color:#fff; background:var(--accent,#157A57); cursor:pointer; border-radius:0 2px 2px 0 }
.grid .dv-arrow:hover{ background:var(--accent-press,#0F5E43) }

/* спарклайны */
.grid td.has-spark{ padding:2px 3px }
.spark-wrap{ display:block; width:100%; height:100% }
