:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f1f4);
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --text: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  /* --accent/--accent-text ставит theme.js, если сотрудник выбрал свой цвет в «Оформлении» */
  --link: var(--accent, var(--tg-theme-link-color, #2481cc));
  --btn: var(--accent, var(--tg-theme-button-color, #2481cc));
  --btn-text: var(--accent-text, var(--tg-theme-button-text-color, #ffffff));
  --danger: var(--tg-theme-destructive-text-color, #e5393b);
  --sep: color-mix(in srgb, var(--hint) 25%, transparent);
  --radius: 12px;
  --page: var(--bg2);
}
:root[data-scheme="dark"] {
  color-scheme: dark;            /* системные элементы (часы/календарь в полях) — светлые на тёмном */
  --page: color-mix(in srgb, var(--bg2) 50%, #000);
  --section: color-mix(in srgb, var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e)) 92%, #fff);
}
/* Тема, выбранная вручную в «Оформлении»: свои цвета вместо цветов Telegram (фон шапки — PAGE в theme.js) */
:root[data-forced="light"] { color-scheme: light; --bg: #ffffff; --bg2: #f1f1f4; --section: #ffffff; --text: #111111;
  --hint: #8a8a8e; --page: #f1f1f4; --danger: #e5393b; }
:root[data-forced="dark"] { color-scheme: dark; --bg: #1c1c1e; --bg2: #141416; --section: #232326; --text: #f2f2f4;
  --hint: #8d8e93; --page: #0f0f10; --danger: #ff5f5c; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--page); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
       overflow-x: hidden; padding-bottom: env(safe-area-inset-bottom); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 96px; }
h1 { font-size: 22px; margin: 4px 0 12px; line-height: 1.25; overflow-wrap: anywhere; }
h2 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em;
     color: var(--hint); margin: 20px 4px 6px; }
p { margin: 8px 4px; }
.hint { color: var(--hint); font-size: 14px; }
.loading, .empty { color: var(--hint); text-align: center; padding: 32px 8px; }

.head { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.head h1 { margin: 0; flex: 1; min-width: 0; }
.head .sub { color: var(--hint); font-size: 14px; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--section);
            font-size: 18px; cursor: pointer; }
.icon-btn.small { width: 36px; height: 36px; font-size: 16px; background: var(--bg2); color: var(--link); }
.icon-btn.small.danger { color: var(--danger); }
.row-actions { flex: none; display: flex; gap: 8px; }


.avatar { flex: none; border-radius: 50%; object-fit: cover; display: grid; place-items: center;
          font-weight: 600; color: var(--btn-text); background: var(--btn); overflow: hidden; }

.list { background: var(--section); border-radius: var(--radius); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px;
       width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left;
       position: relative; cursor: pointer; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 1px solid var(--sep); }
.row .main { flex: 1; min-width: 0; }
.row .title { overflow-wrap: anywhere; }
.row .sub { color: var(--hint); font-size: 14px; white-space: pre-line; }
.row .chev { color: var(--hint); flex: none; }
.row:active { background: var(--bg2); }
.row.static { cursor: default; }
.row.sortable { padding-left: 6px; cursor: default; }
.row.sortable:active { background: none; }
.row.sortable.nogrip { padding-left: 14px; }   /* без ручки — отступ как у обычных строк */
.row .grip { flex: none; width: 28px; align-self: stretch; display: grid; place-items: center; color: var(--hint); cursor: grab; touch-action: none; }
.row .moves { flex: none; display: flex; flex-direction: column; }
.row .moves button { border: 0; background: none; color: var(--hint); width: 28px; height: 20px; padding: 0; cursor: pointer; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; border: 0; background: none; color: inherit;
            font: inherit; text-align: left; padding: 0; cursor: pointer; }
.row.static:active { background: none; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--section); border-radius: var(--radius); padding: 14px; border: 0; color: inherit;
        font: inherit; text-align: left; min-height: 88px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.tile .ico { font-size: 24px; }
.tile .sub { color: var(--hint); font-size: 13px; }
/* Главная: разделы в одну строку, без подписей */
.tiles.nav { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.tiles.nav .tile { min-height: 0; padding: 10px 6px; align-items: center; justify-content: center; gap: 2px; font-size: 14px; text-align: center; line-height: 1.2; }
.tiles.nav .tile .ico { font-size: 22px; }
.tiles.nav > :last-child { grid-column: auto; }   /* перебить растяжку последней плитки из .tiles */

.btn { display: block; width: 100%; min-height: 48px; padding: 12px 16px; margin: 10px 0 0; border: 0;
       border-radius: var(--radius); background: var(--btn); color: var(--btn-text); font: inherit; font-weight: 600;
       cursor: pointer; }
.btn:disabled { opacity: .45; }
.btn.secondary { background: var(--section); color: var(--link); }
.btn.danger { background: var(--section); color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; width: auto; display: inline-block; font-weight: 500; }
.sticky { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
          background: color-mix(in srgb, var(--page) 92%, transparent); backdrop-filter: blur(8px); }
.sticky .btn { max-width: 608px; margin: 0 auto; }
/* Ввод с клавиатуры (app.js: watchKeyboard): место, чтобы поднять нижний пункт над клавиатурой */
body.typing #app { padding-bottom: 60vh; }

.field { display: block; padding: 10px 14px; position: relative; }
.field + .field::before { content: ""; position: absolute; top: 0; left: 14px; right: 0; border-top: 1px solid var(--sep); }
.field span { display: block; font-size: 13px; color: var(--hint); margin-bottom: 2px; }
.opens-row { display: flex; align-items: center; gap: 12px; } .opens-row input { flex: 1; min-width: 0; } .opens-row .btn-link { flex: none; width: auto; margin: 0; padding: 4px 0; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: transparent; border: 0;
                          width: 100%; padding: 4px 0; outline: none;
                          caret-color: var(--text); }   /* иначе iOS берёт оттенок Telegram — на белом фоне курсор не виден */
select { appearance: none; }
input::placeholder, textarea::placeholder { color: var(--hint); }
/* iOS центрирует значение в полях времени/даты — во всех формах ровняем влево, как остальные поля */
input[type="time"], input[type="date"] { text-align: left; -webkit-appearance: none; appearance: none; min-height: 1.4em; }
input[type="time"]::-webkit-date-and-time-value, input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.check { display: flex; align-items: center; gap: 12px; }
.check input { width: 22px; height: 22px; accent-color: var(--btn); flex: none; }

.item { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px 8px 6px; position: relative; background: var(--section); }
.item + .item::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; border-top: 1px solid var(--sep); }
.item .grip { flex: none; width: 28px; min-height: 40px; display: grid; place-items: center; color: var(--hint);
              cursor: grab; touch-action: none; font-size: 18px; }
.item .type { flex: none; width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--bg2);
              font-size: 20px; cursor: pointer; }
.item .body { flex: 1; min-width: 0; }
.item .body input.t { padding: 8px 0 2px; }
.item .body input.h { font-size: 14px; color: var(--hint); padding: 0 0 6px; }
.item .x { flex: none; width: 36px; height: 40px; border: 0; background: none; color: var(--hint); font-size: 20px; cursor: pointer; }
.item .moves { display: flex; flex-direction: column; }
.item .moves button { border: 0; background: none; color: var(--hint); width: 28px; height: 20px; padding: 0; cursor: pointer; }
.sortable-ghost { opacity: .4; }
.adders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--hint); }
.linkbox { font-size: 14px; word-break: break-all; padding: 12px 14px; }

#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
         max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 12px; background: rgba(30, 30, 32, .92); color: #fff;
         font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: rgba(200, 40, 40, .95); }


[hidden] { display: none !important; }
.st { font-size: 12px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex: none; background: var(--bg2); color: var(--text); }
.st-ontime { background: color-mix(in srgb, #2ea043 18%, var(--section)); }
.st-late { background: color-mix(in srgb, #f08c00 20%, var(--section)); }
.st-missed { background: color-mix(in srgb, #e5393b 18%, var(--section)); }
.st-in_progress { background: color-mix(in srgb, #f5c400 22%, var(--section)); }
.note { margin: 0 4px 10px; padding: 10px 12px; border-radius: 12px; background: var(--section); color: var(--hint); font-size: 14px; }
.note.warn { background: color-mix(in srgb, #f08c00 18%, var(--section)); color: var(--text); }
.row.fill { min-height: 60px; }
.row.fill:disabled { cursor: default; color: inherit; opacity: 1; }
.row .box { flex: none; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--hint); display: grid;
            place-items: center; font-weight: 700; color: var(--btn-text); }
.row .box.on { background: var(--btn); border-color: var(--btn); }
.thumb { flex: none; width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--bg2);
         display: grid; place-items: center; font-size: 24px; cursor: zoom-in; }
.badge { flex: none; font-size: 18px; }
.sub.err { color: var(--danger); }
.cam { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: flex; flex-direction: column; }
.cam-top { display: flex; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; }
.cam-icon { width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 20px; cursor: pointer; }
.cam-icon.on { background: #ffd54a; color: #000; }
.cam-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.cam-video { width: 100%; height: 100%; object-fit: contain; }
.cam-msg { position: absolute; left: 20px; right: 20px; text-align: center; line-height: 1.5; }
.cam-msg:empty { display: none; }
.cam-play { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); }
.cam-bottom { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
.cam-shutter { width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; background: rgba(255,255,255,.25); cursor: pointer; }
.cam-shutter:active { background: #fff; }
.cam-shutter:disabled { opacity: .4; }
.cam-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 480px; }
.cam-actions .btn { margin: 0; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: grid; place-items: center; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

.presets { display: flex; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.presets .btn { margin: 0; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.chip-field { display: flex; align-items: center; gap: 6px; min-width: 0; min-height: 44px; padding: 0 12px;
              background: var(--section); border-radius: 12px; }
.chip-field.wide { grid-column: 1 / -1; }
.chip-field span { flex: none; font-size: 14px; color: var(--hint); }
.chip-field input, .chip-field select { flex: 1; min-width: 0; width: auto; padding: 0; min-height: 0; text-align: left; }
.pct { font-size: 18px; flex: none; }
.pct.good { color: #2ea043; } .pct.mid { color: #d98a00; } .pct.bad { color: var(--danger); }
.count { font-size: 16px; flex: none; white-space: nowrap; }
.count.good { color: #2ea043; } .count.mid { color: #d98a00; } .count.bad { color: var(--danger); }
.venue-label { font-weight: 600; margin: 14px 4px 6px; }
.dept-label { color: var(--hint); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em;
              margin: 10px 14px 6px; }
.venue-label + div > div:first-child > .dept-label { margin-top: 4px; }

textarea { resize: vertical; min-height: 96px; }
.static-tile { cursor: default; min-height: 72px; }
.big { font-size: 24px; }
.shot { display: block; max-width: 100%; border-radius: 12px; margin-top: 10px; cursor: zoom-in; }
.ctx { margin: 0; padding: 12px 14px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }

.adders { grid-template-columns: 1fr 1fr 1fr; }
.adders .btn { padding: 12px 6px; }
.item.zone { background: color-mix(in srgb, var(--btn) 10%, var(--section)); }
.item.zone .type { background: transparent; font-size: 20px; display: grid; place-items: center; }
.item.zone input.t { font-weight: 700; padding: 8px 0; }
.zone-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 18px 4px 6px; font-weight: 700; }
.zone-head span:first-child { overflow-wrap: anywhere; }
.zone-count { flex: none; color: var(--hint); font-weight: 500; font-size: 14px; }
.zone-count.full { color: #2ea043; }

.btn-link { display: block; width: 100%; max-width: 608px; margin: 6px auto 0; padding: 6px; border: 0; background: none;
            color: var(--link); font: inherit; font-size: 14px; cursor: pointer; }
main { padding-bottom: 140px; }

/* Режим просмотра владельца «глазами сотрудника» */
.preview-bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 8px 16px;
               background: #f5c400; color: #111; font-size: 14px; line-height: 1.3; }
.preview-bar span { flex: 1; min-width: 0; }
.preview-bar button { flex: none; border: 0; border-radius: 999px; padding: 6px 12px; background: #111; color: #fff;
                      font: inherit; font-weight: 600; cursor: pointer; }

/* Две кнопки в ряд (главная: обратная связь и канал обновлений) */
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btn-row .btn { margin: 0; padding: 12px 8px; font-size: 15px; }

/* Расписание: дни недели у чек-листа и у пунктов/зон */
.daychips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.daychip { border: 0; border-radius: 8px; padding: 6px 0; width: 38px; background: var(--bg2); color: var(--text);
           font: inherit; font-size: 14px; cursor: pointer; }
.daychip.on { background: var(--btn); color: var(--btn-text); }
.sched-extra { margin-top: 2px; }
.sched-extra:empty { display: none; }
.sched-pair { display: flex; gap: 8px; margin-top: 6px; }
.sched-pair select { flex: 1; min-width: 0; }
.days-btn { border: 0; background: none; padding: 2px 0; color: var(--hint); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.days-btn.on { color: var(--link); }
.days-panel .hint { margin: 4px 0 0; font-size: 12px; }
.days-panel .daychips { flex-wrap: nowrap; }
.days-panel .daychip { flex: 1; width: auto; min-width: 0; font-size: 13px; }
/* «Первый ▾ / понедельник ▾», «15-е ▾» — видно, что это выбор */
.sched-extra select { background: var(--bg2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a8a8e'/%3E%3C/svg%3E") no-repeat right 10px center;
                      border-radius: 8px; padding: 8px 26px 8px 10px; margin-top: 6px; -webkit-appearance: none; appearance: none; }
.sched-pair select { margin-top: 0; }

/* Обучение: что умеет приложение + раскрывающиеся темы */
.guide-can { padding: 4px 0; }
.guide-li { padding: 8px 14px; font-size: 15px; line-height: 1.35; }
.guide-li + .guide-li { border-top: 1px solid var(--sep); }
.guide-topic { background: var(--section); border-radius: var(--radius); margin-bottom: 8px; }
.guide-topic summary { padding: 14px; font-weight: 500; cursor: pointer; list-style: none; display: flex; align-items: center; }
.guide-topic summary::-webkit-details-marker { display: none; }
.guide-topic summary::after { content: "›"; margin-left: auto; color: var(--hint); transition: transform .15s; }
.guide-topic[open] summary::after { transform: rotate(90deg); }
.guide-body { padding: 0 14px 10px; }
.guide-body p { margin: 0 0 8px; font-size: 15px; line-height: 1.4; }

/* Несколько фото в пункте */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumbwrap { position: relative; flex: none; }
.thumbwrap .thumb { display: block; cursor: zoom-in; }
.thumb-del { position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; border-radius: 50%; border: 0;
             background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; line-height: 24px; padding: 0; cursor: pointer; }
.thumb-wait { position: absolute; left: 4px; bottom: 4px; font-size: 13px; }
.row.photo-item { align-items: flex-start; }
.row.photo-item > .btn, .row.photo-item > .badge { align-self: center; }
.sub.need { color: #d98a00; }
.min-photos { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--hint); margin-top: 2px; }
.min-photos select { width: auto; padding: 2px 6px; border-radius: 6px; background: var(--bg2); font-size: 13px; }

/* Иконки Lucide (web/js/icons.js): линия 2px, цвет — от текста вокруг */
.ic { width: 1.2em; height: 1.2em; vertical-align: -0.24em; flex: none; }
.btn .ic { margin-right: 2px; }
.tile .ico { color: var(--link); line-height: 0; }
.tile .ico .ic { width: 26px; height: 26px; }
.icon-btn { display: grid; place-items: center; color: var(--link); }
.icon-btn .ic { width: 22px; height: 22px; }
.icon-btn.small .ic { width: 18px; height: 18px; }
.row .chev .ic, .chip-field span .ic { width: 18px; height: 18px; vertical-align: middle; }
.row .grip .ic, .item .grip .ic { width: 18px; height: 18px; }
.row .moves .ic, .item .moves .ic { width: 16px; height: 16px; }
.item .type { display: grid; place-items: center; color: var(--link); }
.item .type .ic { width: 22px; height: 22px; }
.item .x .ic { width: 20px; height: 20px; }
.row .box .ic { width: 18px; height: 18px; stroke-width: 3; }
.thumb.ph { color: var(--hint); }
.thumb.ph .ic { width: 26px; height: 26px; }
.badge { line-height: 0; }
.badge .ic { width: 22px; height: 22px; }
.badge.ok { color: #2ea043; } .badge.wait { color: #d98a00; } .badge.err { color: var(--danger); }
.cam-icon { display: grid; place-items: center; }
.cam-icon .ic { width: 22px; height: 22px; }
.thumb-del { display: grid; place-items: center; }
.thumb-del .ic { width: 14px; height: 14px; }
.thumb-wait { line-height: 0; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 50%; padding: 3px; }
.thumb-wait .ic { width: 14px; height: 14px; }
.st .ic { width: 14px; height: 14px; vertical-align: -2px; }
.st-ontime .ic { color: #2ea043; } .st-late .ic { color: #d98a00; } .st-missed .ic { color: var(--danger); }
.st-in_progress .ic { color: #b38f00; } .st-not_started .ic { color: var(--hint); }
.note.warn .ic { color: #d98a00; }
.guide-topic summary { gap: 8px; }
.guide-topic summary .ic { color: var(--link); width: 20px; height: 20px; }
.adders .btn { display: flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap; padding-inline: 8px; }
.adders .btn .ic { margin: 0; }

/* Оформление (#/appearance) */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--section); border-radius: var(--radius); }
.seg button { border: 0; background: none; color: var(--text); font: inherit; font-size: 14px; padding: 10px 4px; border-radius: 9px;
  cursor: pointer; display: grid; justify-items: center; gap: 4px; }
.seg button .ic { width: 20px; height: 20px; color: var(--hint); }
.seg button[aria-pressed="true"] { background: var(--bg2); font-weight: 600; }
.seg button[aria-pressed="true"] .ic { color: var(--link); }
.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch { border: 0; background: var(--section); color: var(--text); font: inherit; font-size: 12.5px; line-height: 1.2; border-radius: var(--radius);
  padding: 12px 4px 10px; display: grid; justify-items: center; gap: 6px; cursor: pointer; text-align: center; }
.swatch .dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.swatch .dot .ic { width: 18px; height: 18px; stroke-width: 3; }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--link); font-weight: 600; }
.demo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo .btn { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; cursor: default; padding-inline: 8px; }
/* Отчёты: вовремя · опоздание · не сдан — значки цветом статуса */
.tally .i-circle-check { color: #2ea043; } .tally .i-clock-alert { color: #d98a00; } .tally .i-circle-x { color: var(--danger); }

/* Экран заведения: две кнопки создания в ряд; карандаш у чек-листа в «Сегодня» */
.adders.two { grid-template-columns: 1fr 1fr; }
.row-edit { margin-right: 8px; }
