:root {
  color-scheme: light;
  --paper: #f7fbff;
  --paper-deep: #eef6ff;
  --paper-warm: #fff8ee;
  --ink: #172033;
  --muted: #718097;
  --line: #dbe7f3;
  --yellow: #ffd861;
  --yellow-soft: #fff6c9;
  --green: #20a37a;
  --green-soft: #e8fbf4;
  --blue: #4f8cff;
  --blue-soft: #eaf2ff;
  --coral: #ff7b72;
  --white: #ffffff;
  --danger: #d35b51;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { max-width: 100%; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 216, 97, 0.32), transparent 22rem),
    radial-gradient(circle at 92% 4%, rgba(79, 140, 255, 0.22), transparent 24rem),
    linear-gradient(135deg, var(--paper), var(--paper-deep) 58%, var(--paper-warm));
}

button, input, select { font: inherit; }
button { display: inline-flex; align-items: center; justify-content: center; line-height: 1.15; cursor: pointer; }

main { width: min(1760px, calc(100% - 22px)); min-width: 0; margin: 0 auto; padding: 18px 0 40px; }

.login-card {
  width: min(600px, 100%);
  margin: 11vh auto 0;
  padding: clamp(28px, 6vw, 56px);
  border: 1px solid rgba(74, 67, 53, 0.18);
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 24px 70px rgba(91, 116, 144, 0.16);
  backdrop-filter: blur(16px);
}

.brand-mark {
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  margin-bottom: 34px;
  border-radius: 50%;
  color: var(--white);
  background: linear-gradient(135deg, var(--blue), var(--green));
  font-family: Georgia, serif;
  font-weight: 700;
}

h1, h2, p { margin-top: 0; }
h1, h2 { font-weight: 700; letter-spacing: -0.04em; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 1; }
h2 { margin-bottom: 0; font-size: 1.55rem; }

.eyebrow {
  margin-bottom: 8px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.intro { max-width: 470px; margin-bottom: 32px; color: var(--muted); line-height: 1.55; }
label { display: block; margin-bottom: 7px; font-size: 0.78rem; font-weight: 600; }

input, select {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  outline: none;
  background: var(--white);
}

input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.14); }

.input-row { display: flex; gap: 10px; }
.input-row input { flex: 1; }
.input-row button, .button-icon-text, .status-banner button {
  padding: 12px 19px;
  border: 0;
  border-radius: 14px;
  color: var(--white);
  background: linear-gradient(135deg, var(--blue), var(--green));
  font-weight: 600;
}

.form-status, .form-error { min-height: 1.2em; margin: 10px 0 0; font-size: 0.85rem; }
.form-status { color: var(--muted); }
.form-error { margin-top: 0; color: var(--danger); }

