:root {
  --adm-bg: #0c0a0f;
  --adm-panel: rgba(25, 19, 30, 0.85);
  --adm-card: rgba(255, 255, 255, 0.055);
  --adm-border: rgba(255, 255, 255, 0.13);
  --adm-accent: #e11d48;
  --adm-accent-hover: #f43f5e;
  --adm-text: #f8fafc;
  --adm-muted: #94a3b8;
  --adm-green: #10b981;
  --adm-amber: #f59e0b;
  --adm-red: #ef4444;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: radial-gradient(circle at 10% 10%, #241019 0%, #0c0a0f 65%);
  color: var(--adm-text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--adm-muted);
  font-size: 0.85rem;
}

.glass-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  backdrop-filter: blur(22px);
  border: 1px solid var(--adm-border);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(430px, 100%);
  padding: 2.2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.brand-icon {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #e11d48, #881337);
  font-size: 1.75rem;
  margin-bottom: 0.7rem;
}

.login-brand h1 {
  font-family: 'Playfair Display', serif;
  font-size: 1.65rem;
}

.login-brand p {
  font-size: 0.85rem;
  color: var(--adm-muted);
  margin-top: 0.25rem;
}

.demo-credentials-hint {
  margin-top: 1rem;
  padding: 0.65rem;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  text-align: center;
  color: #fde68a;
}

.back-store-link {
  display: block;
  text-align: center;
  margin-top: 1.1rem;
  font-size: 0.85rem;
  color: #fda4af;
  text-decoration: none;
}

.error-banner {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(239, 68, 68, 0.45);
  color: #fecaca;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.84rem;
}

/* Layout */
.admin-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: rgba(16, 12, 20, 0.94);
  border-right: 1px solid var(--adm-border);
  padding: 1.35rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.3rem 0.5rem;
}

.brand-icon-sm {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--adm-accent);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.98rem;
}

.sidebar-brand small {
  color: var(--adm-muted);
  font-size: 0.75rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  overflow-y: auto;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--adm-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(225, 29, 72, 0.32), rgba(225, 29, 72, 0.1));
  border-color: rgba(251, 113, 133, 0.4);
  color: #fff;
}

.pill-count {
  background: var(--adm-accent);
  color: #fff;
  font-size: 0.72rem;
  padding: 0.1rem 0.48rem;
  border-radius: 999px;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Main Area */
.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  padding: 1rem 1.8rem;
  border-bottom: 1px solid var(--adm-border);
  background: rgba(16, 12, 20, 0.75);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.admin-topbar h2 {
  font-size: 1.25rem;
}

.admin-topbar small {
  color: #86efac;
  font-size: 0.78rem;
}

.mobile-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--adm-border);
  color: #fff;
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
}

.tab-container {
  padding: 1.6rem 1.8rem 3rem;
}

.tab-pane {
  display: none;
}

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

/* Cards & Grids */
.panel-card {
  background: var(--adm-card);
  border: 1px solid var(--adm-border);
  border-radius: 18px;
  padding: 1.4rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.kpi-box {
  background: linear-gradient(145deg, rgba(255,255,255,0.07), rgba(255,255,255,0.02));
  border: 1px solid var(--adm-border);
  border-radius: 16px;
  padding: 1.15rem;
}

.kpi-box small {
  color: var(--adm-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.kpi-box strong {
  display: block;
  font-size: 1.55rem;
  margin-top: 0.25rem;
}

.charts-grid, .split-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.35rem;
  margin-bottom: 1.4rem;
}

.chart-wrap {
  position: relative;
  height: 270px;
  margin-top: 0.8rem;
}

/* Forms & Buttons */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 0.75rem;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.8rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 0.3rem;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.62rem 0.8rem;
  border-radius: 10px;
  border: 1px solid var(--adm-border);
  background: rgba(12, 10, 16, 0.85);
  color: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #fb7185;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.86rem;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.15rem;
  border-radius: 11px;
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  text-decoration: none;
  transition: 0.18s;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}

.btn-lg {
  padding: 0.82rem 1.4rem;
  font-size: 0.94rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #fff;
}

.btn-primary:hover {
  background: #f43f5e;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--adm-border);
  color: #fff;
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-whatsapp-sm {
  background: rgba(37, 211, 102, 0.2);
  border: 1px solid rgba(37, 211, 102, 0.45);
  color: #86efac;
  padding: 0.48rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.btn-group {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.pos-preview-total {
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(225, 29, 72, 0.15);
  border: 1px solid rgba(251, 113, 133, 0.35);
  font-weight: 800;
  color: #fda4af;
  text-align: center;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th, .data-table td {
  padding: 0.75rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table th {
  color: var(--adm-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Badges */
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.58rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
}

.st-ok { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.st-warn { background: rgba(245, 158, 11, 0.22); color: #fcd34d; }
.st-urgent { background: rgba(239, 68, 68, 0.25); color: #fca5a5; }

.stock-filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-chip {
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--adm-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--adm-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Alerts & Restock */
.alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.8rem;
}

.alert-item {
  padding: 0.85rem;
  border-radius: 12px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.32);
  font-size: 0.84rem;
}

.restock-list, .stack-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.restock-card {
  padding: 0.9rem 1rem;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--adm-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

/* Orders Grid */
.orders-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1rem;
}

.order-adm-card {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--adm-border);
  border-radius: 15px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

/* Admin Map */
.admin-leaflet-map {
  width: 100%;
  height: 360px;
  border-radius: 14px;
  margin-top: 0.75rem;
  border: 1px solid var(--adm-border);
  z-index: 1;
}

.calc-scenario-box select {
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: #120d16;
  color: #fff;
  border: 1px solid var(--adm-border);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-box {
  width: min(650px, 100%);
  padding: 1.5rem;
  max-height: 92vh;
  overflow-y: auto;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--adm-border);
  color: #fff;
  cursor: pointer;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #18111d;
  border: 1px solid #fb7185;
  color: #fff;
  padding: 0.75rem 1.1rem;
  border-radius: 11px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5);
}

@media (max-width: 980px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 270px;
    z-index: 200;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: inline-block;
  }

  .charts-grid, .split-2, .row-2, .row-3 {
    grid-template-columns: 1fr;
  }
}
