/* ============================================================
   Bench Stock — Liquid Glass design system
   ============================================================ */

:root {
  --page-bg: #e6e6e6;
  --page-bg-2: #dcdcdc;

  --ink: #1c1c1e;
  --ink-soft: #55555a;
  --ink-faint: #8a8a8f;

  --accent: #0a84ff;
  --accent-ink: #ffffff;
  --good: #2bb24c;
  --bad: #ff3b30;
  --warn: #ff9500;

  --glass-fill: rgba(255, 255, 255, 0.40);
  --glass-fill-strong: rgba(255, 255, 255, 0.62);
  --glass-edge: rgba(255, 255, 255, 0.85);
  --glass-edge-dim: rgba(255, 255, 255, 0.35);
  --glass-shadow: rgba(20, 20, 25, 0.16);
  --glass-shadow-soft: rgba(20, 20, 25, 0.10);

  --radius-l: 28px;
  --radius-m: 20px;
  --radius-s: 14px;
  --radius-round: 999px;

  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --spring-soft: cubic-bezier(0.22, 1.12, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 15% -10%, #f2f2f2 0%, transparent 55%),
    radial-gradient(120% 90% at 110% 10%, #eceff3 0%, transparent 50%),
    linear-gradient(180deg, var(--page-bg) 0%, var(--page-bg-2) 100%);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; background: none; border: none; }
input, textarea, select { -webkit-appearance: none; appearance: none; }

::selection { background: rgba(10, 132, 255, 0.25); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Glass primitive ---------- */

.glass {
  position: relative;
  background: var(--glass-fill);
  -webkit-backdrop-filter: blur(22px) saturate(190%);
  backdrop-filter: blur(22px) saturate(190%);
  border: 1px solid var(--glass-edge-dim);
  box-shadow:
    0 1px 1px rgba(255, 255, 255, 0.6) inset,
    0 -12px 18px -14px rgba(255, 255, 255, 0.5) inset,
    0 10px 30px -10px var(--glass-shadow);
  border-radius: var(--radius-m);
}

.glass::before {
  /* top specular highlight, direction of light = upper-left */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.12) 22%,
    rgba(255, 255, 255, 0) 45%
  );
  mix-blend-mode: overlay;
}

.glass-strong {
  background: var(--glass-fill-strong);
  border-color: var(--glass-edge);
}

/* ---------- App layout ---------- */

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  padding-bottom: calc(96px + var(--safe-bottom));
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(14px + var(--safe-top)) 16px 10px;
  background: linear-gradient(180deg, rgba(230, 230, 230, 0.92) 60%, rgba(230, 230, 230, 0));
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.title-block h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.02em;
  font-weight: 750;
  color: var(--ink);
}

.title-block p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-faint);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-round);
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  transition: transform 0.35s var(--spring), background 0.2s var(--ease-out), color 0.2s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: scale(0.88); }

/* stat strip */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.stat-pill {
  padding: 10px 8px 9px;
  border-radius: var(--radius-s);
  text-align: center;
}
.stat-pill .num {
  display: block;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat-pill .lbl {
  display: block;
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 2px;
  font-weight: 600;
}
.stat-pill.dot-good .num { color: var(--good); }
.stat-pill.dot-bad .num { color: var(--bad); }
.stat-pill.dot-warn .num { color: var(--warn); }

/* search */
.search-wrap {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-round);
}
.search-wrap svg { width: 17px; height: 17px; color: var(--ink-faint); flex-shrink: 0; }
.search-wrap input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 15px;
  color: var(--ink);
}
.search-wrap input::placeholder { color: var(--ink-faint); }
.search-clear {
  width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-faint);
  transition: transform 0.2s var(--spring);
}
.search-clear:active { transform: scale(0.85); }

/* filter chips */
.chip-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 8px 15px;
  border-radius: var(--radius-round);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: transform 0.3s var(--spring), background 0.25s var(--ease-out), color 0.25s;
  border: 1px solid var(--glass-edge-dim);
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 6px 14px -6px rgba(0, 0, 0, 0.35);
}
.chip:active { transform: scale(0.93); }

/* ---------- List ---------- */

