/* Раздел «Бухгалтерия» (#/accounting). Опирается на переменные кабинета из app.css.
   Широкие таблицы на узком экране превращаются в карточки; поля ввода — 16 px,
   всё нажимаемое — не меньше 44 px по высоте. */

.acc { display: flex; flex-direction: column; gap: 18px; }
.acc .acc-head { margin-bottom: 0; align-items: center; }
.acc-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Вкладки раздела ---------- */
.acc-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.acc-tabs::-webkit-scrollbar { display: none; }
.acc-tabs a {
  flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  font-size: 14px; font-weight: 600; color: var(--ink-dim); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.acc-tabs a:hover { color: var(--ink); }
.acc-tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.acc-subtabs { display: flex; gap: 8px; flex-wrap: wrap; }
.acc-subtabs a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-bright); background: var(--bg-card); color: var(--ink-dim);
  font-size: 13.5px; font-weight: 600;
}
.acc-subtabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Кнопки ---------- */
.acc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px;
  padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-bright); background: var(--bg-card);
  color: var(--ink); font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.acc-btn:hover { border-color: var(--accent); color: var(--accent); }
.acc-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.acc-btn.primary:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.acc-btn.sm { min-height: 34px; padding: 0 11px; font-size: 12.5px; }
/* быстрые кнопки печати: длинное название документа переносится, а не уходит за край экрана */
.acc-quick .acc-btn { max-width: 100%; height: auto; white-space: normal; text-align: left; line-height: 1.3; padding-top: 7px; padding-bottom: 7px; }
.acc-btn.danger:hover { border-color: var(--red); color: var(--red); }
.acc-btn svg { flex: none; }
.acc-link { color: var(--accent); font-weight: 600; cursor: pointer; background: none; border: none; padding: 0; font-size: inherit; text-align: left; }

/* ---------- Панели, плитки показателей ---------- */
.acc-panel {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 3px rgba(16,24,40,.06);
}
.acc-panel > header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.acc-panel > header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.acc-panel > header .sub { font-size: 12.5px; color: var(--ink-faint); }
.acc-panel > .body { padding: 16px 18px; }
.acc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.acc-kpi {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 6px; min-width: 0;
}
.acc-kpi .l { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-dim); }
.acc-kpi .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 21px; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.acc-kpi .s { font-size: 12px; color: var(--ink-faint); line-height: 1.35; }
.acc-kpi.good .v { color: var(--margin); }
.acc-kpi.warn .v { color: var(--amber-deep); }
.acc-kpi.bad .v { color: var(--red); }

