:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --bg: #0b0f1a;
  --surface: #131a2e;
  --surface-2: #1b2340;
  --border: rgba(255, 255, 255, 0.08);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --accent: #f5b400;
  --accent-ink: #1a1400;
  --accent-2: #7c5cff;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
}

body.matrix-mode {
  --bg: #000000;
  --surface: rgba(0, 20, 0, 0.55);
  --surface-2: rgba(0, 40, 0, 0.65);
  --border: rgba(0, 255, 70, 0.35);
  --ink: #00ff66;
  --muted: #00b84d;
  --accent: #00ff41;
  --accent-ink: #001a00;
  --accent-2: #00cc55;
}

#matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: none;
}

body.matrix-mode #matrix-canvas { display: block; }

body.matrix-mode .shell {
  position: relative;
  z-index: 1;
}

body.matrix-mode .sidebar,
body.matrix-mode .topbar,
body.matrix-mode .panel,
body.matrix-mode .kpi {
  backdrop-filter: blur(2px);
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.4);
}

body, .sidebar, .topbar, .panel, .kpi, .btn {
  transition: background-color 220ms var(--ease-out), border-color 220ms var(--ease-out), color 220ms var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  body, .sidebar, .topbar, .panel, .kpi, .btn { transition: none; }
}

@media (prefers-reduced-motion: reduce) {
  body.matrix-mode #matrix-canvas { display: none; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; }

.shell { display: grid; grid-template-columns: clamp(14rem, 18vw, 17rem) 1fr; min-height: 100vh; }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.sidebar .logo {
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  padding: 0 0.5rem;
}
.sidebar .logo span { color: var(--accent); }
.nav-group { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-group-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.6rem 0.5rem 0.3rem;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem;
  border-radius: 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  width: 100%;
  text-align: left;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms var(--ease-out);
}
.nav-item svg { width: 1.05rem; height: 1.05rem; flex-shrink: 0; transition: transform 150ms var(--ease-out); }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item:hover svg { transform: translateX(1px); }
.nav-item.active { background: rgba(124, 92, 255, 0.15); color: #fff; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.4rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.1rem;
  border-radius: 999px;
  background: var(--accent-2);
}
.nav-item .badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.6875rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 15, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar h1 { font-size: 1.0625rem; font-weight: 800; margin: 0; }
.topbar .sub { font-size: 0.8125rem; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.role-pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-2);
  background: rgba(124, 92, 255, 0.15);
  border: 1px solid rgba(124, 92, 255, 0.35);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
}
.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
}

.content { padding: clamp(1.25rem, 3vw, 2.25rem); max-width: 80rem; }

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: clamp(0.75rem, 1.5vw, 1.1rem);
  margin-bottom: 1.75rem;
}
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.1rem 1.25rem;
  overflow: hidden;
  transition: transform 220ms var(--ease-out), border-color 220ms ease, box-shadow 220ms var(--ease-out);
}
.kpi::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  opacity: 0;
  transition: opacity 220ms ease;
}
.kpi:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 92, 255, 0.35);
  box-shadow: 0 16px 32px -20px rgba(0, 0, 0, 0.55);
}
.kpi:hover::before { opacity: 1; }
.kpi .label { font-size: 0.75rem; color: var(--muted); font-weight: 600; margin-bottom: 0.4rem; }
.kpi .value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.kpi .delta { font-size: 0.75rem; font-weight: 700; margin-top: 0.3rem; }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--danger); }

/* Section / card */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.panel-head h2 { font-size: 1.0625rem; font-weight: 800; margin: 0; }
.panel-head p { margin: 0.2rem 0 0; font-size: 0.8125rem; color: var(--muted); }

