:root {
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --accent: #10b981;
  --accent-light: #ecfdf5;
  --bg-main: #f1f5f9;
  --bg-sidebar: #0f172a;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
}

/* Login Modal */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.2);
}
.login-icon i {
  font-size: 3rem;
  color: var(--primary);
  margin-bottom: 16px;
}
.login-card h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 8px;
}
.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.login-error {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 12px;
}

/* Admin Layout */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 24px 20px;
  font-size: 1.2rem;
  font-weight: 800;
  color: white;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #1e293b;
}
.sidebar-brand i {
  color: var(--primary);
}

.sidebar-nav {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.2s;
  position: relative;
}
.nav-item:hover {
  background: #1e293b;
  color: white;
}
.nav-item.active {
  background: var(--primary);
  color: white;
}
.nav-badge {
  position: absolute;
  right: 12px;
  background: #ef4444;
  color: white;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 700;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.view-store-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: #1e293b;
  color: #38bdf8;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.logout-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 8px;
  font-size: 0.85rem;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.top-nav h1 {
  font-size: 1.6rem;
  font-weight: 800;
}
.admin-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Tab panes */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-card.highlight {
  border: 2px solid var(--accent);
  background: #f0fdf4;
}
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: white;
}
.bg-blue { background: #0284c7; }
.bg-green { background: #10b981; }
.bg-orange { background: #f97316; }
.bg-purple { background: #8b5cf6; }

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-info h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 2px;
}
.stat-sub {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

.quick-actions-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.quick-actions-card h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-buttons {
  display: flex;
  gap: 12px;
}

/* Tables */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.section-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.table-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.data-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tr:hover {
  background: #f8fafc;
}

/* Badges */
.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.status-nuevo { background: #fed7aa; color: #9a3412; }
.status-pagado { background: #bbf7d0; color: #166534; }
.status-en_proveedor { background: #e9d5ff; color: #6b21a8; }
.status-enviado { background: #bae6fd; color: #075985; }
.status-entregado { background: #dcfce7; color: #15803d; }
.status-cancelado { background: #fecaca; color: #991b1b; }

.btn-sm-action {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-sm-action:hover {
  background: #e2e8f0;
}
.btn-whatsapp-sm {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

/* Profit Calculator */
.profit-calculator-box {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 16px 0;
}
.profit-calculator-box h4 {
  color: #166534;
  font-size: 0.95rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.profit-result-banner {
  display: flex;
  justify-content: space-around;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #86efac;
  font-size: 0.95rem;
}
.text-green {
  color: #15803d;
  font-weight: 800;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.settings-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.settings-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
}
.card-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.save-settings-bar {
  display: flex;
  justify-content: flex-end;
}

/* Buttons & Inputs */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.9rem;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-secondary {
  background: white;
  border: 1px solid var(--border);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.9rem;
}
.btn-secondary:hover {
  background: #f8fafc;
}
.w-full { width: 100%; justify-content: center; }

.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.check-row {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 12px 0;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}
.modal-content {
  background: white;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
