/* WByved panel — светлая основа, WB-фиолетовый акцент, моно-ключи */
:root {
  --bg: #f7f6fb;
  --surface: #ffffff;
  --ink: #221933;
  --ink-soft: #6b6180;
  --line: #e8e4f2;
  --wb: #cb11ab;
  --wb-deep: #481173;
  --ok: #148a5c;
  --ok-bg: #e3f6ee;
  --warn: #b26a00;
  --warn-bg: #fdf1dd;
  --bad: #c62838;
  --bad-bg: #fde8ea;
  --info-bg: #efe9fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(34,25,51,.05), 0 8px 24px -12px rgba(72,17,115,.12);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 70% -10%, #efe0f7 0%, var(--bg) 60%);
}
.login-card {
  background: var(--surface); padding: 40px 36px; border-radius: 20px;
  box-shadow: var(--shadow); width: min(380px, 92vw); text-align: center;
  border: 1px solid var(--line);
}
.login-logo, .logo {
  font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 26px;
  color: var(--wb-deep); letter-spacing: -.5px;
}
.login-logo span, .logo span { color: var(--wb); }
.login-sub { color: var(--ink-soft); margin: 6px 0 24px; font-size: 14px; }
.login-card input {
  width: 100%; margin-bottom: 14px;
}
.login-err { color: var(--bad); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 0 10px 22px; font-size: 21px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; text-decoration: none;
  color: var(--ink-soft); font-weight: 500; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--ink); }
.nav-link.active { background: var(--info-bg); color: var(--wb-deep); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 10px; }
.store-badge {
  margin: 0 10px 16px; padding: 6px 12px; border-radius: 10px;
  background: var(--info-bg); color: var(--wb-deep);
  font-size: 12.5px; font-weight: 600;
}

.main { flex: 1; padding: 34px 40px 80px; max-width: 1160px; }
.page { display: none; }
.page.active { display: block; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 22px;
}
.page-head h1 { font-family: 'Unbounded', sans-serif; font-weight: 500; font-size: 24px; }
.page-sub { width: 100%; color: var(--ink-soft); font-size: 14px; margin-top: -6px; }

/* ---------- controls ---------- */
.btn {
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font: 600 14px 'Inter', sans-serif; padding: 10px 18px;
  transition: filter .15s, background .15s; text-decoration: none; display: inline-block;
  color: var(--ink);
}
.btn-primary { background: var(--wb); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
input, select, textarea {
  font: 400 14.5px 'Inter', sans-serif; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--wb); box-shadow: 0 0 0 3px rgba(203,17,171,.12); }
textarea { resize: vertical; }

