/* Цвета — с образца (приложение AGENTRIS клиента «Парус Агент»): светлая и темная схемы.
   Тема: как в системе, либо принудительно <html data-theme="light|dark"> (js/theme.js, выбор в «Ещё»). */
:root {
  color-scheme: light;
  --bg: #f2f5f6; --card: #ffffff; --card-2: #efece5; --card-3: #e6e1d8;
  --text: #14213d; --muted: #5b5852; --faint: #8b877f;
  --line: rgba(22, 22, 22, .08); --line-strong: rgba(22, 22, 22, .18);
  --primary: #0a8287; --primary-2: #0b766f; --on-primary: #ffffff; --brand: #0d8f86;
  --accent-soft: rgba(13, 143, 134, .13); --accent-text: #0b766f; --focus: #0d8f86;
  --red: #b91c1c; --red-soft: rgba(220, 38, 38, .12);
  --green: #15803d; --green-soft: rgba(21, 128, 61, .13);
  --orange: #8f4f00; --orange-soft: rgba(217, 119, 6, .16);
  --blue: #1f5fe0; --blue-soft: rgba(31, 95, 224, .12);
  --ok-solid: #15803d; --err-solid: #b91c1c; --warn-solid: #b76a0c;
  --nav-on: linear-gradient(160deg, #45c9df, #0b8198); --nav-on-shadow: 0 6px 14px -6px #0b8198;
  --shadow-1: 0 1px 2px rgba(6, 16, 48, .06); --shadow-2: 0 10px 24px -14px rgba(0, 0, 0, .35);
  --toast-bg: #14213d; --toast-text: #ffffff; --scrim: rgba(6, 16, 48, .45);
  --tab-h: 64px; --top-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111111; --card: #1c1c1e; --card-2: #26262a; --card-3: #303035;
    --text: #f4f2ed; --muted: #aaa69e; --faint: #7d7a73;
    --line: rgba(244, 242, 237, .08); --line-strong: rgba(244, 242, 237, .2);
    --primary-2: #328c86; --accent-soft: rgba(44, 200, 184, .16); --accent-text: #4fd9ca; --focus: #2cc8b8;
    --red: #ff9c90; --red-soft: rgba(255, 156, 144, .14);
    --green: #7be3a0; --green-soft: rgba(123, 227, 160, .14);
    --orange: #ffc766; --orange-soft: rgba(255, 199, 102, .14);
    --blue: #86b4ff; --blue-soft: rgba(91, 156, 255, .2);
    --shadow-1: none; --shadow-2: 0 10px 24px -12px rgba(0, 0, 0, .7);
    --toast-bg: #f4f2ed; --toast-text: #111111; --scrim: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111111; --card: #1c1c1e; --card-2: #26262a; --card-3: #303035;
  --text: #f4f2ed; --muted: #aaa69e; --faint: #7d7a73;
  --line: rgba(244, 242, 237, .08); --line-strong: rgba(244, 242, 237, .2);
  --primary-2: #328c86; --accent-soft: rgba(44, 200, 184, .16); --accent-text: #4fd9ca; --focus: #2cc8b8;
  --red: #ff9c90; --red-soft: rgba(255, 156, 144, .14);
  --green: #7be3a0; --green-soft: rgba(123, 227, 160, .14);
  --orange: #ffc766; --orange-soft: rgba(255, 199, 102, .14);
  --blue: #86b4ff; --blue-soft: rgba(91, 156, 255, .2);
  --shadow-1: none; --shadow-2: 0 10px 24px -12px rgba(0, 0, 0, .7);
  --toast-bg: #f4f2ed; --toast-text: #111111; --scrim: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h3 { margin: 18px 14px 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .red { color: var(--red); } .orange { color: var(--orange); }
.pad { padding: 8px 14px; } .right { margin-left: auto; } .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; } .col { display: flex; flex-direction: column; } .gap { gap: 8px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.err { color: var(--red); margin-top: 10px; min-height: 1.2em; }

/* каркас */
#app { min-height: 100vh; padding-top: var(--top-h); padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
.top { position: fixed; top: 0; left: 0; right: 0; height: var(--top-h); z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; background: var(--bg); color: var(--text); border-bottom: 1px solid var(--line); }
.top-logo { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; }
.top-title { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; border: 0; background: var(--card); color: var(--text);
  font-size: 26px; line-height: 1; padding: 0 0 3px; cursor: pointer; }
.sync { display: flex; align-items: center; gap: 6px; background: var(--card); color: var(--text); border: 1px solid transparent;
  border-radius: 999px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.sync::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--ok-solid); }
.sync.bad { background: var(--orange-soft); color: var(--orange); }
.sync.bad::before { background: var(--warn-solid); }
.sync .ico-sync { display: none; }
.sync.spin::before { display: none; }
.sync.spin .ico-sync { display: inline-block; animation: spin 1s linear infinite; color: var(--accent-text); }
.sync .badge { background: var(--primary); color: var(--on-primary); border-radius: 10px; padding: 0 6px; font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--card); border-top: 1px solid var(--line);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding: 4px 6px env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text); font-size: 12px; }
.tabs a .ico { width: 48px; height: 30px; border-radius: 15px; background: none; color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; -webkit-mask: none; mask: none; }
.tabs a .ico::before { content: ''; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.tabs a.on { font-weight: 600; }
.tabs a.on .ico { background: var(--nav-on); color: #ffffff; box-shadow: var(--nav-on-shadow); }
main { max-width: 820px; margin: 0 auto; }

/* значки (CSS, без картинок) */
.ico { display: inline-block; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.ico-sync { width: 14px; height: 14px; --m: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 4V1L8 5l4 4V6a6 6 0 0 1 5.7 7.9l1.5 1.5A8 8 0 0 0 12 4zm0 14a6 6 0 0 1-5.7-7.9L4.8 8.6A8 8 0 0 0 12 20v3l4-4-4-4z"/></svg>'); }
.ico-clients { --m: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 21V8l9-5 9 5v13h-6v-7H9v7z"/></svg>'); }
.ico-catalog { --m: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9 2h6v4l-1 2v13a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1V8L9 6z"/></svg>'); }
.ico-orders { --m: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 2h14v20l-3-2-2 2-2-2-2 2-2-2-3 2zm3 5v2h8V7zm0 4v2h8v-2zm0 4v2h5v-2z"/></svg>'); }
.ico-more { --m: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle cx="5" cy="12" r="2.5"/><circle cx="12" cy="12" r="2.5"/><circle cx="19" cy="12" r="2.5"/></svg>'); }

/* списки и карточки */
.sticky { position: sticky; top: var(--top-h); z-index: 10; background: var(--bg); padding: 8px 10px; }
.filters .row { margin-top: 6px; }
.search, select, input[type=date], textarea, .form input { width: 100%; padding: 11px 14px; border: 1px solid transparent; border-radius: 14px;
  background: var(--card); color: var(--text); }
.search::placeholder, textarea::placeholder, .form input::placeholder { color: var(--faint); }
.list { background: var(--card); margin: 8px 10px; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-1); }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.item:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 600; overflow-wrap: anywhere; }
.item-sub { color: var(--muted); font-size: 13px; margin-top: 2px; overflow-wrap: anywhere; }
.item-side { flex-shrink: 0; text-align: right; }
.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--card-2); color: var(--muted); margin-top: 4px; }
.tag.red { background: var(--red-soft); color: var(--red); } .tag.green { background: var(--accent-soft); color: var(--accent-text); margin-left: 6px; }
.tag.orange { background: var(--orange-soft); color: var(--orange); } .tag.blue { background: var(--blue-soft); color: var(--blue); }
.tag.grey { background: var(--card-2); color: var(--muted); }
.card { background: var(--card); margin: 10px; padding: 14px 16px; border-radius: 18px; box-shadow: var(--shadow-1); }
.card.point { display: flex; flex-direction: column; gap: 4px; }
.card.point .row { margin-top: 8px; }
.kpis { display: flex; gap: 8px; margin-top: 10px; }
.kpis div { flex: 1; background: var(--card-2); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; }
.kpis b { font-size: 15px; } .kpis span { font-size: 12px; color: var(--muted); }
.kpis .red { background: var(--red-soft); } .kpis .red b { color: var(--red); }
.warnbox { margin-top: 10px; padding: 9px 12px; border-radius: 12px; background: var(--orange-soft); color: var(--orange); font-size: 13px; }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line-strong); }
.line:last-child { border-bottom: 0; }
details.item { display: block; }
details.item summary, details.hist summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details.hist { padding: 8px 0; border-bottom: 1px solid var(--line); }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 16px;
  border: 1px solid transparent; background: var(--card); color: var(--text); font-weight: 600; cursor: pointer; box-shadow: var(--shadow-1); }
.btn:active { background: var(--card-2); }
.card .btn, .lines .btn, .order-bar .btn { background: var(--card-2); box-shadow: none; }
.card .btn:active, .lines .btn:active, .order-bar .btn:active { background: var(--card-3); }
.btn.primary, .card .btn.primary, .order-bar .btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: none; }
.btn.primary:active { background: var(--primary-2); }
.btn.danger-o, .card .btn.danger-o { background: var(--red-soft); color: var(--red); box-shadow: none; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; }
.btn.wide { display: flex; width: calc(100% - 20px); margin: 10px; }
.btn:disabled { opacity: .55; }
.link { background: none; border: 0; color: var(--accent-text); margin-top: 16px; cursor: pointer; font-weight: 600; }
.seg { display: flex; gap: 4px; padding: 4px; margin: 10px; background: var(--card-2); border-radius: 14px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 8px 6px; border-radius: 11px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow-1); }

