@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #f97316;
  --accent-glow: rgba(249,115,22,0.35);
  --bg: #f1f5f9;
  --white: #ffffff;
  --surface: rgba(255,255,255,0.75);
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #22c55e;
  --green-light: #f0fdf4;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --red: #ef4444;
  --red-light: #fee2e2;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 20px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --shadow-blue: 0 4px 16px rgba(37,99,235,0.30);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Grain texture overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.03;
  pointer-events: none;
  z-index: 9999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #1e1b4b, #1e40af, #0369a1);
  background-size: 300% 300%;
  animation: heroGradient 12s ease infinite;
  color: white;
  padding: 1.4rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 70% 50%, rgba(249,115,22,0.12), transparent 60%);
  pointer-events: none;
}

@keyframes heroGradient {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.header-date {
  display: block;
  font-size: 0.8rem;
  opacity: 0.7;
  margin-top: 0.15rem;
  font-weight: 400;
}

.btn-add-toggle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s var(--ease-out);
}

.btn-add-toggle:hover {
  background: rgba(255,255,255,0.25);
  border-color: white;
  box-shadow: 0 0 20px rgba(255,255,255,0.15);
}

.btn-add-toggle.open {
  transform: rotate(45deg);
  background: rgba(239,68,68,0.4);
  border-color: rgba(239,68,68,0.6);
}

/* ── Main ── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem 4rem;
}

/* ── Dashboard ── */
#dashboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #0ea5e9);
  opacity: 0;
  transition: opacity 0.3s;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.stat-card:hover::before { opacity: 1; }

.stat-card.green::before { background: linear-gradient(90deg, var(--green), #14b8a6); }
.stat-card.amber::before { background: linear-gradient(90deg, var(--amber), var(--accent)); }
.stat-card.red::before { background: linear-gradient(90deg, var(--red), #be185d); }
.stat-card.blue::before { background: linear-gradient(90deg, var(--primary), #6366f1); }

.stat-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.stat-number {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 0.2rem;
}

.last-updated {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}

@media (max-width: 550px) {
  #dashboard { grid-template-columns: repeat(2, 1fr); }
}

/* ── Add form ── */
#add-form-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  max-height: 500px;
  transition: max-height 0.4s var(--ease-out), padding 0.4s var(--ease-out),
              opacity 0.3s ease, margin 0.4s var(--ease-out);
  opacity: 1;
}

#add-form-section.collapsed {
  max-height: 0;
  padding: 0 1.5rem;
  opacity: 0;
  margin-bottom: 0;
  border-color: transparent;
}

.form-row {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.form-row input, .form-row select {
  flex: 1;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  background: #f8fafc;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-row input:focus, .form-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: var(--white);
}

.form-row input::placeholder { color: #94a3b8; }

.btn-primary {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-blue);
  transition: all 0.2s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.35);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transform: skewX(-20deg);
  animation: btnSweep 3s ease-in-out infinite;
}

@keyframes btnSweep {
  0% { left: -60%; }
  100% { left: 160%; }
}

@media (max-width: 500px) {
  .form-row { flex-direction: column; }
}

/* ── Controls ── */
#controls {
  margin-bottom: 1rem;
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  background-image: radial-gradient(circle, #e2e8f0 1px, transparent 1px);
  background-size: 18px 18px;
}

.search-bar {
  position: relative;
  margin-bottom: 0.75rem;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 0.65rem 0.85rem 0.65rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-family: inherit;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(4px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

#filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.65rem;
}

.chip {
  padding: 0.32rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.9);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  color: var(--muted);
}

.chip:hover {
  border-color: #bfdbfe;
  color: var(--primary);
  background: var(--primary-light);
}

.chip.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-blue);
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
}

.toggle-label input { accent-color: var(--primary); }

/* ── View Tabs ── */
#view-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.view-tab {
  flex: 1;
  padding: 0.6rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 0.85rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s var(--ease-out);
}

.view-tab:hover { border-color: #bfdbfe; color: var(--primary); }

.view-tab.active {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-blue);
}

.hidden { display: none !important; }

/* ── Items list ── */
#items-list {
  position: relative;
}

.group-header {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 1.2rem 0 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.group-header:first-child { padding-top: 0.2rem; }

.cat-add-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease-out);
  flex-shrink: 0;
}

.cat-add-btn:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: var(--shadow-blue);
  transform: scale(1.15);
}

/* ── Tile Grid ── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 0.65rem;
}

/* ── Tile ── */
.tile {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.25s;
  animation: fadeUp 0.4s var(--ease-out) both;
  cursor: pointer;
}

.tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), #14b8a6);
  opacity: 0;
  transition: opacity 0.3s;
}

.tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: #bfdbfe;
}

.tile:hover::before { opacity: 1; }

