:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #6b7385;
  --line: #e3e6ec;
  --accent: #c2477a;
  --ok: #2f8f5b;
  --warn: #c98a12;
  --bad: #c0392b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #1d2433;
  color: #cfd5e1;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}

.brand { font-size: 20px; font-weight: 700; color: #fff; padding: 0 8px 20px; }
.tag { font-size: 11px; font-weight: 600; background: var(--accent); color: #fff; padding: 2px 6px; border-radius: 4px; vertical-align: middle; }

nav a {
  display: block;
  padding: 8px 10px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}
nav a:hover { background: #2a3347; }
nav a.active { background: var(--accent); color: #fff; }

.sidebar-foot { margin-top: auto; font-size: 12px; color: #8a93a6; padding: 8px; }

main { flex: 1; padding: 24px 28px; min-width: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 22px; }
#search { width: 260px; max-width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 24px; font-weight: 700; margin-top: 4px; }
.card .sub { color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(340px, 2fr); gap: 16px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; overflow-x: auto; }
.panel h2 { margin: 0 0 12px; font-size: 15px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #e3f4ea; color: var(--ok); }
.pill.warn { background: #fbf1dc; color: var(--warn); }
.pill.bad { background: #f9e1de; color: var(--bad); }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 20px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar span.fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar small { color: var(--muted); margin-top: 6px; font-size: 11px; }
.bar b { font-size: 11px; margin-bottom: 4px; }

button.act { font: inherit; font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
button.act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 800px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; }
  .brand { padding: 0 12px 0 4px; }
  nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .sidebar-foot { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
  main { padding: 16px; }
}

#low-stock th, #low-stock td { padding: 8px 6px; }
#low-stock td:first-child { white-space: normal; }
