:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e6e8ec;
  --border-strong: #d4d8de;
  --ink: #111827;
  --ink-2: #4b5563;
  --ink-3: #8a93a1;
  --primary: #0f766e;
  --primary-600: #0d6961;
  --primary-50: #ecfdf8;
  --primary-100: #d1faef;
  --accent: #f59e0b;
  --accent-50: #fff8eb;
  --retail: #0d9488;
  --retail-50: #e8f8f6;
  --wholesale: #6366f1;
  --wholesale-50: #eef0ff;
  --good: #15803d;
  --good-50: #ecfdf3;
  --warn: #b45309;
  --warn-50: #fff7e6;
  --bad: #c2410c;
  --crit: #dc2626;
  --crit-50: #fef1f1;
  --wa: #25d366;
  --sms: #2563eb;
  --mail: #9333ea;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .16);
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --bottom-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
a { color: var(--primary); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex: none; }
.ico svg { width: 100%; height: 100%; display: block; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40;
  transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; }
.brand-logo { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, #0f766e, #14b8a6); display: grid; place-items: center; box-shadow: 0 4px 12px rgba(15,118,110,.3); }
.brand-logo svg { width: 30px; height: 30px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-sub { font-size: 12px; color: var(--ink-3); }
.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; margin-bottom: 2px; position: relative;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--primary-50); color: var(--primary); font-weight: 600; }
.nav a .pill { margin-left: auto; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.sim-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); padding: 8px 12px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); }
.sim-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.sim-chip.live .dot { background: var(--good); box-shadow: 0 0 0 0 rgba(21,128,61,.5); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21,128,61,.45);} 70% { box-shadow: 0 0 0 8px rgba(21,128,61,0);} 100% { box-shadow: 0 0 0 0 rgba(21,128,61,0);} }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: rgba(245,246,248,.85); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 19px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.clock { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--border); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.content { padding: 24px; max-width: 1440px; width: 100%; margin: 0 auto; flex: 1; }
.bottom-nav { display: none; }
.scrim { display: none; }
.only-mobile { display: none !important; }