.list {
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  margin: 40px 20px;
  padding: 34px 22px;
  border-radius: var(--radius-l);
  text-align: center;
}
.empty-state .glyph {
  width: 52px; height: 52px; margin: 0 auto 14px;
  color: var(--ink-faint);
}
.empty-state h3 { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.empty-state p { margin: 0; font-size: 13.5px; color: var(--ink-faint); line-height: 1.5; }

.card {
  border-radius: var(--radius-m);
  padding: 14px 14px 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transform-origin: center;
  animation: card-in 0.5s var(--spring-soft) both;
  transition: transform 0.25s var(--spring), box-shadow 0.25s var(--ease-out);
  touch-action: pan-y;
  will-change: transform;
}
.card:active { transform: scale(0.985); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.status-dot {
  width: 11px; height: 11px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(0,0,0,0.03);
}
.status-dot.working { background: var(--good); box-shadow: 0 0 8px rgba(43,178,76,0.6); }
.status-dot.not-working { background: var(--bad); box-shadow: 0 0 8px rgba(255,59,48,0.55); }
.status-dot.untested { background: var(--warn); box-shadow: 0 0 8px rgba(255,149,0,0.5); }

.card-body { flex: 1; min-width: 0; }
.card-body .name {
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-body .meta {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--ink-faint);
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-body .meta .qty { color: var(--ink-soft); font-weight: 600; }
.card-body .meta .dot-sep { opacity: 0.5; }
.card-body .meta .price { color: var(--accent); font-weight: 650; }

.card-chevron { color: var(--ink-faint); flex-shrink: 0; width: 18px; height: 18px; }

.card-swipe-bg {
  position: absolute; inset: 0;
  border-radius: var(--radius-m);
  background: var(--bad);
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 22px;
  color: #fff;
  opacity: 0;
}
.card-outer { position: relative; }

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  right: max(20px, calc((100vw - 560px) / 2 + 20px));
  bottom: calc(26px + var(--safe-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(155deg, #3aa0ff 0%, var(--accent) 55%, #0a6fdb 100%);
  color: #fff;
  box-shadow:
    0 1px 1px rgba(255,255,255,0.5) inset,
    0 14px 28px -10px rgba(10,132,255,0.55);
  z-index: 40;
  transition: transform 0.45s var(--spring);
}
.fab svg { width: 25px; height: 25px; }
.fab:active { transform: scale(0.88) rotate(-4deg); }

/* ---------- Sheet / modal ---------- */

.scrim {
  position: fixed; inset: 0;
  background: rgba(10, 10, 12, 0.28);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s var(--ease-out);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  max-width: 560px;
  margin: 0 auto;
  max-height: 88vh;
  border-radius: 30px 30px 0 0;
  padding: 10px 18px calc(22px + var(--safe-bottom));
  transform: translateY(104%);
  transition: transform 0.5s var(--spring);
  background: var(--glass-fill-strong);
  -webkit-backdrop-filter: blur(30px) saturate(190%);
  backdrop-filter: blur(30px) saturate(190%);
  border: 1px solid var(--glass-edge);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.18);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 38px; height: 5px; border-radius: 3px;
  background: rgba(120,120,120,0.4);
  margin: 6px auto 14px;
}

.sheet h2 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink-soft);
  margin-bottom: 6px;
  padding-left: 2px;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,255,255,0.55);
  font-size: 15px;
  outline: none;
  transition: box-shadow 0.2s var(--ease-out), border-color 0.2s;
}
.field textarea { min-height: 64px; resize: vertical; font-family: inherit; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,132,255,0.18);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.field-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; padding-left: 2px; }

/* segmented status control */
.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-round);
  background: rgba(0,0,0,0.045);
}
.segmented button {
  flex: 1;
  padding: 9px 6px;
  border-radius: var(--radius-round);
  font-size: 13px;
  font-weight: 650;
  color: var(--ink-soft);
  transition: background 0.35s var(--spring), color 0.25s, transform 0.25s var(--spring);
}
.segmented button.active { background: #fff; box-shadow: 0 3px 10px rgba(0,0,0,0.12); transform: translateY(-1px); }
.segmented button.active.st-working { color: var(--good); }
.segmented button.active.st-not-working { color: var(--bad); }
.segmented button.active.st-untested { color: var(--warn); }
.segmented button:active { transform: scale(0.94); }

.btn-row { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-round);
  font-size: 15.5px;
  font-weight: 650;
  text-align: center;
  transition: transform 0.3s var(--spring), opacity 0.2s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(155deg, #3aa0ff, var(--accent) 60%, #0a6fdb);
  color: #fff;
  box-shadow: 0 10px 22px -8px rgba(10,132,255,0.55), 0 1px 0 rgba(255,255,255,0.4) inset;
}
.btn-ghost {
  background: rgba(0,0,0,0.05);
  color: var(--ink);
}
.btn-danger { background: rgba(255,59,48,0.12); color: var(--bad); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.delete-link {
  width: 100%;
  text-align: center;
  margin-top: 14px;
  padding: 10px;
  font-size: 14px;
  font-weight: 650;
  color: var(--bad);
}
.delete-link:active { opacity: 0.6; }

/* settings sheet */
.settings-section { margin-bottom: 22px; }
.settings-section h3 {
  margin: 0 0 4px;
  font-size: 13px;
  text-transform: none;
  font-weight: 700;
  color: var(--ink-soft);
}
.settings-section .desc { font-size: 12.5px; color: var(--ink-faint); margin: 0 0 10px; line-height: 1.5; }
.status-banner {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 10px;
}
.status-banner.off { background: rgba(0,0,0,0.05); color: var(--ink-soft); }
.status-banner.on { background: rgba(43,178,76,0.12); color: #1f8f39; }
.status-banner.err { background: rgba(255,59,48,0.12); color: var(--bad); }
.status-banner .led { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.settings-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.settings-actions .btn { flex: 1 1 auto; min-width: 120px; }

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(100px + var(--safe-bottom));
  transform: translateX(-50%) translateY(20px) scale(0.9);
  padding: 12px 20px;
  border-radius: var(--radius-round);
  background: rgba(28,28,30,0.86);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.5s var(--spring), opacity 0.3s var(--ease-out);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  white-space: nowrap;
  max-width: 86vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }

/* offline pill */
.offline-pill {
  position: fixed;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  padding: 7px 14px;
  border-radius: var(--radius-round);
  background: rgba(28,28,30,0.88);
  color: #fff;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
  z-index: 90;
  display: flex; align-items: center; gap: 6px;
  transition: transform 0.5s var(--spring);
}
.offline-pill.show { transform: translateX(-50%) translateY(0); }
.offline-pill .led { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); }

/* ripple / press feedback helper */
.pressable { position: relative; overflow: hidden; }

@media (min-width: 560px) {
  .app { padding-left: 0; padding-right: 0; }
}