/* ── Tile states ── */
.tile.out {
  background: var(--red-light);
  border-color: #fca5a5;
}
.tile.out::before { background: linear-gradient(90deg, var(--red), #b91c1c); opacity: 1; }

.tile.low { border-color: #fecdd3; }
.tile.low::before { background: linear-gradient(90deg, var(--red), #be185d); opacity: 1; }

.tile.expiring { border-color: var(--amber-light); }
.tile.expiring::before { background: linear-gradient(90deg, var(--amber), var(--accent)); opacity: 1; }

/* ── Tile inner layout ── */
.tile-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.3rem;
}

.tile-name {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.2px;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}

.tile-edit {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.15s;
}

.tile-edit:hover {
  color: var(--text);
}

.tile-qty {
  margin: 0.6rem 0 0.35rem;
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
}

.tile-qty-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
  color: var(--text);
}

.tile.out .tile-qty-value { color: var(--red); }

.tile-qty-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.tile-badges {
  min-height: 0;
}

.tile-badges:empty { display: none; }

.badge {
  display: inline-block;
  font-size: 0.58rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
}

.badge.out { background: #f3f4f6; color: #9ca3af; }
.badge.low { background: var(--red-light); color: var(--red); }
.badge.expiring { background: var(--amber-light); color: #b45309; }

.tile-price {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.15rem;
}

.tile-expiry {
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.tile-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.5rem;
}

.tile-actions button {
  flex: 1;
  height: 32px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease-out);
  color: var(--muted);
}

.tile-actions button:hover {
  background: var(--primary-light);
  border-color: #bfdbfe;
  color: var(--primary);
}

.tile-updated {
  font-size: 0.62rem;
  color: #b0b5bf;
  margin-top: 0.4rem;
  text-align: center;
}

.empty-msg {
  text-align: center;
  color: var(--muted);
  padding: 3rem 0;
  font-size: 0.92rem;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 400px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .tile { padding: 0.7rem; }
  .tile-qty-value { font-size: 1.3rem; }
}

/* ── Quick Add Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 2rem 1.8rem 1.6rem;
  width: 92%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.04);
  transform: scale(0.92) translateY(10px);
  transition: transform 0.3s var(--ease-spring);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 0.9rem;
  border-bottom: 1.5px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1.5px solid var(--border);
  background: #f8fafc;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--red-light);
  border-color: #fecdd3;
  color: var(--red);
}

/* ── Modal field group ── */
.modal-field {
  margin-bottom: 1.1rem;
}

.modal-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 0.4rem;
}

.modal input[type="text"],
.modal input[type="number"],
.modal select {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.modal input:hover,
.modal select:hover {
  border-color: #bfdbfe;
}

.modal input:focus,
.modal select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
  background: var(--white);
}

.modal input::placeholder {
  color: #94a3b8;
  font-weight: 400;
}

.modal select {
  cursor: pointer;
}

.modal .btn-primary {
  margin-top: 0.5rem;
  height: 48px;
  font-size: 0.95rem;
}

.modal .btn-danger {
  background: linear-gradient(135deg, var(--red), #b91c1c);
  box-shadow: 0 4px 16px rgba(239,68,68,0.3);
}
.modal .btn-danger:hover {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
}

.modal .btn-success {
  background: linear-gradient(135deg, var(--green), #15803d);
  box-shadow: 0 4px 16px rgba(34,197,94,0.3);
}
.modal .btn-success:hover {
  background: linear-gradient(135deg, #15803d, #166534);
}

/* ── Tile action button colors ── */
.tile-actions .btn-consume:hover {
  background: var(--red-light);
  border-color: #fecdd3;
  color: var(--red);
}

.tile-actions .btn-refill:hover {
  background: var(--green-light);
  border-color: #bbf7d0;
  color: var(--green);
}

/* ── Activity Log ── */
#log-view {
  margin-top: 0.5rem;
}

.log-date-picker {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.log-date-picker input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 500;
  background: var(--white);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.log-date-picker input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.1);
}

.log-group {
  margin-bottom: 0.75rem;
}

.log-group-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  letter-spacing: -0.2px;
  padding: 0.6rem 0.75rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.log-group-header:hover {
  background: var(--primary-light);
  border-color: #bfdbfe;
}

.log-group-title { flex: 1; text-align: left; }

.log-group-count {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--muted);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.log-group-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.25s var(--ease-out);
}

.log-group.open .log-group-chevron {
  transform: rotate(0deg);
}

.log-group:not(.open) .log-group-chevron {
  transform: rotate(-90deg);
}

.log-group-entries {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s var(--ease-out), margin 0.3s;
  margin-top: 0;
}

.log-group.open .log-group-entries {
  max-height: 2000px;
  margin-top: 0.35rem;
}

.log-entry {
  background: var(--white);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  border-left: 4px solid var(--green);
  animation: fadeUp 0.3s var(--ease-out) both;
}

.log-entry.consumed { border-left-color: var(--red); }

.log-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.log-body { flex: 1; min-width: 0; }

.log-detail {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.log-detail strong { color: var(--text); }

.log-time {
  font-size: 0.68rem;
  color: #94a3b8;
  margin-top: 0.15rem;
}

/* History modal */
.modal-wide { max-width: 560px; }

.history-body { padding: 1.2rem 1.5rem 1.5rem; }

.history-legend {
  display: flex;
  gap: 1.2rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-dot.consumed { background: var(--red); }
.legend-dot.added { background: var(--green); }

.history-chart-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1rem 0.75rem 0.5rem;
}

.history-chart-wrap canvas {
  display: block;
  width: 100%;
  height: 220px;
}
