:root {
  --bg: #faf6ee;
  --surface: #ffffff;
  --header-bg: #22262e;
  --header-text: #ffffff;
  --header-text-muted: #a7adba;
  --border: #e7dfcd;
  --text: #201c14;
  --text-muted: #756f5f;
  --accent: #ffdd00;
  --accent-hover: #f0cf00;
  --accent-bg: #fff3b0;
  --accent-text: #201c14;
  --danger: #b91c1c;
  --danger-bg: #fdecea;
  --success: #15803d;
  --success-bg: #e6f7ec;
  --warning: #c2410c;
  --warning-bg: #fef0e2;
  --radius: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

/* App shell: sidebar + content */

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.4rem;
  margin-bottom: 1.75rem;
}
.brand-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 800;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-text { font-weight: 800; font-size: 0.95rem; color: var(--text); line-height: 1.2; }

.nav-group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  margin: 1.2rem 0.4rem 0.5rem;
}
.nav-group-label:first-of-type { margin-top: 0; }

.side-link {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}
.side-link:hover { background: var(--bg); }
.side-link.active { background: var(--accent); color: var(--accent-text); }

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.15rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle-btn {
  flex-shrink: 0;
  width: auto;
  margin: 0;
  padding: 0.5rem;
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: none;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle-btn:hover { background: var(--bg); }
.refresh-btn { padding: 0.85rem; }
.sidebar-toggle-btn:active { transform: none; }

.pickup-header { padding: 0.6rem 1.25rem; }
.header-spacer { flex: 1; }
.pickup-supplier-count {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

.app-shell.sidebar-collapsed .sidebar { display: none; }

main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 2rem 3rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  margin: 0 0 0.2rem;
}
.page-sub {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
}
.top-header .page-sub { margin: 0; }

/* Form elements */

label {
  display: block;
  margin: 1rem 0 0.35rem;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
label:first-child { margin-top: 0; }

input, select {
  font-size: 0.95rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  width: 100%;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
input:disabled, select:disabled {
  background: #f4efe1;
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
}

button {
  font-size: 0.95rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  margin-top: 1.25rem;
  cursor: pointer;
  width: 100%;
  background: var(--accent);
  color: var(--accent-text);
  font-family: inherit;
  box-shadow: 0 2px 0 var(--accent-hover);
  transition: transform 0.05s ease;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 0 0 var(--accent-hover); }
button:disabled {
  background: #ece5d3;
  color: #a49c88;
  box-shadow: none;
  cursor: not-allowed;
}
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: none;
}
button.secondary:hover:not(:disabled) { background: var(--bg); }
button.small { width: auto; padding: 0.4rem 0.8rem; font-size: 0.85rem; margin-top: 0; box-shadow: none; }
button.small:active:not(:disabled) { transform: none; }

/* Cards & sections */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.25rem;
  margin-top: 1rem;
  border: 1px solid var(--border);
}
.card:first-child { margin-top: 0; }
.card h2 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card h2::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent);
  display: inline-block;
}

.muted { color: var(--text-muted); font-size: 0.88rem; }

.toast {
  margin-top: 0.9rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
}
.toast:empty { display: none; }

.item-info {
  margin-top: 1rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.92rem;
}
.item-info:empty { display: none; }

/* Scan page */

.scan-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 220px);
}
.scan-card {
  width: 100%;
  max-width: 780px;
  text-align: center;
  padding: 3.25rem 3.5rem 3rem;
  margin-top: 0;
}
.scan-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  color: var(--accent-hover);
}
.scan-icon svg { width: 100%; height: 100%; display: block; }
.scan-heading {
  font-size: 1.85rem;
  font-weight: 800;
  margin: 0 0 0.4rem;
}
.scan-sub {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin: 0 0 1.75rem;
}
.scan-input {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.03em;
  padding: 1.35rem;
  border-width: 2px;
  border-style: dashed;
  border-color: var(--accent-hover);
  transition: background 0.15s ease, color 0.15s ease;
}
.scan-input:placeholder-shown {
  background: var(--header-bg);
  color: var(--header-text);
  border-style: solid;
  animation: scan-pulse 1.8s ease-in-out infinite;
}
.scan-input:focus { border-style: solid; }
.scan-input:placeholder-shown:focus { animation: none; }
.scan-input::placeholder { color: var(--text-muted); font-weight: 600; }
.scan-input:placeholder-shown::placeholder { color: var(--header-text-muted); }

