:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;
  --surface: #ffffff;
  --surface2: #f3f4f6;
  --border: #e5e7eb;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --muted: #9ca3af;
  --accent: #FF6600;
  --accent-hover: #e55c00;
  --accent-dim: rgba(255,102,0,.08);
  --accent-text: #ffffff;
  --green: #22c55e;
  --green-dim: rgba(34,197,94,.08);
  --red: #ef4444;
  --red-dim: rgba(239,68,68,.08);
  --yellow: #eab308;
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.08);
  --nav-height: 60px;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-alt: #1a1a1a;
  --surface: #1c1c1e;
  --surface2: #2c2c2e;
  --border: #3a3a3c;
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --muted: #86868b;
  --accent: #ff7a1a;
  --accent-hover: #ff6600;
  --accent-dim: rgba(255,122,26,.1);
  --green-dim: rgba(34,197,94,.12);
  --red-dim: rgba(239,68,68,.12);
  --shadow: 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { font-size: 15px; scroll-behavior: smooth; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font) !important;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .3s, color .3s;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ─── NAVBAR ─── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 max(24px, calc((100% - 1400px) / 2));
  gap: 8px;
  backdrop-filter: blur(16px);
  transition: background .3s, border-color .3s;
}
.navbar-brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 20px;
  white-space: nowrap;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-brand span { color: var(--accent); }
.navbar-nav {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.navbar-nav::-webkit-scrollbar { display: none; }
.navbar-nav a {
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all .2s;
  text-decoration: none;
}
.navbar-nav a:hover {
  color: var(--text);
  background: var(--surface2);
  text-decoration: none;
}
.navbar-nav a.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}
.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.navbar-btn {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  transition: background .2s;
}
.navbar-btn:hover { background: var(--accent-hover); }
.navbar-btn:disabled { opacity: .5; cursor: default; }

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all .2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ─── ADMIN TABS ─── */
.admin-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--surface2);
  padding: 3px;
  border-radius: var(--radius);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all .2s;
  font-family: var(--font);
  white-space: nowrap;
}
.admin-tab:hover { color: var(--text); background: rgba(0,0,0,.03); }
[data-theme="dark"] .admin-tab:hover { background: rgba(255,255,255,.05); }
.admin-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow);
}

/* ─── STATUS INDICATOR ─── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  font-size: .85rem;
  font-weight: 500;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.status-dot.active { background: var(--green); }
.status-dot.running { background: var(--accent); animation: pulse 1s infinite; }

/* ─── BREADCRUMB ─── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px max(24px, calc((100% - 1400px) / 2));
  font-size: .85rem;
  color: var(--muted);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ─── LAYOUT ─── */
.page-container { flex: 1; max-width: 1400px; width: 100%; margin: 0 auto; padding: 0 24px; }
.page-header { padding: 24px 0 20px; }
.page-title { font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; }
.page-subtitle { font-size: .95rem; color: var(--text-secondary); margin-top: 6px; }

.layout-with-sidebar { display: flex; gap: 24px; }
.sidebar {
  width: 260px;
  min-width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--nav-height) + 16px);
  max-height: calc(100vh - var(--nav-height) - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.main-content { flex: 1; min-width: 0; }

/* ─── SECTION HEADER ─── */
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.section-header h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.section-header p { font-size: .9rem; color: var(--text-secondary); margin-top: 4px; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── PANELS / CARDS ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .9rem;
  font-weight: 600;
}
.panel-body { padding: 20px; }

/* ─── FILTER COMPONENTS ─── */
.filter-section { margin-bottom: 16px; }
.filter-label {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 8px;
  display: block;
}
.filter-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: .9rem;
  font-family: var(--font);
  transition: border-color .2s;
}
.filter-input:focus { outline: none; border-color: var(--accent); }
.filter-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.filter-bar input,
.filter-bar select {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .88rem;
  color: var(--text);
  font-family: var(--font);
  transition: border-color .2s;
}
.filter-bar input:focus,
.filter-bar select:focus { outline: none; border-color: var(--accent); }

.chip-group { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all .15s;
  font-weight: 500;
}
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ─── STATS CARDS ─── */
.stats-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  min-width: 140px;
  box-shadow: var(--shadow);
  flex: 1;
}
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: 4px; }