.app-header { display: flex; width: 100%; min-width: 0; max-width: 100%; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.app-header > div:first-child { min-width: 0; }
.app-header h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 3.25rem); }
.header-actions { display: flex; min-width: 0; max-width: 100%; align-items: center; gap: 9px; }
.points-badge { position: relative; display: flex; min-width: 48px; height: 42px; align-items: center; justify-content: center; gap: 5px; padding: 0 11px; border: 1px solid #f0d36d; border-radius: 999px; color: #725512; background: var(--yellow-soft); white-space: nowrap; cursor: help; }
.points-badge > span { color: #d79d00; }
.points-badge strong { font-size: 0.95rem; font-weight: 700; }
.points-badge::after { position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; width: max-content; max-width: min(260px, calc(100vw - 24px)); padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: var(--white); box-shadow: 0 8px 22px rgba(42, 63, 91, 0.16); content: attr(data-tooltip); font-size: 0.7rem; font-weight: 500; line-height: 1.35; white-space: normal; opacity: 0; pointer-events: none; transform: translateY(-3px); transition: opacity 120ms ease, transform 120ms ease; }
.points-badge:hover::after, .points-badge:focus-visible::after { opacity: 1; transform: translateY(0); }
.points-badge:focus-visible { outline: 3px solid rgba(240, 211, 109, 0.38); outline-offset: 2px; }
.concept-toggle { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.72); }
.concept-toggle-button { padding: 7px 11px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 0.76rem; font-weight: 600; }
.concept-toggle-button.active { color: var(--white); background: linear-gradient(135deg, var(--blue), var(--green)); }
.button-quiet { padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); background: rgba(255, 255, 255, 0.7); }
.button-quiet:hover { background: var(--white); box-shadow: 0 8px 18px rgba(91, 116, 144, 0.12); }
.scan-header-button { width: 52px; height: 52px; flex: 0 0 52px; padding: 0; border: 0; border-radius: 17px; color: var(--white); background: linear-gradient(135deg, var(--green), var(--blue)); box-shadow: 0 10px 24px rgba(43, 146, 133, 0.25); transition: transform 150ms ease, box-shadow 150ms ease; }
.scan-header-button:hover { transform: translateY(-1px); box-shadow: 0 13px 28px rgba(43, 146, 133, 0.32); }
.scan-header-button:active { transform: translateY(0); }
.scan-header-button:focus-visible { outline: 3px solid rgba(79, 140, 255, 0.28); outline-offset: 3px; }
.scan-header-icon { width: 29px; height: 29px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.app-menu { position: relative; }
.app-menu summary { list-style: none; }
.app-menu summary::-webkit-details-marker { display: none; }
.header-menu-button { display: grid; width: 40px; height: 40px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: rgba(255, 255, 255, 0.76); font-weight: 900; letter-spacing: 0.08em; cursor: pointer; }
.header-menu-button:hover, .app-menu[open] .header-menu-button { border-color: #b9d1eb; background: var(--white); box-shadow: 0 8px 18px rgba(91, 116, 144, 0.14); }
.app-menu-popover { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: min(330px, calc(100vw - 20px)); max-height: min(620px, calc(100dvh - 80px)); padding: 12px; overflow-y: auto; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.98); box-shadow: 0 18px 50px rgba(42, 63, 91, 0.2); }
.menu-label { display: block; margin: 0 3px 7px; color: var(--muted); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.app-menu-popover .concept-toggle { width: 100%; }
.app-menu-popover .concept-toggle-button { flex: 1; }
.matching-menu-label { margin-top: 13px; }
.matching-lab { margin-top: 8px; border-top: 1px solid var(--line); }
.matching-lab > summary { padding: 9px 3px 3px; color: var(--blue); font-size: 0.74rem; font-weight: 600; cursor: pointer; }
.matching-lab form { display: grid; gap: 6px; padding-top: 7px; }
.matching-lab input { width: 100%; min-width: 0; padding: 8px 10px; }
.matching-lab button { width: 100%; }
.matching-results { margin-top: 7px; color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.matching-results p { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 6px; margin: 5px 0 0; }
.matching-results strong { color: var(--ink); }
.matching-results span { overflow-wrap: anywhere; }
.menu-storage-button { width: 100%; margin-top: 9px; }
.reward-toast { position: fixed; z-index: 1000; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100% - 24px)); padding: 13px 16px; border: 1px solid #efd16a; border-radius: 16px; color: #5f4710; background: #fff8d7; box-shadow: 0 18px 45px rgba(75, 64, 27, 0.2); font-size: 0.86rem; font-weight: 600; }
.reward-toast-icon { display: grid; flex: 0 0 auto; width: 28px; height: 28px; place-items: center; border-radius: 50%; color: var(--white); background: #e3aa12; }

.barcode-dialog { width: min(440px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 16px; overflow-y: auto; border: 1px solid var(--line); border-radius: 22px; color: var(--ink); background: rgba(255, 255, 255, 0.98); box-shadow: 0 28px 90px rgba(23, 32, 51, 0.25); }
.barcode-dialog::backdrop { background: rgba(23, 32, 51, 0.34); backdrop-filter: blur(5px); }
.barcode-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.barcode-dialog-heading h2 { font-size: 1.3rem; }
.barcode-close { width: 32px; height: 32px; color: var(--ink); background: var(--paper-deep); font-size: 1.25rem; }
.barcode-mode-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 10px; padding: 3px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.barcode-mode-button { padding: 8px 9px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 0.82rem; font-weight: 600; }
.barcode-mode-button.active { color: var(--white); background: linear-gradient(135deg, var(--blue), var(--green)); }
.barcode-camera-box { position: relative; display: grid; min-height: 170px; margin-bottom: 8px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #13202b; }
.barcode-camera-box video { display: block; width: 100%; height: 170px; object-fit: cover; }
.barcode-camera-placeholder { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; color: #d9e6f2; text-align: center; }
.barcode-camera-button { width: 100%; }
.barcode-result { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 9px; margin-top: 9px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.barcode-result[data-kind="success"] { border-color: #bfe4d4; background: var(--green-soft); }
.barcode-result[data-kind="warning"] { border-color: #ead16a; background: var(--yellow-soft); }
.barcode-result[data-kind="error"] { border-color: #efc1bc; background: #fff0ed; }
.barcode-result-icon { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: var(--green); background: var(--white); font-weight: 900; }
.barcode-result strong { display: block; font-size: 0.82rem; font-weight: 600; }
.barcode-status { min-height: 0; margin: 2px 0 0; color: var(--muted); font-size: 0.74rem; line-height: 1.35; overflow-wrap: anywhere; }
.barcode-manual-disclosure { margin-top: 8px; }
.barcode-manual-disclosure > summary { padding: 5px 2px; list-style: none; color: var(--blue); font-size: 0.75rem; font-weight: 600; text-align: center; cursor: pointer; }
.barcode-manual-disclosure > summary::-webkit-details-marker { display: none; }
.barcode-manual-disclosure > summary::after { content: ' ›'; }
.barcode-manual-form { padding-top: 7px; }
.barcode-bind-panel { margin-top: 9px; padding: 11px; border: 1px solid #ead16a; border-radius: 15px; background: var(--yellow-soft); }
.barcode-bind-panel > strong { font-size: 0.86rem; }
.barcode-bind-panel p { margin: 3px 0 9px; color: var(--muted); font-size: 0.72rem; line-height: 1.35; }
.barcode-bind-panel select { flex: 1; }
.barcode-create-divider { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: var(--muted); font-size: 0.68rem; }
.barcode-create-divider::before, .barcode-create-divider::after { height: 1px; flex: 1; content: ''; background: rgba(113, 128, 151, 0.25); }
#barcode-create-product { white-space: nowrap; }

.status-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; padding: 11px 14px; border-radius: 16px; color: #9d3b35; background: #ffe6e2; }
.status-banner[data-kind="loading"] { color: #5e573e; background: #eee4bf; }
.status-banner button { padding: 7px 10px; }

.tabs { position: sticky; top: 0; z-index: 5; display: flex; min-width: 0; gap: 8px; margin-bottom: 12px; padding: 5px; border: 1px solid rgba(133, 167, 205, 0.28); border-radius: 999px; background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(91, 116, 144, 0.1); }
.tab-button { display: inline-flex; flex: 0 1 150px; min-width: 0; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-weight: 600; }
.tab-button > span[aria-hidden] { font-size: 1rem; line-height: 1; }
.tab-button.active { color: var(--white); background: linear-gradient(135deg, var(--coral), var(--blue)); box-shadow: 0 10px 22px rgba(79, 140, 255, 0.22); }

.dashboard { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); align-items: start; gap: 12px; }
.panel { overflow: hidden; border: 1px solid rgba(133, 167, 205, 0.25); border-radius: 26px; background: rgba(255, 255, 255, 0.82); box-shadow: 0 18px 50px rgba(91, 116, 144, 0.1); }
.pantry-panel { min-height: calc(100vh - 126px); padding: clamp(12px, 2vw, 20px); }
.shopping-panel { padding: 16px; color: var(--ink); background: rgba(255, 255, 255, 0.68); }
.shopping-panel .eyebrow { color: var(--blue); }
.consumables-panel, .history-panel, .stats-panel { padding: clamp(16px, 3vw, 28px); }
.history-panel { min-height: calc(100vh - 126px); }
.stats-panel { min-height: calc(100vh - 126px); }

.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.counter { display: grid; min-width: 30px; height: 30px; place-items: center; border-radius: 999px; color: #775c00; background: var(--yellow-soft); font-weight: 700; font-size: 0.86rem; }
.counter-dark { color: #775c00; background: var(--yellow-soft); }

.add-product-form { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(90px, 0.24fr) minmax(170px, 0.52fr) auto; align-items: end; gap: 8px; padding: 10px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 18px; background: rgba(247, 251, 255, 0.78); }
.add-product-form input, .add-product-form select { width: 100%; height: 44px; }
.add-product-form > button { min-height: 44px; }
.stock-tools { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 17px; background: rgba(247, 251, 255, 0.72); }
.stock-tools > summary { display: flex; align-items: center; gap: 7px; padding: 9px 12px; list-style: none; color: var(--green); font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.stock-tools > summary::-webkit-details-marker { display: none; }
.stock-tools > summary::after { margin-left: auto; content: '⌄'; color: var(--muted); transition: transform 160ms ease; }
.stock-tools[open] > summary::after { transform: rotate(180deg); }
.stock-tools > summary small { color: var(--muted); font-size: 0.68rem; font-weight: 500; }
.stock-tools-content { padding: 0 8px 8px; border-top: 1px solid transparent; }
.stock-tools[open] .stock-tools-content { border-top-color: var(--line); padding-top: 8px; }
.stock-tools .add-product-form { margin-bottom: 8px; padding: 0; border: 0; background: transparent; }
.stock-view-settings { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stock-view-settings > span { color: var(--muted); font-size: 0.72rem; font-weight: 600; }
.stock-view-settings .view-toggle { margin: 0; }
.device-form { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(140px, 0.8fr) minmax(180px, 1fr) auto; align-items: end; gap: 10px; padding: 16px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 253, 248, 0.7); }
.device-form input { width: 100%; }
.button-icon-text { gap: 6px; white-space: nowrap; }
.button-icon-text > span[aria-hidden], .stock-tools > summary > span[aria-hidden], .tab-button > span[aria-hidden] { display: inline-grid; place-items: center; line-height: 1; }
.hint { margin: 7px 0 6px; color: var(--muted); font-size: 0.73rem; line-height: 1.35; }
.safety-note { max-width: 760px; margin-bottom: 16px; padding: 11px 13px; border-left: 4px solid var(--yellow); border-radius: 10px; background: rgba(255, 243, 184, 0.55); }
.view-toggle { display: inline-flex; gap: 4px; margin: 0 0 8px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, 0.62); }
.view-toggle-button { padding: 6px 11px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 0.78rem; font-weight: 600; }
.view-toggle-button.active { color: var(--white); background: linear-gradient(135deg, var(--blue), var(--green)); }
.quick-mode-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding: 12px 14px; border: 1px solid #cdeadd; border-radius: 18px; background: linear-gradient(135deg, var(--green-soft), rgba(234, 242, 255, 0.78)); }
.quick-mode-toolbar > div:first-child { display: grid; gap: 2px; }
.quick-mode-toolbar strong { font-size: 0.92rem; }
.quick-mode-toolbar span { color: var(--muted); font-size: 0.72rem; }
.quick-filter { display: flex; gap: 3px; padding: 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.8); }
.quick-filter-button { padding: 7px 10px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 0.72rem; font-weight: 600; white-space: nowrap; }
.quick-filter-button.active { color: var(--ink); background: var(--white); box-shadow: 0 4px 12px rgba(91, 116, 144, 0.12); }
#app-view[data-interface-mode="quick"] .classic-stock-control { display: none; }
.voice-panel { display: grid; grid-template-columns: auto minmax(150px, 1fr) auto; align-items: center; gap: 7px; margin: 0 0 8px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.58); color: var(--muted); font-size: 0.78rem; }
.voice-button { flex: 0 0 auto; padding: 7px 11px; font-weight: 600; }
.voice-submit { padding: 7px 11px; font-weight: 600; }
.voice-panel input { min-height: 32px; padding: 6px 9px; border-radius: 11px; font-size: 0.82rem; }
.voice-panel span { grid-column: 1 / -1; }

.product-list, .shopping-list, .category-products, .device-list, .consumable-list, .history-list { padding: 0; margin: 0; list-style: none; }
.product-list { max-height: none; overflow: visible; padding-right: 0; }
.pantry-panel { overflow: visible; }
.product-group { margin-top: 8px; }
.product-group:first-child { margin-top: 2px; }
.category-heading { position: sticky; top: 58px; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(10px); }
.category-heading h3 { margin: 0; color: var(--blue); font-size: 0.64rem; letter-spacing: 0.055em; text-transform: uppercase; }
.category-heading span { color: var(--muted); font-size: 0.66rem; font-weight: 600; }
.product-item { display: grid; grid-template-columns: 22px minmax(140px, 1fr) 24px minmax(68px, 0.16fr) 24px 24px 24px; align-items: center; gap: 5px; min-height: 29px; margin-top: 2px; padding: 2px 6px; border: 1px solid transparent; border-radius: 8px; font-size: 0.82rem; transition: background 150ms ease, border-color 150ms ease, transform 150ms ease; }
.product-item:hover { background: rgba(234, 242, 255, 0.55); }
.product-item.needed { border-color: #f0d26e; background: var(--yellow-soft); }
.product-check, .shopping-check { width: 18px; height: 18px; margin: 0; accent-color: var(--green); }
.product-title { display: flex; min-width: 0; align-items: center; gap: 6px; }
.product-name { min-width: 0; overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.stock-badge { flex: 0 0 auto; padding: 2px 6px; border-radius: 999px; color: #956b00; background: #fff0a8; font-size: 0.64rem; font-weight: 600; line-height: 1.25; letter-spacing: 0.015em; }
.amount-input { width: 100%; min-height: 24px; padding: 2px 4px; border-color: transparent; border-radius: 7px; background: rgba(255, 255, 255, 0.72); font-size: 0.8rem; font-variant-numeric: tabular-nums; text-align: center; }
.product-item:not(.needed) .amount-input { background: transparent; }

.icon-button { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 7px; color: var(--muted); background: transparent; line-height: 1; text-align: center; }
.icon-button:hover { color: var(--ink); background: rgba(79, 140, 255, 0.12); }
.amount-step { color: var(--blue); background: rgba(79, 140, 255, 0.08); font-size: 0.9rem; font-weight: 700; line-height: 1; }
.amount-step:hover { color: var(--white); background: linear-gradient(135deg, var(--blue), var(--green)); }
.add-to-cart { color: var(--green); }
.delete-button:hover { color: var(--danger); }

.quick-product-item { display: grid; grid-template-columns: minmax(160px, 1fr) auto auto; align-items: center; gap: 8px; min-height: 48px; margin-top: 5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.72); }
.quick-product-item.needed { border-color: #f0d26e; background: var(--yellow-soft); }
.quick-product-title { display: grid; min-width: 0; gap: 2px; }
.quick-product-title strong { overflow: hidden; font-size: 0.88rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.quick-product-title small { color: var(--muted); font-size: 0.7rem; }
.quick-product-actions { display: flex; gap: 5px; }
.quick-action { min-height: 32px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: var(--white); font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.status-action { color: #876100; border-color: #ead16a; background: #fff9dc; }
.status-action.active { color: #725500; background: #ffeaa0; }
.status-action.static-status { cursor: default; color: var(--danger); border-color: #f2c1bb; background: #fff0ed; }
.empty-action { color: var(--danger); }
.buy-action { color: var(--green); }
.quick-action:not(.static-status):hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(91, 116, 144, 0.12); }

.quick-add { display: flex; gap: 7px; margin-bottom: 10px; }
.quick-add input { flex: 1; border-color: var(--line); color: var(--ink); background: var(--white); }
.quick-add input::placeholder { color: #9aa8ba; }
.quick-add input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.14); }
.quick-add button { width: 42px; border: 0; border-radius: 14px; color: var(--white); background: linear-gradient(135deg, var(--coral), var(--yellow)); font-size: 1.15rem; font-weight: 700; }

.shopping-item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.shopping-check { accent-color: var(--green); }
.shopping-text { overflow-wrap: anywhere; }
.shopping-item.done .shopping-text { color: #9aa8ba; text-decoration: line-through; }
.shopping-item .icon-button { color: var(--muted); }
.shopping-item .icon-button:hover { color: var(--danger); background: #fff0ed; }
.clear-completed { width: 100%; margin-top: 12px; padding: 9px; border: 1px solid var(--line); border-radius: 14px; color: var(--muted); background: var(--white); }

@media (min-width: 1100px) {
  .shopping-panel { position: sticky; top: 62px; }
}

.device-list { display: grid; gap: 14px; }
.device-card { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 253, 248, 0.78); }
.device-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.device-card h3 { margin: 0 0 3px; font-family: Georgia, "Times New Roman", serif; font-size: 1.45rem; font-weight: 500; }
.device-card-header p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.device-details { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 12px; margin-bottom: 14px; }
.plate-photo-box { display: grid; min-height: 116px; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); background: rgba(255, 255, 255, 0.5); font-size: 0.8rem; }
.plate-photo-box img { width: 100%; height: 100%; object-fit: cover; }
.device-edit-grid { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(120px, 0.8fr); align-content: start; gap: 8px; }
.device-edit-grid input[type="file"] { grid-column: 1 / -1; padding: 9px; font-size: 0.82rem; }
.compact-input { width: 100%; padding: 7px 9px; border-radius: 8px; font-size: 0.86rem; }
.strong-input { font-weight: 600; }
.consumable-list { display: grid; gap: 8px; margin-bottom: 12px; }
.consumable-item { display: grid; grid-template-columns: 58px minmax(180px, 1.2fr) minmax(170px, 0.9fr) minmax(190px, 1fr) auto; align-items: center; gap: 8px; padding: 9px; border: 1px solid transparent; border-radius: 12px; background: rgba(255, 255, 255, 0.52); }
.consumable-item.due { border-color: #e7b0a7; background: #fff0ed; }
.consumable-item.soon { border-color: #ead16a; background: var(--yellow-soft); }
.consumable-main, .consumable-schedule, .consumable-actions { display: flex; gap: 7px; }
.consumable-main { min-width: 0; }
.consumable-photo-box { display: grid; width: 58px; height: 44px; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); background: rgba(255, 255, 255, 0.62); font-size: 0.68rem; }
.consumable-photo-box img { width: 100%; height: 100%; object-fit: cover; }
.reminder-text { margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.3; }
.consumable-actions { justify-content: end; }
.consumable-actions button, .consumable-form button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--green); background: var(--white); font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.consumable-actions button:hover, .consumable-form button:hover { background: rgba(73, 102, 78, 0.08); }
.consumable-photo-input { max-width: 112px; padding: 6px; border-radius: 8px; font-size: 0.7rem; }
.consumable-form { display: grid; grid-template-columns: minmax(160px, 1.2fr) minmax(110px, 0.7fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr) minmax(130px, 0.8fr) auto; gap: 7px; padding-top: 10px; border-top: 1px solid var(--line); }
.consumable-form input { width: 100%; padding: 8px 9px; border-radius: 8px; font-size: 0.84rem; }

.history-panel .panel-heading { margin-bottom: 16px; }
.history-panel .hint { margin-bottom: 12px; }
.analytics-consent { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid #cfe4d2; border-radius: 16px; background: rgba(239, 249, 240, 0.72); cursor: pointer; }
.analytics-consent input { flex: 0 0 auto; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--green); }
.analytics-consent span { display: grid; gap: 3px; }
.analytics-consent strong { font-size: 0.88rem; font-weight: 600; }
.analytics-consent small { color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.login-consent { margin-top: 14px; }
.history-switch { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(247, 251, 255, 0.75); }
.history-switch-button { min-height: 34px; padding: 6px 11px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 0.78rem; font-weight: 500; }
.history-switch-button.active { color: var(--ink); background: var(--white); box-shadow: 0 2px 8px rgba(55, 82, 107, 0.1); }
.history-switch-button span { margin-left: 3px; color: var(--blue); font-variant-numeric: tabular-nums; }
.history-list { display: grid; gap: 8px; margin-top: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 18px; background: rgba(247, 251, 255, 0.6); }
.history-list:empty { display: none; }
.history-item { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.62); }
.history-time { color: var(--muted); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.history-body { min-width: 0; }
.history-body p { margin: 0 0 3px; font-size: 0.92rem; font-weight: 600; }
.history-body small { color: var(--muted); overflow-wrap: anywhere; }
.scan-failure-list .history-item { border-color: #efcfca; background: rgba(255, 245, 242, 0.7); }
.scan-failure-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.scan-attempts { display: grid; gap: 3px; margin-top: 6px; }
.scan-attempt { color: var(--muted); font-size: 0.74rem; overflow-wrap: anywhere; }

.stats-heading { align-items: center; }
.dashboard-status { min-height: 1.3em; margin: 8px 0 14px; color: var(--muted); font-size: 0.8rem; }
.stats-panel, .stats-grid, .stats-details, .stats-block { min-width: 0; max-width: 100%; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(155px, 100%), 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card { min-width: 0; min-height: 104px; padding: 14px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255, 255, 255, 0.72); }
.stat-card.accent { border-color: #cfe4d2; background: rgba(232, 251, 244, 0.72); }
.stat-card.warning { border-color: #efd77e; background: rgba(255, 246, 201, 0.72); }
.stat-card strong { display: block; min-width: 0; margin-bottom: 6px; color: var(--ink); font-size: 1.7rem; line-height: 1; overflow-wrap: anywhere; }
.stat-card span { color: var(--muted); font-size: 0.76rem; font-weight: 600; line-height: 1.3; }
.stat-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 0.68rem; overflow-wrap: anywhere; }
.stats-details { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr); gap: 12px; }
.stats-block { padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.62); }
.stats-block h3, .stats-block h4 { margin: 0; }
.stats-block h3 { font-size: 1rem; }
.stats-block h4 { margin-top: 16px; font-size: 0.82rem; }
.stats-block-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.stats-block-heading strong { color: var(--green); font-size: 0.76rem; }
.scan-trend { display: grid; gap: 6px; }
.scan-day { display: grid; min-width: 0; grid-template-columns: 44px minmax(0, 1fr) 28px; align-items: center; gap: 8px; font-size: 0.72rem; }
.scan-day time { color: var(--muted); font-weight: 600; }
.scan-bar { height: 9px; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.scan-bar span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--green)); }
.scan-day b { min-width: 0; text-align: right; overflow-wrap: anywhere; }
.catalog-breakdown { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; margin: 14px 0 0; font-size: 0.78rem; }
.catalog-breakdown dt { min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.catalog-breakdown dd { min-width: 0; margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.top-products { display: grid; gap: 6px; margin: 9px 0 0; padding-left: 22px; font-size: 0.78rem; }
.top-products li { min-width: 0; padding-left: 3px; overflow-wrap: anywhere; }
.top-products span { float: right; color: var(--muted); font-weight: 600; }
.stats-note { margin: 12px 0 0; color: var(--muted); font-size: 0.68rem; line-height: 1.4; }
.matching-stats-block { grid-column: 1 / -1; }
.provider-stats-block { grid-column: 1 / -1; }
.matching-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 14px 0; }
.matching-summary > div { min-width: 0; }
.matching-summary dt { color: var(--muted); font-size: 0.68rem; line-height: 1.3; }
.matching-summary dd { margin: 3px 0 0; color: var(--ink); font-size: 0.9rem; font-weight: 600; overflow-wrap: anywhere; }
.matching-mode-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.matching-mode-card { min-width: 0; padding: 11px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(247, 251, 255, 0.72); }
.matching-mode-card > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.matching-mode-card strong { font-size: 0.78rem; }
.matching-mode-card span, .matching-mode-card small { color: var(--muted); font-size: 0.68rem; }
.matching-mode-card p { margin: 8px 0 3px; font-size: 0.74rem; }
.provider-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.provider-secondary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.provider-secondary-grid h4 { margin: 0 0 7px; }
.provider-error-list { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.provider-error-list li { display: flex; min-width: 0; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.74rem; overflow-wrap: anywhere; }
.provider-error-list b { color: var(--ink); font-variant-numeric: tabular-nums; }

.empty-state { padding: 42px 12px; text-align: center; color: var(--muted); }
.empty-state span { display: inline-grid; width: 44px; height: 44px; place-items: center; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 50%; font-size: 1.4rem; }
.empty-state p { margin-bottom: 4px; color: var(--ink); font-weight: 600; }
.empty-state small { font-size: 0.78rem; }
.empty-dark { color: var(--muted); }
.empty-dark span { border-color: var(--line); }
.empty-dark p { color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

button:disabled, input:disabled, select:disabled { cursor: wait; opacity: 0.55; }

.site-footer { display: flex; width: min(1760px, calc(100% - 22px)); align-items: center; justify-content: center; gap: 9px; margin: 0 auto; padding: 4px 0 22px; color: var(--muted); font-size: 0.72rem; text-align: center; }
.site-footer a { color: var(--blue); font-weight: 600; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer span::before { margin-right: 9px; content: '·'; }

.docs-shell { width: min(1180px, calc(100% - 24px)); padding-bottom: 24px; }
.docs-hero { max-width: 880px; padding: 42px 0 28px; }
.docs-hero h1 { max-width: 780px; }
.docs-hero > p:last-child { max-width: 760px; color: var(--muted); font-size: 1rem; line-height: 1.65; }
.docs-back { display: inline-flex; margin-bottom: 30px; color: var(--blue); font-size: 0.82rem; font-weight: 600; text-decoration: none; }
.docs-back:hover { text-decoration: underline; }
.docs-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: 22px; }
.docs-toc { position: sticky; top: 18px; display: grid; gap: 5px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255, 255, 255, 0.78); backdrop-filter: blur(12px); }
.docs-toc strong { margin-bottom: 5px; font-size: 0.82rem; }
.docs-toc a { padding: 4px 0; color: var(--muted); font-size: 0.74rem; line-height: 1.3; text-decoration: none; }
.docs-toc a:hover { color: var(--blue); }
.docs-content { display: grid; min-width: 0; gap: 14px; }
.docs-section { min-width: 0; padding: clamp(20px, 4vw, 34px); border: 1px solid var(--line); border-radius: 24px; background: rgba(255, 255, 255, 0.82); box-shadow: 0 14px 38px rgba(91, 116, 144, 0.08); }
.docs-section h2 { margin-bottom: 18px; font-size: clamp(1.4rem, 4vw, 2rem); }
.docs-section h3 { margin: 26px 0 10px; font-size: 1.02rem; }
.docs-section p, .docs-section li { color: #40506a; font-size: 0.88rem; line-height: 1.65; }
.docs-section p:last-child, .docs-section ul:last-child, .docs-section ol:last-child { margin-bottom: 0; }
.docs-section ul, .docs-section ol { display: grid; gap: 5px; padding-left: 22px; }
.docs-section code { padding: 1px 5px; border-radius: 6px; color: #315d9f; background: var(--blue-soft); font-size: 0.85em; overflow-wrap: anywhere; }
.docs-section pre { max-width: 100%; margin: 14px 0; padding: 16px; overflow-x: auto; border: 1px solid #cbdced; border-radius: 16px; color: #dceaff; background: #17263b; }
.docs-section pre code { padding: 0; color: inherit; background: transparent; font-size: 0.78rem; line-height: 1.55; white-space: pre; }
.docs-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr; align-items: center; gap: 7px; margin: 16px 0 22px; }
.docs-flow span { padding: 10px 7px; border: 1px solid var(--line); border-radius: 12px; color: #315d9f; background: var(--blue-soft); font-size: 0.72rem; font-weight: 600; text-align: center; }
.docs-flow b { color: var(--green); }
.docs-callout { margin: 18px 0; padding: 14px 16px; border: 1px solid #bfe4d4; border-radius: 16px; background: var(--green-soft); }
.docs-callout.docs-warning { border-color: #efd77e; background: var(--yellow-soft); }
.docs-callout strong { font-size: 0.86rem; }
.docs-callout p { margin: 5px 0 0; font-size: 0.8rem; }
.docs-table-wrap { max-width: 100%; margin: 14px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
.docs-section table { width: 100%; min-width: 560px; border-collapse: collapse; background: rgba(255, 255, 255, 0.62); }
.docs-section th, .docs-section td { padding: 10px 12px; border-bottom: 1px solid var(--line); color: #40506a; font-size: 0.78rem; line-height: 1.45; text-align: left; vertical-align: top; }
.docs-section th { color: var(--ink); background: var(--paper-deep); font-weight: 600; }
.docs-section tr:last-child td { border-bottom: 0; }

@media (max-width: 820px) {
  .dashboard { grid-template-columns: 1fr; }
  .shopping-panel { order: 2; }
  .pantry-panel { min-height: auto; }
  .device-form, .device-details, .consumable-item, .consumable-form { grid-template-columns: 1fr; }
  .provider-secondary-grid { grid-template-columns: 1fr; }
  .stats-details { grid-template-columns: minmax(0, 1fr); }
  .consumable-main, .consumable-schedule, .consumable-actions { flex-wrap: wrap; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-toc { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .docs-toc strong { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  main { width: min(100% - 12px, 1180px); padding-top: 10px; }
  input, select { font-size: 16px; }
  .login-card { margin-top: 4vh; border-radius: 20px; }
  .app-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
  .app-header h1 { font-size: clamp(1.55rem, 9vw, 2.25rem); overflow-wrap: anywhere; }
  .app-header .eyebrow { margin-bottom: 4px; }
  .header-actions { min-width: 0; gap: 5px; }
  .points-badge { min-width: 42px; height: 40px; padding: 0 8px; }
  .points-badge::after { right: -96px; max-width: calc(100vw - 24px); }
  .reward-toast { right: 6px; left: 6px; bottom: 8px; width: auto; max-width: none; }
  .scan-header-button { width: 46px; height: 46px; flex-basis: 46px; border-radius: 15px; }
  .scan-header-icon { width: 26px; height: 26px; }
  .concept-toggle-button { padding: 6px 8px; font-size: 0.68rem; }
  .input-row { flex-direction: column; }
  .stock-tools > summary small { display: none; }
  .stock-view-settings { align-items: stretch; flex-direction: column; gap: 5px; }
  .stock-view-settings .view-toggle { display: flex; width: 100%; }
  .stock-view-settings .view-toggle-button { flex: 1; min-width: 0; }
  .add-product-form { grid-template-columns: 1fr 1fr; }
  .add-product-form > div:nth-child(3) { grid-column: 1 / -1; }
  .add-product-form .button-icon-text { grid-column: 1 / -1; }
  .voice-panel { grid-template-columns: 1fr auto; gap: 5px; }
  .voice-button { grid-column: 1; }
  .voice-panel input, .voice-panel span { grid-column: 1 / -1; }
  .quick-mode-toolbar { align-items: stretch; flex-direction: column; padding: 10px; }
  .quick-filter { align-self: stretch; }
  .quick-filter-button { flex: 1; padding-inline: 6px; }
  .quick-product-item { grid-template-columns: minmax(0, 1fr) auto; gap: 6px; padding: 7px; }
  .quick-product-actions { grid-column: 1 / -1; }
  .quick-product-actions .quick-action { flex: 1; }
  .quick-action { min-height: 36px; }
  .tabs { gap: 3px; padding: 4px; }
  .tab-button { flex: 1 1 25%; min-width: 0; min-height: 40px; padding: 7px 4px; }
  .tab-button > span[aria-hidden] { font-size: 1.15rem; }
  .tab-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .device-form { padding: 12px; }
  .device-edit-grid { grid-template-columns: 1fr; }
  .history-panel { min-height: auto; padding: 14px 10px; }
  .stats-panel { min-height: auto; padding: 14px 8px; }
  .stats-heading { gap: 8px; }
  .stats-heading .button-quiet { width: 38px; height: 38px; padding: 0; overflow: hidden; color: transparent; font-size: 0; }
  .stats-heading .button-quiet::before { content: '↻'; color: var(--ink); font-size: 1.1rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
  .stat-card { min-height: 94px; padding: 10px; border-radius: 14px; }
  .stat-card strong { font-size: 1.35rem; }
  .stat-card span { font-size: 0.68rem; }
  .stat-card small { font-size: 0.62rem; line-height: 1.25; }
  .stats-details { gap: 8px; }
  .stats-block { padding: 12px 10px; border-radius: 15px; }
  .stats-block-heading { align-items: flex-start; flex-wrap: wrap; }
  .catalog-breakdown { gap: 7px 8px; font-size: 0.72rem; }
  .matching-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .matching-mode-list { grid-template-columns: 1fr; }
  .history-list { padding: 6px; border-radius: 16px; }
  .history-item { grid-template-columns: 1fr; gap: 4px; padding: 9px 10px; }
  .product-item { grid-template-columns: 18px minmax(0, 1fr) 22px 54px 22px 22px 22px; gap: 4px; padding: 2px 4px; font-size: 0.78rem; }
  .product-check, .shopping-check { width: 17px; height: 17px; }
  .product-title { gap: 4px; }
  .stock-badge { padding: 1px 5px; font-size: 0.58rem; }
  .amount-input { grid-column: auto; grid-row: auto; min-height: 24px; padding: 2px 4px; font-size: 16px; }
  .amount-step, .product-item .icon-button { width: 22px; height: 22px; }
  .category-heading { top: 52px; }
  .barcode-dialog { width: calc(100dvw - 12px); max-width: calc(100dvw - 12px); max-height: calc(100dvh - 12px); margin: auto auto 6px; padding: 13px; border-radius: 20px 20px 16px 16px; }
  .barcode-camera-box { min-height: 150px; }
  .barcode-camera-box video { height: 150px; }
  .barcode-bind-panel .input-row { gap: 7px; }
  .site-footer { width: calc(100% - 16px); flex-direction: column; gap: 3px; padding-bottom: 14px; }
  .site-footer span::before { display: none; }
  .docs-shell { width: calc(100% - 12px); }
  .docs-hero { padding: 20px 8px 18px; }
  .docs-back { margin-bottom: 22px; }
  .docs-section { padding: 18px 14px; border-radius: 18px; }
  .docs-toc { grid-template-columns: 1fr 1fr; padding: 12px; }
  .docs-flow { grid-template-columns: 1fr; }
  .docs-flow b { transform: rotate(90deg); text-align: center; }
}
