/* Стиль под Google Таблицы / Material: системный шрифт с Google Sans и Roboto впереди,
   серые линии сетки, зелёный лист в логотипе и в строках-группах, синий Material в действиях.
   Внешних шрифтов и CDN нет — сервис личный и должен открываться в любых условиях. */
:root {
  --bg: #f8f9fa; --paper: #fff; --ink: #202124; --muted: #5f6368; --line: #dadce0;
  --grid: #e2e3e3; --grid-strong: #c0c0c0; --head: #f8f9fa;
  --group: #e6f4ea; --group-hover: #d7ecdd; --group-ink: #137333;
  --sel: #1a73e8; --sel-bg: #e8f0fe; --blue: #1a73e8; --blue-dark: #1765cc; --blue-soft: #e8f0fe;
  --green: #0f9d58; --red: #d93025; --red-soft: #fce8e6; --warn-bg: #fef7e0; --warn-ink: #b06000;
  --hover: rgba(60,64,67,.08); --press: rgba(60,64,67,.12);
  --shadow-1: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
  --shadow-3: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
  --month: #0d5f2b; --month-ink: #fff; --month-ink-soft: rgba(255,255,255,.74);
  --font: "Google Sans", Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "DejaVu Sans Mono", Menlo, Consolas, monospace;
  --col: 720px; /* ширина колонки содержимого на мониторе: список и блок управления над ним */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.4 var(--font); -webkit-font-smoothing: antialiased; }
