* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #0a0a0a;
  --muted: #8a8a8a;
  --hairline: #ececec;
  --rule: #111;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

.micro, .table-head span, .topnav a, .stat-label, .btn, .status, .cat, .delete-btn {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 2px solid var(--rule);
}
.brand { font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
.topnav { display: flex; gap: 28px; }
.topnav a { color: var(--ink); text-decoration: none; opacity: 0.55; }
.topnav a.active, .topnav a:hover { opacity: 1; }

/* ---------- page ---------- */
.page { padding: 40px 32px 140px; }
.page.hidden { display: none; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 36px;
}
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.subtitle { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  padding: 12px 20px;
  border: 1px solid var(--ink);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { background: #f5f5f5; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #2b2b2b; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- settings: side nav + panels ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
.side-nav {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-nav a {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  padding: 10px 14px;
  border-left: 2px solid transparent;
  opacity: 0.55;
}
.side-nav a:hover { opacity: 1; }
.side-nav a.active { opacity: 1; border-left-color: var(--ink); background: #f7f7f7; }
.panel.hidden { display: none; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.panel-head h2 { font-size: 20px; font-weight: 700; }
.caretaker-head, .caretaker-row {
  grid-template-columns: 1.2fr 1.2fr 0.6fr;
}
.qty-input.text-input { width: 100%; max-width: 260px; text-align: left; font-family: inherit; }
.add-row { border-bottom: none; }

/* ---------- table ---------- */
.table-head, .row {
  display: grid;
  grid-template-columns: minmax(280px, 2.4fr) 1.2fr 1fr 1fr 0.6fr;
  align-items: center;
  gap: 16px;
}
.settings-head, .settings-row {
  grid-template-columns: minmax(240px, 2fr) 1fr 1fr 1.6fr;
}
.threshold-val, .phone-val {
  font-size: 14px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  color: #6d6d6d;
}
.table-head {
  padding: 0 8px 12px;
  border-bottom: 2px solid var(--rule);
  color: #3c3c3c;
}
.table-head .right, .row .right { text-align: right; }

.row { padding: 20px 8px; border-bottom: 1px solid var(--hairline); }

.item-cell { display: flex; align-items: center; gap: 18px; }
.thumb {
  width: 56px; height: 56px;
  background: #f2f2f2;
  object-fit: cover;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #c4c4c4;
}
.item-name { font-size: 15px; font-weight: 600; }
.item-name a { color: inherit; text-decoration: none; }
.item-name a:hover { text-decoration: underline; }
.cat { margin-top: 4px; color: var(--muted); }

/* steppers */
.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn {
  width: 24px; height: 24px;
  border: 1px solid #d8d8d8;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.step-btn:hover { border-color: var(--ink); }
.qty-input {
  width: 100px;
  border: none;
  border-bottom: 1px solid #cfcfcf;
  padding: 6px 4px;
  font-size: 14px;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  text-align: center;
  outline: none;
}
.qty-input:focus { border-bottom-color: var(--ink); }
.qty-input.small { width: 56px; text-align: left; }

/* status */
.status.low {
  display: inline-block;
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
}
.status.ok { color: var(--muted); }
.status.ordered {
  display: inline-block;
  border: 1px solid var(--ink);
  padding: 5px 9px;
}

/* reorder checklist */
.check-row {
  grid-template-columns: 40px minmax(240px, 2.4fr) 1fr 1.2fr;
}
.check-cell input { width: 18px; height: 18px; accent-color: var(--ink); cursor: pointer; }
.qty-note {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: #3c3c3c;
}
.check-row.done .item-cell, .check-row.done .qty-note { opacity: 0.35; }
.note-line { text-transform: none; letter-spacing: 0.02em; font-style: italic; }
.check-row.done .item-name { text-decoration: line-through; }
a.btn { text-decoration: none; display: inline-block; }

.delete-btn {
  border: none;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.delete-btn:hover { text-decoration: underline; }

/* ---------- banner ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--ink);
  color: #fff;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 12px;
}
.banner.hidden { display: none; }
.banner a { color: #fff; }
.banner .btn {
  background: #fff; color: var(--ink); border-color: #fff;
  padding: 8px 14px;
}
.banner .dismiss {
  margin-left: auto;
  background: none; border: none; color: #fff;
  font-size: 16px; cursor: pointer;
}

/* ---------- footer ---------- */
.footbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 14px 32px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid var(--hairline);
}
.footbar-stats { display: flex; gap: 40px; }
.stat-label { display: block; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 18px; font-weight: 700; }
.stat-value.alert { text-decoration: underline; }
.footbar-actions { display: flex; gap: 12px; margin-left: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  font-size: 12px;
  max-width: min(90vw, 480px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- dialog ---------- */
dialog {
  border: 2px solid var(--ink);
  padding: 32px;
  width: min(480px, 90vw);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { font-size: 20px; margin-bottom: 20px; }
dialog label {
  display: block;
  margin-bottom: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3c3c3c;
}
dialog input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid #d8d8d8;
  font-size: 14px;
  outline: none;
}
dialog input:focus { border-color: var(--ink); }
.field-row { display: flex; gap: 12px; }
.field-row label { flex: 1; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

@media (max-width: 860px) {
  .topbar { padding: 16px 20px; }
  .page { padding: 28px 20px 190px; }
  .page-head { flex-direction: column; gap: 16px; }
  .table-head { display: none; }
  .row { grid-template-columns: 1fr; gap: 12px; padding: 16px 4px; }
  .row .right { text-align: left; }
  .threshold-val::before {
    content: "Threshold: ";
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .settings-layout { grid-template-columns: 1fr; gap: 20px; }
  .side-nav { position: static; flex-direction: row; border: 1px solid var(--ink); }
  .side-nav a { flex: 1; text-align: center; border-left: none; padding: 12px 8px; }
  .side-nav a.active { background: var(--ink); color: #fff; }
  .panel-head { flex-direction: column; }
  .footbar { padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .footbar-stats { width: 100%; justify-content: space-between; gap: 16px; }
  .stat { display: flex; align-items: baseline; gap: 8px; }
  .stat-label { margin-bottom: 0; }
  .stat-value { font-size: 15px; }
  .footbar-actions { width: 100%; margin-left: 0; }
  .footbar-actions .btn { flex: 1; text-align: center; padding: 14px 8px; }
  .banner .btn { width: 100%; text-align: center; }
  .toast { bottom: 140px; }
}
