:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warn: #d97706;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}

.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card p.sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; padding: 10px 16px; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #f1f5f9; color: var(--text); padding: 8px 14px; }
.btn-danger { background: #fee2e2; color: var(--danger); padding: 8px 14px; }
.btn-full { width: 100%; margin-top: 18px; padding: 11px; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; }
.ok-msg { color: var(--success); font-size: 13px; margin-top: 10px; }
.link-btn { background: none; color: var(--accent); font-weight: 600; padding: 0; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 20px 0;
  flex-shrink: 0;
}
.sidebar .brand { font-weight: 700; font-size: 16px; padding: 0 20px 18px; }
.sidebar select { margin: 0 16px 16px; width: calc(100% - 32px); }
.sidebar nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: #cbd5e1;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
}
.sidebar nav button.active { background: #1e293b; color: #fff; }
.sidebar nav button:hover { background: #1e293b; }
.sidebar .bottom { margin-top: auto; padding: 16px 20px; }

.main { flex: 1; padding: 28px 32px; max-width: 1000px; }
.main h2 { margin-top: 0; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 20px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.pending_review { background: #fef3c7; color: var(--warn); }
.badge.confirmed { background: #dbeafe; color: var(--accent-dark); }
.badge.shipped { background: #e0e7ff; color: #4338ca; }
.badge.delivered { background: #dcfce7; color: var(--success); }
.badge.cancelled { background: #fee2e2; color: var(--danger); }

.product-card, .faq-card { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; align-items: center; }
.product-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #f1f5f9; }
.product-card .info { flex: 1; }
.product-card .name { font-weight: 600; }
.product-card .meta { color: var(--muted); font-size: 13px; }

.inbox-layout { display: flex; gap: 16px; height: 70vh; }
.conv-list { width: 260px; border: 1px solid var(--border); border-radius: 10px; overflow-y: auto; background: var(--card); }
.conv-item { padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.conv-item:hover, .conv-item.active { background: #eff6ff; }
.conv-item .name { font-weight: 600; }
.conv-item .chan { color: var(--muted); font-size: 12px; text-transform: capitalize; }

.chat-pane { flex: 1; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 10px; font-size: 14px; line-height: 1.4; }
.msg.customer { align-self: flex-start; background: #f1f5f9; }
.msg.ai, .msg.owner { align-self: flex-end; background: var(--accent); color: #fff; }
.msg .meta { font-size: 11px; opacity: .7; margin-top: 3px; }
.chat-form { display: flex; border-top: 1px solid var(--border); }
.chat-form input { border: none; border-radius: 0; flex: 1; }
.chat-form button { border-radius: 0; padding: 0 20px; background: var(--accent); color: #fff; }

.empty-state { color: var(--muted); text-align: center; padding: 40px 20px; }
.code-box { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; font-family: monospace; font-size: 13px; overflow-x: auto; }
.hint { color: var(--muted); font-size: 13px; margin-top: 6px; }

@media (max-width: 800px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; }
  .main { padding: 16px; }
  .inbox-layout { flex-direction: column; height: auto; }
  .conv-list { width: 100%; max-height: 200px; }
}
