:root {
  --navy: #1b3a6b;
  --navy-dark: #0f2447;
  --orange: #f97316;
  --teal: #06b6d4;
  --green: #22c55e;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --sidebar-w: 260px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; }
body.admin-body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--orange); }

.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: #fff;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h1 { margin: 0; font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.sidebar-brand span { font-size: 0.75rem; color: var(--teal); font-style: italic; }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; }
.nav-section { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.45); padding: 0.75rem 0.75rem 0.35rem; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  color: rgba(255,255,255,0.85);
  font-weight: 500;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link.active { background: var(--orange); color: #fff; }
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.9; }

.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user { display: flex; align-items: center; gap: 0.65rem; font-size: 0.8rem; }
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.admin-main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.75rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.breadcrumbs { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--muted); }
.breadcrumbs strong { color: var(--text); font-weight: 600; }
.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

.admin-content { padding: 1.75rem; flex: 1; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.page-header h2 { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.page-header p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent, var(--navy));
}
.stat-card .label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.stat-card .value { font-size: 1.75rem; font-weight: 800; margin-top: 0.25rem; letter-spacing: -0.03em; }
.stat-card .sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.75rem;
}
.card-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.25rem; }
.card-body.flush { padding: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem; font-weight: 600;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  text-decoration: none;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-accent { background: var(--orange); color: #fff; }
.btn-accent:hover { background: #ea580c; color: #fff; }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: #e2e8f0; color: var(--text); }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-icon { padding: 0.45rem; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 0.75rem 1.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-muted { background: #f1f5f9; color: #475569; }
.badge-navy { background: #dbeafe; color: var(--navy); }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
@media (max-width: 768px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 0.35rem; }
.form-group .hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }
.form-control {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.12);
}
textarea.form-control { min-height: 100px; resize: vertical; }
.form-check { display: flex; align-items: center; gap: 0.5rem; }
.form-check input { width: 18px; height: 18px; accent-color: var(--navy); }

.alert {
  padding: 0.85rem 1.1rem;
  border-radius: 10px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.filters-bar {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.filters-bar .form-group { margin: 0; flex: 1; min-width: 140px; }

.pagination-wrap { padding: 1rem 1.25rem; display: flex; justify-content: center; }
.pagination { display: flex; gap: 0.35rem; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.pagination li a, .pagination li span {
  display: block; padding: 0.4rem 0.75rem;
  border-radius: 8px; border: 1px solid var(--border);
  font-size: 0.85rem;
}
.pagination li.active span { background: var(--navy); color: #fff; border-color: var(--navy); }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }
.product-thumb {
  width: 48px; height: 48px; border-radius: 10px;
  background: linear-gradient(135deg, #e2e8f0, #f8fafc);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}
.image-preview-wrap { margin-bottom: 0.75rem; }
.image-preview {
  max-width: 220px;
  max-height: 220px;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  object-fit: cover;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 1024px) { .grid-2 { grid-template-columns: 1fr; } }

.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 50%, #1e4a7a 100%);
}
.login-panel {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  padding: 3rem;
  color: #fff;
}
.login-panel h1 { font-size: 2.5rem; font-weight: 800; margin: 0 0 0.5rem; }
.login-panel p { opacity: 0.9; max-width: 400px; line-height: 1.6; }
.login-features { margin-top: 2rem; display: flex; flex-direction: column; gap: 0.75rem; }
.login-features div { display: flex; align-items: center; gap: 0.65rem; font-size: 0.9rem; opacity: 0.95; }
.login-form-wrap {
  width: 440px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem;
  box-shadow: -8px 0 32px rgba(0,0,0,0.15);
}
.login-form { width: 100%; max-width: 340px; }
.login-form h2 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.login-form .subtitle { color: var(--muted); margin-bottom: 1.75rem; font-size: 0.9rem; }

.actions-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.color-preview { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); }

/* ── Mobile navigation ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.2s ease;
}
body.sidebar-open .sidebar-backdrop {
  display: block;
  opacity: 1;
}
.sidebar-toggle { display: none; flex-shrink: 0; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.card-body.flush { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { min-width: 640px; }

/* ── Tablet & mobile ── */
@media (max-width: 1024px) {
  .sidebar-toggle { display: inline-flex; }

  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.18);
  }
  body.sidebar-open .admin-sidebar { transform: translateX(0); }

  .admin-main { margin-left: 0; }

  .admin-topbar {
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .admin-content { padding: 1.25rem; }

  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
  }

  .stat-card .value { font-size: 1.5rem; }
}

@media (max-width: 768px) {
  .admin-topbar {
    flex-wrap: wrap;
    align-items: center;
  }

  .breadcrumbs {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header h2 { font-size: 1.25rem; }

  .page-header .btn,
  .page-header .btn-accent,
  .page-header .btn-ghost {
    width: 100%;
    justify-content: center;
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .card-header .btn { width: 100%; justify-content: center; }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filters-bar .form-group { min-width: 0; width: 100%; }

  .filters-bar .btn { width: 100%; justify-content: center; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .data-table th,
  .data-table td {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
  }

  .actions-row .btn { flex: 1 1 auto; justify-content: center; }

  .login-page { flex-direction: column; }

  .login-panel {
    padding: 2rem 1.5rem 1.5rem;
    text-align: center;
    align-items: center;
  }

  .login-panel h1 { font-size: 1.85rem; }

  .login-panel p { max-width: none; }

  .login-features { align-items: flex-start; text-align: left; }

  .login-form-wrap {
    width: 100%;
    box-shadow: none;
    padding: 1.75rem 1.5rem 2rem;
  }
}

@media (max-width: 480px) {
  body.admin-body { font-size: 13px; }

  .admin-content { padding: 1rem; }

  .stats-grid { grid-template-columns: 1fr; }

  .stat-card { padding: 1rem; }

  .card-body { padding: 1rem; }

  .breadcrumbs span:first-child { display: none; }

  .breadcrumbs span:nth-child(2) { display: none; }

  .sidebar-brand { padding: 1.15rem 1rem; }

  .sidebar-brand h1 { font-size: 1.15rem; }

  .nav-link { padding: 0.75rem 0.85rem; }

  .product-thumb {
    width: 40px;
    height: 40px;
  }

  .image-preview {
    max-width: 100%;
    height: auto;
  }

  .pagination li a,
  .pagination li span {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
  }
}

@media (min-width: 1025px) {
  .sidebar-toggle { display: none !important; }
}

body.sidebar-open { overflow: hidden; }
