:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --ink: #111315;
  --muted: #666c73;
  --border: #dfe2dc;
  --urgent-bg: #111315;
  --urgent-fg: #ffffff;
  --soon-border: #111315;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px calc(124px + env(safe-area-inset-bottom, 0px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #ffffff;
  image-rendering: pixelated;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 750;
  letter-spacing: -0.025em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.battery-pill {
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
  white-space: nowrap;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.submeta {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
}

select, input[type="text"], input[type="date"], input[type="number"] {
  font: inherit;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}

select:focus, input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.topbar-actions select {
  width: auto;
  max-width: 180px;
  font-weight: 600;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #e7e9e3;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.tab {
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

/* INVENTORY PRIMARY CTA */
.inv-top-actions {
  margin-bottom: 14px;
}

.add-cta {
  width: 100%;
  padding: 13px 18px;
  font-size: 1rem;
  border-radius: 13px;
  box-shadow: 0 3px 10px rgba(17, 19, 21, 0.14);
}

/* STEP-BY-STEP PHONE-APP WIZARD MODAL */
.sheet-modal {
  padding: 0;
  max-width: 440px;
  width: calc(100% - 24px);
  border-radius: 20px;
  overflow: hidden;
}

.wizard-shell {
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-top {
  display: grid;
  grid-template-columns: 72px 1fr 36px;
  align-items: center;
  gap: 8px;
}

.wizard-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.step-caption {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.step-dots {
  display: flex;
  gap: 6px;
}

.step-dots .dot {
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: #e2e5de;
}

.step-dots .dot.active {
  background: var(--ink);
}

.icon-close {
  border: none;
  background: #f0f2ec;
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  justify-self: end;
}

.icon-close:hover { background: #e3e6de; }

.wiz-step {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wiz-title {
  margin: 0;
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.choice-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fafbf8;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.choice-card:hover {
  border-color: var(--ink);
  background: #f2f4ee;
}

.choice-emoji {
  font-size: 1.45rem;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.choice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.choice-body strong { font-size: 0.96rem; }
.choice-body span { font-size: 0.8rem; color: var(--muted); }
.choice-arrow { font-size: 1.3rem; color: var(--muted); font-weight: 600; }

.place-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.place-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fafbf8;
  color: var(--ink);
  font: inherit;
  font-size: 0.94rem;
  cursor: pointer;
}

.place-card.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.field-label-text {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.wiz-step input[type="text"],
.wiz-step input[type="date"] {
  padding: 12px;
  font-size: 1rem;
}

.preset-hint {
  font-size: 0.8rem;
  color: #2f522b;
  background: #edf4ea;
  padding: 8px 10px;
  border-radius: 9px;
  font-weight: 600;
}

.wiz-summary {
  background: #f4f5f2;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
}

.wiz-final-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wiz-next-btn {
  width: 100%;
  padding: 13px 16px;
  font-size: 0.98rem;
  border-radius: 12px;
}

.wiz-sub-btn {
  width: 100%;
  padding: 9px;
  font-size: 0.86rem;
}

/* FAVORITES GRID */
.favorites-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.staples-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.staples-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.staple-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1.5px solid var(--border);
  background: #f8f9f6;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.staple-chip:hover {
  border-color: var(--ink);
  background: #eff1ec;
}

.staple-chip .staple-meta {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
}

.staple-chip.editing {
  border-color: #d9827b;
  background: #fff6f5;
}

.staple-del {
  font-weight: 800;
  color: #b42318;
  margin-left: 2px;
}

.checkbox-label {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 0.86rem !important;
  color: var(--ink) !important;
  cursor: pointer;
}

.checkbox-label input {
  width: auto !important;
}

/* SECTION HEADERS IN INVENTORY */
.section-head {
  font-size: 0.74rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 10px 4px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-head:first-child { margin-top: 2px; }
.section-head.urgent-head { color: #b42318; }

.item-row.is-urgent {
  border-color: #111315;
  background: #fcfcfa;
}

/* TOAST (SITS ABOVE BOTTOM NAV) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: #111315;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
  z-index: 60;
  white-space: nowrap;
}

/* FLOATING (+) ACTION BUTTON & POPOVER MENU */
.fab-btn {
  position: fixed;
  right: 20px;
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(17, 19, 21, 0.28);
  z-index: 45;
  transition: transform 0.16s ease, background 0.16s ease;
}

.fab-btn:hover { background: #262a2e; }
.fab-btn:active { transform: scale(0.95); }
.fab-btn.open .fab-plus { transform: rotate(45deg); }

.fab-plus {
  font-size: 2rem;
  font-weight: 400;
  line-height: 1;
  margin-top: -2px;
  transition: transform 0.18s ease;
}

.fab-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 21, 0.25);
  z-index: 42;
}

.fab-menu {
  position: fixed;
  right: 20px;
  bottom: calc(146px + env(safe-area-inset-bottom, 0px));
  width: 196px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.18);
  z-index: 46;
  transform-origin: bottom right;
  animation: fabPop 0.14s ease-out;
}

@keyframes fabPop {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.fab-menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 11px 14px;
  border-radius: 10px;
  font: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.fab-menu-item:hover { background: #f2f4ee; }

/* CLASSIC IPHONE BOTTOM NAVIGATION BAR */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 6px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}

.bnav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
}

.bnav-btn.active {
  color: var(--ink);
}

.bnav-icon {
  width: 23px;
  height: 23px;
}

/* ADMIN DETAILS IN SETTINGS */
.admin-tools {
  margin-top: 18px;
}

.admin-details summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 0.92rem;
  color: var(--muted);
}

.admin-inner, .sim-body {
  margin-top: 12px;
}

.sim-controls-row {
  margin-bottom: 10px;
}

.toast-undo {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.toast-undo:hover { background: rgba(255, 255, 255, 0.3); }

.hidden { display: none !important; }

.btn {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: #f0f2ec; }
.btn.primary {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
.btn.primary:hover { background: #262a2e; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: #eceee8; }
.btn.danger { color: #b42318; border-color: #f3c4c0; }
.btn.small { padding: 6px 10px; font-size: 0.8rem; }

.add-details summary, .recent-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

.detail-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1.5px solid var(--border);
  background: #f8f9f6;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 11px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover { border-color: var(--ink); }

.chip.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.pill-group {
  display: flex;
  gap: 6px;
}

.pill {
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
}

.pill span {
  font-family: var(--mono);
  margin-left: 4px;
  opacity: 0.75;
}

.pill.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
}

.check-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #c5cac0;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  color: transparent;
}

.check-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.item-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.item-title {
  font-weight: 650;
  font-size: 0.98rem;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.item-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.loc-tag {
  font-size: 0.68rem;
  font-family: var(--mono);
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 5px;
  background: #eef0ea;
  color: #444a50;
}

.badge {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 7px;
  white-space: nowrap;
}

.badge.urgent {
  background: var(--urgent-bg);
  color: var(--urgent-fg);
}

.badge.soon {
  border: 2px solid var(--soon-border);
  color: var(--ink);
}

.badge.ok {
  background: #f0f2ec;
  color: #363b40;
}

.open-btn {
  border: 1px solid var(--border);
  background: #fafbf8;
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
}

.open-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.recent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid #f0f2ec;
}

/* E-INK SIMULATOR */
.sim-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.customize-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6f7f4;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}

.title-edit-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.title-edit-row .inline-label {
  flex: 1;
}

.icon-picker-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.picker-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.icon-pills {
  flex-wrap: wrap;
}

.bat-slider {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.eink-bezel {
  background: #f8f8f5;
  border: 3px solid #222528;
  border-radius: 22px;
  padding: 18px 18px 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12), inset 0 1px 0 #fff;
  max-width: 842px;
  margin: 0 auto;
}

.eink-screen-wrap {
  background: #e9ebe4;
  border: 2px solid #181a1c;
  border-radius: 6px;
  overflow: hidden;
  line-height: 0;
}

.eink-screen-wrap img {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
  filter: contrast(1.02) sepia(0.05);
}

.ee04-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.hw-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 2px solid #222528;
  background: #ffffff;
  color: #111315;
  border-radius: 10px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 0 #222528;
}

.hw-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

.hw-num {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: #111315;
  color: #fff;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.sim-meta {
  margin-top: 10px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* SETUP */
.muted { color: var(--muted); font-size: 0.88rem; margin: 4px 0 10px; }
.small-note { font-size: 0.8rem; }
.steps { margin: 8px 0 10px; padding-left: 20px; line-height: 1.6; font-size: 0.9rem; }

.copy-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f4f5f2;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
}

.copy-box code {
  flex: 1;
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-x: auto;
  white-space: nowrap;
}

.settings-form, .inline-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.inline-form {
  flex-direction: row;
}

.endpoint-info {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.modal {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2);
}

.modal::backdrop {
  background: rgba(17, 19, 21, 0.45);
}

.modal h3 { margin: 0 0 8px; }
.modal-actions { display: flex; gap: 8px; margin-top: 8px; }
.spacer { flex: 1; }