/* ---------- Фильтры и период ---------- */
.acc-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.acc-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); min-width: 0; }
.acc-filters select, .acc-filters input {
  min-height: 40px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line-bright);
  background: var(--bg-card); color: var(--ink); font-family: var(--body); font-size: 14px;
  font-weight: 500; letter-spacing: 0; text-transform: none; max-width: 100%; outline: none;
}
.acc-filters select:focus, .acc-filters input:focus { border-color: var(--accent); }
.acc-period { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.acc-period .seg { display: inline-flex; border: 1px solid var(--line-bright); border-radius: 9px; overflow: hidden; background: var(--bg-card); }
.acc-period .seg button { min-height: 40px; padding: 0 13px; border: none; background: none; color: var(--ink-dim); font-size: 13.5px; font-weight: 600; }
.acc-period .seg button.on { background: var(--accent); color: #fff; }
.acc-period .lbl { font-weight: 700; font-size: 14.5px; min-width: 128px; text-align: center; }
.acc-period .pnav { width: 40px; padding: 0; flex: none; }

/* ---------- Таблицы → карточки ---------- */
.acc-tablewrap { overflow-x: auto; }
.page table.acc-t { width: 100%; border-collapse: collapse; font-size: 13.5px; display: table; }
.acc-t th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-faint); background: var(--surface-sunken); white-space: nowrap;
}
.acc-t td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.acc-t .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-t .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-t .act { text-align: right; white-space: nowrap; }
/* «Объект» в кассе: строка названия не переносится — иначе одна операция растягивалась на 4–5 строк */
.acc-t td.obj { width: 22%; max-width: 1px; }      /* max-width у ячейки — чтобы многоточие сработало */
.acc-t td.note { width: 28%; }
.acc-t td.auth { white-space: nowrap; }
.acc-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-clamp2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.acc-t tfoot td { font-weight: 700; background: var(--surface-sunken); border-top: 1.5px solid var(--line-bright); }
.acc-t tr.clickable { cursor: pointer; }
.acc-t tr.clickable:hover td { background: var(--bg-raise); }
.acc-t tr.cancelled td { color: var(--ink-faint); }
.acc-t tr.cancelled td.num, .acc-t tr.cancelled td.main { text-decoration: line-through; }
.acc-t tr.virtual td { background: rgba(224,138,0,.06); }
.acc-t .dim { color: var(--ink-faint); font-size: 12.5px; }
.acc-t .main { font-weight: 600; color: var(--ink); }
.acc-t select { min-height: 34px; border-radius: 8px; border: 1px solid var(--line-bright); background: var(--bg-card); padding: 0 8px; font-family: var(--body); font-size: 13px; color: var(--ink); max-width: 190px; }
.acc-in { color: var(--margin); }
.acc-out { color: var(--red); }
.acc-empty { padding: 30px 18px; text-align: center; color: var(--ink-faint); font-size: 13.5px; line-height: 1.5; }
.acc-tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border-radius: 999px; padding: 2px 9px; border: 1px solid var(--line-bright); color: var(--ink-dim); white-space: nowrap; }
.acc-tag.issued { color: var(--accent); border-color: rgba(10,77,166,.4); background: rgba(10,77,166,.07); }
.acc-tag.signed { color: var(--violet); border-color: rgba(105,65,198,.4); background: rgba(105,65,198,.08); }
.acc-tag.paid { color: var(--green); border-color: rgba(31,157,87,.4); background: rgba(31,157,87,.09); }
.acc-tag.cancelled { color: var(--red); border-color: rgba(217,45,32,.35); }
.acc-tag.warn { color: var(--amber-deep); border-color: rgba(224,138,0,.4); background: rgba(224,138,0,.09); }

/* ---------- Подсказки и предупреждения ---------- */
.acc-note { font-size: 13px; line-height: 1.5; color: var(--ink-dim); background: var(--bg-raise); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; }
.acc-note.warn { background: rgba(224,138,0,.09); border-color: rgba(224,138,0,.35); color: var(--ink); }
.acc-note b { color: var(--ink); }
.acc-foot { font-size: 12px; color: var(--ink-faint); line-height: 1.5; max-width: 860px; }
.acc-hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; line-height: 1.4; }

/* ---------- Кассы ---------- */
.acc-cash { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.acc-cash .c { background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer; font-family: var(--body); color: var(--ink); min-height: 44px; }
.acc-cash .c.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,77,166,.12); }
.acc-cash .c.off { opacity: .55; }
.acc-cash .n { font-weight: 700; font-size: 14px; }
.acc-cash .o { font-size: 12px; color: var(--ink-faint); }
.acc-cash .b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 19px; margin-top: 4px; }

/* ---------- Карточки заказчиков и юрлиц ---------- */
.acc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.acc-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 6px; text-align: left; cursor: pointer; font-family: var(--body); color: var(--ink); transition: border-color .15s; }
.acc-card:hover, .acc-card.on { border-color: var(--accent); }
.acc-card .t { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.acc-card .m { font-size: 12.5px; color: var(--ink-dim); line-height: 1.45; overflow-wrap: anywhere; }

/* ---------- Формы ---------- */
.acc-form .field { margin-bottom: 14px; }
.acc-form input, .acc-form select, .acc-form textarea, .acc-grid input, .acc-grid select, .acc-grid textarea {
  width: 100%; min-height: 44px; font-size: 16px; font-family: var(--body); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line-bright); border-radius: 10px; padding: 10px 13px; outline: none;
}
.acc-form textarea, .acc-grid textarea { min-height: 76px; resize: vertical; line-height: 1.4; }
.acc-form input:focus, .acc-form select:focus, .acc-form textarea:focus,
.acc-grid input:focus, .acc-grid select:focus, .acc-grid textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,77,166,.15); }
.acc-form .check input, .acc-grid .check input { width: 20px; min-height: 20px; height: 20px; padding: 0; }
.acc-form .check, .acc-grid .check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 14px; color: var(--ink-dim); margin: 0 0 8px; }
.acc-form .seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-bright); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.acc-form .seg button { min-height: 44px; border: none; background: var(--bg); color: var(--ink-dim); font-size: 14px; font-weight: 600; }
.acc-form .seg button.on { background: var(--accent); color: #fff; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 16px; }
.acc-grid .wide { grid-column: 1 / -1; }
.acc-grid h4 { grid-column: 1 / -1; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); margin: 14px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.acc-grid h4:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.modal:has(.acc-form) { max-width: 560px; }
.modal:has(.acc-form) .actions button { min-height: 44px; }

/* ---------- Нумерация документов: список видов и окно, где номер собирают из частей ---------- */
.acc-numlist { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg-card); }
.acc-numrow {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 8px 14px;
  background: none; border: none; border-top: 1px solid var(--line); font-family: var(--body);
  font-size: 14px; color: var(--ink); text-align: left;
}
.acc-numrow:first-child { border-top: none; }
button.acc-numrow:hover { background: var(--bg-raise); }
button.acc-numrow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.acc-numrow .t { flex: 1; min-width: 0; font-weight: 600; line-height: 1.35; }
.acc-numrow .n { flex: 0 0 220px; min-width: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; overflow-wrap: anywhere; }
.acc-numrow .go { flex: 0 0 104px; display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.acc-numrow.head { min-height: 0; padding: 9px 14px; background: var(--surface-sunken); }
.acc-numrow.head span { font-family: var(--body); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); }

