:root {
  --primary: #ffe600;
  --primary-dark: #e6cf00;
  --bg: #f4f6f9;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #c8c8d4;
  --sidebar-active: #ffe600;
  --white: #ffffff;
  --text: #2d2d2d;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* AUTH */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}

.auth-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-card .logo span {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--sidebar-bg);
}

.auth-card .logo span em {
  color: var(--primary);
  font-style: normal;
}

/* LAYOUT */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar .logo {
  padding: 1.5rem 1.25rem 1rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--white);
}

.sidebar .logo em {
  color: var(--primary);
  font-style: normal;
}

.sidebar nav {
  flex: 1;
  padding: 0.5rem 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--sidebar-active);
  background: rgba(255,230,0,0.07);
  border-left-color: var(--sidebar-active);
}

.sidebar nav a .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar .ml-status {
  margin: 1rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--sidebar-text);
}

.sidebar .ml-status .nickname { font-weight: 600; color: var(--white); }
.sidebar .ml-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block; margin-right: 4px; }
.sidebar .ml-status .dot.off { background: var(--danger); }

.main-content {
  margin-left: 230px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.topbar h1 { font-size: 1.1rem; font-weight: 700; }

.page-body { padding: 1.5rem; flex: 1; }

/* CARDS */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card .card-label { font-size: 12px; color: var(--text-muted); margin-bottom: 0.4rem; }
.card .card-value { font-size: 1.6rem; font-weight: 700; }
.card .card-value.green { color: var(--success); }
.card .card-value.blue { color: #3b82f6; }

/* TABLES */
.table-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-card .table-header {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.table-card .table-header h2 { font-size: 0.95rem; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 0.65rem 1rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}

.badge.paid, .badge.active { background: #dcfce7; color: #15803d; }
.badge.pending { background: #fef9c3; color: #854d0e; }
.badge.cancelled, .badge.closed { background: #fee2e2; color: #991b1b; }
.badge.paused { background: #e0e7ff; color: #3730a3; }
.badge.shipped { background: #dbeafe; color: #1e40af; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: var(--text); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 12px; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 0.35rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,230,0,0.2);
}

.error-msg { color: var(--danger); font-size: 12px; margin-top: 0.5rem; }

/* FILTERS */
.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filters input, .filters select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  outline: none;
  background: var(--white);
}

/* ITEM THUMBNAIL */
.item-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}

/* MESSAGES */
.messages-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  height: calc(100vh - 140px);
}

.conversations-list {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.conv-item {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.conv-item:hover, .conv-item.active { background: #fafafa; }
.conv-item .conv-buyer { font-weight: 600; font-size: 13px; }
.conv-item .conv-preview { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .unread-dot { width: 8px; height: 8px; border-radius: 50%; background: #3b82f6; display: inline-block; }

.chat-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-bubble {
  max-width: 60%;
  padding: 0.6rem 0.85rem;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.chat-bubble.mine { background: var(--primary); color: var(--text); align-self: flex-end; }
.chat-bubble.theirs { background: var(--bg); align-self: flex-start; }

.chat-input-area {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.5rem;
}

.chat-input-area textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  resize: none;
  outline: none;
}

/* CONNECT BANNER */
.connect-banner {
  background: linear-gradient(135deg, var(--sidebar-bg), #16213e);
  color: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.connect-banner h3 { font-size: 1rem; margin-bottom: 0.25rem; }
.connect-banner p { font-size: 12px; color: rgba(255,255,255,0.6); }

/* CHART */
.chart-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.chart-card h2 { font-size: 0.95rem; font-weight: 700; margin-bottom: 1rem; }

/* LOADING */
.loading { color: var(--text-muted); padding: 2rem; text-align: center; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.modal h3 { margin-bottom: 1rem; }

.hidden { display: none !important; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .messages-layout { grid-template-columns: 1fr; }
}
