/* Приложение поставщика: цвета — из темы Telegram (светлая и тёмная сами), вне Telegram — свои. */
:root {
  --fb-bg: #ffffff; --fb-text: #16181d; --fb-hint: #80858f; --fb-link: #2a7bd4; --fb-button: #2a7bd4;
  --fb-button-text: #ffffff; --fb-secondary: #f1f2f5; --fb-danger: #d9363e;
  --bg: var(--tg-theme-bg-color, var(--fb-bg));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --link: var(--tg-theme-link-color, var(--fb-link));
  --button: var(--tg-theme-button-color, var(--fb-button));
  --button-text: var(--tg-theme-button-text-color, var(--fb-button-text));
  --secondary: var(--tg-theme-secondary-bg-color, var(--fb-secondary));
  --section: var(--tg-theme-section-bg-color, var(--bg));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-danger));
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --ok: #2e9e5b; --warn: #d98a00;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root { --fb-bg: #17191d; --fb-text: #eceef2; --fb-hint: #8d939e; --fb-link: #5ea6f2; --fb-button: #3b8ce0;
    --fb-secondary: #0f1013; --fb-danger: #ff5a5f; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--secondary); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; padding-bottom: calc(64px + var(--safe-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px 4px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; border: 0; background: transparent; padding: 0; text-align: left; }
.brand.many { cursor: pointer; }
.brand.many b::after { content: " ▾"; color: var(--hint); font-size: 14px; }
.brand b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint, .muted { color: var(--hint); font-size: 13px; }
.screen { padding: 6px 12px 24px; max-width: 760px; margin: 0 auto; }
.loading, .empty { text-align: center; color: var(--hint); padding: 36px 12px; }
.empty .btn { margin-top: 14px; }

/* нижние вкладки */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + var(--safe-bottom)); z-index: 10; }
.tab { position: relative; border: 0; background: transparent; padding: 6px 2px; display: flex; flex-direction: column; align-items: center;
  gap: 1px; color: var(--hint); cursor: pointer; }
.tab .ico { font-size: 19px; line-height: 1.1; filter: grayscale(1); opacity: .75; }
.tab .label { font-size: 11px; }
.tab.active { color: var(--button); }
.tab.active .ico { filter: none; opacity: 1; }
.badge { position: absolute; top: 2px; left: calc(50% + 6px); background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 5px; display: none; }
.badge.on { display: block; }

/* блоки */
h1 { font-size: 20px; margin: 8px 4px 10px; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; color: var(--hint); margin: 18px 6px 6px; }
.card { background: var(--section); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; }
.card.tight { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--line); cursor: pointer; background: var(--section); }
.card.tight .row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--hint); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .r .s { text-align: right; }
.row.dim { opacity: .55; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; }
.kv > span:first-child { color: var(--hint); }
.kv > span:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.kv.big { font-size: 17px; font-weight: 700; }
.kv.big > span:first-child { color: var(--text); }
.sum { font-variant-numeric: tabular-nums; white-space: nowrap; }
.red, .row .s.red { color: var(--danger); }
.green, .row .s.green { color: var(--ok); }
.amber { color: var(--warn); }
.note { white-space: pre-wrap; word-break: break-word; }

/* метки статуса и оплаты */
.chip { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; font-weight: 600; background: var(--secondary); color: var(--hint); white-space: nowrap; }
.chip.new { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.chip.accepted, .chip.packed { background: color-mix(in srgb, var(--button) 14%, transparent); color: var(--button); }
.chip.shipped { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.delivered { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.paid { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.chip.partial, .chip.overdue { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.overdue { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* кнопки */
.btn { display: block; width: 100%; border: 0; border-radius: 10px; padding: 12px 14px; font-weight: 600; margin-top: 8px; cursor: pointer;
  background: var(--section); color: var(--text); text-align: center; }
.card .btn { background: var(--secondary); }
.btn.primary { background: var(--button); color: var(--button-text); }
.btn.danger { color: var(--danger); }
.btn.link { background: transparent; color: var(--link); padding: 8px 4px; width: auto; display: inline-block; margin: 0; }
.btn.small { width: auto; display: inline-block; padding: 7px 12px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .5; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btns .btn { flex: 1 1 140px; margin: 0; }
.back { border: 0; background: transparent; color: var(--link); padding: 6px 2px; cursor: pointer; font-size: 15px; }

/* переключатели */
.seg { display: flex; background: var(--section); border-radius: 10px; padding: 3px; gap: 3px; margin: 6px 0 8px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 4px; font-weight: 600; font-size: 14px; color: var(--hint); cursor: pointer; white-space: nowrap; }
.seg button.active { background: var(--button); color: var(--button-text); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.chips button { border: 1px solid var(--line); background: var(--section); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chips button.active { background: var(--button); border-color: var(--button); color: var(--button-text); }

/* формы */
label.f { display: block; margin: 10px 0 0; }
label.f > span { display: block; font-size: 13px; color: var(--hint); margin: 0 2px 4px; }
input[type=text], input[type=search], input[type=tel], input[type=date], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--button); }
textarea { min-height: 64px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 2px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--button); }
.search { position: sticky; top: 0; z-index: 5; background: var(--secondary); padding: 6px 0; }
input[type=date] { color-scheme: light dark; }

/* строки заказа в форме */
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--section); }
.card.tight .line:first-child { border-top: 0; }
.line .name { font-weight: 600; }
.line .meta { color: var(--hint); font-size: 13px; }
.line .warn { color: var(--danger); font-size: 13px; grid-column: 1 / -1; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 32px; height: 32px; border: 0; border-radius: 8px; background: var(--secondary); font-size: 18px; font-weight: 700; cursor: pointer; }
.qty input { width: 64px; text-align: center; padding: 6px 4px; }
.pick { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; border: 0; background: var(--section);
  border-top: 1px solid var(--line); padding: 10px 14px; text-align: left; cursor: pointer; }
.card.tight .pick:first-child { border-top: 0; }
.pick .s { color: var(--hint); font-size: 13px; }
.totals { position: sticky; bottom: calc(64px + var(--safe-bottom)); background: var(--secondary); padding: 8px 0 0; }

/* таблицы отчётов */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { color: var(--hint); font-weight: 600; font-size: 12px; text-align: right; padding: 4px 0 6px 8px; }
table.t th:first-child, table.t td:first-child { text-align: left; padding-left: 0; }
table.t td { text-align: right; padding: 7px 0 7px 8px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.t td:first-child { word-break: break-word; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stat { background: var(--section); border-radius: var(--radius); padding: 10px 12px; }
.stat .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--hint); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: color-mix(in srgb, var(--text) 88%, transparent); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 90vw;
  transition: .2s; pointer-events: none; z-index: 20; font-size: 14px; text-align: center; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
