/* Каркас и экраны T-One Sale. Только токены из tokens.css. */
:root { --scrim: #0000008c; }
html { color-scheme: light; }
[data-theme="dark"] { --scrim: #000000b3; }
* { box-sizing: border-box; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--link); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--space-4); top: -60px; z-index: 100; }
.skip:focus { top: var(--space-4); }

/* Каркас */
.app { display: flex; min-height: 100vh; }
.app > .to-side { position: sticky; top: 0; height: 100vh; flex: none; overflow-y: auto; }
.app__main { flex: 1; min-width: 0; padding: 0 var(--space-8) var(--space-8); }
.app__main .to-top { padding: var(--space-2) 0; min-height: var(--topbar-h); height: auto; margin-bottom: var(--space-4); }
.app__main .to-top__title { margin-right: var(--space-2); }
.to-side__item { cursor: pointer; }
.to-side__user { cursor: default; border: 0; width: 100%; text-align: left; color: var(--ink); }
.to-side__foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.to-side__foot .to-side__user { margin-top: 0; }
.to-side__logout { cursor: pointer; border: 0; background: transparent; font: 500 14px/20px var(--font-sans); width: 100%; }
.to-top__bell:hover, .to-btn--icon:hover { background: var(--surface-3); }
.to-top__bell, .to-top__bell:focus-visible { outline: 2px solid transparent; }
.to-top__bell:focus-visible { box-shadow: var(--focus-ring); }
.to-top__search kbd { font-family: var(--font-sans); }
.to-top__search select { border: 0; background: transparent; }
a.to-btn { text-decoration: none; }
.to-link { color: var(--link); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; border-radius: var(--radius-xs); }
.to-link:focus-visible, .to-cell-btn:focus-visible, .to-check:focus-visible, .to-folder:focus-visible, .to-tab:focus-visible, .to-cal__day:focus-visible, .to-pack:focus-visible, .to-field__input:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus-ring); }
.to-field__input:focus-visible { box-shadow: none; }
.to-cell-btn { background: none; border: 0; padding: 0; text-align: left; color: var(--ink); cursor: pointer; font: inherit; border-radius: var(--radius-xs); }
.to-cell-btn:hover b { text-decoration: underline; }
.to-check { cursor: pointer; border: 0; padding: 0; background: transparent; color: var(--on-primary); }
.to-check.is-on { background: var(--primary); }
.to-check .to-icon { margin: auto; }