.acc-num-doc { position: relative; z-index: 2; margin: -12px 0 14px; font-size: 13.5px; line-height: 1.4; color: var(--ink-dim); }
/* Пример номера всегда на виду: прилипает к верху окна, пока листают настройки. Прилипает он
   ниже верхнего поля окна, поэтому сплошная тень вверх закрывает то, что проезжает над ним
   (название документа стоит выше тени — z-index у .acc-num-doc). */
.acc-num-ex {
  position: sticky; top: 0; z-index: 1; display: flex; flex-direction: column; gap: 3px;
  margin-bottom: 16px; padding: 11px 14px 12px; border-radius: 12px;
  background: #EEF4FC; border: 1px solid rgba(10,77,166,.22); box-shadow: 0 -30px 0 var(--bg-card);
}
.acc-num-ex .l { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-dim); }
.acc-num-ex .v { min-height: 29px; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; line-height: 1.2; color: var(--navy); overflow-wrap: anywhere; }
.modal:has(.acc-num-ex) { scroll-padding-top: 96px; }
.acc-num-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-num-presets button {
  min-width: 48px; min-height: 44px; max-width: 100%; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line-bright);
  background: var(--bg); color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 14px; font-weight: 600; overflow-wrap: anywhere;
}
.acc-num-presets button:hover { border-color: var(--accent); color: var(--accent); }
.acc-num-presets button.on { border-color: var(--accent); background: rgba(10,77,166,.08); color: var(--accent); }
.acc-num .seg { margin-bottom: 0; }
.acc-num .seg button { min-width: 0; padding: 0 4px; }
.acc-num .seg button + button { border-left: 1px solid var(--line-bright); }
.acc-num .seg button.on + button, .acc-num .seg button.on { border-left-color: var(--accent); }
.acc-num .seg.two button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 54px; padding: 6px 4px; line-height: 1.15; }
.acc-num .seg.two b { font-family: var(--mono); font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.acc-num .seg.two i { font-style: normal; font-size: 11.5px; font-weight: 600; }
.acc-num .seg.two [data-ns] b { font-size: 20px; line-height: 1; }
.acc-switch { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 0 0 14px; font-size: 14px; font-weight: 600; line-height: 1.25; color: var(--ink); cursor: pointer; align-self: end; }
.acc-form .acc-switch input { position: absolute; left: 0; top: 50%; width: 46px; height: 28px; min-height: 0; margin: -14px 0 0; padding: 0; opacity: 0; cursor: pointer; }
.acc-switch .tr { flex: none; position: relative; width: 46px; height: 28px; border-radius: 999px; background: var(--line-bright); transition: background .15s; }
.acc-switch .tr::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16,24,40,.25); transition: transform .15s; }
.acc-switch input:checked + .tr { background: var(--accent); }
.acc-switch input:checked + .tr::after { transform: translateX(18px); }
.acc-switch input:focus-visible + .tr { box-shadow: 0 0 0 3px rgba(10,77,166,.22); }
.acc-switch .dim { display: block; font-size: 12px; font-weight: 500; color: var(--ink-faint); }
.acc-num-custom { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 14px; border-radius: 12px; border: 1px dashed var(--line-bright); background: var(--bg-raise); }
.acc-num-custom .h { font-size: 14px; font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.acc-num-custom .h b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.acc-num-custom p { font-size: 13px; line-height: 1.45; color: var(--ink-dim); }
.acc-num-back { margin: -4px 0 12px; }
.acc-num-back .acc-link { min-height: 44px; }

/* ---------- Предпросмотр документа ---------- */
.acc-doc { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 20px; align-items: start; }
.acc-doc .side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 12px; }
.acc-doc .sheet { min-width: 0; overflow-x: auto; }
.acc-doc .side .acc-btn { width: 100%; min-height: 44px; }

