:root {
  --brand: #0f5c4d; --brand-2: #13806a; --brand-soft: #e6f2ee; --accent: #f2b33d;
  --bg: #f5f6f4; --card: #ffffff; --ink: #17211e; --muted: #5f6b67; --line: #e3e7e4;
  --ok: #1f8a4c; --ok-soft: #e5f5eb; --warn: #b26b00; --warn-soft: #fff4dc; --bad: #c0392b; --bad-soft: #fdecea;
  --info-soft: #e8f0fb; --radius: 14px; --shadow: 0 1px 2px rgba(16,24,20,.06), 0 4px 16px rgba(16,24,20,.06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.boot { display: grid; place-items: center; min-height: 100vh; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } * { transition: none !important; } }

/* ---------- кнопки и поля ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px; padding: .55rem 1rem;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600;
  text-decoration: none; color: var(--ink); transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: #c9d1cd; background: #fafbfa; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.sm { min-height: 34px; padding: .3rem .7rem; font-size: .88rem; border-radius: 8px; }
.btn.icon { width: 38px; min-height: 38px; padding: 0; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; flex: none; }
label { display: block; font-weight: 600; font-size: .88rem; margin: .7rem 0 .3rem; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: .55rem .75rem; border: 1px solid #cfd6d2;
  border-radius: 10px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { min-height: 140px; resize: vertical; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(19,128,106,.15); }
.input.invalid { border-color: var(--bad); }
.field-err { color: var(--bad); font-size: .82rem; margin-top: .25rem; }
.hint { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; margin: .6rem 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* ---------- вход ---------- */
.auth { display: grid; min-height: 100vh; grid-template-columns: 1fr; }
.auth-hero { background: linear-gradient(150deg, #0c4a3e, #13806a 70%, #1c9a80); color: #fff; padding: 28px 20px 30px; }
.auth-hero .logo { color: #fff; }
.auth-hero h1 { font-size: 1.7rem; margin: 1.2rem 0 .6rem; }
.auth-hero p { opacity: .9; margin: 0 0 1rem; }
.auth-hero ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.auth-hero li { display: flex; gap: .6rem; align-items: flex-start; }
.auth-hero li svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--accent); }
.auth-demo { margin-top: 1.4rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); border-radius: 14px;
  padding: 12px 14px; font-size: .9rem; }
.auth-demo .chat { background: #fff; color: var(--ink); border-radius: 12px 12px 12px 4px; padding: 8px 12px; margin: 6px 0;
  white-space: pre-line; max-width: 92%; }
.auth-demo .arrow { text-align: center; opacity: .8; margin: 2px 0; }
.auth-demo .inv { background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 12px; font-size: .85rem; }
.auth-demo .inv div { display: flex; justify-content: space-between; gap: 8px; }
.auth-form { padding: 24px 20px 40px; display: flex; justify-content: center; }
.auth-form .card { width: 100%; max-width: 420px; }
.tabs-auth { display: flex; gap: 6px; background: #eef1ef; padding: 4px; border-radius: 12px; margin-bottom: 1rem; }
.tabs-auth button { flex: 1; border: 0; background: transparent; padding: .55rem; border-radius: 9px; font-weight: 600; cursor: pointer; }
.tabs-auth button.on { background: #fff; box-shadow: var(--shadow); }
@media (min-width: 900px) {
  .auth { grid-template-columns: 1.05fr 1fr; }
  .auth-hero { padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; }
  .auth-hero h1 { font-size: 2.3rem; }
  .auth-form { align-items: center; }
}

/* ---------- каркас ---------- */
.logo { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.08rem; color: var(--brand);
  text-decoration: none; letter-spacing: -.01em; }
.logo img { width: 30px; height: 30px; }
.shell { min-height: 100vh; padding-bottom: 76px; }
.side { display: none; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: 10px 14px; background: rgba(245,246,244,.92); backdrop-filter: saturate(1.4) blur(6px); border-bottom: 1px solid var(--line); }
.main { padding: 14px; max-width: 1180px; margin: 0 auto; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding: 4px 2px calc(4px + env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; font-size: .7rem; color: var(--muted);
  text-decoration: none; font-weight: 600; position: relative; }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--brand); }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--bad); color: #fff;
  font-size: .72rem; font-weight: 700; align-items: center; justify-content: center; }
