/* ============================================================
   LUMEN — Admin Dashboard Template
   Pure CSS. No framework. No build step.
   ------------------------------------------------------------
   CUSTOMIZE COLORS HERE — change the variables below and the
   whole page follows. No other file needs editing for colors.
   ============================================================ */
:root {
  --bg: #f1f4f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e3e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #4f46e5;          /* main accent — change to your brand color */
  --accent-dark: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --green: #16a34a;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --sidebar-w: 248px;
  --radius: 14px;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
code { font-family: ui-monospace, 'SF Mono', monospace; font-size: 13px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; }

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  transition: background .15s ease, transform .15s ease;
  text-align: center;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, .28); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { display: block; width: 100%; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; white-space: nowrap; }
.link:hover { color: var(--accent-dark); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 16px;
  z-index: 200;
}
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 21px; letter-spacing: .03em; padding: 2px 10px 18px; }
.logo-mark { color: var(--accent); font-size: 24px; line-height: 1; }

.side-nav { flex: 1; overflow-y: auto; }
.nav-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text-muted);
  padding: 18px 10px 7px;
}
.nav-section:first-child { padding-top: 0; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #334155;
  font-weight: 500;
  font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-link svg { width: 19px; height: 19px; fill: currentColor; flex-shrink: 0; opacity: .75; }
.nav-link:hover { background: var(--surface-soft); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link.active svg { opacity: 1; }
.nav-count {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 21px;
  height: 21px;
  line-height: 21px;
  text-align: center;
  border-radius: 999px;
  padding: 0 6px;
}

.side-promo {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 14px;
}
.side-promo strong { font-size: 14.5px; }
.side-promo p { font-size: 13px; color: var(--text-muted); margin: 5px 0 12px; }

/* ---------- Main + topbar ---------- */
.main { margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 64px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  max-width: 460px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 12px;
}
.search svg { width: 17px; height: 17px; fill: var(--text-muted); flex-shrink: 0; }
.search input {
  border: none;
  outline: none;
  background: none;
  font: inherit;
  font-size: 14px;
  width: 100%;
  color: var(--text);
}
.search input::placeholder { color: var(--text-muted); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  transition: border-color .15s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 19px; height: 19px; fill: #475569; }
.bell-dot {
  position: absolute;
  top: 9px; right: 10px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #fff;
}
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}
.menu-toggle span { display: block; width: 19px; height: 2px; background: var(--text); }
.overlay { display: none; }

/* ---------- Content ---------- */
.content { padding: 28px; max-width: 1180px; margin: 0 auto; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.page-head p { color: var(--text-muted); margin-top: 3px; }

/* ---------- Stat cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.stat-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-label { font-size: 13.5px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 27px; font-weight: 800; letter-spacing: -0.02em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
.delta { display: inline-block; font-weight: 700; padding: 2px 7px; border-radius: 999px; margin-right: 5px; }
.delta.up { background: var(--green-soft); color: var(--green); }
.delta.down { background: var(--red-soft); color: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.card-head h2 { font-size: 17px; font-weight: 700; }
.card-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 2px; }
.card-sub strong { color: var(--text); }

/* ---------- Range buttons ---------- */
.range-btns { display: flex; gap: 4px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.range-btn {
  border: none;
  background: none;
  padding: 6px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.range-btn:hover { color: var(--text); }
.range-btn.active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px rgba(15, 23, 42, .12); }

/* ---------- Chart ---------- */
.chart-wrap { display: flex; gap: 10px; }
.chart-y {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 2px 0 0;
  text-align: right;
  width: 50px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.chart-body {
  position: relative;
  flex: 1;
  height: 240px;
  /* faint gridlines at the $max and $max/2 levels */
  background-image: linear-gradient(var(--border) 1px, transparent 1px);
  background-size: 100% 120px;
}
.chart-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  gap: 0; /* no gap: bar centers must sit exactly at (i+0.5)/n so the SVG line aligns */
}
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; padding: 0 4px; }
.bar {
  width: 100%;
  max-width: 44px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #818cf8, var(--accent));
  opacity: .85;
  transition: height .6s ease, opacity .15s;
}
.bar-col:hover .bar { opacity: 1; }
.chart-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.chart-labels {
  display: flex;
  gap: 0; /* matches .chart-bars: label centers align with bar centers */
  margin-left: 60px;
  margin-top: 8px;
}
.chart-labels span { flex: 1; text-align: center; font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }

/* ---------- Two-column grid ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}
.grid-2 > * { min-width: 0; /* lets cards shrink below their content (e.g. the 560px table) so the page never scrolls sideways on phones */ }
.grid-2 .card { margin-bottom: 0; }

/* ---------- Orders table ---------- */
.table-scroll { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.orders-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.orders-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.orders-table td { padding: 13px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.orders-table tbody tr:last-child td { border-bottom: none; }
.orders-table tbody tr:hover { background: var(--surface-soft); }
.order-id { font-weight: 700; color: var(--accent); }
.order-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}
.badge.paid { background: var(--green-soft); color: var(--green); }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.shipped { background: var(--blue-soft); color: var(--blue); }
.badge.refunded { background: var(--red-soft); color: var(--red); }
.empty-msg { padding: 22px 0 8px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ---------- Top products ---------- */
.products-list { list-style: none; display: grid; gap: 16px; }
.product-item { display: flex; align-items: center; gap: 13px; }
.product-thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-info strong { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-info span { font-size: 13px; color: var(--text-muted); }
.product-rev { text-align: right; flex-shrink: 0; }
.product-rev strong { display: block; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.product-rev span { font-size: 12.5px; color: var(--text-muted); }
.product-bar { height: 6px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; margin-top: 9px; }
.product-fill { height: 100%; border-radius: 999px; background: var(--accent); width: 0; transition: width 1s ease; }

.foot-note { margin-top: 22px; font-size: 13px; color: var(--text-muted); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: 0 0 60px rgba(15, 23, 42, .18);
  }
  .sidebar.open { transform: translateX(0); }
  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .overlay.show { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px; }
}

@media (max-width: 520px) {
  /* Topbar: search drops to a full-width second row so the
     placeholder is never truncated on narrow phones. */
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  /* Stat cards: 2 columns on phones instead of one tall stack. */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 22px; margin-top: 8px; }
  .page-head h1 { font-size: 22px; }
  .page-head .btn { width: 100%; }
  /* Chart x-labels: smaller text so W10–W12 don't truncate to "W…". */
  .chart-labels span { font-size: 9.5px; padding: 0; }
  .card { padding: 18px 14px; }
}