@media (max-width: 900px) {
  .acc-doc { grid-template-columns: 1fr; }
  .acc-doc .side { position: static; }
}

@media (max-width: 720px) {
  .acc { gap: 14px; }
  .acc-btn { min-height: 44px; }
  .acc-btn.sm { min-height: 44px; padding: 0 14px; font-size: 13.5px; }
  .acc-subtabs a { min-height: 44px; }
  .acc-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .acc-kpi { padding: 12px 13px; }
  .acc-kpi .v { font-size: 16px; }
  .acc-kpi .l { font-size: 10.5px; }
  .acc-filters { gap: 8px; }
  .acc-filters label { flex: 1 1 46%; }
  .acc-filters select, .acc-filters input { min-height: 44px; font-size: 16px; width: 100%; }
  .acc-period { width: 100%; justify-content: space-between; }
  .acc-period .seg button, .acc-period .pnav { min-height: 44px; }
  .acc-period .pnav { width: 44px; }
  .acc-period .lbl { flex: 1; min-width: 0; }
  .acc-period .seg { flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .acc-panel > header { padding: 12px 14px; }
  .acc-panel > .body { padding: 14px; }

  /* таблица → стопка карточек: шапка скрыта, подпись колонки берётся из data-label */
  .acc-tablewrap { overflow-x: visible; }
  .page table.acc-t, .acc-t tbody, .acc-t tfoot { display: block; width: 100%; }
  .acc-t thead { display: none; }
  .acc-t tr { display: block; padding: 12px 14px; border-top: 1px solid var(--line); }
  .acc-t tbody tr:first-child { border-top: none; }
  .acc-t td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 3px 0; border: none; text-align: right; white-space: normal; }
  .acc-t td::before { content: attr(data-label); flex: none; max-width: 46%; text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); font-family: var(--body); }
  .acc-t td.main { display: block; text-align: left; font-size: 14.5px; padding-bottom: 6px; }
  .acc-t td.main::before, .acc-t td.act::before { content: none; }
  .acc-t td.act { justify-content: flex-end; padding-top: 8px; flex-wrap: wrap; }
  .acc-t td:empty, .acc-t td.skip { display: none; }
  .acc-t tfoot tr { background: var(--surface-sunken); }
  .acc-t tfoot td { background: none; border: none; }
  .acc-t select { min-height: 44px; font-size: 16px; max-width: 60%; }
  .acc-t tr.clickable:hover td { background: none; }
}

@media (max-width: 330px) {
  .acc-kpis { grid-template-columns: 1fr; }
}
/* телефон: таблицы — карточками, названию объекта есть где переноситься */
@media (max-width: 720px) {
  /* нумерация: название документа — строкой, под ним следующий номер и «Настроить» */
  .acc-numrow { flex-wrap: wrap; gap: 2px 12px; padding: 10px 14px; }
  .acc-numrow.head { display: none; }
  .acc-numrow.head + .acc-numrow { border-top: none; }
  .acc-numrow .t { flex: 1 1 100%; }
  .acc-numrow .n { flex: 1 1 0; }
  .acc-numrow .n::before { content: "следующий № "; font-family: var(--body); font-size: 12px; font-weight: 500; color: var(--ink-faint); }
  .acc-numrow .go { flex: none; min-height: 30px; }
  .acc-num-ex .v { font-size: 22px; }
  .acc-t td.obj, .acc-t td.note { width: auto; max-width: none; }
  .acc-t td.obj .acc-clip { white-space: normal; }
  .acc-t td.note .acc-clamp2 { display: block; }
  .acc-t td.auth { white-space: normal; }
}
