:root {
  --bg: #0B1220;
  --panel: #111A2C;
  --panel-2: #16213A;
  --line: rgba(255,255,255,.08);
  --text: #FFFFFF;
  --muted: rgba(255,255,255,.66);
  --lime: #B8F53A;
  --green: #0E7A3D;
  --warn: #FFB547;
  --danger: #FF6B6B;
  --radius: 10px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Manrope, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
h2 { font-size: 26px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 4px 0 0; line-height: 1.45; }

/* buttons + inputs */
.btn { font: inherit; font-weight: 700; border-radius: var(--radius); padding: 11px 16px; border: 1px solid transparent; cursor: pointer; transition: transform .08s, opacity .15s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--lime); color: var(--bg); font-weight: 800; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: rgba(184,245,58,.5); }
.wide { width: 100%; margin-top: 4px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { width: 100%; margin-top: 6px; font: inherit; font-size: 16px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--lime); }
.form { display: grid; gap: 12px; margin-top: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 80% -10%, rgba(14,122,61,.35), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; text-align: center; }
.login-card form { text-align: left; display: grid; gap: 14px; margin-top: 20px; }
.login-logo { width: 64px; height: 64px; border-radius: 14px; margin-bottom: 12px; }
.login-card h1 { font-size: 24px; font-weight: 800; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px; background: rgba(11,18,32,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; border-radius: 9px; }
.brand strong { display: block; font-size: 15px; font-weight: 800; }
.brand span { display: block; font-size: 12px; color: var(--lime); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.topnav { display: none; gap: 4px; margin-left: 12px; }
.topnav button, .tabbar button { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; position: relative; }
.topnav button { padding: 8px 12px; border-radius: 8px; font-weight: 700; }
.topnav button.active { color: var(--bg); background: var(--lime); }
.agent-pill { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; }
.agent-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.agent-pill.online i { background: var(--lime); box-shadow: 0 0 8px var(--lime); }
.agent-pill.offline i { background: var(--danger); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px calc(96px + var(--safe-b)); }
.view { display: none; }
.view.active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 6px calc(6px + var(--safe-b)); background: rgba(17,26,44,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabbar button { display: grid; justify-items: center; gap: 3px; padding: 8px 0; font-size: 11px; font-weight: 700; }
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--lime); }
.dot { position: absolute; top: 4px; right: calc(50% - 18px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 10px; line-height: 16px; text-align: center; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.grid2 { display: grid; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.kpi .label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 24px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: linear-gradient(135deg, rgba(184,245,58,.16), rgba(14,122,61,.18)); border-color: rgba(184,245,58,.35); }
.kpi.warn .value { color: var(--warn); }
.kpi.danger .value { color: var(--danger); }
.badge { font-size: 12px; font-weight: 800; padding: 4px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }
.badge.ok { background: rgba(184,245,58,.15); color: var(--lime); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .main { min-width: 0; }
.list .title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .meta { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .right { text-align: right; flex-shrink: 0; font-weight: 800; }
.list .empty { color: var(--muted); justify-content: center; padding: 18px 0; }
.status { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: capitalize; margin-top: 4px; }
.status.processing { background: rgba(255,181,71,.15); color: var(--warn); }
.status.completed { background: rgba(184,245,58,.15); color: var(--lime); }
.status.on-hold, .status.pending { background: rgba(255,255,255,.08); color: var(--muted); }
.status.refunded, .status.cancelled, .status.failed { background: rgba(255,107,107,.12); color: var(--danger); }
.stock { font-weight: 800; }
.stock.out { color: var(--danger); }
.stock.low { color: var(--warn); }
.alert-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--panel-2); flex-shrink: 0; font-size: 16px; }
.alert-row { display: flex; gap: 12px; align-items: center; min-width: 0; }
li.unread .title::after { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); margin-left: 8px; vertical-align: middle; }

/* toggles */
.toggle { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); color: var(--text); font-size: 15px; font-weight: 600; cursor: pointer; }
.toggle:first-of-type { border-top: 0; }
.toggle input { display: none; }
.toggle i { width: 44px; height: 26px; border-radius: 13px; background: var(--panel-2); border: 1px solid var(--line); position: relative; transition: background .15s; flex-shrink: 0; }
.toggle i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle input:checked + i { background: rgba(184,245,58,.25); border-color: var(--lime); }
.toggle input:checked + i::after { transform: translateX(18px); background: var(--lime); }
.push-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* chat */
.chat-view.active { display: flex; flex-direction: column; height: calc(100dvh - 170px - var(--safe-b)); }
.chat-box { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--lime); color: var(--bg); font-weight: 600; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.msg .tool { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg.typing::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--lime); }
@keyframes blink { 50% { opacity: 0; } }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 320px; }
.chat-empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 12px 10px; scrollbar-width: none; }
.chips button { flex-shrink: 0; font: inherit; font-size: 13px; font-weight: 700; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; cursor: pointer; }
.chips button:hover { border-color: var(--lime); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.composer textarea { margin: 0; resize: none; max-height: 140px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--lime); color: var(--bg); font-weight: 800; padding: 10px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 860px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  main { padding-bottom: 40px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .chat-view.active { height: calc(100dvh - 120px); }
  .toast { bottom: 28px; }
}