/* ─── PRODUCT CARDS ─── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s, transform .2s;
  position: relative;
  display: flex;
  flex-direction: column;
}
.product-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.product-card .card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.product-card .title { font-size: 1rem; font-weight: 600; line-height: 1.4; flex: 1; }
.product-card .new-badge { background: var(--green); color: #fff; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 6px; white-space: nowrap; margin-left: 8px; flex-shrink: 0; }

.specs-row { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.spec-tag { background: var(--surface2); border-radius: 6px; padding: 4px 11px; font-size: .8rem; color: var(--text-secondary); }
.spec-tag.highlight { color: var(--accent); background: var(--accent-dim); font-weight: 600; }

.color-row { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.color-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.color-dot:hover { transform: scale(1.15); border-color: var(--text); }
.color-dot.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.color-name { font-size: .8rem; color: var(--muted); min-width: 60px; }

.price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.price { font-size: 1.35rem; font-weight: 700; color: var(--accent); }
.price-change { font-size: .75rem; font-weight: 600; }
.price-change.down { color: var(--green); }
.price-change.up { color: var(--red); }

.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 10px; }
.card-footer .sku { font-size: .78rem; color: var(--muted); font-family: var(--mono); }
.card-footer a { font-size: .85rem; font-weight: 500; }

/* ─── SPARKLINE ─── */
.sparkline-wrap {
  position: absolute;
  bottom: 14px;
  right: 16px;
  width: 80px;
  height: 36px;
  cursor: crosshair;
}
.sparkline-wrap canvas { width: 100%; height: 100%; display: block; }
.sparkline-tooltip {
  position: absolute;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: .65rem;
  color: var(--text);
  pointer-events: none;
  white-space: nowrap;
  display: none;
  z-index: 10;
  right: 0;
  bottom: 100%;
  margin-bottom: 4px;
}

/* ─── TOOL CARDS ─── */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.tool-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); }
.tool-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: var(--accent-dim);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 12px;
}
.tool-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; }
.tool-card p { font-size: .88rem; color: var(--text-secondary); line-height: 1.5; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  font-family: var(--font);
}
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--accent); background: var(--accent-dim); }
.btn-sm { padding: 7px 16px; font-size: .85rem; }
.btn-xs { padding: 5px 12px; font-size: .78rem; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn:disabled { opacity: .5; cursor: default; }

/* ─── FORM COMPONENTS ─── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: .88rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.form-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text);
  font-size: .95rem;
  font-family: var(--font);
  transition: border-color .2s, box-shadow .2s;
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-input::placeholder { color: var(--muted); }

.search-box { position: relative; }
.search-box input { padding-left: 40px; }
.search-box .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  width: 18px;
  height: 18px;
}

/* ─── RESULT BARS ─── */
.result-bar-wrap { margin-bottom: 14px; }
.result-bar-label { display: flex; justify-content: space-between; font-size: .82rem; margin-bottom: 5px; }
.result-bar-label span:first-child { font-weight: 500; }
.result-bar-label span:last-child { font-weight: 700; }
.result-bar-track {
  height: 10px;
  background: var(--surface2);
  border-radius: 5px;
  overflow: hidden;
}
.result-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width .8s ease;
}

/* ─── TABS ─── */
.tab-group { display: flex; gap: 4px; background: var(--surface2); border-radius: var(--radius-sm); padding: 3px; }
.tab-btn {
  padding: 9px 18px;
  border-radius: 6px;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  transition: all .2s;
  font-family: var(--font);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: var(--shadow); }

/* ─── DATA TABLE ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface2);
}
.data-table tr:hover td { background: var(--surface2); }

.tab-content table th { white-space: nowrap; }
.overflow-x-auto { overflow-x: hidden !important; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,.1); color: #16a34a; }
.badge-warning { background: rgba(234,179,8,.1); color: #ca8a04; }
.badge-danger { background: rgba(239,68,68,.1); color: #dc2626; }
.badge-info { background: rgba(59,130,246,.1); color: #2563eb; }
.badge-accent { background: var(--accent-dim); color: var(--accent); }

/* ─── MODAL ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--surface2);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: var(--red-dim); color: var(--red); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── EMPTY STATE ─── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ─── TOAST ─── */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: .85rem;
  font-weight: 500;
  color: #fff;
  transition: opacity .3s, transform .3s;
}
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

/* ─── SPINNER ─── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ─── FOOTER ─── */
.site-footer {
  margin-top: auto;
  padding: 28px max(28px, calc((100% - 1400px) / 2));
  text-align: center;
  font-size: .82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .navbar { padding: 0 12px; gap: 4px; }
  .navbar-brand { font-size: 1rem; margin-right: 8px; }
  .navbar-nav a { padding: 6px 10px; font-size: .8rem; }
  .page-container { padding: 0 12px; }
  .layout-with-sidebar { flex-direction: column; }
  .sidebar { width: 100%; min-width: 0; position: static; max-height: none; }
  .product-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 1.3rem; }
  .breadcrumb { padding: 10px 12px; }
  .section-header { flex-direction: column; align-items: flex-start; }
  .admin-tabs { overflow-x: auto; }
  .stats-bar { flex-direction: column; }
  .stat-card { min-width: 0; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
  .stats-bar { flex-direction: column; }
  .stat-card { min-width: 0; }
}
