:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --primary-lighter: #ecfdf5;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --success: #10b981;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 15px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 10px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: var(--font-mono);
}

.nav-section {
  padding: 8px 12px;
}

.nav-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  padding: 8px 12px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  font-size: 13.5px;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-lighter);
  color: var(--primary-dark);
}

.nav-item .icon {
  width: 16px; height: 16px;
  stroke-width: 2;
}

/* Main */
.main {
  padding: 24px 32px;
  max-width: 100%;
  overflow-x: hidden;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Buttons */
.btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.btn:hover { background: var(--bg); border-color: var(--text-soft); }

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

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

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

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }

.kpi-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 32px; height: 32px;
  background: var(--primary-lighter);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-dark);
}

/* Grid layouts */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-2-eq {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg);
}

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

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--primary-lighter); }

.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: #d1fae5; color: #047857; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.full { grid-column: span 2; }

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

.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  transition: all 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* Chart bars */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding-top: 8px;
}

.bar {
  flex: 1;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: opacity 0.15s;
  cursor: pointer;
}

.bar:hover { opacity: 0.85; }

.bar-label {
  position: absolute;
  bottom: -20px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.bar-value {
  position: absolute;
  top: -18px;
  left: 0; right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 32px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Progress */
.progress {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
  min-width: 60px;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.progress-bar.low { background: var(--danger); }
.progress-bar.mid { background: var(--warning); }

/* Search & filters */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 360px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.search-box .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  width: 15px; height: 15px;
}

/* Timeline */
.timeline {
  list-style: none;
  padding: 0;
  position: relative;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 28px;
  padding-bottom: 16px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
  position: absolute;
  left: 3px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-dot.done { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.pending { background: var(--surface); box-shadow: 0 0 0 2px var(--text-soft); }

.timeline-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Utility */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.tabular { font-variant-numeric: tabular-nums; }

/* Product cell */
.product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.product-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: var(--primary-lighter);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.product-name {
  font-weight: 500;
  font-size: 13px;
}

.product-sku {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Alert */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #78350f;
}

/* Donut chart */
.donut-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}

.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-value { font-size: 22px; font-weight: 700; }
.donut-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Action link */
a.link {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
}
a.link:hover { text-decoration: underline; }

/* Empty state */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .grid-2, .grid-2-eq { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: span 1; }
  .main { padding: 20px; }
}
