/* === Dashboard — IKrafted Theme === */
@import url("https://fonts.googleapis.com/css2?family=Bebas+Neue&family=DM+Sans:wght@300;400;500;600&display=swap");

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

:root {
  --bg: #0d0d0d;
  --bg-card: #141414;
  --bg-card-accent: #1e1a0e;
  --fg: #f0ece4;
  --fg-muted: #8a857a;
  --accent: #e8a832;
  --accent-dim: rgba(232, 168, 50, 0.12);
  --border: rgba(240, 236, 228, 0.08);
  --border-accent: rgba(232, 168, 50, 0.25);
  --green: #4ade80;
  --red: #f87171;
  --blue: #60a5fa;
  --purple: #a78bfa;
  --cyan: #22d3ee;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* === Nav === */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(13, 13, 13, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topnav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topnav-brand {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.05em;
  color: var(--fg);
  text-decoration: none;
}

.topnav-tag {
  font-size: 0.7rem;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.nav-link:hover, .nav-link.active {
  color: var(--fg);
  border-color: var(--border);
  background: rgba(255,255,255,0.04);
}

.nav-link.active {
  color: var(--accent);
  border-color: var(--border-accent);
  background: var(--accent-dim);
}

/* === Layout === */
.dash-wrap {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

.dash-header {
  margin-bottom: 2.5rem;
}

.dash-header-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.dash-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.5rem;
  letter-spacing: 0.03em;
  color: var(--fg);
}

.dash-subtitle {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-weight: 300;
}

.dash-badge {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.25);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
}

/* === KPI Row === */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent) 0%, transparent 80%);
  opacity: 0.4;
}

.kpi-label {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}

.kpi-val {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.5rem;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 0.35rem;
}

.kpi-val.accent { color: var(--accent); }

.kpi-delta {
  font-size: 0.8rem;
  font-weight: 500;
}

.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

.kpi-period {
  font-size: 0.7rem;
  color: var(--fg-muted);
  margin-top: 0.2rem;
}

.kpi-icon {
  position: absolute;
  top: 1rem;
  right: 1rem;
  opacity: 0.3;
}

/* === Charts Row === */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.chart-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.04em;
}

.chart-period-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.chart-wrap {
  position: relative;
  height: 220px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.bar-track {
  width: 100%;
  background: var(--bg);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
}

.bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 4px 4px 0 0;
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-label {
  font-size: 0.6rem;
  color: var(--fg-muted);
  text-align: center;
  letter-spacing: 0.05em;
}

.bar-val {
  font-size: 0.65rem;
  color: var(--fg-muted);
  text-align: center;
}

/* === Donut === */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.donut-svg {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  transform: rotate(-90deg);
}

.donut-track {
  fill: none;
  stroke: var(--bg);
  stroke-width: 16;
}

.donut-segment {
  fill: none;
  stroke-width: 16;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.donut-center {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.75rem;
  color: var(--fg);
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-name { color: var(--fg-muted); flex: 1; }
.legend-val { color: var(--fg); font-weight: 600; }
.legend-pct { color: var(--fg-muted); font-size: 0.7rem; }

/* === Bottom Row === */
.bottom-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1rem;
}

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.section-label-sm {
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

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

.data-table th {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  text-align: left;
  padding: 0 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.data-table td {
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid rgba(240, 236, 228, 0.04);
  font-size: 0.82rem;
}

.data-table tr:last-child td { border-bottom: none; }

.td-name { color: var(--fg); font-weight: 500; }
.td-muted { color: var(--fg-muted); }

.td-rev {
  color: var(--accent);
  font-weight: 600;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1rem;
}

.rank-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}

.rank-badge.gold { background: rgba(232, 168, 50, 0.25); }
.rank-badge.silver { background: rgba(192,192,192,0.1); border-color: rgba(192,192,192,0.3); }
.rank-badge.bronze { background: rgba(205,127,50,0.1); border-color: rgba(205,127,50,0.3); }

/* === Inventory === */
.inv-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.inv-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.inv-supplier {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  flex: 1;
}

.inv-name {
  font-size: 0.85rem;
  color: var(--fg);
  font-weight: 500;
  flex: 2;
}

.inv-count {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-family: 'DM Mono', monospace;
  flex: 1;
  text-align: right;
}

.status-pill {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  flex: 1;
  text-align: center;
  max-width: 100px;
}

.status-ok { color: var(--green); background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74, 222, 128, 0.2); }
.status-low { color: #fbbf24; background: rgba(251, 191, 36, 0.1); border: 1px solid rgba(251, 191, 36, 0.2); }
.status-out { color: var(--red); background: rgba(248, 113, 113, 0.1); border: 1px solid rgba(248, 113, 113, 0.2); }

/* === Responsive === */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .dash-wrap { padding: 1.5rem 1rem 3rem; }
  .topnav-inner { padding: 0.75rem 1rem; }
  .topnav-tag { display: none; }
  .kpi-val { font-size: 2rem; }
  .donut-wrap { flex-direction: column; }
}

/* === Micro animation === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeUp 0.4s ease-out both;
}

.kpi-card:nth-child(1) { animation-delay: 0ms; }
.kpi-card:nth-child(2) { animation-delay: 60ms; }
.kpi-card:nth-child(3) { animation-delay: 120ms; }
.kpi-card:nth-child(4) { animation-delay: 180ms; }

.chart-card:nth-child(1) { animation-delay: 200ms; }
.chart-card:nth-child(2) { animation-delay: 280ms; }