/* Страница */
.page { display: flex; flex-direction: column; gap: var(--space-6); }
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-6); }
.grid > .s3 { grid-column: span 3; } .grid > .s4 { grid-column: span 4; } .grid > .s5 { grid-column: span 5; }
.grid > .s6 { grid-column: span 6; } .grid > .s7 { grid-column: span 7; } .grid > .s12 { grid-column: span 12; }
.kpis { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-4); }
.kpis > :nth-child(-n+4) { grid-column: span 3; } .kpis > :nth-child(n+5) { grid-column: span 4; }
.toolbar { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.toolbar__sp { margin-left: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }
.to-field--inline { flex-direction: row; align-items: center; gap: var(--space-2); }
.to-field__control .to-field__input { min-width: 90px; }
.to-field__control--select { position: relative; padding-right: var(--space-3); }
select.to-field__input { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 4px; color: var(--ink); }
select.to-field__input option { color: var(--ink); background: var(--surface); }
textarea.to-field__input { height: auto; padding: var(--space-3) var(--space-4); resize: vertical; line-height: 20px; }
.to-field__control--area { height: auto; border-radius: var(--radius-md); align-items: stretch; padding: 0; }
.to-field__control--area textarea { padding: var(--space-3) var(--space-4); min-height: 84px; }
.muted { color: var(--ink-muted); }
.pos { color: var(--positive-ink); } .neg { color: var(--danger-ink); } .warn { color: var(--amber-ink); }
.empty { padding: var(--space-8) var(--space-6); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); color: var(--ink-muted); font: 400 16px/24px var(--font-sans); }
.empty h3 { margin: 0; font: 600 18px/24px var(--font-display); text-transform: uppercase; letter-spacing: .02em; color: var(--ink); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.to-table td.is-right, .to-table th.is-right { text-align: right; }
.to-table td.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.to-table td.wrap { white-space: normal; }
.to-table--pad { margin-top: 0; }

/* Канбан */
.to-board { padding: 0 0 var(--space-4); }
.to-kcard { text-align: left; border: 0; width: 100%; color: var(--ink); font: inherit; }
.to-kcard.is-over, .to-kcol__body.is-over { background: var(--violet-soft); border-radius: var(--radius-md); }
.to-kcol__body { min-height: 60px; }
.to-kcol__add { background: transparent; }
.to-kcard__amount { text-transform: uppercase; font-variant-numeric: tabular-nums; }

/* Задачи, события */
.task { display: flex; align-items: center; gap: var(--space-3); }
.task__main { flex: 1; min-width: 0; }
.task__main b { font-weight: 600; display: block; }
.task.is-done .task__main b { text-decoration: line-through; color: var(--ink-muted); }
.to-event { text-align: left; width: 100%; border: 0; color: var(--ink); font-family: inherit; }
.to-event__meta { color: var(--ink); }

/* Графики */
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg text { font: 500 12px/16px var(--font-sans); fill: var(--ink-muted); }
.chart-svg .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.legend { display: flex; gap: var(--space-5); font: 500 13px/18px var(--font-sans); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 2px; display: inline-block; border-radius: 2px; }
.to-funnel__bar { min-width: 4px; }

/* Календарь */
.cal-year { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.cal-month { background: var(--surface); border-radius: var(--radius-lg); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); min-height: 150px; }
.cal-month.is-now { box-shadow: inset 0 0 0 2px var(--violet); }
.cal-month h3 { margin: 0; font: 600 18px/24px var(--font-display); text-transform: uppercase; letter-spacing: .02em; display: flex; justify-content: space-between; align-items: baseline; }
.cal-month h3 span { font: 500 12px/16px var(--font-sans); color: var(--ink-muted); text-transform: none; letter-spacing: 0; }
.cal-month .to-event { padding: 6px 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font: 600 11px/14px var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); padding: 0 var(--space-2) var(--space-1); }
.to-cal__day { min-height: 96px; border-radius: var(--radius-sm); background: var(--surface-2); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.to-cal__day.is-out { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.to-cal__day.is-out .to-cal__n { color: var(--ink-muted); }
.to-cal__day.is-today { background: var(--violet-soft); }
.to-cal__n { font: 600 12px/16px var(--font-sans); }
.to-cal__day.is-today .to-cal__n { color: var(--violet-ink); }
.cal-head { display: flex; align-items: center; gap: var(--space-3); }
.cal-head h2 { margin: 0; font: 600 24px/28px var(--font-display); text-transform: uppercase; min-width: 190px; text-align: center; }
.cal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }

/* Пакеты, материалы */
.pack-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.to-pack { text-align: left; font-family: inherit; color: var(--ink); border: 0; }
button.to-pack { cursor: pointer; width: 100%; }
.mat { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.to-folder { display: flex; align-items: center; gap: var(--space-3); height: 44px; padding: 0 var(--space-4); border-radius: var(--radius-full); border: 0; background: transparent; color: var(--ink); font: 500 14px/20px var(--font-sans); cursor: pointer; width: 100%; text-align: left; }
.to-folder:hover { background: var(--surface-3); }
.to-folder.is-on { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--space-4); }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); padding: var(--space-6); text-align: center; color: var(--ink-muted); display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.to-file { border: 0; text-align: left; font-family: inherit; color: var(--ink); }

/* Вкладки в панелях */
.tabs { margin-bottom: var(--space-1); overflow-x: auto; max-width: 100%; }

