:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---- Auth pages ---- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}

.auth-card {
  background: var(--card);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.auth-card .logo {
  text-align: center;
  margin-bottom: 28px;
}

.auth-card .logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.auth-card .logo p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* ---- App layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid #334155;
}

.sidebar-brand h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand p {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 8px 20px 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: #263548;
  color: #e2e8f0;
}

.sidebar-nav a.active {
  background: #1e3a5f;
  color: #60a5fa;
  border-left-color: #2563eb;
}

.sidebar-nav a svg { flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #334155;
  font-size: 13px;
  color: #64748b;
}

.sidebar-footer a {
  color: #94a3b8;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-footer a:hover { color: #e2e8f0; }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 13px;
}

.page-body {
  padding: 28px;
  flex: 1;
}

/* ---- Cards ---- */
.card {
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ---- Stat grid ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-card.danger .value { color: var(--danger); }
.stat-card.warning .value { color: var(--warning); }
.stat-card.success .value { color: var(--success); }

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  transition: border 0.15s;
  outline: none;
}

textarea.form-control { resize: vertical; min-height: 60px; font-family: inherit; }

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn-danger:hover { background: #fecaca; }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }

td {
  padding: 12px;
  font-size: 14px;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: #dcfce7; color: #16a34a; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-default { background: #f1f5f9; color: var(--muted); }

/* ---- Flash messages ---- */
.flash-messages { margin-bottom: 20px; }

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 8px;
}

.flash.success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash.error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---- Filter bar ---- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: flex-end;
}

.filter-bar .form-control { width: auto; flex: 1; min-width: 160px; }

/* ---- Grid ---- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---- Hamburger ---- */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 4px;
  background: none;
  border: none;
}
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.25s;
}

/* ---- Overlay ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ---- Mobile ---- */
@media (max-width: 768px) {
  .hamburger { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; overflow-x: hidden; width: 100%; }

  /* Layout */
  .two-col { grid-template-columns: 1fr; }
  .page-body { padding: 12px; }
  .topbar { padding: 0 12px; height: 52px; }
  .topbar h1 { font-size: 15px; }

  /* Stat cards — compact 2x2 grid */
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card { padding: 12px; min-width: 0; }
  .stat-card .value { font-size: 20px; }
  .stat-card .label { font-size: 11px; }

  /* Cards */
  .card { padding: 14px; border-radius: 8px; }
  .card-title { font-size: 14px; margin-bottom: 12px; }

  /* Tables — horizontal scroll, no min-width so they adapt */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 0; width: 100%; }
  thead th { font-size: 10px; padding: 8px; white-space: nowrap; }
  td { padding: 10px 8px; font-size: 13px; }

  /* Hide less important columns on mobile */
  .hide-mobile { display: none; }

  /* Filter bar — stack vertically */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-bar .form-control { width: 100%; min-width: unset; flex: unset; }
  .filter-bar a,
  .filter-bar button { width: 100%; justify-content: center; margin-left: 0 !important; }

  /* Forms */
  .card[style*="max-width"] { max-width: 100% !important; }

  /* Buttons */
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-sm { padding: 7px 10px; font-size: 12px; }

  /* Qty control */
  .qty-control { padding: 4px 8px; }
  .qty-btn { font-size: 18px; }

  /* Auth */
  .auth-card { padding: 24px 16px; margin: 12px; }

  /* Sold stats — single column */
  .sold-stats { grid-template-columns: 1fr !important; }

  /* Notes under product name on mobile */
  .mobile-notes {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
    font-weight: 400;
  }

  /* Lang toggle */
  .lang-toggle { transform: scale(0.9); }

  /* Topbar user — hide username text on mobile */
  .topbar-user span:not(.avatar) { display: none; }
}

/* ---- Misc ---- */
/* ---- Quantity control ---- */
.qty-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}

.qty-btn {
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.1s;
}

.qty-btn:hover { background: var(--border); }

.qty-value {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

/* ---- Nav badge ---- */
.nav-badge {
  margin-left: auto;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ---- Language toggle ---- */
.lang-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}

.lang-btn {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
}

.lang-btn:hover { color: var(--text); }

.lang-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.text-muted { color: var(--muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.empty-state { text-align: center; padding: 40px; color: var(--muted); }
