:root {
  color-scheme: light;
  --bg: #f7fbff;
  --panel: rgba(255, 255, 255, 0.58);
  --panel-strong: rgba(255, 255, 255, 0.82);
  --text: #0f172a;
  --muted: #68758a;
  --line: rgba(255, 255, 255, 0.62);
  --line-dark: rgba(24, 57, 98, 0.12);
  --brand: #0a84ff;
  --brand-strong: #0057d9;
  --brand-soft: rgba(218, 235, 255, 0.78);
  --rose: #c45252;
  --blue: #0a84ff;
  --shadow: 0 18px 50px rgba(21, 47, 84, 0.12);
  --shadow-soft: 0 8px 24px rgba(21, 47, 84, 0.08);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.76);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(145deg, #ffffff 0%, #eef6ff 42%, #f8fbff 100%);
  color: var(--text);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 42%),
    linear-gradient(116deg, rgba(10, 132, 255, 0.18) 0 24%, rgba(255, 255, 255, 0) 24% 48%, rgba(90, 169, 255, 0.16) 48% 74%, rgba(255, 255, 255, 0) 74% 100%),
    repeating-linear-gradient(105deg, rgba(255, 255, 255, 0.22) 0 1px, rgba(255, 255, 255, 0) 1px 18px);
  pointer-events: none;
}

body::after {
  position: fixed;
  inset: auto 0 0;
  z-index: -1;
  height: 38vh;
  content: "";
  background: linear-gradient(0deg, rgba(10, 132, 255, 0.1), rgba(10, 132, 255, 0));
  pointer-events: none;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.loading-screen,
.auth-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: 24px 18px;
}

.loading-screen {
  justify-items: center;
  text-align: center;
}

.loading-screen h1,
.auth-screen h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.loading-screen p,
.auth-screen p {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  width: 72px;
  aspect-ratio: 1;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(232, 243, 255, 0.98), rgba(198, 225, 255, 0.88)) 50% 23% / 48% 18% no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(235, 244, 255, 0.86)) 50% 62% / 58% 58% no-repeat,
    var(--brand);
  box-shadow: 0 14px 34px rgba(10, 132, 255, 0.24), var(--glass-highlight);
}

.auth-card,
.panel,
.product-card,
.recipe-card,
.expiry-row {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.24));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
  backdrop-filter: blur(28px) saturate(1.35);
}

.auth-card::before,
.panel::before,
.product-card::before,
.recipe-card::before,
.expiry-row::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.1) 32%, rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.auth-card > *,
.panel > *,
.product-card > *,
.recipe-card > *,
.expiry-row > * {
  position: relative;
}

.auth-card {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 18px;
  box-shadow: 0 22px 52px rgba(21, 47, 84, 0.11), var(--glass-highlight);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(248, 251, 255, 0.66);
  border-bottom: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 30px rgba(24, 57, 98, 0.08);
  -webkit-backdrop-filter: blur(26px) saturate(1.35);
  backdrop-filter: blur(26px) saturate(1.35);
}

.app-title {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.app-title .brand-mark {
  width: 42px;
  border-radius: 13px;
  flex: 0 0 auto;
}

.app-title h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  color: var(--brand);
  border: 1px solid rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow-soft), var(--glass-highlight);
  font-size: 22px;
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

.screen {
  padding: 18px 14px calc(98px + env(safe-area-inset-bottom));
  max-width: 920px;
  margin: 0 auto;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1.1;
}

.section-title span,
.fine-print {
  color: var(--muted);
  font-size: 13px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat {
  min-width: 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  box-shadow: var(--shadow-soft), var(--glass-highlight);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
}

.stat strong {
  display: block;
  font-size: 25px;
  line-height: 1.1;
  color: var(--brand-strong);
}

.stat span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 0 0 12px;
}

.field,
.inline-field {
  display: grid;
  gap: 6px;
}

.field label,
.inline-field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.inline-field input,
.inline-field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(24, 57, 98, 0.1);
  border-radius: 8px;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82), 0 10px 22px rgba(24, 57, 98, 0.06);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-field input:focus,
