:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface2: #f0f0f2;
  --border: #e0e0e5;
  --accent: #F0820F;
  --accent-dark: #C96A0C;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --sidebar-w: 230px;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s;
}

.sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 64px;
}

.sidebar-brand img {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface2);
  flex-shrink: 0;
}

.sidebar-brand .brand-name {
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding: 12px 10px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}

.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: rgba(0,113,227,.12); color: var(--accent); }

.nav-link svg { flex-shrink: 0; width: 16px; height: 16px; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 20px;
}

.nav-lock {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.plan-pill {
  margin: 10px 10px 14px;
  background: rgba(0,113,227,.08);
  border: 1px solid rgba(0,113,227,.2);
  border-radius: 10px;
  padding: 10px 12px;
}

.plan-pill .pp-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.plan-pill .pp-name { font-size: 13px; font-weight: 800; color: var(--accent); margin-top: 2px; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ── Main layout ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.topbar-title { font-size: 16px; font-weight: 800; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px; flex: 1; max-width: 1100px; }

/* ── Store status card ── */
.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
  transition: border-color .3s, background .3s;
}

.status-card.open {
  border-color: rgba(34,197,94,.35);
  background: rgba(34,197,94,.04);
}

.status-card.closed {
  border-color: rgba(239,68,68,.25);
  background: rgba(239,68,68,.03);
}

.status-info .s-title { font-size: 16px; font-weight: 800; }
.status-info .s-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* ── Toggle ── */
.toggle { position: relative; width: 52px; height: 28px; cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0;
  background: var(--border);
  border-radius: 14px;
  transition: background .25s;
}
.toggle-thumb {
  position: absolute;
  width: 20px; height: 20px;
  top: 4px; left: 4px;
  background: #aaa;
  border-radius: 50%;
  transition: transform .25s, background .25s;
}
.toggle input:checked ~ .toggle-track { background: rgba(34,197,94,.25); }
.toggle input:checked ~ .toggle-thumb { transform: translateX(24px); background: var(--success); }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

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

.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 900; line-height: 1; }
.stat-value.accent { color: var(--accent); }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 20px;
}

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

.card-title { font-size: 14px; font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

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

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

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface2); }

.btn-danger { background: rgba(239,68,68,.12); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.22); }

.btn-success { background: rgba(34,197,94,.12); color: var(--success); border: 1px solid rgba(34,197,94,.25); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-icon {
  width: 34px; height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 8px;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Product grid ── */
.product-grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.pc-admin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .2s;
  display: flex;
  flex-direction: column;
}

.pc-admin:hover { border-color: #c0c0c8; }

.pc-admin .pc-img {
  display: block;
  width: 100%; height: 150px;
  object-fit: contain;
  background: var(--surface2);
  padding: 12px;
  flex-shrink: 0;
}

.pc-admin .pc-body { padding: 12px; flex: 1; display: flex; flex-direction: column; }
.pc-admin .pc-name { font-size: 13px; font-weight: 700; margin-bottom: 3px; line-height: 1.3; }
.pc-admin .pc-specs { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.pc-admin .pc-price { font-size: 16px; font-weight: 900; color: var(--accent); }
.pc-admin .pc-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.pc-admin .pc-stock { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.72);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform .2s;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  padding: 20px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 17px; font-weight: 800; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 0 24px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 7px;
}

input[type=text], input[type=number], input[type=email],
input[type=password], input[type=tel], input[type=url],
input[type=color], select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s;
}

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

textarea { resize: vertical; min-height: 80px; }

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

.input-prefix-group { display: flex; }
.input-prefix {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 9px 0 0 9px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.input-prefix-group input { border-radius: 0 9px 9px 0; }

/* ── Image upload ── */
.img-upload {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  position: relative;
}

.img-upload:hover { border-color: var(--accent); }

.img-upload input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  background: none;
}

.img-upload p { font-size: 13px; color: var(--muted); margin-top: 4px; }

#imgPreview, #logoPreview, #bannerPreview {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  border-radius: 8px;
  margin-top: 10px;
  display: none;
}

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

