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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1e293b;
  background: linear-gradient(145deg, #e8f4fd, #fff 40%, #d6ebfa 80%);
  min-height: 100vh;
}

/* Auth */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.12);
  border: 1px solid #c5e3f8;
}

.auth-logo { display: block; margin: 0 auto 1.5rem; height: 120px; width: auto; max-width: 220px; object-fit: contain; }
.auth-card h1 { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; color: #1e3a5f; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.35rem; color: #475569; }
input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid #c5e3f8;
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 1rem;
  background: #f8fbff;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-primary { background: #2563eb; color: #fff; width: 100%; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: transparent; border: 1px solid #c5e3f8; color: #475569; }
.btn-outline:hover { background: #f0f7ff; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; width: auto; }
.btn-edit { background: #e0f2fe; color: #0369a1; }
.btn-edit:hover { background: #bae6fd; }

.auth-footer { text-align: center; margin-top: 1rem; font-size: 0.875rem; color: #64748b; }
.auth-footer a { color: #2563eb; text-decoration: none; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.875rem; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }

/* Dashboard layout */
.dashboard-page { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: #fff;
  border-right: 1px solid #c5e3f8;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.sidebar-logo { height: 90px; width: auto; max-width: 180px; object-fit: contain; margin-bottom: 2rem; align-self: center; }

.sidebar nav { display: flex; flex-direction: column; gap: 0.35rem; flex: 1; }

.nav-btn {
  background: none;
  border: none;
  text-align: left;
  padding: 0.7rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover { background: #f0f7ff; color: #2563eb; }
.nav-btn.active { background: #dbeafe; color: #1d4ed8; font-weight: 600; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
  font-size: 0.85rem;
  color: #64748b;
}

.main-content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.topbar h1 { font-size: 1.5rem; color: #1e3a5f; }

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

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #c5e3f8;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.06);
}
.stat-card .value { font-size: 2rem; font-weight: 700; color: #2563eb; }
.stat-card .label { font-size: 0.85rem; color: #64748b; margin-top: 0.25rem; }
.stat-card.warn .value { color: #f59e0b; }

/* Tables */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.toolbar input, .toolbar select { margin-bottom: 0; max-width: 280px; }

.table-wrap {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #c5e3f8;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.06);
}

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th { background: #f0f7ff; padding: 0.75rem 1rem; text-align: left; font-weight: 600; color: #475569; white-space: nowrap; }
td { padding: 0.75rem 1rem; border-top: 1px solid #e2e8f0; vertical-align: middle; }
tr:hover td { background: #f8fbff; }

.product-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; background: #f1f5f9; }
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-draft { background: #fef9c3; color: #a16207; }
.badge-archived { background: #f1f5f9; color: #64748b; }
.badge-low { background: #fef2f2; color: #b91c1c; }
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-user { background: #f1f5f9; color: #475569; }

.actions { display: flex; gap: 0.4rem; }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal.hidden { display: none; }
.modal-content {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #94a3b8; }
#modal-form { padding: 1.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
}

/* Toast */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #1e293b; color: #fff;
  padding: 0.85rem 1.25rem; border-radius: 8px;
  font-size: 0.875rem; z-index: 2000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { background: #b91c1c; }

@media (max-width: 768px) {
  .dashboard-page { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 1rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: unset; }
  .form-row { grid-template-columns: 1fr; }
}
