:root {
  --bg: #f4f6fb;
  --ink: #10172a;
  --muted: #667085;
  --line: #dce3ef;
  --purple: #7427e8;
  --purple2: #4f1bbb;
  --green: #13b981;
  --orange: #f59e0b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { border: 0; border-radius: 10px; background: var(--purple); color: white; font-weight: 850; cursor: pointer; min-height: 42px; padding: 0 16px; }
button.ghost { background: #eef2fb; color: #24304a; }
button.primary { width: 100%; background: linear-gradient(135deg, var(--purple), var(--orange)); }
.hidden { display: none !important; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top left, #7c3aed, #10172a 54%, #070a12); }
.login-card { width: min(440px, 100%); background: white; border-radius: 18px; padding: 28px; box-shadow: 0 24px 80px rgba(0,0,0,.28); display: grid; gap: 16px; }
.login-card h1 { margin: 0; font-size: 30px; }
.login-card p, .login-card small { color: var(--muted); margin: 0; line-height: 1.45; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand span { width: 38px; height: 38px; display: grid; place-items: center; background: linear-gradient(135deg, var(--purple), var(--orange)); color: white; border-radius: 12px; font-weight: 950; }
label { display: grid; gap: 7px; font-size: 12px; color: #4a5670; font-weight: 800; }
input, textarea, select { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: white; color: var(--ink); outline: 0; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(116,39,232,.12); }
.app { height: 100vh; display: grid; grid-template-columns: 330px minmax(360px, 1fr) 360px; overflow: hidden; }
.sidebar, .pos-panel { background: white; border-right: 1px solid var(--line); min-height: 0; overflow: auto; }
.pos-panel { border-left: 1px solid var(--line); border-right: 0; padding: 18px; display: grid; gap: 14px; align-content: start; }
.sidebar header, .topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 10px; }
.session-list { padding: 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.session-pill { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; justify-content: space-between; gap: 8px; background: #fafcff; }
.session-pill.online { border-color: #b5f0db; background: #edfff8; }
.session-pill small { display: block; color: var(--muted); }
.token-copy { display: inline-flex; width: fit-content; margin-top: 6px; border: 0; border-radius: 8px; padding: 6px 8px; background: #efe7ff; color: #5b21b6; font-size: 11px; font-weight: 900; cursor: pointer; }
.search-box { padding: 12px; }
.search-box input { width: 100%; }
.chat-list { display: grid; }
.chat-item { border: 0; border-top: 1px solid var(--line); padding: 14px; text-align: left; background: white; color: var(--ink); border-radius: 0; display: grid; gap: 5px; min-height: 74px; }
.chat-item.active { background: #f2ecff; box-shadow: inset 4px 0 0 var(--purple); }
.chat-item strong, .chat-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item small { color: var(--muted); }
.unread { justify-self: end; min-width: 22px; height: 22px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 20px; font-size: 12px; }
.conversation { min-width: 0; display: grid; grid-template-rows: 70px 1fr auto; background: #eef2f7; }
.topbar { background: white; }
.topbar div { min-width: 0; display: grid; gap: 3px; }
.topbar strong, .topbar small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: #f1eaff; color: var(--purple2); border: 1px solid #dac7ff; border-radius: 999px; padding: 8px 11px; font-size: 12px; font-weight: 850; }
.messages { padding: 18px; overflow: auto; display: flex; flex-direction: column; gap: 10px; }
.empty { margin: auto; color: var(--muted); background: white; border: 1px dashed var(--line); padding: 24px; border-radius: 16px; }
.msg { max-width: min(640px, 78%); padding: 11px 13px; border-radius: 14px; background: white; box-shadow: 0 1px 2px rgba(16,23,42,.08); line-height: 1.35; }
.msg.out { margin-left: auto; background: #dbffd9; }
.msg small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.reply { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 12px; background: white; border-top: 1px solid var(--line); }
.reply textarea { resize: none; min-height: 48px; }
.pos-panel header { display: grid; gap: 4px; }
.pos-panel header p { margin: 0; color: var(--purple); font-size: 11px; font-weight: 950; letter-spacing: .08em; }
.pos-panel header strong { font-size: 22px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.orders { display: grid; gap: 8px; }
.order-card { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcff; }
.order-card strong { display: flex; justify-content: space-between; }
dialog { border: 0; border-radius: 18px; padding: 0; box-shadow: 0 22px 70px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(16,23,42,.45); }
.dialog-card { width: min(460px, calc(100vw - 24px)); padding: 22px; display: grid; gap: 14px; }
.dialog-card h3 { margin: 0; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.token-box { background: #10172a; color: #d8f8ff; border-radius: 10px; padding: 12px; overflow-wrap: anywhere; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #10172a; color: white; padding: 12px 16px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; }
#mobileMenu { display: none; }
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr 42vh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(330px, 90vw); z-index: 10; transform: translateX(-105%); transition: .2s; box-shadow: 24px 0 80px rgba(16,23,42,.2); }
  .sidebar.open { transform: translateX(0); }
  .conversation { grid-row: 1; }
  .pos-panel { grid-row: 2; border-left: 0; border-top: 1px solid var(--line); overflow: auto; }
  #mobileMenu { display: inline-grid; place-items: center; }
  .reply { grid-template-columns: 1fr; }
}