.tab-btn {
  padding: 9px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  transition: all .15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

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

/* ── Alerts ── */
.alert {
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 13.5px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.alert-info { background: rgba(0,113,227,.07); border: 1px solid rgba(0,113,227,.2); color: #ccc; }
.alert-success { background: rgba(34,197,94,.07); border: 1px solid rgba(34,197,94,.2); color: #ccc; }
.alert-danger { background: rgba(239,68,68,.07); border: 1px solid rgba(239,68,68,.2); color: #ccc; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-muted   { background: var(--surface2); color: var(--muted); }
.badge-accent  { background: rgba(0,113,227,.15); color: var(--accent); }

/* ── Orders ── */
.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s;
  display: flex;
  align-items: center;
  gap: 16px;
}

.order-card:hover { border-color: #c0c0c8; }

.order-num {
  font-size: 28px;
  font-weight: 900;
  color: var(--accent);
  min-width: 52px;
  text-align: center;
}

.order-info { flex: 1; }
.order-client { font-weight: 700; font-size: 14px; }
.order-items { font-size: 12px; color: var(--muted); margin-top: 2px; }
.order-total { font-size: 15px; font-weight: 800; color: var(--accent); }

.order-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  transition: all .15s;
}

.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Steps ── */
.steps { counter-reset: step; list-style: none; padding: 0; }

.steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  font-size: 14px;
  color: #ccc;
  line-height: 1.5;
}

.steps li::before {
  content: counter(step);
  background: rgba(0,113,227,.12);
  color: var(--accent);
  font-weight: 800;
  font-size: 11px;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.steps li a { color: var(--accent); }

/* ── Key display ── */
.key-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 14px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--success);
  word-break: break-all;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

/* ── Feature locked ── */
.feature-locked-wrap { position: relative; }

.locked-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,15,15,.88);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 5;
  backdrop-filter: blur(2px);
}

.locked-overlay .lock-icon { font-size: 28px; color: var(--muted); margin-bottom: 10px; }
.locked-overlay p { font-size: 13px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: block;
  width: 64px; height: 64px;
  object-fit: contain;
  margin: 0 auto 10px;
  border-radius: 12px;
}

.login-title { text-align: center; font-size: 22px; font-weight: 900; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.powered-by { text-align: center; font-size: 11px; color: var(--muted); margin-top: 20px; }
.powered-by a { color: var(--accent); text-decoration: none; font-weight: 700; }

/* ── License banner ── */
.license-banner {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: #f87171;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ── Misc utils ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.text-muted { color: var(--muted); font-size: 13px; }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .product-grid-admin { grid-template-columns: 1fr 1fr; }
  .mobile-menu-btn { display: flex !important; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  font-size: 20px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

.badge-danger-sm  { background:rgba(239,68,68,.12); color:#ef4444; font-size:10px; font-weight:700; padding:2px 7px; border-radius:20px; white-space:nowrap; }
.badge-warning-sm { background:rgba(245,158,11,.12); color:#f59e0b; font-size:10px; font-weight:700; padding:2px 7px; border-radius:20px; white-space:nowrap; }

.sidebar-backdrop.active { display: block; }

/* ── Multi-image upload grid ── */
.img-upload-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.img-slot {
  position: relative;
  aspect-ratio: 1;
  border: 2px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  overflow: hidden;
  transition: border-color .15s;
}

.img-slot:hover { border-color: var(--accent); }
.img-slot.has-image { border-style: solid; border-color: #d0d0d5; }

.slot-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.slot-plus { font-size: 24px; color: var(--muted); line-height: 1; }
.slot-ph small { font-size: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.slot-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.slot-rm {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.75);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 3;
  padding: 0;
  line-height: 1;
}

.slot-rm:hover { background: var(--danger); }

.drag-over { border-color: var(--accent) !important; background: rgba(0,113,227,.1); }

.slot-label {
  position: absolute;
  bottom: 5px;
  left: 5px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .img-upload-grid { grid-template-columns: repeat(3, 1fr); }
}
