:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --success: #059669;
  --success-soft: #ecfdf5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --info: #0284c7;
  --info-soft: #f0f9ff;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.12);
  --sidebar-w: 268px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h1 { font-size: .95rem; font-weight: 700; letter-spacing: -.01em; }
.sidebar-brand p { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.brand-mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .35);
}
.brand-mark.sm { width: 36px; height: 36px; font-size: .75rem; border-radius: 9px; }

.sidebar-nav { flex: 1; padding: 18px 14px; overflow-y: auto; }

.nav-section {
  display: block; padding: 14px 12px 8px;
  font-size: .68rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-secondary); font-size: .875rem; font-weight: 500;
  margin-bottom: 2px; transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
}
.nav-icon { opacity: .55; font-size: .8rem; width: 18px; text-align: center; }
.nav-link.active .nav-icon { opacity: 1; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 32px; border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.85); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}

.topbar-eyebrow {
  font-size: .72rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 2px;
}
.topbar h2 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--surface-muted); border: 1px solid var(--border);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
}
.user-meta { line-height: 1.25; }
.user-meta strong { display: block; font-size: .82rem; }
.user-meta span { font-size: .72rem; color: var(--muted); }

.content { padding: 28px 32px 40px; max-width: 1440px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: none;
  font-family: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(79,70,229,.2);
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.25); }
.btn-soft { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-soft:hover { background: var(--surface-muted); color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: .8rem; }
.btn-block { width: 100%; }

.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.stat-card strong {
  display: block; font-size: 1.65rem; font-weight: 700;
  letter-spacing: -.03em; margin-bottom: 4px;
}
.stat-card span { color: var(--muted); font-size: .82rem; font-weight: 500; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}
.panel-head h3 { font-size: .95rem; font-weight: 700; }
.panel-body { padding: 24px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--surface); }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: var(--surface-muted); color: var(--muted);
  font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
td .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-neutral { background: #f1f5f9; color: var(--muted); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }

.alert {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px;
  font-size: .875rem; font-weight: 500;
}
.alert-success { background: var(--success-soft); border: 1px solid #a7f3d0; color: #047857; }
.alert-error { background: var(--danger-soft); border: 1px solid #fecaca; color: #b91c1c; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
textarea { min-height: 110px; resize: vertical; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; }

.filters {
  display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px;
  padding: 16px; background: var(--surface-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.filters input, .filters select { width: auto; min-width: 160px; max-width: 240px; flex: 1 1 160px; }

.product-thumb {
  width: 48px; height: 48px; border-radius: 8px; object-fit: contain;
  background: var(--surface-muted); border: 1px solid var(--border);
  display: block;
}
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }

/* Auth */
.auth-body { background: var(--bg); }
.auth-layout {
  min-height: 100vh; display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth-hero {
  background: linear-gradient(145deg, #1e1b4b 0%, #312e81 45%, #4338ca 100%);
  color: #fff; display: flex; align-items: center; padding: 48px;
  position: relative; overflow: hidden;
}
.auth-hero::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,.12), transparent 45%),
              radial-gradient(circle at 80% 80%, rgba(255,255,255,.08), transparent 40%);
}
.auth-hero-inner { position: relative; max-width: 440px; }
.auth-hero .brand-mark { margin-bottom: 28px; width: 52px; height: 52px; font-size: 1rem; }
.auth-hero h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; margin-bottom: 12px; }
.auth-hero p { color: rgba(255,255,255,.78); font-size: .95rem; line-height: 1.65; margin-bottom: 32px; }
.auth-features { list-style: none; }
.auth-features li {
  padding: 10px 0 10px 28px; position: relative;
  color: rgba(255,255,255,.88); font-size: .9rem;
}
.auth-features li::before {
  content: '✓'; position: absolute; left: 0; top: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,.15); font-size: .65rem;
  display: grid; place-items: center;
}

.auth-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 32px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 36px; box-shadow: var(--shadow-lg);
}
.auth-card-head h2 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-card-head p { color: var(--muted); font-size: .9rem; margin-bottom: 28px; }
.auth-form .field { margin-bottom: 18px; }
.auth-footnote {
  margin-top: 24px; text-align: center; font-size: .78rem; color: var(--muted);
}

.invoice {
  max-width: 820px; margin: 0 auto; background: #fff; color: #111;
  border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow);
}
.invoice h1 { color: #111; margin-bottom: 4px; }
.invoice .meta { color: #666; font-size: .9rem; margin-bottom: 32px; }
.invoice table { color: #111; }
.invoice th, .invoice td { border-color: #e5e7eb; }
.invoice .total-row td { font-weight: 700; font-size: 1.05rem; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
}

@media (max-width: 960px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .sidebar { transform: translateX(-100%); }
  .main { margin-left: 0; }
  .content { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 16px 20px; flex-wrap: wrap; gap: 12px; }
  .user-chip { display: none; }
}

.admin-pagination,
.catalog-pagination {
  margin-top: 28px;
}
.pagination-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.pagination-btn,
.pagination-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.pagination-btn:hover,
.pagination-num:hover {
  background: var(--surface-2);
}
.pagination-num.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pagination-btn.is-disabled {
  opacity: .45;
  pointer-events: none;
}
.pagination-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  color: var(--muted);
  font-weight: 700;
}
.pagination-meta {
  width: 100%;
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  margin-top: 4px;
}
.pagination-summary {
  margin: 0 0 18px;
  font-size: .88rem;
  color: var(--muted);
}
