:root {
  --bg: #0f1419;
  --card: #1a222c;
  --border: #2c3642;
  --text: #e8eef4;
  --muted: #9aa8b5;
  --primary: #3d8bfd;
  --ok: #3dd68c;
  --warn: #f5a524;
  --danger: #f31260;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
.top {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: #121820;
}
.top h1 { margin: 0; font-size: 1.35rem; }
.muted { color: var(--muted); margin: 0.25rem 0 0; font-size: 0.95rem; }
.top-actions { display: flex; gap: 0.5rem; align-items: center; }
.badge {
  background: #123524; color: var(--ok); padding: 0.35rem 0.65rem;
  border-radius: 999px; font-size: 0.85rem; font-weight: 700;
}
.hidden { display: none !important; }
#app { max-width: 1100px; margin: 0 auto; padding-bottom: 2rem; }
.stock-card { margin: 1rem 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.inline-label { font-size: 0.85rem; color: var(--muted); }
.inline-label select {
  display: inline-block; width: auto; min-width: 8rem;
  margin-left: 0.35rem; margin-top: 0;
}
.st-line input.st-count { margin: 0; }
.card, .login {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin: 1.25rem;
}
.login label, .panel label {
  display: block; margin-bottom: 0.75rem; font-weight: 600;
}
.login input, .panel input, .panel textarea, .panel select, .search {
  display: block; width: 100%; margin-top: 0.35rem;
  padding: 0.7rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border); background: #0f1419; color: var(--text);
  font-size: 1.02rem;
}
.search { margin: 0.75rem 0; max-width: 420px; }
.btn {
  border: 1px solid var(--border); background: #243040; color: var(--text);
  border-radius: 10px; padding: 0.65rem 1rem; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary { background: var(--primary); border-color: transparent; color: #061018; }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.btn.danger { background: #3a121c; border-color: #5c1a2a; color: #ff8fab; }
.error { color: var(--danger); min-height: 1.25rem; }
.msg { color: var(--ok); font-weight: 600; min-height: 1.2rem; }
.hint { font-size: 0.9rem; color: var(--muted); }
.tabs {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20; background: #121820;
}
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 0.55rem 0.85rem; border-radius: 999px; font-weight: 700; cursor: pointer;
}
.tab.active { color: var(--text); background: var(--card); border-color: var(--border); }
.tab.tab-hot {
  color: #c8f0d8;
  border-color: rgba(61, 214, 140, 0.45);
  background: rgba(61, 214, 140, 0.12);
}
.tab.tab-hot.active {
  color: #061018;
  background: var(--ok);
  border-color: transparent;
}
.dash-shortcuts {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}
.dash-shortcuts .btn { font-size: 0.95rem; }
.panel { padding: 1rem 1.25rem; }
.subh { margin: 1.25rem 0 0.5rem; font-size: 1rem; color: var(--muted); }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 0.5rem; }
.list { display: grid; gap: 0.65rem; margin-top: 0.75rem; }
.item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.9rem 1rem; display: grid; gap: 0.35rem;
}
.item h3 { margin: 0; font-size: 1.05rem; }
.item .meta { color: var(--muted); font-size: 0.9rem; }
.status {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 6px;
  font-size: 0.78rem; font-weight: 800; text-transform: uppercase;
}
.status.new, .status.low, .status.received { background: #3b2a12; color: var(--warn); }
.status.confirmed { background: #1a2a40; color: #8ec5ff; }
.status.preparing { background: #3b2a12; color: var(--warn); }
.status.ready, .status.in_stock { background: #123524; color: var(--ok); }
.status.completed, .status.done { background: #1e2430; color: var(--muted); }
.status.cancelled, .status.out_of_stock { background: #3a121c; color: #ff8fab; }
.status-card.status-ready { border-color: #1f6b45; }
.status-card.status-preparing { border-color: #7a4a10; }
.status.pay-paid { background: #123524; color: var(--ok); }
.status.pay-awaiting_funds { background: #3b2a12; color: var(--warn); }
.status.pay-unpaid { background: #3a2a12; color: #ffd27a; }
.status.pay-collect_on_delivery { background: #1a2a40; color: #8ec5ff; }
.status.pay-refunded, .status.pay-failed { background: #3a121c; color: #ff8fab; }
.pay-line code.pay-ref, .pay-ref {
  font-family: ui-monospace, Consolas, monospace;
  background: #0f1419;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: #ffd27a;
}
.actions, .item .actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem; margin: 1rem 0;
}
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.stat b { display: block; font-size: 1.5rem; margin-top: 0.25rem; }

/* Business Manager assistant */
.tab-hot { box-shadow: inset 0 -2px 0 #d4a017; }
.biz-log {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  min-height: 280px; max-height: 52vh; overflow: auto; padding: 0.85rem 1rem; margin: 0.75rem 0;
}
.biz-msg { margin: 0 0 0.85rem; }
.biz-msg.user .biz-bubble { background: #1a2a40; border-color: #2a4a70; margin-left: 12%; }
.biz-msg.assistant .biz-bubble { background: #14241a; border-color: #1f4a30; margin-right: 8%; }
.biz-bubble {
  border: 1px solid var(--border); border-radius: 12px; padding: 0.7rem 0.9rem;
  white-space: pre-wrap; line-height: 1.45; font-size: 0.95rem;
}
.biz-msg .biz-role { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.25rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.biz-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.biz-pending {
  margin-top: 0.55rem; padding: 0.65rem 0.75rem; border-radius: 10px;
  background: #3b2a12; border: 1px solid #7a4a10;
}
.biz-pending strong { display: block; margin-bottom: 0.35rem; }
.biz-compose {
  display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center;
}
.biz-compose input {
  width: 100%; padding: 0.7rem 0.85rem; border-radius: 10px;
  border: 1px solid var(--border); background: #0f1419; color: var(--text); font-size: 1rem;
}
.biz-quick { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0 0; }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
.btn.listening { background: #a11; border-color: #c44; color: #fff; animation: biz-pulse 1s infinite; }
@keyframes biz-pulse { 50% { opacity: 0.75; } }
.muted.small { font-size: 0.85rem; }
@media (max-width: 640px) {
  .biz-compose { grid-template-columns: 1fr 1fr; }
  .biz-compose input { grid-column: 1 / -1; order: -1; }
  .biz-msg.user .biz-bubble, .biz-msg.assistant .biz-bubble { margin-left: 0; margin-right: 0; }
}

/* Persistent Biz Manager dock - clear of OS taskbar / Android nav */
:root {
  --biz-os-clear: max(56px, env(safe-area-inset-bottom, 0px));
}
body.biz-live #mainView {
  padding-bottom: calc(10rem + var(--biz-os-clear));
}
body.biz-live.biz-expanded #mainView {
  padding-bottom: calc(min(46vh, 400px) + var(--biz-os-clear));
}
.biz-dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--biz-os-clear);
  z-index: 40;
  pointer-events: none;
  font-family: inherit;
}
.biz-dock > * { pointer-events: auto; }
.biz-dock-pill {
  margin: 0 auto 8px; max-width: 920px; width: calc(100% - 20px);
  display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap;
  background: #0f2418; border: 1px solid #2d8a45; border-radius: 999px;
  padding: 0.45rem 0.75rem 0.45rem 1rem;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  cursor: pointer;
}
.biz-dock-pill strong { color: #8fd49c; font-size: 0.92rem; }
.biz-live-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #3dd68c;
  box-shadow: 0 0 0 0 rgba(61,214,140,0.6);
  animation: biz-live-pulse 1.6s infinite;
  flex-shrink: 0;
}
@keyframes biz-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,214,140,0.55); }
  70% { box-shadow: 0 0 0 10px rgba(61,214,140,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,214,140,0); }
}
.biz-dock-panel {
  margin: 0 auto; max-width: 1100px; width: 100%;
  background: #121a14; border-top: 2px solid #2d8a45;
  box-shadow: 0 -12px 40px rgba(0,0,0,0.5);
  padding: 0.65rem 1rem 0.75rem;
  max-height: min(46vh, 400px);
  display: flex; flex-direction: column;
  border-radius: 14px 14px 0 0;
}
.biz-dock-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.35rem;
}
.biz-dock-title { display: flex; align-items: center; gap: 0.55rem; }
.biz-dock-title strong { color: #e8eef4; font-size: 1.05rem; }
.biz-dock-toggles {
  display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center;
}
.biz-toggle {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.82rem; color: var(--muted); font-weight: 600;
  margin: 0; white-space: nowrap;
}
.biz-toggle input { width: auto; margin: 0; }
.biz-compose-top {
  flex-shrink: 0;
  margin: 0.15rem 0 0.25rem;
  position: relative;
  z-index: 2;
}
.biz-compose-top .btn.primary {
  min-height: 2.6rem;
  min-width: 5.5rem;
  font-size: 1rem;
}
.biz-dock-panel .biz-log {
  flex: 1; min-height: 80px; max-height: none; margin: 0.35rem 0 0;
  background: #0c120e;
}
.biz-dock-panel .biz-quick { margin: 0.2rem 0; flex-shrink: 0; }
.biz-fab {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + var(--biz-os-clear));
  z-index: 35;
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: #2d8a45; color: #fff; font-weight: 800;
  font-size: 0.95rem; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.biz-fab:hover { filter: brightness(1.08); }
body.biz-live .biz-fab { display: none !important; }
@media (max-width: 700px) {
  .biz-dock-panel { max-height: 50vh; padding: 0.5rem 0.65rem 0.65rem; }
  .biz-dock-pill { border-radius: 16px; }
  :root { --biz-os-clear: max(64px, env(safe-area-inset-bottom, 0px)); }
}
