* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  background: #f5f5f4;
  color: #1c1917;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
}

h1 { font-size: 24px; margin: 0 0 20px; }

label {
  display: block;
  font-weight: 600;
  margin: 18px 0 6px;
}

select, input[type=file], input[type=password], input[type=date], input:not([type]) {
  width: 100%;
  font-size: 17px;
  padding: 12px;
  border: 1px solid #d6d3d1;
  border-radius: 10px;
  background: #fff;
}

button, .button {
  display: block;
  width: 100%;
  margin-top: 28px;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: #15803d;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

button:disabled { background: #78716c; }

.items {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
}

.items td { padding: 8px 10px; border-bottom: 1px solid #e7e5e4; }
.items .num { text-align: right; white-space: nowrap; }
.items .sum td { font-weight: 600; }
.muted { color: #78716c; font-size: 15px; }

/* ---------- Manager pages ---------- */

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 14px 16px;
  background: #1c1917;
}
nav a { color: #fff; text-decoration: none; font-weight: 600; }
.nav-user { margin-left: auto; color: #d6d3d1; font-size: 15px; }
.nav-user a { color: #d6d3d1; font-weight: 400; }

main.wide { max-width: 1100px; }
h2 { font-size: 19px; margin: 32px 0 10px; }
a { color: #15803d; }
.small-link { font-size: 14px; font-weight: 400; margin-left: 8px; }

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 12px;
  align-items: end;
}
.filters label { margin-top: 10px; }
.filters button { margin-top: 10px; padding: 12px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 24px 0 16px;
}
.tile {
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 10px;
  padding: 14px;
}
.tile span { display: block; color: #78716c; font-size: 14px; }
.tile strong { font-size: 24px; }
.tile.warn { background: #fef3c7; border-color: #f59e0b; }

.exports { display: flex; flex-wrap: wrap; gap: 10px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0 28px;
}

.report {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 15px;
}
.report th, .report td {
  padding: 9px 10px;
  border-bottom: 1px solid #e7e5e4;
  text-align: left;
}
.report th { background: #f5f5f4; font-weight: 600; }
.report .num { text-align: right; white-space: nowrap; }
.report tr.clickable { cursor: pointer; }
.report tr.clickable:hover { background: #f0fdf4; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e7e5e4;
  color: #44403c;
  vertical-align: middle;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }

.receipt-photo {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #e7e5e4;
}

button.small, .button.small {
  display: inline-block;
  width: auto;
  margin-top: 0;
  padding: 10px 16px;
  font-size: 15px;
}
.button.secondary { background: #44403c; }
button.danger { background: #b91c1c; margin-top: 16px; }
button.link {
  width: auto;
  margin: 0;
  padding: 0;
  background: none;
  color: #15803d;
  font-size: 14px;
  font-weight: 400;
  text-decoration: underline;
}

.rename summary { cursor: pointer; list-style: none; }
.rename summary::-webkit-details-marker { display: none; }
.rename-link {
  margin-left: 10px;
  color: #15803d;
  font-size: 14px;
  text-decoration: underline;
}
.rename[open] .rename-link { display: none; }

.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; }

.flash {
  padding: 12px;
  border-radius: 10px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
}

/* ---------- Store upload page ---------- */

.store-label { margin: 0 0 2px; }
.signed-in {
  padding: 12px;
  border-radius: 10px;
  background: #dcfce7;
  border: 1px solid #86efac;
}
button.secondary, .button.secondary { background: #44403c; }
form + form button.secondary { margin-top: 14px; }
.pin-message { min-height: 1.4em; margin: 8px 0 0; font-size: 15px; }
.pin-message.error { color: #b91c1c; font-weight: 600; }
.footer-link { margin-top: 36px; text-align: center; font-size: 14px; }

/* ---------- Staff, stores and managers pages ---------- */

.store-block { margin-bottom: 8px; }
.inline-action summary {
  cursor: pointer;
  color: #15803d;
  font-size: 14px;
  text-decoration: underline;
  list-style: none;
}
.inline-action summary::-webkit-details-marker { display: none; }
.add-row .pin-input { flex: 0 0 90px; }
.num button.link { margin-left: auto; }   /* line action links up on the right */
.num .inline-action + form { margin-top: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 8px 0; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.check input { width: 18px; height: 18px; }
.narrow-form { max-width: 420px; }
.link-text { font-size: 13px; word-break: break-all; color: #44403c; }

/* ---------- Printable QR page ---------- */

.qr-page { text-align: center; }
.qr-page h1 { font-size: 34px; margin-bottom: 6px; }
.qr-instructions { font-size: 20px; margin: 0 0 16px; }
.qr-code svg { width: 100%; max-width: 360px; height: auto; }

@media print {
  nav, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .qr-code svg { max-width: 12cm; }
}

/* ---------- Phase 2: review, duplicates, item editing ---------- */

nav .count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1c1917;
  font-size: 13px;
  text-align: center;
}
.tile span a { font-size: 13px; }
.reason-text { margin: 6px 0 0; font-size: 14px; color: #44403c; }
.duplicate-box {
  margin: 12px 0;
  padding: 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fdba74;
}
.duplicate-box .muted { margin: 6px 0 0; }
.save-name { margin: 8px 0 16px; }
.save-name button { white-space: normal; }

.edit-items td { padding: 4px; }
.edit-items .head td { font-size: 13px; color: #78716c; font-weight: 600; }
.edit-items input { width: 100%; font-size: 15px; padding: 8px; border: 1px solid #d6d3d1; border-radius: 8px; }
.edit-items input.qty { width: 60px; }
.edit-items input.price { width: 90px; text-align: right; }
.edit-items input[type=checkbox] { width: 20px; height: 20px; }
.edit-items .center { text-align: center; }
#add-row { display: inline-block; margin: 8px 0 0; }
.items-check { font-size: 15px; margin: 8px 0 0; }
.items-check.good { color: #166534; }
.items-check.bad { color: #b91c1c; font-weight: 600; }
.totals-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; }
.totals-grid label { margin-top: 8px; }
.button-row { display: flex; gap: 10px; }
.button-row button { margin-top: 20px; }

.printed-names summary { margin-top: 4px; }
.small-label { font-size: 13px; font-weight: 400; margin: 8px 0 4px; }
textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 8px;
  border: 1px solid #d6d3d1;
  border-radius: 8px;
}

/* ---------- Upload queue: live list of photos ---------- */

.hint { margin: 8px 0 0; }
.upload-list { list-style: none; padding: 0; margin: 18px 0 0; }
.upload-list .up {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: #fff;
  border-left: 5px solid #a8a29e;
  font-size: 15px;
}
.upload-list .up span { color: #44403c; overflow-wrap: anywhere; }
.upload-list .up-processing { border-left-color: #2563eb; }
.upload-list .up-done { border-left-color: #15803d; }
.upload-list .up-failed, .upload-list .up-error { border-left-color: #b91c1c; }
.upload-list .up-failed strong, .upload-list .up-error strong { color: #b91c1c; }
.badge.bad { background: #fee2e2; color: #991b1b; }

/* ---------- Dashboard charts (Part 2) ---------- */

.charts { margin: 20px 0 8px; }
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
.kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 12px;
  padding: 14px;
}
.kpi-label { color: #57534e; font-size: 14px; }
.kpi-value { font-size: 26px; font-weight: 600; }
.delta { font-size: 13px; }
.delta.up { color: #006300; }
.delta.down { color: #b91c1c; }
.delta.flat { color: #78716c; }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.chart-card {
  margin: 0;
  min-width: 0;
  background: #fff;
  border: 1px solid #e7e5e4;
  border-radius: 12px;
  padding: 16px;
}
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h2 { margin: 0; font-size: 17px; }
.chart-card h3 { margin: 8px 0 4px; font-size: 14px; font-weight: 600; color: #57534e; }
.chart-card figcaption p, .chart-card > p.muted { margin: 2px 0 8px; font-size: 14px; }
.chart-box { position: relative; height: 280px; }
.chart-box.bars { height: 330px; }      /* vertical bars: room for names under the bars */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair > div { min-width: 0; }
.small { font-size: 13px; }

.table-view { margin-top: 10px; font-size: 14px; }
.table-view summary { cursor: pointer; color: #15803d; }
.table-scroll { overflow-x: auto; margin-top: 8px; }
.small-table { font-size: 13px; }
.small-table th, .small-table td { padding: 6px 8px; white-space: nowrap; }

.heatmap-wrap { overflow-x: auto; }
.heatmap { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.heatmap th { color: #78716c; font-weight: 400; padding: 0; text-align: center; overflow: visible; white-space: nowrap; }
.heatmap th.day-col { width: 36px; }
.heatmap th[scope="row"] { text-align: left; }
.heatmap td { height: 24px; min-width: 0; border-radius: 4px; }
.ramp-legend { display: flex; align-items: center; gap: 2px; margin-top: 8px; font-size: 12px; color: #78716c; }
.ramp-legend i { display: inline-block; width: 18px; height: 10px; border-radius: 2px; }
.ramp-legend span { margin: 0 6px; }

.slow-list { margin: 4px 0 0; padding-left: 22px; font-size: 15px; }
.slow-list li { padding: 5px 0; border-bottom: 1px solid #f5f5f4; }
.slow-list li span:last-child { display: block; font-size: 13px; }
.slow-list li.muted { list-style: none; margin-left: -22px; font-size: 14px; }

.health-list { list-style: none; margin: 6px 0 10px; padding: 0; }
.health-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f5f5f4; }

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 21px; }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-box { height: 230px; }
  .chart-box.bars { height: 300px; }
  .pair { grid-template-columns: 1fr; }
}

/* ---------- Change my PIN (Part 3) ---------- */

.change-pin-link { margin: 14px 0 0; text-align: center; font-size: 15px; }
.pin-change input { font-size: 22px; letter-spacing: 6px; text-align: center; }
.pin-change + .button { margin-top: 12px; }
.pin-info { font-size: 13px; color: #78716c; margin-top: 2px; }