/* Front Desk: touch-friendly, built for a vertical/portrait screen at the counter */

.pickup-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding-top: 0.75rem;
}
.pickup-list { padding: 0.75rem 1.75rem; }
.pickup-list .list-row { padding: 0.85rem 0; font-size: 1.35rem; }
.pickup-list .badge { font-size: 1.3rem; padding: 0.4rem 1.05rem; min-width: 2.7rem; flex-shrink: 0; margin-left: 1rem; }
.pickup-qty { font-size: 1.35rem; font-weight: 800; color: var(--text); }
.supplier-row-name {
  font-size: 1.9rem;
  font-weight: 800;
}
.supplier-row-sub {
  display: inline-block;
  margin-left: 1.1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  vertical-align: middle;
}
.pickup-panel { padding: 1.5rem 1.75rem 1.75rem; }
.pickup-input {
  font-size: 1.5rem;
  padding: 1.25rem 1.1rem;
}
.pickup-btn {
  font-size: 1.4rem;
  padding: 1.4rem;
  margin-top: 1.5rem;
}
button.pickup-back-btn {
  font-size: 1.15rem;
  padding: 0.75rem 1.2rem;
}
#detailSupplierName { font-size: 2.4rem !important; font-weight: 800; }
.scan-card label { text-align: left; }
.scan-card .item-info { text-align: center; font-size: 1.05rem; }
@keyframes scan-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-bg); }
  50% { box-shadow: 0 0 0 10px transparent; }
}
.toast.ok { background: var(--success-bg); color: var(--success); }
.toast.err { background: var(--danger-bg); color: var(--danger); }
.hidden { display: none !important; }

/* Lists: suppliers, pending items, catalog */

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row.clickable { cursor: pointer; }
.list-row.clickable:hover { background: var(--accent-bg); margin: 0 -0.5rem; padding: 0.7rem 0.5rem; border-radius: var(--radius-sm); }

.badge {
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 800;
  min-width: 1.6rem;
  text-align: center;
  background: var(--accent);
  color: var(--accent-text);
}
/* Dashboard: stat bar */

.stat-bar {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.stat-item {
  flex: 1;
  text-align: center;
  padding: 0.9rem 0.75rem;
  border-right: 1px solid var(--border);
}
.stat-item:last-child { border-right: none; }
.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.35rem;
}
.stat-value {
  font-size: 1.55rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Dashboard: worst suppliers ranked list */

.worst-suppliers { display: flex; flex-direction: column; }
.worst-supplier-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.worst-supplier-row:last-child { border-bottom: none; }
.worst-supplier-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 800;
  font-size: 0.78rem;
  margin-right: 0.7rem;
}
.worst-supplier-name { font-weight: 700; color: var(--text); }
.worst-supplier-value {
  font-variant-numeric: tabular-nums;
  color: var(--danger);
  font-weight: 800;
}

/* Overview: filter bar + pagination */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.1rem;
}
.filter-input { width: 180px; flex: 0 0 auto; }
.filter-date-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0;
  flex: 0 0 auto;
}
.filter-date-label input { width: 150px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.pagination button { width: auto; margin: 0; padding: 0.5rem 1rem; }

/* Dashboard: activity feed */

.status-pill {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-pill.pending { background: var(--warning-bg); color: var(--warning); }
.status-pill.collected { background: var(--success-bg); color: var(--success); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.data-table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0 0.6rem 0.55rem 0;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.6rem 0.6rem 0.6rem 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg); }
.data-table th.num, .data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.data-table td.muted-cell { color: var(--text-muted); }
