/* ============================================================
   Store Tracker — styles.css (mobile-first)
   Small screens first, then wider screens via @media queries.
   ============================================================ */
:root {
  --blue: #1a56db;
  --blue-dark: #14419c;
  --green: #0e9f6e;
  --red: #e02424;
  --amber: #c27803;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- Top bar ---------- */
.topbar {
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.topbar .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar .who { font-size: 12px; opacity: .85; }
button.logout {
  background: rgba(255,255,255,.15); color: #fff; border: none;
  padding: 6px 10px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
button.logout:hover { background: rgba(255,255,255,.3); }

/* ---------- Tabs ---------- */
nav.tabs {
  display: flex; overflow-x: auto; gap: 4px; margin-top: 8px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  background: transparent; color: #dbe4ff; border: none;
  padding: 8px 12px; border-radius: 8px; font-size: 14px;
  white-space: nowrap; cursor: pointer;
}
nav.tabs button.active { background: #fff; color: var(--blue); font-weight: 700; }

/* ---------- Layout ---------- */
main { padding: 12px; max-width: 980px; margin: 0 auto; padding-bottom: 60px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 12px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Forms ---------- */
form.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
input, select, textarea {
  width: 100%; padding: 10px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
textarea { min-height: 60px; resize: vertical; }
.btn {
  display: inline-block; background: var(--blue); color: #fff; border: none;
  padding: 11px 16px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: wait; }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); }
.btn.ghost { background: #eef2ff; color: var(--blue); }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Tables ---------- */
.tblwrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f9fafb; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.pos { background: #def7ec; color: var(--green); }
.badge.neg { background: #fde8e8; color: var(--red); }
.badge.zero { background: #f3f4f6; color: var(--muted); }

/* ---------- Photo grids ---------- */
.photogrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.photogrid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); background: #eee; cursor: pointer;
}
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 14px; text-align: center; color: var(--muted); cursor: pointer; font-size: 13px;
}
.dropzone.drag { border-color: var(--blue); background: #eef2ff; }

/* ---------- Toasts & modal ---------- */
#toasts { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 200; width: min(94vw, 480px); }
.toast {
  background: #111827; color: #fff; border-radius: 8px; padding: 10px 14px;
  margin-top: 8px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.3);
  word-break: break-word;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; border-radius: 14px 14px 0 0; width: 100%; max-width: 640px;
  max-height: 92vh; overflow-y: auto; padding: 16px;
}
@media (min-width: 640px) {
  .modal-back { align-items: center; }
  .modal { border-radius: 14px; }
  form.grid.two { grid-template-columns: 1fr 1fr; }
}

/* ---------- Login ---------- */
.login-wrap { max-width: 380px; margin: 8vh auto; padding: 0 14px; }
.login-wrap .logo { text-align: center; font-size: 40px; }
.notice {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 10px 0;
}
.err-text { color: var(--red); font-size: 13px; margin: 8px 0; min-height: 18px; }

/* ---------- CSV paste/report ---------- */
textarea.paste { min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.report-ok { color: var(--green); font-weight: 600; }
.report-err { color: var(--red); }
.report-table { font-size: 13px; }
.simslider { width: 100%; }
.statline { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }

/* ---------- Dashboard stat cards ---------- */
.statrow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; text-align: center;
}
.stat .num { font-size: 24px; font-weight: 800; }
.stat .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat.warn .num { color: var(--red); }
@media (min-width: 640px) { .statrow { grid-template-columns: repeat(4, 1fr); } }

/* ---------- row action buttons ---------- */
.rowbtns { white-space: nowrap; }
button.rowdel { color: var(--red); }
@media print {
  body * { visibility: hidden; }
  #qr-modal, #qr-modal * { visibility: visible; }
  #qr-modal { position: absolute; inset: 0; max-height: none; box-shadow: none; }
}