/* Drawer, модальные окна */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; display: flex; justify-content: flex-end; }
.scrim--center { justify-content: center; align-items: center; padding: var(--space-4); }
.drawer { width: var(--drawer-w); max-width: 100%; height: 100%; background: var(--surface); border-radius: var(--radius-xl) 0 0 var(--radius-xl); box-shadow: var(--shadow-lg); padding: var(--space-10); display: flex; flex-direction: column; gap: var(--space-5); overflow-y: auto; }
.drawer__head { display: flex; flex-direction: column; gap: var(--space-3); }
.drawer__row { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.drawer__company { margin: 0; font: 600 18px/24px var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.drawer__sum { font: 500 36px/40px var(--font-display); text-transform: uppercase; font-variant-numeric: tabular-nums; }
.drawer__meta { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.drawer__body { display: flex; flex-direction: column; gap: var(--space-4); flex: 1; }
.drawer__note { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.modal { background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: var(--space-8); width: 560px; max-width: 100%; max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-4); }
.modal--wide { width: 920px; }
.modal h2 { margin: 0; font: 600 24px/28px var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 320px); gap: var(--space-6); }
.pop { position: absolute; right: 0; top: 52px; width: 400px; max-width: 90vw; max-height: 70vh; overflow-y: auto; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: var(--space-4); z-index: 40; text-align: left; }
.pop h3 { margin: 0 0 var(--space-3); font: 600 18px/24px var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.to-top__actions > .rel { position: relative; }
.toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translateX(-50%); background: var(--primary); color: var(--on-primary); border-radius: var(--radius-full); padding: 10px 20px; font: 500 14px/20px var(--font-sans); box-shadow: var(--shadow-lg); z-index: 80; }

/* Вход */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: var(--space-4); padding: var(--space-4); }
.login__brand { background: var(--violet); color: var(--on-violet); border-radius: var(--radius-xl); padding: var(--space-16); display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-8); min-height: 560px; }
.login__brand .to-side__brand { gap: var(--space-3); }
.login__brand .to-side__product { color: var(--on-violet); }
.hero { margin: 0; font: 700 72px/68px var(--font-display); letter-spacing: -.01em; text-transform: uppercase; }
.login__mini { display: flex; gap: var(--space-2); align-items: flex-end; height: 120px; }
.login__mini i { flex: 1; background: var(--surface); border-radius: var(--radius-md); opacity: 1; }
.login__form { background: var(--surface); border-radius: var(--radius-xl); padding: var(--space-16); display: flex; flex-direction: column; justify-content: center; gap: var(--space-5); max-width: 560px; width: 100%; margin: 0 auto; }
.login__form h2 { margin: 0; font: 600 32px/36px var(--font-display); text-transform: uppercase; }
.login__form .to-field__control { height: var(--control-lg); }
.login__top { position: absolute; top: var(--space-6); right: var(--space-6); }

/* Адаптивность */
@media (max-width: 1280px) {
  .grid > .s3, .grid > .s4, .grid > .s5, .grid > .s6, .grid > .s7 { grid-column: span 12; }
  .grid > .s4.keep { grid-column: span 6; }
  .cal-year { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  :root { --sidebar-w: 88px; }
  .to-side { padding: var(--space-5) var(--space-3); align-items: center; }
  .to-side__item { justify-content: center; padding: 0; width: 48px; position: relative; }
  .to-side__item span:not(.to-side__count) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .to-side__count { position: absolute; top: -2px; right: -4px; margin: 0; min-width: 18px; height: 18px; font-size: 10px; line-height: 18px; padding: 0 4px; }
  .to-side__brand .to-side__product, .to-side__user > div { display: none; }
  .to-side__brand .logo-full { display: none; } .to-side__brand .logo-star { display: inline-flex; }
  .to-logo-pill.is-star { padding: 0; width: 48px; justify-content: center; }
  .to-side__user { padding: var(--space-2); }
  .to-side__logout span { display: none; }
  .app__main { padding: 0 var(--space-4) var(--space-6); }
  .kpis > * { grid-column: span 6 !important; }
  .cal-year { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mat { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login__brand { padding: var(--space-8); min-height: 0; }
  .hero { font-size: 48px; line-height: 48px; }
  .login__form { padding: var(--space-8); }
  .editor { grid-template-columns: 1fr; }
}
.logo-star { display: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Рабочая версия: теги-переключатели, сетка полей, форма задачи */
.tagrow { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.tagbtn { background: none; border: 0; padding: 0; margin: 0; cursor: pointer; border-radius: var(--radius-full); font: inherit; }
.tagbtn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.task-add { display: grid; gap: var(--space-3); }
.to-field__input:disabled { cursor: not-allowed; opacity: .7; }

/* Материалы */
.dropzone.is-over { border-color: var(--violet-ink); background: var(--violet-soft); color: var(--ink); }
.mat > nav { display: flex; flex-direction: column; gap: var(--space-1); }
.to-folder:disabled, .to-btn:disabled { opacity: .6; cursor: not-allowed; }
.mat > * { min-width: 0; }
.mat .to-table { overflow-x: auto; }
.mat > nav { flex-direction: row; flex-wrap: wrap; }
@media (min-width: 901px) { .mat > nav { flex-direction: column; flex-wrap: nowrap; } }
