/* ================= KHAN OIL 2.0: вход, синхронизация, сотрудники, телефон ================= */
body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
.page.no-anim { animation: none; }
.qty-wrap { position: relative; }
.qty-wrap .cur { position: absolute; right: 12px; top: 13px; color: var(--faint); font-size: 14px; pointer-events: none; }
.qty-wrap .inp { padding-right: 36px; }
.av { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; text-transform: uppercase; }
.av.big { width: 52px; height: 52px; font-size: 22px; }
[data-theme="graphite"] .av { color: var(--text); }

/* Значок синхронизации */
.sync-badge { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border-radius: 17px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); font-size: 12.5px; white-space: nowrap; transition: .2s; }
.sync-badge:hover { color: var(--text); }
.sync-badge i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.sync-badge.wait i { background: var(--warn); }
.sync-badge.off i { background: var(--red); }
.sync-badge.busy i { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }
.clock { margin-left: 16px; }

/* Сотрудник в меню */
.drawer-who { display: flex; align-items: center; gap: 12px; margin: 0 12px 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); text-align: left; transition: .15s; }
.drawer-who:hover { border-color: var(--accent); }
.drawer-who b { display: block; }
.drawer-who small { color: var(--muted); font-size: 12px; }

/* ================= Вход ================= */
body.logged-out .topbar, body.logged-out main, body.logged-out .watermark { visibility: hidden; }
.login { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto;
  background: radial-gradient(900px 500px at 50% -10%, var(--glow), transparent 65%), var(--bg); }
.login[hidden] { display: none; }
.login-box { width: min(440px, 100%); text-align: center; animation: fade .3s ease; }
.login-box > .logo { justify-content: center; margin-bottom: 30px; }
.login-names { display: flex; flex-direction: column; gap: 10px; }
.login-name { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); font-size: 17px; font-weight: 600; text-align: left; transition: .15s; }
.login-name:hover, .login-name:active { border-color: var(--accent); background: var(--surface2); transform: translateY(-1px); }
.login-wait { color: var(--muted); padding: 20px; line-height: 1.6; }
.login-who { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; font-size: 20px; }
.login-code { height: 58px; text-align: center; font-size: 24px; letter-spacing: 6px; }
.login-go { width: 100%; height: 52px; margin-top: 12px; font-size: 16px; }
.login-msg { color: var(--red); min-height: 20px; margin-top: 12px; font-size: 14px; }
.login-back { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); padding: 10px 14px; border-radius: 10px; }
.login-back svg { width: 18px; height: 18px; }
.login-back:hover { color: var(--text); background: var(--surface2); }
.login-server { margin-top: 18px; display: inline-flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12.5px; padding: 8px 12px; border-radius: 9px; }
.login-server svg { width: 15px; height: 15px; }
.login-server:hover { color: var(--text); background: var(--surface2); }

/* ================= Отчёты / статистика ================= */
.receipt-head .who { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 14px; }
.receipt-head .who svg { width: 14px; height: 14px; }
[data-theme="graphite"] .receipt-head .who { color: var(--text); }
.today-item .names em { font-style: normal; font-size: 12px; color: var(--faint); margin-left: 8px; }
.emp-card h3 { display: flex; align-items: center; gap: 8px; }
.emp-card h3 svg { width: 18px; height: 18px; color: var(--accent); }
.tbl-wrap { overflow-x: auto; }
.day-scroll { display: flex; flex-direction: column; gap: 4px; }

