:root {
  --bg: #05040a;
  --bg-card: #0f0b1a;
  --bg-card-hover: #18112b;
  --border: #2a1f47;
  --text: #f5f3ff;
  --muted: #a79ec2;
  --primary: #9333ea;
  --primary-hover: #a855f7;
  --emerald: #10b981;
  --amber: #f59e0b;
  --blue: #c084fc;
  --danger: #ef4444;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #080610;
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 22px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 6px 20px rgba(147, 51, 234, 0.4);
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.4px;
}

.brand-title span {
  color: var(--primary-hover);
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.nav-menu {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: rgba(168, 85, 247, 0.08);
  color: var(--text);
}

.nav-item.active {
  background: rgba(147, 51, 234, 0.18);
  border-color: rgba(168, 85, 247, 0.45);
  color: #fff;
  font-weight: 600;
}

.badge-pill {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.worker-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.worker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 10px var(--emerald);
}

.status-dot.paused {
  background: var(--amber);
  box-shadow: 0 0 10px var(--amber);
}

.worker-meta {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 10px;
}

.main-content {
  padding: 26px 32px;
  max-width: 1480px;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 800;
}

.page-subtitle {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.stat-label {
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-size: 30px;
  font-weight: 800;
  margin: 6px 0 4px;
}

.stat-foot {
  font-size: 11.5px;
  color: var(--muted);
}

.accent-amber .stat-value { color: var(--amber); }
.accent-blue .stat-value { color: var(--blue); }
.accent-emerald .stat-value { color: var(--emerald); }
.accent-orange .stat-value { color: var(--primary); }

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card h3 {
  font-size: 16.5px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 14px;
}

.sub-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* Forms & Buttons */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: #08060e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-emerald {
  background: var(--emerald);
  color: #052e16;
}

.btn-secondary {
  background: #1b1330;
  color: #fff;
  border: 1px solid var(--border);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.w-full {
  width: 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Filter bar & pills */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Offers Grid */
.offers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(430px, 1fr));
  gap: 18px;
}

.offer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.offer-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.status-tag {
  padding: 3px 9px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 11px;
}

.status-pending_approval { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }
.status-queued { background: rgba(59, 130, 246, 0.18); color: #93c5fd; }
.status-sent { background: rgba(16, 185, 129, 0.18); color: #6ee7b7; }
.status-error { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }

.offer-body {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
}

.offer-thumb {
  width: 120px;
  height: 120px;
  border-radius: 10px;
  object-fit: cover;
  background: #08060e;
  border: 1px solid var(--border);
}

.offer-meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
}

.offer-meta-badge {
  background: #08060e;
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}

.wa-bubble {
  background: #075e54;
  background: linear-gradient(180deg, #132a23 0%, #0f231d 100%);
  border: 1px solid #1f4d3d;
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  white-space: pre-wrap;
  color: #e2e8f0;
}

.wa-preview-container {
  background: #08060e;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  min-height: 280px;
}

.wa-preview-card {
  background: #140f23;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  max-width: 380px;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.wa-preview-card img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}

.wa-preview-text {
  white-space: pre-wrap;
  font-size: 13.5px;
  color: #e9edef;
}

/* Explorer Grid */
.explorer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.product-card img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  background: #08060e;
}

.product-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-title {
  font-size: 13.5px;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  background: #08060e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.webhook-feed {
  background: #06040a;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: monospace;
  font-size: 11.5px;
  max-height: 170px;
  overflow-y: auto;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
}

.qr-box {
  margin-top: 18px;
  text-align: center;
  background: #08060e;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.qr-box img {
  max-width: 240px;
  background: #fff;
  padding: 10px;
  border-radius: 12px;
  margin: 12px auto;
  display: block;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

#toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}

.toast {
  background: #1b1330;
  border-left: 4px solid var(--primary);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* Login Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, #241142 0%, #050409 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 410px;
  padding: 30px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.login-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-grid, .grid-2col { grid-template-columns: 1fr; }
  .offers-grid { grid-template-columns: 1fr; }
}
