:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232738;
  --border: #2e3347;
  --text: #e2e6f0;
  --text-muted: #7a82a0;
  --primary: #4f6ef7;
  --danger: #e05470;
  --success: #3ecf72;
  --warning: #f59e0b;
  --radius: 10px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 { font-size: 1.2rem; font-weight: 700; }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#admin-key-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 200px;
  direction: ltr;
}

/* ── Login panel ── */
#login-panel {
  display: flex;
  align-items: center;
  gap: 8px;
}
.login-separator {
  color: var(--text-muted);
  font-size: 0.78rem;
}
#user-panel {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-email-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #000; }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-google {
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.btn-google:hover { background: #f8f9fa; opacity: 1; }

/* ── Badges ── */
.badge {
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-offline { background: #2a2a3a; color: var(--text-muted); }
.badge-online { background: rgba(62,207,114,0.15); color: var(--success); }
.badge-held { background: rgba(79,110,247,0.15); color: var(--primary); }
.badge-released { background: rgba(62,207,114,0.15); color: var(--success); }
.badge-disputed { background: rgba(224,84,112,0.15); color: var(--danger); }
.badge-refunded { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-pending_payment { background: #2a2a3a; color: var(--text-muted); }

/* ── Main ── */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.hidden { display: none !important; }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card.dispute { border-color: var(--danger); }
.stat-card.revenue { border-color: var(--success); }

.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.stat-value { font-size: 1.8rem; font-weight: 700; }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── Section ── */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 1rem; flex: 1; }
.section-header select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* ── Card list ── */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.empty-state { color: var(--text-muted); text-align: center; padding: 40px; }

/* ── Escrow card ── */
.escrow-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.escrow-card.disputed { border-color: var(--danger); }

.escrow-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.escrow-id { font-family: monospace; font-size: 0.78rem; color: var(--text-muted); flex: 1; }

.escrow-body {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.escrow-field { display: flex; flex-direction: column; gap: 2px; }
.field-label { font-size: 0.72rem; color: var(--text-muted); }
.field-value { font-size: 0.9rem; }

.dispute-box {
  background: rgba(224,84,112,0.08);
  border: 1px solid rgba(224,84,112,0.3);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 0.85rem;
}
.dispute-reason { margin-bottom: 6px; }
.dispute-photo a { color: var(--primary); font-size: 0.8rem; }

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Listing card ── */
.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}
.listing-header { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.listing-seller { font-weight: 600; flex: 1; }
.listing-items { display: flex; gap: 8px; flex-wrap: wrap; }
.listing-item { background: var(--surface2); border-radius: 4px; padding: 3px 8px; font-size: 0.8rem; }

/* ── Filter inputs ── */
.filter-input,
.filter-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.filter-input { width: 180px; direction: ltr; }

/* ── Monitor card ── */
.monitor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.monitor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.monitor-row:last-child { border-bottom: none; }

.monitor-label { color: var(--text-muted); flex-shrink: 0; margin-left: 12px; }
.monitor-value { font-weight: 500; text-align: left; direction: ltr; }

/* ── Message cards ── */
.message-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.message-card.msg-in  { border-right: 3px solid var(--primary); }
.message-card.msg-out { border-right: 3px solid var(--success); }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.msg-phone { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); flex: 1; }
.msg-time  { font-size: 0.75rem; color: var(--text-muted); }
.msg-body  { font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg-reply { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); }

/* ── Toast ── */
#toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.85rem;
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
