:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --sidebar: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--card); padding: 36px 32px; border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12); width: 360px;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.login-card .hint { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: var(--sidebar); color: #cbd5e1; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 20px 20px 14px; color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 9px; }
.sidebar .brand .logo { width: 26px; height: 26px; background: var(--primary); border-radius: 7px;
  display: flex; align-items: center; justify-content: center; font-size: 15px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px; }
.nav-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: #64748b; padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  color: #cbd5e1; font-size: 14px; margin-bottom: 2px; cursor: pointer;
}
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; }
.nav a .ico { width: 18px; text-align: center; }
.sidebar .user-box { padding: 12px 16px; border-top: 1px solid #334155; font-size: 13px; }
.sidebar .user-box .name { color: #fff; font-weight: 600; }
.sidebar .user-box .role { color: #94a3b8; font-size: 12px; }
.sidebar .user-box button { margin-top: 8px; width: 100%; background: #334155; color: #e2e8f0;
  border: none; padding: 7px; border-radius: 7px; font-size: 13px; }
.sidebar .user-box button:hover { background: #475569; }

.main { flex: 1; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 14px 26px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 18px; }
.content { padding: 24px 26px; max-width: 1240px; }

/* ---------- Cards & KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.kpi .value.green { color: var(--green); }
.kpi .value.red { color: var(--red); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; }
.card-head h3 { font-size: 15px; }
.card-body { padding: 4px 0; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 10px 18px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.material { background: #fef3c7; color: #92400e; }
.badge.detail { background: #dbeafe; color: #1e40af; }
.badge.kit { background: #ede9fe; color: #6d28d9; }
.badge.product { background: #dcfce7; color: #166534; }
.badge.in { background: #dcfce7; color: #166534; }
.badge.out { background: #fee2e2; color: #991b1b; }
.badge.gray { background: #f1f5f9; color: #475569; }
.pos { color: var(--red); font-weight: 600; }
.zero { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn { background: var(--primary); color: #fff; border: none; padding: 9px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 500; }
.btn:hover { background: var(--primary-dark); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.light { background: #eef2ff; color: var(--primary); }
.btn.light:hover { background: #e0e7ff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger { background: var(--red); }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex;
  align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: 720px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex;
  justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-head .x { background: none; border: none; font-size: 22px; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex;
  justify-content: flex-end; gap: 10px; }

/* Line editor rows */
.lines-table td { padding: 6px 8px; }
.lines-table input, .lines-table select { padding: 7px 8px; }
.line-del { background: #fee2e2; color: #991b1b; border: none; border-radius: 6px; width: 30px; height: 32px; font-size: 16px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: #0f172a; color: #fff;
  padding: 12px 18px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.3); z-index: 100;
  font-size: 14px; opacity: 0; transform: translateY(10px); transition: .25s; max-width: 360px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #991b1b; }
.toast.ok { background: #166534; }

.empty { padding: 40px; text-align: center; color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search { max-width: 260px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: #fff; border: 1px solid var(--border); padding: 7px 14px; border-radius: 20px;
  font-size: 13px; color: var(--muted); }
.tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.check-preview { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-top: 8px; font-size: 13px; }
.check-preview .ok { color: var(--green); }
.check-preview .bad { color: var(--red); }

/* ==================== МОБИЛЬНЫЙ / КИОСК-ИНТЕРФЕЙС ==================== */
/* Нижняя навигация (видна только на телефоне) */
.bottom-nav { display: none; }
.fab-sheet-bg { display: none; }

/* Плитки выбора (иконки-кнопки, как в киоске) */
.kiosk-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: #fff; border: 2px solid var(--border); border-radius: 18px; padding: 16px 12px;
  text-align: center; cursor: pointer; min-height: 120px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; transition: transform .08s, border-color .1s; }
.tile:hover { border-color: var(--primary); }
.tile:active { transform: scale(.96); }
.tile .tile-ico { font-size: 36px; line-height: 1; }
.tile .tile-name { font-weight: 700; font-size: 15px; }
.tile .tile-sub { font-size: 13px; color: var(--muted); }
.tile.add { border-style: dashed; color: var(--primary); }

/* Крупный степпер количества */
.kiosk-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.kiosk-head .back { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: #fff; font-size: 20px; flex-shrink: 0; }
.kiosk-head .title { font-size: 18px; font-weight: 700; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 24px 0 8px; }
.stepper button { width: 72px; height: 72px; border-radius: 50%; border: none; font-size: 34px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; }
.stepper .minus { background: #fee2e2; color: #991b1b; }
.stepper .plus { background: #dcfce7; color: #166534; }
.stepper .minus:active, .stepper .plus:active { transform: scale(.92); }
.qty-big { font-size: 46px; font-weight: 800; min-width: 130px; text-align: center; font-variant-numeric: tabular-nums; }
.qty-unit { font-size: 18px; color: var(--muted); text-align: center; margin-top: -4px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 14px 0; }
.chip { background: #eef2ff; color: var(--primary); border: none; padding: 13px 18px; border-radius: 14px;
  font-size: 17px; font-weight: 700; min-width: 64px; }
.chip:active { transform: scale(.94); }
.chip.minus { background: #fef2f2; color: #b91c1c; }
.big-btn { width: 100%; padding: 18px; font-size: 18px; font-weight: 800; border-radius: 16px; border: none;
  color: #fff; margin-top: 6px; }
.big-btn.accept { background: var(--green); }
.big-btn.accept:active { background: #15803d; }
.big-btn.blue { background: var(--primary); }
.big-btn.ghost { background: #f1f5f9; color: var(--text); }
.kiosk-cart .cart-row { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.kiosk-cart .cart-row .cn { flex: 1; font-weight: 600; }
.kiosk-cart .cart-row .cq { font-weight: 700; font-variant-numeric: tabular-nums; }
.kiosk-cart .cart-row .cx { background: #fee2e2; color: #991b1b; border: none; width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
.kiosk-input { width: 100%; font-size: 26px; text-align: center; padding: 12px; border: 2px solid var(--border);
  border-radius: 14px; font-weight: 700; }
.opt-row { display: flex; gap: 10px; align-items: center; margin: 12px 0; }

/* Крупные действия-плитки на «Создать» */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.action-tile { border: none; border-radius: 18px; padding: 22px 14px; color: #fff; font-size: 17px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 10px; }
.action-tile .ai { font-size: 34px; }
.action-tile.pu { background: #d97706; } .action-tile.pr { background: #7c3aed; }
.action-tile.sa { background: #16a34a; } .action-tile.fi { background: #2563eb; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { width: 100%; }
  .topbar { padding: 12px 16px; position: sticky; top: 0; }
  .topbar h2 { font-size: 17px; }
  .content { padding: 14px 14px 96px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .kpi .value { font-size: 20px; }
  .card-body { overflow-x: auto; }
  table { min-width: 520px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  /* модалки как нижние «шторки» */
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto; }
  /* нижняя навигация */
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; height: 66px;
    background: #fff; border-top: 1px solid var(--border); z-index: 40; box-shadow: 0 -2px 12px rgba(0,0,0,.05); }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 11px; color: var(--muted); cursor: pointer; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a .bico { font-size: 22px; line-height: 1; }
  .bottom-nav .fab { position: relative; }
  .bottom-nav .fab .plus-btn { width: 56px; height: 56px; border-radius: 50%; background: var(--primary);
    color: #fff; font-size: 30px; display: flex; align-items: center; justify-content: center; margin-top: -22px;
    box-shadow: 0 6px 18px rgba(37,99,235,.45); }
  .fab-sheet-bg { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 45; }
  .fab-sheet-bg.open { display: flex; align-items: flex-end; }
  .fab-sheet { background: #fff; width: 100%; border-radius: 20px 20px 0 0; padding: 18px 18px 26px; }
  .fab-sheet h3 { font-size: 16px; margin-bottom: 14px; text-align: center; }
  .kiosk-tiles { grid-template-columns: 1fr 1fr; }
  .tile { min-height: 108px; }
}
@media (min-width: 861px) {
  .bottom-nav, .fab-sheet-bg { display: none !important; }
}