.tabbar .badge { position: absolute; top: 0; right: calc(50% - 22px); min-width: 18px; height: 18px; font-size: .66rem; }
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 240px 1fr; padding-bottom: 0; }
  .tabbar { display: none; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; background: #fff;
    border-right: 1px solid var(--line); }
  .side nav { display: grid; gap: 2px; margin-top: 22px; }
  .side nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 10px; color: var(--ink);
    text-decoration: none; font-weight: 600; }
  .side nav a svg { width: 20px; height: 20px; color: var(--muted); }
  .side nav a:hover { background: #f3f5f4; }
  .side nav a.on { background: var(--brand-soft); color: var(--brand); }
  .side nav a.on svg { color: var(--brand); }
  .side nav a .badge { margin-left: auto; }
  .side .foot { margin-top: auto; font-size: .85rem; }
  .topbar .logo { display: none; }
  .main { padding: 22px 28px; }
}

/* ---------- карточки, списки ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.seg { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: 10px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .85rem; font-weight: 600;
  cursor: pointer; font-size: .88rem; display: inline-flex; gap: .35rem; align-items: center; }
.seg button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg button .cnt { opacity: .7; font-weight: 500; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 36px; }
.list { display: grid; gap: 8px; }
.order-card { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s; }
.order-card:hover { border-color: #c5cfca; box-shadow: var(--shadow); }
.order-card .ch { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); grid-row: span 2; }
.order-card .ch svg { width: 20px; height: 20px; }
.order-card .ch.whatsapp { background: #e6f7ec; color: #1a9e4b; }
.order-card .ch.telegram { background: #e6f2fb; color: #2481cc; }
.order-card .t { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card .sub { color: var(--muted); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card .sum { font-weight: 700; text-align: right; }
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.manual { background: var(--bad-soft); color: var(--bad); }
.pill.confirmed { background: var(--ok-soft); color: var(--ok); }
.pill.rejected { background: #eceff1; color: #546e7a; }
.pill.info { background: var(--info-soft); color: #2557a7; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty svg { width: 54px; height: 54px; color: #b9c4bf; margin-bottom: 8px; }
.empty h3 { color: var(--ink); }
.skeleton { background: linear-gradient(90deg, #eef1ef 25%, #f6f8f7 37%, #eef1ef 63%); background-size: 400% 100%;
  animation: sk 1.2s ease infinite; border-radius: 12px; height: 64px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .v { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: .82rem; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }

/* ---------- онбординг ---------- */
.onb { background: linear-gradient(135deg, #fff, #f2f8f5); }
.onb ol { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: 6px; }
.onb li { display: flex; gap: .7rem; align-items: center; padding: .55rem .6rem; border-radius: 10px; background: #fff; border: 1px solid var(--line); }
.onb li .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #c9d2cd; display: grid; place-items: center; flex: none; }
.onb li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.onb li.done .txt { color: var(--muted); text-decoration: line-through; }
.onb li .dot svg { width: 14px; height: 14px; }
.progress { height: 8px; background: #e7ece9; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand-2); border-radius: 99px; }

/* ---------- заказ ---------- */
.order-head { display: grid; gap: 10px; }
.src { background: #f8faf9; border: 1px dashed #cfd8d3; border-radius: 12px; padding: 10px 12px; white-space: pre-wrap; font-size: .9rem;
  max-height: 260px; overflow: auto; }
.lines { display: grid; gap: 8px; }
.line { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 12px; padding: 10px 12px;
  display: grid; grid-template-columns: 1fr; gap: 6px; }
.line.low { border-left-color: #e0a100; background: #fffdf6; }
.line.unknown { border-left-color: var(--bad); background: #fffafa; }
.line .raw { color: var(--muted); font-size: .82rem; }
.line .raw b { color: var(--ink); font-weight: 600; }
.line .prod { display: flex; gap: .5rem; align-items: center; justify-content: space-between; width: 100%; text-align: left; border: 1px solid var(--line);
  background: #fff; border-radius: 10px; padding: .45rem .6rem; cursor: pointer; min-height: 42px; }
.line .prod:hover { border-color: var(--brand-2); }
.line .prod .pn { font-weight: 600; }
.line .prod .sku { color: var(--muted); font-size: .78rem; }
.line .prod.none { color: var(--bad); border-style: dashed; }
.line .ctr { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.qty { display: inline-flex; align-items: center; border: 1px solid #cfd6d2; border-radius: 10px; overflow: hidden; background: #fff; }
.qty button { border: 0; background: #f3f5f4; width: 36px; height: 40px; cursor: pointer; font-size: 1.1rem; }
.qty input { width: 70px; height: 40px; border: 0; text-align: center; outline: none; font-weight: 700; }
.line .sum { margin-left: auto; text-align: right; }
.line .sum b { display: block; }
.warnline { font-size: .8rem; color: var(--warn); display: flex; gap: .35rem; align-items: center; }
.warnline.bad { color: var(--bad); }
.warnline svg { width: 15px; height: 15px; flex: none; }
.conf { font-size: .74rem; padding: .05rem .4rem; border-radius: 6px; background: #eef1ef; color: var(--muted); }
.sticky-foot { position: sticky; bottom: 64px; z-index: 15; margin-top: 14px; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 -2px 20px rgba(0,0,0,.08); padding: 10px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sticky-foot .tot { font-size: 1.2rem; font-weight: 800; }
@media (min-width: 960px) {
  .sticky-foot { bottom: 12px; }
  .order-grid { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
  .line { grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 16px; }
  .line .raw { grid-column: 1 / -1; }
}
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; font-size: .86rem; }
.timeline li { display: grid; grid-template-columns: 8px 1fr; gap: 10px; }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); margin-top: 7px; }

/* ---------- модальные окна ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15,25,20,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal .mh { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 8px; }
.modal .mh h2 { margin: 0; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .modal { width: min(640px, 94vw); border-radius: 18px; padding: 22px; }
  .modal.wide { width: min(900px, 96vw); }
}
.pick { display: grid; gap: 6px; margin-top: 10px; max-height: 50vh; overflow: auto; }
.pick button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .55rem .7rem; cursor: pointer;
  display: flex; justify-content: space-between; gap: .6rem; align-items: center; }
.pick button:hover, .pick button:focus { border-color: var(--brand-2); background: var(--brand-soft); }
.drop { border: 2px dashed #c4cec9; border-radius: 14px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: #fafcfb; }
.drop.on { border-color: var(--brand-2); background: var(--brand-soft); }
.drop svg { width: 30px; height: 30px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfa; white-space: nowrap; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; }
table.t tbody tr:hover { background: #fafcfb; cursor: pointer; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: #eef1ef; color: var(--muted); font-weight: 600; }
.chip.ok { background: var(--ok-soft); color: var(--ok); } .chip.warn { background: var(--warn-soft); color: var(--warn); }
.mobile-cards { display: grid; gap: 8px; }
.mcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; }
@media (min-width: 760px) { .only-mobile { display: none !important; } }
@media (max-width: 759px) { .only-desktop { display: none !important; } }

/* ---------- графики ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.bars rect { fill: var(--brand-2); }
.bars rect.alt { fill: var(--accent); }
.axis text { font-size: 10px; fill: var(--muted); }
.legend { display: flex; gap: 12px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.grid2 { display: grid; gap: 12px; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- уведомления ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: 86px; display: grid; gap: 8px; width: min(440px, 92vw); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 500;
  animation: up .2s ease-out; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
@media (min-width: 960px) { #toasts { bottom: 24px; } }
.steps { counter-reset: s; list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: 6px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 26px 1fr; gap: 8px; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  font-weight: 700; font-size: .8rem; display: grid; place-items: center; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .84rem; }
pre { background: #0f1a17; color: #d7f0e6; padding: 12px; border-radius: 10px; overflow-x: auto; white-space: pre; }
.secret { background: var(--warn-soft); border: 1px solid #f1d28b; border-radius: 10px; padding: 10px; word-break: break-all; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: #b0bab5; }
.status-dot.ok { background: var(--ok); } .status-dot.error { background: var(--bad); } .status-dot.starting { background: var(--accent); }
.lang-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang-switch button { border: 0; background: #fff; padding: .25rem .55rem; font-weight: 700; font-size: .8rem; cursor: pointer; }
.lang-switch button.on { background: var(--ink); color: #fff; }
button > svg, a > svg, .prod svg { width: 18px; height: 18px; flex: none; }
.line .prod > svg { width: 16px; height: 16px; color: var(--muted); }
.mcard > svg { width: 22px; height: 22px; color: var(--brand); }
/* дочерние элементы сетки не растягиваются длинным содержимым (pre, таблицы) — без горизонтальной прокрутки на телефоне */
.shell > div, .main, .grid2 > *, .stack > *, .order-grid > * { min-width: 0; }
.secret code { word-break: break-all; }
