/* ================= 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; } }