/* заказ */
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 15px; margin: 0; white-space: nowrap; }
.form .row label { margin-bottom: 0; }
.form .card input, .form .card select, .form .card textarea, .card .search { background: var(--card-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); }
.lines { background: var(--card); margin: 10px; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-1); }
.line-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.line-row:last-child { border-bottom: 0; }
.line-row .grow { flex-basis: 100%; }
.line-sum { margin-left: auto; font-weight: 700; }
.stepper { display: flex; align-items: center; border-radius: 12px; overflow: hidden; flex-shrink: 0; background: var(--card-2); }
.stepper button { width: 40px; height: 38px; border: 0; background: var(--accent-soft); color: var(--accent-text); font-size: 20px; font-weight: 700; cursor: pointer; }
.stepper input { width: 58px; height: 38px; border: 0; text-align: center; background: transparent; color: var(--text); -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.promo { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line-strong); }
.promo input { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.order-bar { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 10; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line); box-shadow: var(--shadow-2); }
.total { display: flex; flex-direction: column; } .total b { font-size: 18px; }

/* подбор */
.picker { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; }
.picker .top { position: static; }
.picker-body { flex: 1; overflow-y: auto; }
.picker .sticky { top: 0; }
.picker .order-bar { position: static; }
.prod .thumb { width: 54px; height: 54px; object-fit: contain; border-radius: 10px; background: #ffffff; flex-shrink: 0; }
.prod .thumb.none { background: var(--card-2); }
.prod .stepper button { width: 34px; } .prod .stepper input { width: 46px; }

/* вход и PIN */
.enroll { max-width: 420px; margin: 0 auto; padding: 40px 20px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
#app:has(.enroll) { padding: 0; }
.logo img { width: 84px; height: 84px; border-radius: 24px; }
.enroll h1 { margin: 0; font-size: 22px; }
.enroll input { padding: 12px; border: 1px solid transparent; border-radius: 14px; text-align: center; background: var(--card); color: var(--text); }
.code-input { font-size: 26px; letter-spacing: 4px; font-family: ui-monospace, Consolas, monospace; }
#lock { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: flex; align-items: center; justify-content: center; }
#lock[hidden] { display: none; }
.pin { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; }
.pin-logo { width: 56px; height: 56px; border-radius: 16px; }
.pin-title { font-size: 18px; font-weight: 600; }
.pin-dots { display: flex; gap: 14px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }
.pin-msg { min-height: 20px; color: var(--red); font-size: 14px; }
.pin-keys { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.pin-key { height: 64px; border-radius: 50%; border: 0; background: var(--card); color: var(--text); font-size: 26px; box-shadow: var(--shadow-1); cursor: pointer; }
.pin-key:active { background: var(--accent-soft); }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 70px); transform: translate(-50%, 20px); opacity: 0; transition: .25s; z-index: 200;
  background: var(--toast-bg); color: var(--toast-text); padding: 10px 16px; border-radius: 14px; max-width: 90vw; font-size: 14px; box-shadow: var(--shadow-2); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: var(--ok-solid); color: #ffffff; } .toast.err { background: var(--err-solid); color: #ffffff; }

@media (min-width: 900px) {
  .tabs { left: 50%; transform: translateX(-50%); max-width: 820px; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; }
}