/* ---------- Primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-head h3 { font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-top: 2px; }
.card-body { padding: 14px 18px 18px; }
.row { display: flex; align-items: center; }
.gap-sm { gap: 8px; } .gap { gap: 12px; } .gap-lg { gap: 18px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mt-sm { margin-top: 8px; } .mb { margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(15,118,110,.25); }
.btn-primary:hover { background: var(--primary-600); }
.btn-accent { background: var(--accent); color: #1f1300; }
.btn-accent:hover { background: #e48f06; }
.btn-light { background: var(--surface); border-color: var(--border-strong); color: var(--ink); }
.btn-light:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--crit-50); color: var(--crit); border-color: #fbd5d5; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 48px; font-size: 15px; padding: 0 20px; border-radius: 12px; }
.btn-block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); display: inline-grid; place-items: center; color: var(--ink-2); position: relative; flex: none; }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.bell .badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; border: 2px solid var(--bg); }
.bell.ring .ico { animation: ring .8s ease; }
@keyframes ring { 0%,100% { transform: rotate(0);} 20% { transform: rotate(14deg);} 40% { transform: rotate(-12deg);} 60% { transform: rotate(8deg);} 80% { transform: rotate(-4deg);} }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.pill .ico { width: 12px; height: 12px; }
.pill-retail { background: var(--retail-50); color: #0b766c; border-color: #c4ece7; }
.pill-wholesale { background: var(--wholesale-50); color: #4b4fd6; border-color: #d9dcff; }
.pill-good { background: var(--good-50); color: var(--good); border-color: #c8efd5; }
.pill-warn { background: var(--warn-50); color: var(--warn); border-color: #fde3b5; }
.pill-crit { background: var(--crit-50); color: var(--crit); border-color: #fbd5d5; }
.pill-info { background: #eff6ff; color: #1d4ed8; border-color: #dbe7ff; }
.pill-dark { background: var(--ink); color: #fff; border-color: var(--ink); }

.input, select.input, textarea.input {
  height: 38px; width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 0 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.14); }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.search { position: relative; }
.search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 16px; height: 16px; }
.search .input { padding-left: 36px; }

.seg { display: inline-flex; background: #eef0f3; border-radius: 11px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg button .sw { width: 8px; height: 8px; border-radius: 50%; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

.toggle { position: relative; width: 40px; height: 23px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: #d5d9df; border-radius: 999px; transition: .2s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--primary); }
.toggle input:checked + span::after { transform: translateX(17px); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfd; }
.table .right { text-align: right; }
.prod-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.emoji { width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; font-size: 19px; flex: none; }
.stockbar { width: 90px; height: 6px; background: #eef0f3; border-radius: 3px; overflow: hidden; margin-top: 5px; }
.stockbar span { display: block; height: 100%; border-radius: 3px; }

/* ---------- KPI ---------- */
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.kpi-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-foot { font-size: 12px; color: var(--ink-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.up { color: var(--good); font-weight: 600; } .down { color: var(--crit); font-weight: 600; }

/* ---------- Chart ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: 260px; display: block; overflow: visible; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: 12px; box-shadow: var(--shadow-lg); white-space: nowrap; transform: translate(-50%, -100%); z-index: 3; }
.chart-tip .r { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.chart-tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }

/* ---------- Lists ---------- */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .meta { font-size: 12px; color: var(--ink-3); }
.feed-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.feed-icon .ico { width: 15px; height: 15px; }
.empty { text-align: center; padding: 30px 12px; color: var(--ink-3); }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pos-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 12px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 13px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
.prod {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, box-shadow .15s, transform .1s; position: relative;
}
.prod:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(15,118,110,.12); }
.prod:active { transform: scale(.98); }
.prod.out { opacity: .55; }
.prod .emoji { width: 44px; height: 44px; font-size: 24px; }
.prod-name { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.prod-ta { font-size: 11.5px; color: var(--ink-3); }
.prod-price { font-weight: 800; font-size: 15px; }
.prod-stock { font-size: 11.5px; }
.prod .qty-badge { position: absolute; top: 10px; right: 10px; background: var(--primary); color: #fff; font-weight: 700; font-size: 12px; min-width: 24px; height: 24px; border-radius: 12px; display: grid; place-items: center; padding: 0 6px; }
.cart { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 32px); }
.cart-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cart-items { overflow-y: auto; padding: 4px 18px; flex: 1; min-height: 120px; }
.cart-line { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.cart-line:last-child { border-bottom: 0; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.qty button { width: 28px; height: 28px; border: 0; background: var(--surface-2); font-weight: 700; }
.qty input { width: 40px; height: 28px; border: 0; text-align: center; font-weight: 600; outline: none; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.cart-foot { padding: 14px 18px 18px; border-top: 1px solid var(--border); display: grid; gap: 10px; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.sum-row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); }
.sum-row.total { font-size: 19px; font-weight: 800; color: var(--ink); }
.pay-methods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pay-methods button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 9px; padding: 7px 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.pay-methods button.active { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.cart-fab { display: none; }

.receipt { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; background: #fffef8; border: 1px dashed var(--border-strong); border-radius: 10px; padding: 16px; }
.receipt .c { text-align: center; }
.receipt hr { border: 0; border-top: 1px dashed var(--border-strong); margin: 8px 0; }
.receipt .r { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- Suppliers ---------- */
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.sup-card { padding: 16px; display: grid; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; }
.credit-meter { height: 8px; background: #eef0f3; border-radius: 4px; overflow: hidden; }
.credit-meter span { display: block; height: 100%; border-radius: 4px; }
.stat-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-mini div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.stat-mini b { display: block; font-size: 14px; }
.stat-mini span { font-size: 11px; color: var(--ink-3); }

/* ---------- Automations ---------- */
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.auto-card { padding: 16px; display: grid; gap: 12px; align-content: start; }
.auto-flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
.auto-flow .node { background: var(--surface-2); border: 1px solid var(--border); padding: 4px 9px; border-radius: 8px; font-weight: 600; color: var(--ink-2); }
.auto-flow .node.t { background: var(--accent-50); border-color: #fde3b5; color: var(--warn); }
.auto-flow .node.a { background: var(--primary-50); border-color: var(--primary-100); color: var(--primary); }
.auto-flow .arrow { color: var(--ink-3); }
.log { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; max-height: 420px; overflow-y: auto; }
.log-line { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--border); align-items: flex-start; }
.log-line time { color: var(--ink-3); flex: none; }
.log-line .tag { flex: none; }
.log-line.new { animation: flash 1.2s ease; }
@keyframes flash { from { background: #fff7d6; } to { background: transparent; } }

/* ---------- Simulator ---------- */
.sim-hero { padding: 20px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; background: linear-gradient(120deg, #f0fdfa 0%, #ffffff 55%, #fff8eb 100%); }
.sim-hero h2 { font-size: 20px; }
.speed { display: flex; gap: 6px; }
.scenario { padding: 16px; display: flex; gap: 12px; align-items: flex-start; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); transition: .15s; }
.scenario:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.scenario .feed-icon { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
.scenario b { display: block; margin-bottom: 2px; }
.scenario span { font-size: 12.5px; color: var(--ink-3); }
.counter { font-size: 28px; font-weight: 800; }

/* ---------- Messages ---------- */
.msg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.pos > div { min-width: 0; }
.msg-list { max-height: calc(100vh - var(--topbar-h) - 110px); overflow-y: auto; }
.msg-row { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: flex-start; }
.msg-row:hover { background: var(--surface-2); }
.msg-row.sel { background: var(--primary-50); }
.msg-row .ch { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; }
.msg-row .ch .ico { width: 17px; height: 17px; }
.msg-preview { font-size: 12.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ticks { font-size: 11px; font-weight: 600; }
.ticks.read { color: #0ea5e9; }
.phone { width: 100%; max-width: 330px; margin: 0 auto; border: 10px solid #1f2937; border-radius: 34px; overflow: hidden; background: #efe7dd; box-shadow: var(--shadow-lg); position: sticky; top: calc(var(--topbar-h) + 16px); }
.phone-top { background: #075e54; color: #fff; padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.phone-top.sms { background: #1d4ed8; } .phone-top.email { background: #7e22ce; }
.phone-top .av { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.25); display: grid; place-items: center; font-weight: 700; }
.phone-body { min-height: 380px; padding: 16px 12px; background-image: radial-gradient(rgba(0,0,0,.04) 1px, transparent 1px); background-size: 14px 14px; }
.phone-body.light { background: #f3f4f6; }
.bubble { background: #dcf8c6; border-radius: 10px 0 10px 10px; padding: 8px 10px 6px; margin-left: 30px; font-size: 13px; white-space: pre-wrap; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.bubble.sms { background: #2563eb; color: #fff; border-radius: 16px 16px 4px 16px; }
.bubble.email { background: #fff; margin-left: 0; border-radius: 10px; }
.bubble .bt { font-size: 10.5px; color: #667781; text-align: right; margin-top: 4px; }
.bubble.sms .bt { color: #dbeafe; }

/* ---------- Panel / modal / toast ---------- */
.panel { position: fixed; top: calc(var(--topbar-h) - 4px); right: 16px; width: 380px; max-width: calc(100vw - 32px); max-height: min(560px, calc(100vh - 100px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60; display: flex; flex-direction: column; animation: pop .16s ease; }
.panel-head { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.panel-body { overflow-y: auto; padding: 4px 14px; }
.alert-item { display: flex; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.alert-item.unread .t::after { content: ""; display: inline-block; width: 7px; height: 7px; background: var(--crit); border-radius: 50%; margin-left: 6px; vertical-align: middle; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98);} to { opacity: 1; transform: none; } }

.modal-wrap { position: fixed; inset: 0; background: rgba(17,24,39,.42); z-index: 80; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; width: 560px; max-width: 100%; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal.wide { width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal-foot:empty { display: none; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; width: 360px; max-width: calc(100vw - 32px); }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: flex-start; animation: slide .25s ease; }
.toast.warn { border-left-color: var(--accent); } .toast.crit { border-left-color: var(--crit); } .toast.wa { border-left-color: var(--wa); } .toast.auto { border-left-color: var(--wholesale); }
.toast b { display: block; font-size: 13px; }
.toast span { font-size: 12.5px; color: var(--ink-2); }
.toast.out { opacity: 0; transform: translateX(20px); transition: .3s; }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }

/* ---------- Tour ---------- */
.tour { position: fixed; inset: 0; z-index: 100; }
.tour-spot { position: fixed; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(17,24,39,.55), 0 0 0 4px rgba(245,158,11,.9); transition: all .35s cubic-bezier(.4,.1,.2,1); pointer-events: none; }
.tour-spot.center { width: 0; height: 0; left: 50%; top: 50%; box-shadow: 0 0 0 9999px rgba(17,24,39,.55); }
.tour-card { position: fixed; width: 340px; max-width: calc(100vw - 24px); background: var(--surface); border-radius: 16px; padding: 18px; box-shadow: var(--shadow-lg); transition: top .35s ease, left .35s ease; }
.tour-step { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
.tour-card h4 { font-size: 16.5px; margin: 4px 0 6px; }
.tour-card p { margin: 0 0 12px; color: var(--ink-2); font-size: 13.5px; }
.tour-progress { height: 4px; background: #eef0f3; border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.tour-progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.tour-actions { display: flex; justify-content: space-between; align-items: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 1024px) {
  .g-main, .msg-layout { grid-template-columns: 1fr; }
  .phone { position: static; }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.4); z-index: 35; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-grid !important; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px calc(var(--bottom-h) + 24px); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--border); z-index: 30;
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-decoration: none; position: relative; }
  .bottom-nav a.active { color: var(--primary); }
  .bottom-nav a.active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
  .bottom-nav .ico { width: 21px; height: 21px; }
  .pos { grid-template-columns: minmax(0, 1fr); }
  .msg-list { max-height: 60vh; }
  .cart { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 85vh; z-index: 70; border-radius: 20px 20px 0 0; transform: translateY(105%); transition: transform .3s ease; box-shadow: var(--shadow-lg); }
  .cart.open { transform: none; }
  .cart-foot { border-radius: 0; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .cart-fab { display: flex; position: fixed; left: 16px; right: 16px; bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom)); z-index: 31; height: 52px; border-radius: 14px; background: var(--ink); color: #fff; border: 0; align-items: center; justify-content: space-between; padding: 0 18px; font-weight: 700; box-shadow: var(--shadow-lg); }
  .toasts { bottom: auto; top: calc(var(--topbar-h) + 8px); right: 12px; left: 12px; width: auto; max-width: none; }
  .panel { right: 8px; left: 8px; width: auto; max-width: none; }
  .sim-hero { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .g-4 { gap: 10px; }
  .g-3, .g-2, .form-grid { grid-template-columns: 1fr; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 21px; }
  .kpi-icon { width: 30px; height: 30px; }
  .prod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .topbar-title h1 { font-size: 17px; }
  .clock { display: none; }
  .hide-xs { display: none !important; }
  .modal-wrap { align-items: end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .chart svg { height: 220px; }
  .sup-grid, .auto-grid { grid-template-columns: 1fr; }
  .table td, .table th { padding: 10px; }
  .hide-sm { display: none; }
  .tour-card { left: 12px !important; right: 12px; width: auto; }
}