.inline-field select:focus {
  border-color: rgba(10, 132, 255, 0.46);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.13), inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-cols {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  padding: 15px;
  margin-bottom: 14px;
  box-shadow: var(--shadow), var(--glass-highlight);
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.action-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  padding: 11px 15px;
  font-weight: 800;
  box-shadow: var(--shadow-soft), var(--glass-highlight);
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.primary:active,
.secondary:active,
.danger:active,
.ghost:active,
.mini-button:active,
.sync-button:active,
.nav-button:active {
  transform: scale(0.98);
}

.primary {
  background: linear-gradient(180deg, #2f9bff, var(--brand-strong));
  color: white;
}

.primary:active {
  background: var(--brand-strong);
}

.secondary {
  background:
    linear-gradient(180deg, rgba(242, 248, 255, 0.92), rgba(218, 235, 255, 0.76));
  color: var(--brand-strong);
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.danger {
  background: rgba(249, 225, 222, 0.78);
  color: #8e2727;
  border: 1px solid rgba(255, 255, 255, 0.72);
}

.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid rgba(255, 255, 255, 0.64);
}

.product-list,
.recipe-list,
.expiry-list {
  display: grid;
  gap: 10px;
}

.product-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 12px;
  box-shadow: var(--shadow), var(--glass-highlight);
}

.product-image,
.product-placeholder {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  object-fit: cover;
  background:
    linear-gradient(145deg, rgba(233, 244, 255, 0.96), rgba(215, 234, 255, 0.9)),
    linear-gradient(45deg, rgba(10, 132, 255, 0.12), rgba(94, 156, 255, 0.1));
  border: 1px solid rgba(255, 255, 255, 0.62);
}

.product-placeholder {
  display: grid;
  place-items: center;
  color: var(--brand);
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.product-main {
  min-width: 0;
}

.product-main h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.48);
  color: #506179;
  border: 1px solid rgba(255, 255, 255, 0.58);
  font-weight: 700;
  font-size: 12px;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.badge.good {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.badge.warn {
  background: #fff0ea;
  color: #a4471f;
}

.badge.bad {
  background: #f6ddda;
  color: #8e2727;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.mini-button {
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: var(--brand);
  font-weight: 800;
  box-shadow: var(--shadow-soft), var(--glass-highlight);
}

.empty-state {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
  border: 1px dashed rgba(24, 57, 98, 0.18);
  border-radius: 8px;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.bottom-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 25;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  box-shadow: 0 18px 48px rgba(21, 47, 84, 0.16), var(--glass-highlight);
  -webkit-backdrop-filter: blur(30px) saturate(1.45);
  backdrop-filter: blur(30px) saturate(1.45);
}

.nav-button {
  min-width: 0;
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: 21px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nav-button span:first-child {
  width: 27px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
}

.nav-button.active {
  background: rgba(255, 255, 255, 0.76);
  color: var(--brand-strong);
  box-shadow: 0 8px 20px rgba(21, 47, 84, 0.1), var(--glass-highlight);
}

.nav-button.active span:first-child {
  color: white;
  background: linear-gradient(180deg, #2f9bff, #0057d9);
  box-shadow: 0 8px 16px rgba(10, 132, 255, 0.24);
}

.message {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 50;
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: rgba(0, 87, 217, 0.84);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
}

.message.error {
  background: var(--rose);
}

.message-inline {
  padding: 12px 14px;
  margin: 0 0 12px;
  border-radius: 8px;
  color: white;
  background: rgba(0, 87, 217, 0.84);
  box-shadow: var(--shadow-soft);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.message-inline.error {
  background: var(--rose);
}

.scanner-frame {
  overflow: hidden;
  border-radius: 22px;
  background: #0b1220;
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
}

.scanner-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.38);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.segmented label {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 800;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented input:checked + span {
  background: var(--panel-strong);
  color: var(--brand-strong);
  box-shadow: 0 4px 14px rgba(21, 47, 84, 0.08);
}

.segmented span {
  width: 100%;
  min-height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
}

.recipe-card {
  padding: 14px;
  box-shadow: var(--shadow), var(--glass-highlight);
}

.recipe-card h3 {
  margin: 0 0 8px;
  font-size: 19px;
}

.recipe-card ol {
  margin: 10px 0 0;
  padding-left: 22px;
}

.recipe-card li {
  margin: 0 0 8px;
}

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

.expiry-row {
  padding: 12px;
  box-shadow: var(--shadow-soft), var(--glass-highlight);
}

.expiry-row h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  font-size: 16px;
}

.expiry-row p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.profile-choice {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.profile-choice label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: var(--shadow-soft), var(--glass-highlight);
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .screen {
    padding-left: 22px;
    padding-right: 22px;
  }

  .product-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .recipe-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (max-width: 430px) {
  .two-cols,
  .three-cols {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .auth-screen {
    align-content: start;
    padding-top: max(28px, env(safe-area-inset-top));
  }
}

@supports not ((backdrop-filter: blur(10px)) or (-webkit-backdrop-filter: blur(10px))) {
  .auth-card,
  .panel,
  .product-card,
  .recipe-card,
  .expiry-row,
  .bottom-nav,
  .app-header,
  .sync-button,
  .stat,
  .badge,
  .empty-state,
  .message,
  .message-inline {
    background: rgba(255, 255, 255, 0.9);
  }
}
