﻿:root {
  --choco: #351b0f;
  --choco-2: #5b2d17;
  --caramel: #c9803c;
  --cream: #fff6e8;
  --paper: #fffaf2;
  --ink: #28170f;
  --muted: #7a6253;
  --line: #eadbc8;
  --green: #168a4a;
  --red: #b42318;
  --shadow: 0 16px 36px rgba(53, 27, 15, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--cream);
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; border-radius: 8px; font-weight: 800; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: white;
  color: var(--ink);
}
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 15%, rgba(201, 128, 60, .24), transparent 24%),
    linear-gradient(135deg, var(--cream), #fff);
}
.login-card {
  width: min(390px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  text-align: center;
}
.login-logo { width: 92px; height: 92px; object-fit: cover; border-radius: 50%; margin: 0 auto; }
.login-card h1 { margin: 0; }
.login-card p, .login-card small { color: var(--muted); }
.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}
.password-field input {
  border: 0;
  border-radius: 0;
}
.password-field button {
  border-radius: 0;
  background: #f3e3cf;
  color: var(--choco);
  padding: 0 12px;
  min-width: 86px;
}
.login-card button, .form-grid button, #refreshBtn {
  background: var(--choco);
  color: white;
  padding: 12px 16px;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 244px;
  background: var(--choco);
  color: white;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.side-brand { display: flex; align-items: center; gap: 10px; }
.side-brand img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
.store-link {
  display: block;
  padding: 10px 11px;
  border-radius: 8px;
  color: var(--choco);
  background: #f9ead7;
  text-decoration: none;
  font-weight: 900;
  text-align: center;
}
.sidebar nav { display: grid; gap: 6px; }
.sidebar nav button, .logout {
  text-align: left;
  background: transparent;
  color: #f9ead7;
  padding: 10px 11px;
}
.sidebar nav button.active, .sidebar nav button:hover, .logout:hover { background: rgba(255,255,255,.12); }
.logout { margin-top: auto; }
.admin-main { margin-left: 244px; padding: 22px; }
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.eyebrow { margin: 0; color: var(--caramel); font-size: .76rem; text-transform: uppercase; font-weight: 900; }
.admin-top h1 { margin: 3px 0 0; font-size: clamp(1.8rem, 4vw, 2.8rem); }
.view { display: none; }
.view.active { display: block; }
.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.kpi, .panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.kpi { padding: 14px; }
.kpi span { color: var(--muted); font-size: .8rem; font-weight: 800; }
.kpi strong { display: block; font-size: 1.35rem; margin-top: 5px; }
.panel { padding: 16px; overflow: hidden; }
.panel h2 { margin: 0 0 12px; font-size: 1.1rem; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.table th, .table td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-size: .78rem; text-transform: uppercase; }
.table select { min-width: 140px; padding: 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.secondary { background: #f3e3cf; color: var(--choco); padding: 8px 10px; }
.danger { background: #fee4e2; color: var(--red); padding: 8px 10px; }
.success { background: #dcfae6; color: var(--green); padding: 8px 10px; }
.product-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.product-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3e3cf;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.thumb-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: .72rem;
  text-align: center;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.form-grid textarea, .form-grid button { grid-column: span 3; }
.compact-form button { grid-column: auto; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--muted); }
.checkline input { width: auto; }
.status-chart { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 34px; align-items: center; gap: 8px; font-size: .88rem; }
.bar { height: 12px; border-radius: 999px; background: #f1dfc8; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--caramel); }
.calculator {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 10px;
  margin-bottom: 14px;
}
.customer-filter-grid {
  grid-template-columns: minmax(220px, 1.4fr) 1fr 1fr auto auto;
}
.result {
  grid-column: 1 / -1;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.result strong { display: block; font-size: 1.1rem; }
.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: .75rem;
  font-weight: 900;
  background: #f4e4ce;
  color: var(--choco);
}
.pill.low { background: #fee4e2; color: var(--red); }
.pill.ok { background: #dcfae6; color: var(--green); }
canvas { width: 100%; max-width: 100%; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 8px;
  color: white;
  background: var(--choco);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(255, 250, 242, .82);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
}
.loading-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.loading-card {
  width: min(340px, 100%);
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--choco);
}
.loading-card span {
  color: var(--muted);
  font-size: .9rem;
}
.loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #f3e3cf;
  border-top-color: var(--choco);
  animation: spin .75s linear infinite;
}
body.is-loading #refreshBtn {
  opacity: .72;
  cursor: wait;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (max-width: 980px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; z-index: 5; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-main { margin-left: 0; padding: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .form-grid, .calculator, .result, .filter-grid { grid-template-columns: 1fr; }
  .form-grid textarea, .form-grid button { grid-column: auto; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (max-width: 560px) {
  .admin-top { align-items: start; flex-direction: column; }
  .kpis { grid-template-columns: 1fr; }
}

