/* Keeper staff PWA — phone-first, custom properties only (CONVENTIONS.md) */
:root {
  --bg: #f6f2f4;
  --panel: #ffffff;
  --line: #e3d9de;
  --ink: #241c20;
  --ink-soft: #7a6d74;
  --accent: #8e3b6e;
  --good: #2e7d4f;
  --warn: #b07818;
  --bad: #b3364a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191316;
    --panel: #241c21;
    --line: #3a2f36;
    --ink: #f0e8ec;
    --ink-soft: #a3949c;
    --accent: #cf7fae;
    --good: #5dbd8a;
    --warn: #d9a44a;
    --bad: #e06378;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0.2em 0 0.4em; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--accent); }

#view { max-width: 640px; margin: 0 auto; padding: 12px 12px 24px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: 10px 2px 8px;
  display: flex; align-items: center; gap: 8px;
}
.topbar h1 { flex: 1; margin: 0; }

/* ---- panels / lists ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
  width: 100%;
  text-align: left;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.row:active { border-color: var(--accent); }
.row .grow { flex: 1; min-width: 0; }
.row .sub { color: var(--ink-soft); font-size: 0.85rem; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none; }
.mt8 { margin-top: 8px; }
.my8 { margin: 10px 0; }
.ml8 { margin-left: 8px; }
.sp10 { height: 10px; }
.grow1 { flex: 1; }
.row.col { flex-direction: column; align-items: stretch; cursor: default; }
.panel.tight { margin-bottom: 0; }
input.check { width: auto; min-height: auto; }
label.field.inline { display: flex; gap: 8px; align-items: center; }
.login-wrap { padding-top: 14vh; }
.login-title { font-size: 1.8rem; }
#msg { min-height: 1.4em; margin-top: 12px; }
#msg.bad { color: var(--bad); }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- badges / banners ---- */
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.badge.low  { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); border-color: var(--warn); }
.badge.bad  { background: color-mix(in srgb, var(--bad) 15%, transparent);  color: var(--bad);  border-color: var(--bad); }
.badge.good { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); border-color: var(--good); }
.banner {
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-weight: 600;
}
.banner.allergy {
  background: color-mix(in srgb, var(--bad) 14%, var(--panel));
  color: var(--bad);
  border: 1px solid var(--bad);
}
#offline-banner {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: var(--warn); color: #fff;
  text-align: center; padding: 8px; font-weight: 600;
}
body.offline #offline-banner { display: block; }

/* ---- forms ---- */
label.field { display: block; margin-bottom: 10px; }
label.field span { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 3px; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
/* Checkboxes/radios opt out of the full-width text-input treatment above —
   without this, a bare checkbox renders as a giant white slab. */
input[type="checkbox"], input[type="radio"] {
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  flex: none;
  accent-color: var(--accent);
}
input.switch { width: 26px; height: 26px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
input.grams {
  font-size: 1.6rem;
  text-align: center;
  min-height: 56px;
  font-variant-numeric: tabular-nums;
}

/* ---- buttons ---- */
button.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit; font-weight: 600;
  cursor: pointer;
}
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.danger { color: var(--bad); border-color: var(--bad); background: var(--panel); }
button.btn.wide { width: 100%; }
button.btn:disabled { opacity: 0.5; }
button.iconbtn {
  min-width: 44px; min-height: 44px;
  border: none; background: none;
  font-size: 1.3rem; color: var(--accent); cursor: pointer;
}

/* ---- bottom tab bar ---- */
nav.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabbar a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-height: 56px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.68rem;
}
nav.tabbar a .ico { font-size: 1.35rem; line-height: 1; }
nav.tabbar a.active { color: var(--accent); font-weight: 700; }

/* ---- photos ---- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
}

/* ---- timeline ---- */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item { border-left: 3px solid var(--accent); padding-left: 10px; }
.tl-date { font-weight: 700; }

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  width: min(92vw, 480px);
  padding: 16px;
}
dialog::backdrop { background: rgba(0,0,0,0.45); }

.cost-line { font-size: 1.2rem; font-weight: 700; }
.toast {
  position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  border-radius: 999px; padding: 10px 18px;
  z-index: 60; font-weight: 600; max-width: 88vw;
}

/* More tab */
.menu-ico { font-size: 1.3rem; width: 32px; text-align: center; }
.big-num { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
button.btn.on { border-color: var(--accent); color: var(--accent); }
.row-line { padding: 8px 0; border-bottom: 1px solid var(--line); min-height: 44px; }
.row-line:last-child { border-bottom: none; }
a.paylink {
  display: block; text-align: center;
  font-size: 1.05rem; font-weight: 700;
  padding: 16px 12px; margin: 10px 0;
  border: 1px solid var(--accent); border-radius: 12px;
  word-break: break-all;
}
.photo-grid .ph-cap {
  font-size: 0.7rem; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
details.audit summary {
  min-height: 44px; display: flex; align-items: center;
  cursor: pointer; font-weight: 600;
}