/* ================= Настройки ================= */
.profile { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.prof-l { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 200px; }
.prof-l b { display: block; font-size: 18px; }
.prof-l span:not(.av) { font-size: 13px; color: var(--muted); }
.page > .card, .page > .settings-grid { margin-bottom: 20px; }
.stock-layout > *, .rep-layout > *, .settings-grid > * { min-width: 0; }
.emp-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.emp-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface2); border: 1px solid var(--border); }
.emp-row b { flex: 1; font-weight: 600; }
.emp-row b small { color: var(--faint); font-weight: 400; }
.emp-row.editing { flex-wrap: wrap; }
.emp-row.editing .inp { flex: 1 1 180px; height: 40px; }
.icon-btn.plain:hover { background: var(--accent-soft); color: var(--accent); }
.emp-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; }
.admin-lock { max-width: 460px; margin: 0 auto 20px; text-align: center; }
.admin-lock h3 { justify-content: center; }
.admin-form .inp { text-align: center; font-size: 20px; letter-spacing: 8px; height: 52px; }
.admin-form .btn { width: 100%; margin-top: 10px; }
.admin-form .err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }
.about { margin-bottom: 10px; }
.theme-set { margin-bottom: 20px; }

/* ================= Телефон ================= */
@media (max-width: 760px) {
  html, body { font-size: 15px; }
  .inp, input, select { font-size: 16px; } /* без авто-увеличения на iPhone */
  .topbar { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0; gap: 8px; }
  .topbar .logo { font-size: 16px; letter-spacing: 2px; gap: 6px; }
  .topbar .logo svg { width: 20px; height: 20px; }
  .crumb, .clock, .watermark { display: none; }
  .sync-badge { height: 32px; padding: 0 10px; font-size: 12px; max-width: 46vw; overflow: hidden; }
  .sync-badge span { overflow: hidden; text-overflow: ellipsis; }
  main { height: calc(100% - 56px - env(safe-area-inset-top)); padding: 16px 12px calc(110px + env(safe-area-inset-bottom)); }
  .drawer { width: min(86vw, 320px); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .page-head { flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; gap: 10px; }
  .page-head h1 { font-size: 22px; }
  .page-head p { font-size: 13.5px; }
  .page-head .btn { height: 38px; padding: 0 12px; font-size: 13px; }
  .card { border-radius: 14px; }

  /* Продажа: строки — карточки */
  .sale-card { padding: 10px; background: transparent; border: none; backdrop-filter: none; }
  .sale-grid.head { display: none; }
  .sale-row { display: grid; grid-template-columns: 1fr 1fr 40px; grid-template-areas: "prod prod del" "price qty qty" "sum sum sum"; gap: 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
  .sale-row .no { display: none; }
  .sale-row .combo { grid-area: prod; }
  .sale-row .price-wrap { grid-area: price; }
  .sale-row .qty-wrap { grid-area: qty; }
  .sale-row .del { grid-area: del; margin-top: 4px; }
  .sale-row .sum-cell { grid-area: sum; height: auto; justify-content: space-between; font-size: 17px; padding-top: 8px; border-top: 1px dashed var(--border); }
  .sale-row .sum-cell::before { content: "Сумма"; font-size: 13px; font-weight: 400; color: var(--muted); }
  .price-wrap .inp { font-size: 17px; }
  .combo-list { max-height: 52vh; top: 52px; }
  .combo-item { padding: 12px; }
  .add-row { margin-top: 2px; }
  .sale-footer { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 5; margin-top: 12px; padding: 12px 14px; gap: 12px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
  .total span { font-size: 11px; letter-spacing: 1px; }
  .total b { font-size: 24px; }
  .total small { display: block; margin: 0; }
  .btn.sold { height: 56px; padding: 0 22px; font-size: 17px; letter-spacing: 1.5px; flex: 1; max-width: 220px; }
  .today-item { flex-wrap: wrap; gap: 6px 12px; }
  .today-item .names { flex-basis: calc(100% - 60px); order: 2; }
  .today-item .s { margin-left: auto; }

  /* Остатки: категории — лента, товары — карточки */
  .stock-layout { grid-template-columns: 1fr; gap: 12px; }
  .cat-list { position: static; padding: 6px; }
  .cat-scroll { flex-direction: row; max-height: none; overflow-x: auto; gap: 6px; padding-bottom: 2px; scrollbar-width: none; }
  .cat-scroll::-webkit-scrollbar { display: none; }
  .cat { flex: none; padding: 9px 12px; }
  .cat-count { display: none; }
  .add-cat { height: 38px; }
  .stock-card { padding: 14px 12px; }
  .cat-title { flex-wrap: wrap; }
  .cat-title input { font-size: 19px; flex-basis: 100%; }
  .cat-title .hint { display: none; }
  .stock-tbl thead { display: none; }
  .stock-tbl, .stock-tbl tbody { display: block; }
  .stock-tbl tr { display: grid; grid-template-columns: 1fr 1fr 40px; grid-template-areas: "name name del" "cost price price" "lit qty qty"; gap: 6px 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface2); }
  .stock-tbl tr.no-items { display: block; background: transparent; border: none; }
  .stock-tbl td { padding: 0; border: none; display: block; }
  .stock-tbl td:first-child { display: none; }
  .stock-tbl td:nth-child(2) { grid-area: name; }
  .stock-tbl td:nth-child(3) { grid-area: cost; }
  .stock-tbl td:nth-child(4) { grid-area: price; }
  .stock-tbl td:nth-child(5) { grid-area: lit; }
  .stock-tbl td:nth-child(6) { grid-area: qty; }
  .stock-tbl td:nth-child(7) { grid-area: del; }
  .stock-tbl td[data-l]::before { content: attr(data-l); display: block; font-size: 11.5px; color: var(--faint); margin: 0 0 3px 2px; }
  .stock-tbl td:nth-child(2)::before { display: none; }
  .stock-tbl .inp { height: 42px; background: var(--bg2); border-color: var(--border2); }
  .stock-tbl .inp.num { text-align: left; }
  .stock-tbl td:nth-child(2) .inp { font-weight: 600; }
  .stock-sum { gap: 8px 16px; font-size: 13px; }

  /* Отчёты */
  .rep-layout { grid-template-columns: 1fr; gap: 12px; }
  .day-list { position: static; max-height: none; padding: 8px; }
  .day-scroll { flex-direction: row; overflow-x: auto; gap: 8px; scrollbar-width: none; }
  .day-scroll::-webkit-scrollbar { display: none; }
  .day { flex: none; flex-direction: column; gap: 6px; padding: 8px; min-width: 96px; }
  .day .info span, .day .info div { display: none; }
  .day .rv { font-size: 12px; }
  .detail-head h2 { font-size: 18px; }
  .receipt { padding: 12px; }
  .receipt-head { flex-wrap: wrap; }
  .receipt .tbl { min-width: 560px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tiles.five { grid-template-columns: 1fr 1fr; }
  .tiles .tile.profit { grid-column: 1 / -1; }
  .tile { padding: 12px 14px; }
  .tile span { font-size: 11px; }
  .tile b { font-size: 19px; }

  /* Статистика */
  .period-bar { flex-wrap: wrap; gap: 10px; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 8px; }
  .period-nav { margin: 0; width: 100%; justify-content: space-between; }
  .period-label { min-width: 0; font-size: 14px; }
  .chart-card, .top-card { padding: 14px 12px; }
  .chart { height: 170px; gap: 2px; }
  .chart .grid span { font-size: 10px; }
  .bar { width: 46%; border-radius: 3px 3px 0 0; }
  .xlabels { gap: 2px; }
  .xlabels span { font-size: 9.5px; overflow: hidden; }
  .legend { gap: 10px; font-size: 12px; }
  .top-card .tbl { min-width: 480px; }

  /* Настройки */
  .settings-grid { grid-template-columns: 1fr; gap: 14px; }
  .page > .card, .page > .settings-grid { margin-bottom: 14px; }
  .set-card { padding: 16px; }
  .theme-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tp { height: 96px; }
  .tc-name span { font-size: 11.5px; }
  .emp-add { grid-template-columns: 1fr; }
  .profile .row-btns { width: 100%; }
  .profile .row-btns .btn { flex: 1; }

  /* Окна */
  #toasts { left: 12px; right: 12px; bottom: calc(90px + env(safe-area-inset-bottom)); }
  .toast { min-width: 0; max-width: none; }
  .modal { width: calc(100vw - 24px); }
  .lock-card { width: 100%; padding: 30px 20px; }
  .splash-title { font-size: 48px; letter-spacing: 6px; }
  .splash-sub { letter-spacing: 5px; font-size: 11px; }
}
@media (max-width: 380px) {
  .sync-badge span { display: none; }
  .btn.sold { padding: 0 14px; font-size: 15px; }
}

/* подсказки графика не должны расширять страницу */
main { overflow-x: hidden; }
.chart-card { overflow: hidden; }
.chart { margin-top: 26px; }
.col:last-child .tip, .col:nth-last-child(2) .tip { left: auto; right: 0; transform: none; }
.col:nth-child(5) .tip, .col:nth-child(6) .tip { left: 0; transform: none; }

/* строка «Новый товар» */
.stock-tbl tr.draft td:first-child { color: var(--accent); font-size: 18px; font-weight: 800; }
.stock-tbl tr.draft .inp { border: 1px dashed var(--border2); background: transparent; }
.stock-tbl tr.draft .inp:focus { border-style: solid; border-color: var(--accent); }
.stock-tbl tr.draft [data-del] { visibility: hidden; }
@media (max-width: 760px) { .stock-tbl tr.draft { border-style: dashed; border-color: var(--accent); background: transparent; } }

/* ================= 3.0: штрихкоды, печать, сканер, камера ================= */
.w-act { width: 128px; }
.stock-tbl td.acts { white-space: nowrap; text-align: right; }
.stock-tbl td.acts .icon-btn { display: inline-grid; width: 34px; height: 34px; }
.stock-tbl tr.draft .acts .icon-btn { visibility: hidden; }
.codes-line { display: flex; align-items: center; gap: 6px; margin: 2px 0 0 14px; font-size: 11.5px; color: var(--faint); font-family: Consolas, monospace; }
.codes-line svg { width: 13px; height: 13px; flex: none; }
.codes-line .fbc { font-family: "Segoe UI", sans-serif; color: var(--green); }

.pop { position: fixed; z-index: 85; padding: 14px; background: var(--surface2); border: 1px solid var(--border2); box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, .1); animation: pop .14s ease; }
.pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.pop-head b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-head span { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.pop-head .icon-btn { margin-left: auto; width: 32px; height: 32px; flex: none; }
.pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 13.5px; }
.pr-one { display: grid; grid-template-columns: 1fr 96px; gap: 12px; align-items: end; padding: 10px 12px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--border); }
.pr-code { font-family: Consolas, monospace; font-size: 15px; font-weight: 700; display: flex; flex-direction: column; gap: 3px; }
.pr-code small { font-family: "Segoe UI", sans-serif; font-weight: 400; font-size: 12px; color: var(--muted); }
.pr-one label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.pr-one .inp { height: 42px; text-align: center; font-weight: 800; font-size: 18px; padding: 0 4px; }
.cd-own { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--border); }
.cd-own span, .cd-sub { font-size: 12px; color: var(--muted); }
.cd-own b { font-family: Consolas, monospace; font-size: 15px; }
.cd-sub { margin: 12px 0 6px; }
.cd-list { display: flex; flex-direction: column; gap: 6px; max-height: 30vh; overflow-y: auto; }
.cd-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 4px 12px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--border); font-family: Consolas, monospace; }
.cd-row .icon-btn { width: 32px; height: 32px; }
.cd-none { font-size: 13px; padding: 4px 2px; }
.cd-hint { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 8px; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.cd-hint svg { width: 16px; height: 16px; flex: none; color: var(--accent); margin-top: 1px; }
.cd-add { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.cd-add .inp { height: 40px; font-family: Consolas, monospace; }

.nav-item.open-all { margin-top: 8px; border: 1px dashed var(--border2); }
.nav-item.open-all.on { border-style: solid; border-color: var(--green); color: var(--green); background: rgba(34, 197, 94, .08); }
.pw-inp { text-align: center; font-size: 20px; letter-spacing: 6px; height: 52px; margin-bottom: 6px; }
.modal h3 { display: flex; align-items: center; gap: 8px; }
.modal h3 svg { width: 20px; height: 20px; color: var(--accent); }
.modal .err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 10px; }

.stock-value { padding: 18px 20px; margin-bottom: 20px; }
.stock-value h3 { display: flex; align-items: center; gap: 8px; font-size: 16px; margin-bottom: 12px; }
.stock-value h3 svg { width: 19px; height: 19px; color: var(--accent); }
.stock-value h3 small { margin-left: auto; color: var(--muted); font-weight: 400; font-size: 13px; }
.sv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.sv { padding: 12px 14px; border-radius: 11px; background: var(--surface2); border: 1px solid var(--border); }
.sv span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.sv b { display: block; font-size: 22px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sv.cost b { color: var(--red); }
.sv.diff b { color: var(--green); }
.sv.diff.neg b { color: var(--red); }

.bk-list { display: flex; flex-direction: column; gap: 8px; }
.bk-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px; background: var(--surface2); border: 1px solid var(--border); flex-wrap: wrap; }
.bk-row > div { flex: 1; min-width: 160px; }
.bk-row b { display: block; }
.bk-row small { color: var(--muted); font-size: 12.5px; }

/* Камера-сканер (телефон) */
.cam-bar { position: relative; height: var(--camh, 84px); background: #000; overflow: hidden; z-index: 9; border-bottom: 1px solid var(--border); }
.cam-bar[hidden] { display: none; }
.cam-bar video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-line { position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: rgba(239, 68, 68, .85); box-shadow: 0 0 8px rgba(239, 68, 68, .9); pointer-events: none; }
.cam-msg { position: absolute; left: 10px; bottom: 6px; right: 120px; font-size: 12px; color: #fff; text-shadow: 0 1px 3px #000; pointer-events: none; }
.cam-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px;
  background: rgba(0, 0, 0, .55); color: #fff; border: 1px solid rgba(255, 255, 255, .35); font-size: 13px; font-weight: 600; }
.cam-btn svg { width: 16px; height: 16px; }
.cam-bar.off { background: var(--surface); }
.cam-bar.off video, .cam-bar.off .cam-line { display: none; }
.cam-bar.off .cam-btn { left: 50%; right: auto; transform: translate(-50%, -50%); background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.cam-bar.hit { animation: camHit .5s; }
.cam-bar.miss { animation: camMiss .6s; }
@keyframes camHit { 0% { box-shadow: inset 0 0 0 4px #22c55e; } 100% { box-shadow: inset 0 0 0 0 transparent; } }
@keyframes camMiss { 0% { box-shadow: inset 0 0 0 4px #ef4444; } 100% { box-shadow: inset 0 0 0 0 transparent; } }

@media (max-width: 760px) {
  body.has-cam main { height: calc(100% - 56px - env(safe-area-inset-top) - var(--camh, 84px)); }
  .pop { left: 8px !important; right: 8px; width: auto !important; top: auto !important; bottom: calc(8px + env(safe-area-inset-bottom)); }
  .stock-tbl tr { grid-template-areas: "name name acts" "cost price price" "lit qty qty"; grid-template-columns: 1fr 1fr auto; }
  .stock-tbl td.acts { grid-area: acts; display: flex; gap: 2px; align-items: flex-start; }
  .stock-tbl td:nth-child(7) { grid-area: acts; }
  .codes-line { margin-left: 4px; }
  .sv-grid { grid-template-columns: 1fr; gap: 8px; }
  .sv b { font-size: 19px; }
}

/* открыто окошко внизу экрана — уведомления сверху, чтобы не закрывали его */
@media (max-width: 760px) { body:has(.pop) #toasts { bottom: auto; top: calc(64px + env(safe-area-inset-top)); } }