/* Колонка на всю высоту: серое поле списка (.list, flex: 1) тянется до низа экрана даже при одном чеке */
body { display: flex; flex-direction: column; min-height: 100vh; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
h1, h2, h3 { margin: 0; font-weight: 500; }
h1 { font-size: 18px; font-weight: 400; }
h2 { font-size: 18px; }
h3 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
[hidden] { display: none !important; }
/* Скрыть, не убирая из раскладки: iOS не открывает камеру у file-input с display:none. */
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.spacer { flex: 1; }

/* Иконки */
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* Кнопки Material: outlined по умолчанию, filled для главного действия, text для второстепенных, icon — круглые */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 4px; border: 1px solid var(--line); background: var(--paper); color: var(--blue); font: inherit; font-size: 14px; font-weight: 500; letter-spacing: .25px; cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none; -webkit-tap-highlight-color: transparent; transition: background .12s, box-shadow .12s; }
.btn:hover { background: #f6fafe; }
.btn:active { background: var(--blue-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: var(--shadow-1); }
.btn.primary:hover { background: var(--blue-dark); box-shadow: var(--shadow-3); }
.btn.primary:active { background: var(--blue-dark); }
.btn.text { border-color: transparent; }
.btn.text:hover { background: var(--blue-soft); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.danger.filled { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger.filled:hover { background: #c5221f; }
.btn.icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; border-color: transparent; color: var(--muted); }
.btn.icon:hover { background: var(--hover); }
.btn.icon:active { background: var(--press); }
.btn.icon .ic { width: 22px; height: 22px; }
.btn.icon.small { width: 32px; height: 32px; }
.btn.icon.small .ic { width: 18px; height: 18px; }
.btn.icon .lbl { display: none; }
.inline { display: inline; margin: 0; }

/* Шапка документа */
/* На iPhone с главного экрана нет строки браузера, и шапка встаёт под часы/«чёлку» — отступ сверху на safe-area. */
.top { display: flex; align-items: center; gap: 8px; height: 56px; box-sizing: content-box; padding: env(safe-area-inset-top) 8px 0 12px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.logo { width: 28px; height: 36px; border-radius: 3px; background: var(--green); position: relative; flex: none; }
.logo::before { content: ""; position: absolute; left: 7px; right: 7px; top: 12px; bottom: 8px; border: 2px solid #fff; border-radius: 1px; }
.logo::after { content: ""; position: absolute; left: 7px; right: 7px; top: 19px; height: 2px; background: #fff; box-shadow: 0 5px 0 #fff; }
.logo.big { width: 40px; height: 52px; border-radius: 4px; }
.logo.big::before { left: 10px; right: 10px; top: 17px; bottom: 11px; }
.logo.big::after { left: 10px; right: 10px; top: 27px; height: 2px; box-shadow: 0 7px 0 #fff; }
.top .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Строка периода под шапкой: «‹ [📅 Февраль 2026 ▾] ›». Не липкая — скроллится вместе со списком,
   липкой остаётся только шапка, поэтому top у заголовка таблицы не трогаем. */
.period-bar { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 4px; border-bottom: 1px solid var(--grid); }
.period-arrow { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.period-arrow:hover { background: var(--hover); }
.period-arrow:active { background: var(--press); }
.period-arrow[disabled] { opacity: .3; cursor: default; background: none; }
.period-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; height: 40px; padding: 0 10px 0 14px; border: 0; border-radius: 20px; background: transparent; font: inherit; font-size: 16px; font-weight: 500; color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.period-name:hover { background: var(--hover); }
.period-name span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.period-name .ic { width: 18px; height: 18px; color: var(--muted); }
.period-name .chev { width: 20px; height: 20px; }
/* Режим ленты: суффикс « · по загрузке» серым — состояние видно всегда, но не спорит с названием месяца */
.period-name #periodLabel { display: flex; flex-direction: column; align-items: flex-start; line-height: 18px; }
.period-name .mode { font-size: 11px; line-height: 12px; font-weight: 400; color: var(--muted); }

/* Всплывающие меню: шапки (статичное) и строк редактора (собираются в JS). position: fixed —
   placeMenu() выставляет top/left по якорю и вылезает за границы прокручиваемой шторки. */
.menu { position: fixed; z-index: 40; min-width: 224px; padding: 8px 0; background: var(--paper); border-radius: 4px; box-shadow: var(--shadow-3); }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 16px; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink); text-align: left; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.menu-item:hover { background: var(--hover); }
.menu-item:active { background: var(--press); }
.menu-item[disabled] { opacity: .5; cursor: default; background: none; }
.menu-item .ic { color: var(--muted); }
.menu-item.danger, .menu-item.danger .ic { color: var(--red); }
.menu-sep { height: 1px; margin: 8px 0; background: var(--line); }
.menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 20px; }
.menu-text .sub { font-size: 12px; line-height: 16px; color: var(--muted); }
.menu .inline { display: block; }

/* Тумблер «Чёрный список» в меню: сам чекбокс скрыт, рисуется дорожка с кружком */
.switch-item { cursor: pointer; user-select: none; }
.switch { position: relative; display: inline-block; flex: none; width: 36px; height: 20px; margin-left: 4px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: 10px; background: #bdc1c6; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .15s; }
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 2px var(--blue-soft); }

/* Индикатор загрузки — тонкая полоса под шапкой, как в Material */
.progress { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 5; height: 3px; margin-bottom: -3px; background: var(--blue-soft); overflow: hidden; }
.progress .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 40%; background: var(--blue); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Панель действий, как тулбар Sheets */
.toolbar { display: flex; gap: 8px; align-items: center; padding: 6px 8px; margin: 10px 12px 8px; background: #f1f3f4; border-radius: 24px; }
.toolbar .btn { background: transparent; border-color: transparent; }
.toolbar .btn:hover { background: var(--hover); }
.toolbar .btn.primary { background: var(--blue); border-color: var(--blue); }
.toolbar .btn.primary:hover { background: var(--blue-dark); }

/* Баннеры: ошибки красные и остаются до закрытия, подсказки серые */
.banner { display: flex; align-items: flex-start; gap: 10px; margin: 0 12px 8px; padding: 10px 8px 10px 14px; border-radius: 8px; font-size: 13px; line-height: 20px; }
.banner .ic { margin-top: 0; width: 20px; height: 20px; }
.banner .text { flex: 1; word-break: break-word; padding-top: 0; }
.banner .btn.icon.small { margin: -6px -2px -6px 0; }
.banner.error { background: var(--red-soft); color: #a50e0e; }
.banner.error .ic { color: var(--red); }
.banner.info { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.banner.info .ic { color: var(--blue); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.warn .ic { color: #f29900; }
.banner.compact { margin: 0 0 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* Сводка периода: цифры текстом слева, справа единственная кнопка «Чёрный список N ›» */
.summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 16px 12px; }
.stats { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
/* Сумма и подпись — flex с переносом: на узком экране рядом с кнопкой ЧС подпись уходит под сумму, а не наезжает */
.stats .total { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stats .total > span { white-space: nowrap; }
.stats .total small { font-size: 13px; font-weight: 400; color: var(--muted); }
.stats .sub { font-size: 12px; color: var(--muted); }
.chip-link { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 6px 0 12px; border-radius: 18px; border: 1px solid var(--blue); background: var(--paper); color: var(--blue); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.chip-link:hover { background: var(--blue-soft); }
.chip-link .ic { width: 18px; height: 18px; }
.chip-link .n { padding: 0 6px; border-radius: 9px; background: var(--blue-soft); font-variant-numeric: tabular-nums; }
.chip { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 12px; border-radius: 14px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; background: var(--paper); }
.chip b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.chip.total { background: var(--group); border-color: transparent; color: var(--group-ink); }
.chip.total b { color: var(--group-ink); }
.chip.action { font: inherit; font-size: 12px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chip.action:hover { background: var(--hover); }
.chip.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn-ink); }
.chip.warn:hover { background: #fdefc3; }

/* Список чеков: серое поле, на нём полоса месяца во всю ширину и белые «бумажки» чеков с зубчатым низом.
   Бумажка набрана моноширинным, как кассовая лента; название магазина — как хранится, капс даёт CSS. */
.list { flex: 1; padding: 12px 0 84px; background: var(--bg); border-top: 1px solid var(--grid-strong); }
.list .month + .month { margin-top: 20px; }
.month-band { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 11px 16px; background: var(--month); color: var(--month-ink); }
.month-band .name { font-size: 19px; font-weight: 700; letter-spacing: .2px; line-height: 22px; }
.month-band .sub { font-size: 12px; line-height: 15px; color: var(--month-ink-soft); margin-top: 3px; }
.month-band .sum { font-size: 20px; font-weight: 700; line-height: 22px; }
/* 12px между полосой и первой бумажкой и между бумажками; тень — filter на обёртке, чтобы шла по зубцам */
.receipts { padding: 12px 12px 6px; }
.card { margin: 0 0 12px; filter: drop-shadow(0 1px 1.5px rgba(60,64,67,.30)) drop-shadow(0 2px 6px rgba(60,64,67,.12)); }
.card:last-child { margin-bottom: 0; }
/* Зубцы шагом 16px по нижнему краю — маска из сплошного поля и ряда треугольников, ширина бумажки любая.
   Бумажка целиком — тап-цель: без выделения текста и синей вспышки при долгом нажатии. */
.paper { background: var(--paper); padding: 12px 12px 20px; font-family: var(--mono); font-size: 12px; line-height: 1.4; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at 50% 100%, #000 90deg, #0000 0) bottom / 16px 8px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at 50% 100%, #000 90deg, #0000 0) bottom / 16px 8px repeat-x; }
.paper.selected { box-shadow: inset 0 0 0 2px var(--sel); }
/* Шапка бумажки: слева день крупно и месяц под ним за пунктирной чертой, справа магазин капсом и «№ · позиции» */
.phead { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; }
.phead .date { flex: none; width: 46px; padding-right: 10px; margin-right: -2px; border-right: 1px dashed var(--line); font-family: var(--font); }
.phead .day { font-size: 24px; font-weight: 400; line-height: 26px; color: var(--ink); letter-spacing: -.3px; }
.phead .mon { font-size: 12px; line-height: 14px; color: var(--muted); margin-top: 1px; text-transform: lowercase; }
.phead .who { flex: 1 1 auto; min-width: 0; padding-top: 2px; }
.shop { font-weight: 700; font-size: 13px; line-height: 16px; letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere; }
.stamp { color: var(--muted); font-size: 11.5px; line-height: 15px; margin-top: 3px; white-space: normal; }
.stamp .badge { font-family: var(--font); margin-left: 0; vertical-align: 0; }
.paper .rule { border: 0; border-top: 1px dashed var(--line); margin: 10px 0; }
/* Позиция: «название … сумма» с точечной дорожкой; длинное название переносится, сумма не ломается */
.pos { padding: 3px 0; cursor: pointer; }
.pos:hover { background: var(--bg); }
.pos.selected { background: var(--sel-bg); box-shadow: inset 0 0 0 1px var(--sel); }
.pos .line { display: flex; align-items: flex-end; }
.pos .nm { flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.pos .dots { flex: 1 0 14px; height: 3px; margin: 0 3px 5px; background: radial-gradient(circle, var(--muted) .8px, transparent 1.1px) 0 100% / 5px 3px repeat-x; }
.pos .sum { flex: none; }
/* Исключённая: серая и зачёркнутая, под ней «перечёркнутый глаз» и кто исключил — правило ЧС или рука */
.pos.excluded { color: var(--muted); }
.pos.excluded .nm, .pos.excluded .sum { text-decoration: line-through; text-decoration-color: rgba(95,99,104,.7); }
.pos.excluded .dots { opacity: .55; }
.pos .flag { display: flex; align-items: center; gap: 4px; font-size: 11px; line-height: 14px; color: var(--muted); padding: 1px 0 1px; }
.pos .flag .ic { width: 13px; height: 13px; }
.paper .total { display: flex; justify-content: space-between; font-weight: 700; font-size: 13.5px; padding-top: 2px; }
.paper .counted { display: flex; justify-content: space-between; color: var(--group-ink); font-size: 12px; margin-top: 4px; }
.list .empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 36px 16px; color: var(--muted); font-size: 13px; }
.list .empty .ic { width: 36px; height: 36px; margin-bottom: 8px; color: #bdc1c6; }
/* Десктоп: список по центру, ширина колонки — --col (см. блок «Монитор» в конце файла) */
@media (min-width: 720px) { .list .month { max-width: var(--col); margin-left: auto; margin-right: auto; } }
/* Подсветка строки редактора, к которой подвели из шторки («Изменить») */
table.items tr.flash td input { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--blue-soft); box-shadow: 0 0 0 1px var(--blue); } to { background: var(--paper); } }
.badge { display: inline-block; font-size: 11px; line-height: 16px; color: var(--warn-ink); background: var(--warn-bg); padding: 0 7px; border-radius: 8px; margin-left: 6px; font-weight: 400; vertical-align: 1px; }
.badge.muted { color: var(--muted); background: #f1f3f4; }

.modal-body.lightbox { display: flex; flex-direction: column; max-height: calc(100vh - env(safe-area-inset-top)); }
.modal-body.lightbox img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; object-fit: contain; background: #202124; }

/* История добавления */
.hi-day { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin: 12px 0 2px; }
.hi-day:first-child { margin-top: 4px; }
.hi-row .main { cursor: pointer; }
.hi-row .t { display: flex; justify-content: space-between; gap: 8px; }
.hi-row .t .num { font-weight: 400; font-variant-numeric: tabular-nums; flex: none; }
.hi-row.deleted .t { color: var(--muted); text-decoration: line-through; }
.hi-row.deleted .s { color: var(--muted); }
.hi-row .s .del { color: var(--red); }
.hi-row .btn.icon.confirm { color: var(--red); }
.hi-row .btn.text { flex: none; font-size: 13px; padding: 0 10px; color: var(--red); }

/* Диалоги Material: на телефоне — шторка снизу, на широком экране — окно по центру */
.modal { position: fixed; inset: 0; background: rgba(32,33,36,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; padding-top: env(safe-area-inset-top); }
.modal-body { background: var(--paper); width: 100%; max-width: 680px; max-height: 94vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 12px 16px 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-3); }
@media (min-width: 720px) { .modal { align-items: center; padding: 24px; } .modal-body { border-radius: 8px; padding: 16px 24px 20px; } }
.modal-body.center { text-align: center; padding: 28px 32px; border-radius: 8px; width: auto; min-width: 260px; max-width: 320px; align-self: center; }
.modal-body.center p { margin: 0; }
.modal-body.center .hint { margin-top: 6px; }
.modal-body.confirm { max-width: 400px; border-radius: 8px; align-self: center; padding: 20px 24px 16px; }
.modal-body.confirm p { color: var(--muted); margin: 10px 0 0; }
.dialog-head { display: flex; align-items: center; gap: 8px; margin: 0 -8px 12px 0; min-height: 40px; }
.dialog-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.via { color: var(--muted); font-size: 12px; }
.scanner video { width: 100%; border-radius: 8px; background: #000; aspect-ratio: 3 / 4; object-fit: cover; }
.scanner .hint { text-align: center; }
.spinner { width: 36px; height: 36px; border: 4px solid #e8eaed; border-top-color: var(--blue); border-radius: 50%; margin: 0 auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Окно «Чёрный список»: форма добавления сверху, ниже список записей; запись в правке — та же форма на месте */
.modal-body.blacklist { min-height: 50vh; }
.bl-form { display: flex; flex-direction: column; gap: 8px; }
.bl-row { display: flex; align-items: center; gap: 8px; }
.bl-row input { flex: 1; }
.bl-row select { flex: none; width: 116px; }
.bl-row .btn { flex: none; height: 40px; }
.bl-list { list-style: none; margin: 8px 0 0; padding: 0; }
.bl-entry { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.bl-entry.editing { display: block; background: var(--bg); margin: 0 -16px; padding: 12px 16px; border-bottom-color: var(--line); }
@media (min-width: 720px) { .bl-entry.editing { margin: 0 -24px; padding: 12px 24px; } }
.bl-main { flex: 1; min-width: 0; }
.bl-pattern { font-weight: 500; overflow-wrap: anywhere; }
.bl-pattern .badge { margin-left: 4px; }
.bl-sub { font-size: 12px; color: var(--muted); }
.bl-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 24px 16px; color: var(--muted); font-size: 13px; }
.bl-empty .ic { width: 36px; height: 36px; color: #bdc1c6; }

/* Окно «Реестр и xlsx»: три блока — нераспечатанные, список реестров, таблица */
.modal-body.export { min-height: 40vh; }
.ex-block { padding: 12px 0 14px; border-bottom: 1px solid var(--grid); }
.ex-block:last-child { border-bottom: 0; }
.ex-block h3 { margin-bottom: 8px; }
.ex-new { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ex-new-text { flex: 1; min-width: 0; font-size: 14px; }
.ex-new-text b { font-weight: 500; font-variant-numeric: tabular-nums; }
.ex-new-text .sub { display: block; font-size: 12px; color: var(--muted); }
.ex-new .btn { flex: none; }
.ex-list { list-style: none; margin: 0; padding: 0; }
.ex-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); }
.ex-row:last-child { border-bottom: 0; }
.ex-row .main { flex: 1; min-width: 0; }
.ex-row .t { font-weight: 500; }
.ex-row .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ex-row .btn.icon { flex: none; }
.ex-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }
.ex-row.cut .t, .ex-row.cut .s { color: var(--muted); }
.ex-row .s .tag { color: var(--group-ink); }
.ex-new-text .warn { display: block; font-size: 12px; color: var(--warn-ink); }
#exCuts { margin-top: 8px; }
/* Метка «не распечатан» на бумажке — синяя, чтобы не путать с жёлтым предупреждением «без позиций» */
.badge.new { color: var(--blue); background: var(--blue-soft); }

/* Поля формы: подпись сверху, как в Material outlined */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.grid label, .field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.grid label > span, .field > span { font-size: 12px; color: var(--muted); }
.grid .wide { grid-column: 1 / -1; }
input[type=text], input[type=number], input[type=datetime-local], input[type=password] { font: inherit; font-size: 14px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; width: 100%; min-width: 0; background: var(--paper); color: var(--ink); }
input::placeholder { color: #9aa0a6; }
input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select { font: inherit; font-size: 14px; height: 40px; padding: 0 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); color: var(--ink); }
select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }

/* Позиции чека внутри редактора */
.items-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 2px; }
.items-head .btn { height: 32px; padding: 0 10px 0 6px; }
table.items { width: 100%; border-collapse: collapse; font-size: 13px; }
table.items th { text-align: left; color: var(--muted); font-weight: 500; padding: 4px 4px 6px; font-size: 12px; border-bottom: 1px solid var(--grid); }
table.items td { padding: 3px 2px; }
table.items td input { height: 36px; padding: 0 8px; }
table.items th.q, table.items td.q { width: 64px; }
table.items th.s, table.items td.s { width: 96px; }
table.items td.s input, table.items td.q input { text-align: right; }
table.items th.x, table.items td.x { width: 32px; padding: 0; }
/* Строка «не учитывать» в редакторе: поля приглушены, чтобы пометка была видна не только по иконке */
table.items tr.excluded td input { color: var(--muted); background: var(--bg); text-decoration: line-through; }
table.items tr.excluded td.x .btn { color: var(--warn-ink); }
table.items tfoot td { color: var(--muted); padding: 8px 4px 0; border-top: 1px solid var(--grid); }
table.items tfoot td#itemsSum { text-align: right; font-weight: 500; color: var(--ink); padding-right: 10px; font-variant-numeric: tabular-nums; }
table.items tfoot td#itemsSum.mismatch { color: var(--red); }
#mismatch { margin-top: 10px; }
.fiscal { margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.fiscal summary { cursor: pointer; padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 6px; }
.fiscal summary::-webkit-details-marker { display: none; }
.fiscal summary::before { content: ""; width: 0; height: 0; border: 5px solid transparent; border-left-color: var(--muted); margin-left: 4px; transition: transform .12s; }
.fiscal[open] summary::before { transform: rotate(90deg); }
.fiscal .grid { margin-top: 8px; }
.editor-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }
.editor-foot .btn { padding: 0 12px; }
/* В редакторе подвал липнет к низу шторки: «Сохранить» всегда под рукой, длинный чек не надо доскролливать. */
.modal-body.editor { padding-bottom: 0; }
.modal-body.editor .editor-foot { position: sticky; bottom: 0; z-index: 3; margin: 16px -16px 0; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
@media (min-width: 720px) { .modal-body.editor .editor-foot { margin: 16px -24px 0; padding: 12px 24px; } }

/* Нижняя шторка действий (#veil/#sheet): подложка, ручка, заголовок, пункты ≥56px */
/* Подложка темнеет, а сама шторка остаётся непрозрачной и только выезжает снизу — иначе в момент анимации
   сквозь неё просвечивает таблица. */
.veil { position: fixed; inset: 0; z-index: 35; background: rgba(32,33,36,0); display: flex; align-items: flex-end; justify-content: center; transition: background .24s ease; touch-action: none; overscroll-behavior: none; }
.veil.open { background: rgba(32,33,36,.55); }
.bsheet { width: 100%; max-width: 680px; max-height: 88vh; overflow: auto; background: var(--paper); border-radius: 16px 16px 0 0; padding: 8px 0 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-3); transform: translateY(100%); transition: transform .24s ease; touch-action: none; overscroll-behavior: contain; }
.veil.open .bsheet { transform: none; }
.bsheet .handle { width: 40px; height: 5px; margin: 2px auto 12px; border-radius: 3px; background: var(--line); touch-action: none; cursor: grab; }
.bsheet .head { padding: 0 16px 10px; border-bottom: 1px solid var(--line); }
.bsheet .head .t { font-size: 16px; line-height: 22px; font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bsheet .head .s { font-size: 13px; line-height: 18px; color: var(--muted); margin-top: 2px; }
.act { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 56px; padding: 8px 16px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; text-align: left; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.act:hover { background: var(--hover); }
.act:active { background: var(--press); }
.act .ic { width: 24px; height: 24px; color: var(--muted); }
.act .tx { display: flex; flex-direction: column; line-height: 22px; min-width: 0; }
.act .tx small { font-size: 13px; line-height: 18px; color: var(--muted); }
.act.primary, .act.primary .ic { color: var(--blue); }
.act.danger, .act.danger .ic { color: var(--red); }
.act.on .ic { color: var(--blue); }
.act .amt { margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.act[aria-checked="true"] { color: var(--blue); font-weight: 500; }
.act[aria-checked="true"] .ic, .act[aria-checked="true"] .amt { color: var(--blue); }
.bsheet .sep { height: 1px; margin: 6px 0; background: var(--line); }
/* Сегмент «По дате чека | По загрузке» в шторке периода: две радиокнопки в одной рамке, выбранная — синяя заливка */
.seg-wrap { padding: 12px 16px 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.seg-btn { flex: 1; height: 36px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background .12s; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn:hover { background: var(--hover); }
.seg-btn[aria-checked="true"] { background: var(--blue-soft); color: var(--blue); }
.seg-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.seg-sub { margin-top: 6px; font-size: 12px; line-height: 16px; color: var(--muted); text-align: center; }
.bsheet .sheet-confirm { padding: 4px 16px 8px; }
.bsheet .sheet-confirm p { margin: 8px 0 16px; color: var(--muted); }
.bsheet .sheet-confirm .row { display: flex; gap: 8px; justify-content: flex-end; }
.bsheet .sheet-confirm .btn { height: 40px; }
@media (min-width: 720px) { .veil { align-items: center; padding: 24px; } .bsheet { max-width: 440px; border-radius: 8px; } .bsheet .handle { display: none; } }
@media (prefers-reduced-motion: reduce) { .veil, .bsheet, table.items tr.flash td input { transition: none; animation: none; } }

/* Тост-снекбар: не перекрывает кнопки, тянется по ширине на телефоне */
.toast { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 8px; max-width: calc(100vw - 24px); min-width: 280px; padding: 12px 8px 12px 16px; border-radius: 4px; background: #323232; color: #fff; font-size: 14px; line-height: 20px; box-shadow: var(--shadow-3); animation: rise .18s ease-out; }
.toast .text { flex: 1; }
/* Тост не перехватывает тапы по тому, что под ним, — кликабельна только его кнопка. */
.toast { pointer-events: none; }
.toast .toast-action { pointer-events: auto; }
.toast-action { font: inherit; font-weight: 500; color: #8ab4f8; background: none; border: 0; padding: 6px 8px; border-radius: 4px; cursor: pointer; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.toast-action:hover { background: rgba(255,255,255,.08); }
/* Поверх редактора тост не наверх, а над его липким подвалом */
.toast.raised { bottom: calc(64px + env(safe-area-inset-bottom)); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Вход */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 16px; }
.login { background: var(--paper); padding: 32px 28px 28px; border-radius: 8px; width: min(100%, 360px); display: flex; flex-direction: column; gap: 14px; border: 1px solid var(--line); align-items: stretch; }
.login .logo { align-self: center; margin-bottom: 4px; }
.login h1 { font-size: 24px; text-align: center; }
.login .sub { margin: -8px 0 8px; text-align: center; color: var(--muted); font-size: 14px; }
.login .btn { height: 40px; margin-top: 4px; }
.err { color: var(--red); margin: -6px 0 0; font-size: 13px; }

/* Телефон: шапка и тулбар плотнее, поля редактора в одну колонку */
@media (max-width: 600px) {
  .top { gap: 4px; padding: 0 4px 0 10px; }
  .toolbar { margin: 8px 8px 8px; padding: 6px; gap: 6px; }
  .toolbar .btn { flex: 1; padding: 0 8px; gap: 6px; }
  .lbl { display: none; }
  .banner { margin-left: 8px; margin-right: 8px; }
  .summary { padding-left: 12px; padding-right: 8px; gap: 8px; }
  .chip { padding: 0 10px; }
  .btn.icon.small { width: 40px; height: 40px; }
  .grid { grid-template-columns: 1fr; }
  table.items th.q, table.items td.q { width: 56px; }
  table.items th.s, table.items td.s { width: 88px; }
  table.items td input { padding: 0 6px; }
  .editor-foot .btn.text { padding: 0 10px; }
  .toast { left: 8px; right: 8px; transform: none; min-width: 0; max-width: none; }
  .ex-new { flex-direction: column; align-items: stretch; }
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* Монитор: блок управления (.controls) — сетка шириной со списком, по центру. Период слева, стрелки прижаты
   к названию (на телефоне они разведены по краям — тут на 1920px это выглядело бы как два одиноких крючка),
   тулбар справа, баннеры и сводка под ними во всю ширину колонки. Отступ 12px совпадает с полем .receipts,
   так что край бумажки чека, сумма сводки и кнопки над ними стоят на одной вертикали. */
@media (min-width: 720px) {
  .controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; width: 100%; max-width: var(--col); margin: 0 auto; padding: 12px 12px 4px; }
  .controls .period-bar { justify-content: flex-start; gap: 2px; height: 44px; padding: 0; margin-left: -8px; border-bottom: 0; }
  .controls .period-arrow { width: 36px; height: 36px; }
  .controls .period-name { height: 36px; padding-left: 10px; }
  .controls .toolbar { margin: 0; padding: 4px; }
  .controls .banner { grid-column: 1 / -1; margin: 10px 0 0; }
  .controls .summary { grid-column: 1 / -1; padding: 12px 0 8px; }
}