/* ---------- cards / stats ---------- */
.panel-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .num { font-family: 'Unbounded', sans-serif; font-size: 28px; font-weight: 700; color: var(--wb-deep); }
.stat .lbl { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.stat.alert .num { color: var(--bad); }

/* ---------- products ---------- */
.products-list { display: flex; flex-direction: column; gap: 14px; }
.product-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 22px;
}
.product-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.product-title { font-weight: 700; font-size: 16px; }
.product-article {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  background: var(--info-bg); color: var(--wb-deep);
  padding: 3px 9px; border-radius: 7px;
}
.product-account { font-size: 12.5px; color: var(--ink-soft); }
.product-stock { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.pill {
  border-radius: 99px; padding: 4px 12px; font-size: 13px; font-weight: 600;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-muted { background: var(--bg); color: var(--ink-soft); }
.product-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.product-body { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 14px; display: none; }
.product-card.open .product-body { display: block; }

.voucher-grid { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.voucher-chip {
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 500;
  padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); display: inline-flex; align-items: center; gap: 7px;
}
.voucher-chip.issued { opacity: .45; text-decoration: line-through; }
.voucher-chip button {
  border: 0; background: none; cursor: pointer; color: var(--bad); font-size: 13px; padding: 0;
}

/* ---------- orders ---------- */
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar input { flex: 1; min-width: 220px; }
.filter-bar select { width: auto; }
.order-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 12px;
}
.order-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.order-id { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px; }
.order-name { font-weight: 600; }
.order-meta { color: var(--ink-soft); font-size: 13px; }
.order-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.status-badge { border-radius: 99px; padding: 4px 12px; font-size: 12.5px; font-weight: 700; }
.st-await_code { background: var(--warn-bg); color: var(--warn); }
.st-code_received { background: var(--info-bg); color: var(--wb-deep); }
.st-closed { background: var(--ok-bg); color: var(--ok); }
.st-no_voucher, .st-error { background: var(--bad-bg); color: var(--bad); }
.st-canceled { background: var(--bg); color: var(--ink-soft); }
.st-manual { background: var(--warn-bg); color: var(--warn); }
.st-new { background: var(--info-bg); color: var(--wb-deep); }

/* конвейер статуса — фирменный элемент */
.pipeline { display: flex; align-items: center; gap: 0; margin-top: 10px; }
.pipe-step { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.pipe-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--line); flex-shrink: 0;
}
.pipe-step.done .pipe-dot { background: var(--wb); box-shadow: 0 0 0 3px rgba(203,17,171,.15); }
.pipe-step.done { color: var(--wb-deep); font-weight: 600; }
.pipe-line { width: 38px; height: 2px; background: var(--line); margin: 0 8px; }
.pipe-line.done { background: var(--wb); }
.order-code {
  font-family: 'JetBrains Mono', monospace; letter-spacing: 2px;
  background: var(--info-bg); color: var(--wb-deep);
  padding: 2px 8px; border-radius: 6px; font-weight: 700;
}
.order-err { color: var(--bad); font-size: 13px; margin-top: 8px; }
.order-warn { color: var(--warn); font-size: 13px; margin-top: 8px; font-weight: 600; }
.order-card.order-stale { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn), var(--shadow); }
.order-log { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; font-size: 13px; display:none; }
.order-card.open .order-log { display: block; }
.log-row { display: flex; gap: 10px; padding: 2px 0; color: var(--ink-soft); }
.log-row b { color: var(--ink); font-weight: 600; }

/* ---------- modal / misc ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(34,25,51,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px; z-index: 50; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  width: min(560px, 100%); padding: 28px; max-height: 84vh; overflow: auto;
}
.modal h2 { font-family: 'Unbounded', sans-serif; font-weight: 500; font-size: 19px; margin-bottom: 18px; }
.modal label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 12px; }
.modal label input, .modal label textarea, .modal label select { margin-top: 5px; font-weight: 400; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; justify-content: flex-end; }

/* ---------- chat ---------- */
.chat-messages {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 50vh; overflow-y: auto; margin: 0 -28px; padding: 14px 28px;
  background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.chat-msg { max-width: 78%; padding: 8px 12px; border-radius: 14px; font-size: 14px; }
.chat-msg-in { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-msg-out { align-self: flex-end; background: var(--wb); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-sender { font-size: 11.5px; font-weight: 700; opacity: .75; margin-bottom: 2px; }
.chat-msg-text { white-space: pre-wrap; word-break: break-word; }
.chat-msg-img { max-width: 220px; max-height: 220px; border-radius: 10px; margin-top: 6px; display: block; }
.chat-msg-time { font-size: 10.5px; opacity: .6; margin-top: 4px; text-align: right; }
.chat-form { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.chat-form input[type=text] { flex: 1; }
.settings-form label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 16px; }
.settings-form textarea, .settings-form input { margin-top: 5px; font-weight: 400; }
.form-row { display: flex; gap: 14px; }
.form-row label { flex: 1; }
.saved-note { color: var(--ok); font-size: 13.5px; margin-left: 12px; }
.photo-preview { max-width: 180px; border-radius: 10px; border: 1px solid var(--line); display: block; margin-top: 8px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); z-index: 99;
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px);} }

@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 12px; }
  .sidebar .logo { padding: 0 12px 0 4px; font-size: 17px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .nav-link { padding: 8px 10px; white-space: nowrap; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 14px 60px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