[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.8125rem;
  border-radius: 0.6rem;
  padding: 0.5rem 0.95rem;
  transition: transform 100ms var(--ease-out), background-color 150ms ease, box-shadow 150ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { box-shadow: 0 0 0 3px rgba(245, 180, 0, 0.25); }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { background: #28335a; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.75rem; }

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.6rem;
  border-radius: 0.5rem;
  transition: background-color 150ms ease, color 150ms ease;
}
.logout-btn:hover { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }
.logout-btn svg { width: 1rem; height: 1rem; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 700;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.7rem 0.75rem;
  font-size: 0.8125rem;
  border-bottom: 1px solid var(--border);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 150ms ease; }
tbody tr:hover { background: var(--surface-2); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.status.ok { background: rgba(34, 197, 94, 0.15); color: var(--ok); }
.status.pending { background: rgba(245, 158, 11, 0.15); color: var(--warn); }
.status.danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: clamp(0.75rem, 1.5vw, 1.1rem);
}
.module-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.1rem;
  transition: transform 200ms var(--ease-out), border-color 200ms ease, box-shadow 200ms var(--ease-out);
}
.module-card:hover {
  transform: translateY(-3px);
  border-color: rgba(124, 92, 255, 0.4);
  box-shadow: 0 18px 34px -22px rgba(0, 0, 0, 0.6);
}
.module-card .icon-chip {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.6rem;
  background: rgba(124, 92, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.7rem;
  transition: transform 200ms var(--ease-out), background-color 200ms ease;
}
.module-card:hover .icon-chip { transform: scale(1.06); background: rgba(124, 92, 255, 0.24); }
.module-card svg { width: 1.3rem; height: 1.3rem; color: var(--accent-2); margin-bottom: 0.6rem; }
.module-card .icon-chip svg { width: 1.15rem; height: 1.15rem; margin-bottom: 0; }
.module-card h3 { font-size: 0.9375rem; font-weight: 700; margin: 0 0 0.3rem; }
.module-card p { font-size: 0.8125rem; color: var(--muted); margin: 0; line-height: 1.5; }

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.reveal.in-view { opacity: 1; transform: translateY(0); }
.reveal-stagger.in-view { transition-delay: var(--stagger, 0ms); }

@media (prefers-reduced-motion: reduce) {
  .reveal { transition: opacity 250ms ease; transform: none; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ===== Modal (shared) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 14, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms var(--ease-out);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  width: 100%;
  max-width: 26rem;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: 0 32px 72px -24px rgba(0, 0, 0, 0.6);
  transform: scale(0.95) translateY(8px);
  transition: transform 200ms var(--ease-out);
}
.modal-overlay.open .modal-card { transform: scale(1) translateY(0); }
.modal-card.modal-lg { max-width: 32rem; }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay { transition: opacity 150ms ease; }
  .modal-card { transition: none; transform: none; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-head h3 { margin: 0; font-size: 1.0625rem; font-weight: 800; letter-spacing: -0.01em; }
.modal-close {
  background: var(--surface-2);
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: background-color 150ms ease, color 150ms ease;
}
.modal-close:hover { background: #28335a; color: var(--ink); }

.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 0.4rem; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.6rem 0.8rem;
  color: var(--ink);
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.field textarea { resize: vertical; min-height: 4.5rem; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.2);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.modal-error {
  font-size: 0.8125rem;
  color: #fca5a5;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-radius: 0.6rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.9rem;
  display: none;
}
.modal-error.show { display: block; }
.modal-success {
  font-size: 0.8125rem;
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 0.6rem;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.9rem;
  display: none;
}
.modal-success.show { display: block; }
.modal-submit { width: 100%; margin-top: 0.25rem; }

/* ===== Image upload slots ===== */
.img-upload-row { display: flex; gap: 0.75rem; }
.img-slot {
  width: 5.5rem;
  height: 5.5rem;
  border-radius: 0.75rem;
  border: 1.5px dashed var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 150ms ease, transform 150ms var(--ease-out);
}
.img-slot:hover { border-color: var(--accent-2); }
.img-slot input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.img-slot img { width: 100%; height: 100%; object-fit: cover; }
.img-slot svg { width: 1.3rem; height: 1.3rem; color: var(--muted); pointer-events: none; }
.img-slot .remove-img {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.img-slot .remove-img svg { width: 0.75rem; height: 0.75rem; color: #fff; }

/* Product thumbnail in tables */
.prod-cell { display: flex; align-items: center; gap: 0.6rem; }
.prod-cell .thumb {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}
.prod-cell .thumb-placeholder {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
}

/* ===== Chat / contact drawer ===== */
.chat-modal { display: flex; flex-direction: column; height: 28rem; padding: 0; overflow: hidden; }
.chat-modal .modal-head { padding: 1.1rem 1.25rem; margin: 0; border-bottom: 1px solid var(--border); }
.chat-thread { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.chat-msg {
  max-width: 80%;
  font-size: 0.8125rem;
  line-height: 1.45;
  padding: 0.55rem 0.75rem;
  border-radius: 0.75rem;
}
.chat-msg.in { background: var(--surface-2); align-self: flex-start; border-bottom-left-radius: 0.25rem; }
.chat-msg.out { background: var(--accent-2); color: #fff; align-self: flex-end; border-bottom-right-radius: 0.25rem; }
.chat-msg .time { display: block; font-size: 0.625rem; opacity: 0.65; margin-top: 0.2rem; }
.chat-input-row { display: flex; gap: 0.5rem; padding: 0.9rem 1.1rem; border-top: 1px solid var(--border); }
.chat-input-row input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.55rem 0.8rem;
  color: var(--ink);
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 150ms ease;
}
.chat-input-row input:focus { border-color: var(--accent-2); }
.chat-input-row button {
  background: var(--accent-2);
  color: #fff;
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 100ms var(--ease-out), background-color 150ms ease;
}
.chat-input-row button:hover { background: #8f7dff; }
.chat-input-row button:active { transform: scale(0.94); }

/* ===== Toggle switch ===== */
.switch { position: relative; display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 2.6rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out);
  flex-shrink: 0;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 0.15rem;
  left: 0.15rem;
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 180ms var(--ease-out);
}
.switch input:checked + .track { background: #ef4444; border-color: #ef4444; }
.switch input:checked + .track::after { transform: translateX(1.1rem); }
.switch .switch-label { font-size: 0.875rem; font-weight: 600; }

/* ===== Black Friday admin module ===== */
.bf-hero {
  border-radius: 1rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
  border: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.bf-hero h2 { margin: 0 0 0.25rem; font-size: 1.15rem; color: #fff; }
.bf-hero p { margin: 0; color: #a3a3a3; font-size: 0.8125rem; }
.bf-hero-status { display: flex; align-items: center; gap: 0.6rem; }
.bf-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}
.bf-pill.off { background: rgba(148, 163, 184, 0.15); color: var(--muted); }
.bf-pill .dot { width: 0.4rem; height: 0.4rem; border-radius: 50%; background: currentColor; }
.bf-countdown-preview {
  display: flex;
  gap: 0.6rem;
}
.bf-countdown-preview .box {
  background: #000;
  border: 1px solid #2a2a2a;
  border-radius: 0.6rem;
  min-width: 3.2rem;
  padding: 0.5rem 0.4rem;
  text-align: center;
}
.bf-countdown-preview .box strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffcc00;
  font-variant-numeric: tabular-nums;
}
.bf-countdown-preview .box span { font-size: 0.625rem; color: #a3a3a3; text-transform: uppercase; }
.bf-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 860px) { .bf-options { grid-template-columns: 1fr; } }
.bf-theme-row { display: flex; gap: 0.6rem; }
.bf-theme-chip {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  padding: 0.6rem;
  cursor: pointer;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  transition: border-color 150ms ease, color 150ms ease;
}
.bf-theme-chip .swatch { height: 1.4rem; border-radius: 0.4rem; margin-bottom: 0.4rem; }
.bf-theme-chip.active { border-color: #ef4444; color: var(--ink); }
.bf-notify-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
  flex-wrap: wrap;
}
.bf-notify-box p { margin: 0; font-size: 0.8125rem; color: var(--muted); }
.bf-save-row { display: flex; align-items: center; gap: 0.75rem; }
.bf-saved-msg { font-size: 0.8125rem; color: var(--ok); opacity: 0; transition: opacity 200ms ease; }
.bf-saved-msg.show { opacity: 1; }

.bf-seller-alert {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
  border: 1px solid #ef4444;
  border-radius: 0.9rem;
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
.bf-seller-alert .icon-chip { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.bf-seller-alert strong { display: block; color: #fff; font-size: 0.9rem; margin-bottom: 0.2rem; }
.bf-seller-alert p { margin: 0; font-size: 0.8125rem; color: #a3a3a3; }
.chat-input-row button svg { width: 1.05rem; height: 1.05rem; }
