/* ================================================================
   ДИЗАЙН-ТОКЕНЫ NeoСклад. Взяты из CRM, чтобы системы выглядели роднёй.
   Конкретные #hex и px ниже по файлу не пишем — только переменные.
   Верстка mobile-first: основной сценарий — телефон в руках повара.
   ================================================================ */
:root {
  --bg: #eceff5;
  --panel: #ffffff;
  --panel2: #f2f5fa;
  --panel3: #e6eaf2;

  --line: #ccd5e3;
  --line-strong: #9fadc2;

  --text: #131722;
  --muted: #566072;

  --accent: #2563eb;
  --accent-hover: #1b4fd0;
  --accent-soft: #e7effe;
  --green: #15803d;
  --green-soft: #e3f6e9;
  --red: #c62828;
  --red-soft: #fde8e7;
  --yellow: #a16207;
  --yellow-soft: #fdf0d5;

  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(17,24,39,.06), 0 1px 3px rgba(17,24,39,.10);
  --sh-2: 0 4px 12px rgba(17,24,39,.10), 0 2px 4px rgba(17,24,39,.06);
  --sh-3: 0 24px 60px rgba(17,24,39,.22), 0 8px 20px rgba(17,24,39,.12);
  --ring: 0 0 0 3px rgba(37,99,235,.30);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; outline: none;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---- кнопки ---- */
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: var(--r-md);
  padding: 11px 16px; font-weight: 600;
}
.btn:hover { background: var(--accent-hover); }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { background: var(--panel2); }
.btn.danger { background: var(--red); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---- вход ---- */
#login { position: fixed; inset: 0; display: none; place-items: center; padding: 16px; background: var(--bg); }
#login.show { display: grid; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 26px; width: min(360px, 100%); box-shadow: var(--sh-3);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card h1 span { color: var(--accent); }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.login-card label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
.login-card .btn { width: 100%; margin-top: 18px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-eye {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; font-size: 17px; padding: 6px 8px; line-height: 1;
}
.err { color: var(--red); min-height: 18px; margin-top: 10px; font-size: 13px; }

/* ---- шапка ---- */
header {
  position: sticky; top: 0; z-index: 20;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.hdr-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.logo { font-weight: 800; font-size: 17px; white-space: nowrap; }
.logo span { color: var(--accent); }
.hdr-top .spacer { flex: 1; }
.who { color: var(--muted); font-size: 12.5px; text-align: right; line-height: 1.25; }
.who b { display: block; color: var(--text); font-size: 13.5px; }

/* вкладки и склады */
.chips { display: flex; gap: 6px; padding: 0 12px 10px; overflow-x: auto; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-pill); padding: 7px 14px; white-space: nowrap; font-size: 13.5px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip .cnt { opacity: .8; font-size: 12px; }
.tabs { display: flex; gap: 4px; padding: 0 8px; border-top: 1px solid var(--line); }
.tab {
  flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 11px 4px; color: var(--muted); font-size: 13.5px; font-weight: 500;
}
.tab.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

main { padding: 12px; max-width: 900px; margin: 0 auto; }

/* ---- панель поиска ---- */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.toolbar input[type=search] { flex: 1; }
.toolbar .btn { flex: none; white-space: nowrap; }

/* ---- сводка склада ---- */
.kpis { display: flex; gap: 8px; margin-bottom: 10px; }
.kpi {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 9px 10px; box-shadow: var(--sh-1);
}
.kpi b { display: block; font-size: 18px; }
.kpi span { color: var(--muted); font-size: 12px; }
.kpi.warn b { color: var(--red); }

/* ---- список товаров ---- */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 11px 12px; box-shadow: var(--sh-1);
}
.row:hover { border-color: var(--line-strong); }
.row.low { border-left: 4px solid var(--red); }
.row.zero { background: var(--red-soft); }
.row .nm { flex: 1; min-width: 0; }
.row .nm b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .nm span { color: var(--muted); font-size: 12.5px; }
.row .qty { text-align: right; white-space: nowrap; }
.row .qty b { font-size: 17px; }
.row .qty span { display: block; color: var(--muted); font-size: 11.5px; }
.row .qty.low b { color: var(--red); }
.badge {
  display: inline-block; background: var(--panel3); border-radius: var(--r-pill);
  padding: 1px 8px; font-size: 11.5px; color: var(--muted); margin-right: 6px;
}
.empty { color: var(--muted); text-align: center; padding: 34px 10px; }

/* ---- журнал ---- */
.mv { display: flex; gap: 10px; align-items: baseline; padding: 9px 12px;
      background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md); }
.mv .d { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mv .t { flex: 1; min-width: 0; }
.mv .t b { font-weight: 600; }
.mv .t span { display: block; color: var(--muted); font-size: 12px; }
.mv .v { font-weight: 700; white-space: nowrap; }
.mv .v.plus { color: var(--green); }
.mv .v.minus { color: var(--red); }

/* ---- модалка ---- */
#modal { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: none;
         align-items: flex-end; justify-content: center; z-index: 50; }
#modal.show { display: flex; }
.sheet {
  background: var(--panel); width: min(560px, 100%); max-height: 92vh; overflow-y: auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 16px 16px 22px; box-shadow: var(--sh-3);
}
.sheet h2 { margin: 0 0 2px; font-size: 18px; padding-right: 34px; }
.sheet .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.sheet .x { position: absolute; right: 12px; top: 10px; background: none; border: 0; font-size: 26px;
            line-height: 1; color: var(--muted); }
.sheet-head { position: relative; }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }
.seg { display: flex; gap: 6px; margin-bottom: 14px; }
.seg button {
  flex: 1; background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 4px; font-size: 13.5px;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.big-qty { font-size: 22px; font-weight: 700; text-align: center; }
.hint { color: var(--muted); font-size: 12.5px; margin: -6px 0 12px; }
.hint b { color: var(--text); }
.chips-inline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chips-inline button { background: var(--panel2); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 5px 11px; font-size: 12.5px; }
.sheet-moves { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.sheet-moves h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sheet-moves .mv { border: 0; padding: 5px 0; background: none; }

/* ---- люди ---- */
.utab { width: 100%; border-collapse: collapse; background: var(--panel);
        border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.utab th, .utab td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.utab th { background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 12.5px; }
.utab tr:last-child td { border-bottom: 0; }
.utab tr.off td { opacity: .5; }
.utab .acts { white-space: nowrap; text-align: right; }
.utab .acts button { background: none; border: 0; font-size: 15px; padding: 2px 5px; }

/* ---- тост ---- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 11px 18px; border-radius: var(--r-pill);
  opacity: 0; transition: .22s; pointer-events: none; z-index: 90; box-shadow: var(--sh-2);
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

@media (min-width: 700px) {
  main { padding: 18px; }
  #modal { align-items: center; }
  .sheet { border-radius: var(--r-xl); }
}
