:root {
  color-scheme: light;
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-2: #edf2f0;
  --border: #dce5e1;
  --text: #203830;
  --text-muted: #61756d;
  --accent: #24664f;
  --accent-strong: #174c39;
  --accent-contrast: #ffffff;
  --warn: #a33c32;
  --warn-bg: #fff3f0;
  --warn-border: #e8bfb7;
  --ok-bg: #f3f9f5;
  --ok-border: #c5dacd;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; }
button { cursor: pointer; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button:disabled { opacity: .35; cursor: default; }
[hidden], #importFileInput { display: none !important; }
.app { max-width: 720px; margin: auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 24px 24px 16px; border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { margin: 0; font-size: 1.05rem; font-weight: 650; letter-spacing: -.025em; line-height: 1.25; }
.brand strong { display: block; font-size: 1.8rem; font-weight: 750; margin-top: 3px; }
.brand-sub { margin: 6px 0 0; font-size: .8rem; color: var(--text-muted); }
.icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 40px; height: 40px; flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; }
.edit-toggle { width: auto; padding: 0 12px; font-size: .8rem; font-weight: 600; }
.icon-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.dept-switch { display: flex; gap: 4px; margin-top: 22px; padding: 4px; background: var(--surface-2); border-radius: 10px; }
.dept-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--text-muted); font-size: .9rem; font-weight: 650; }
.dept-tab.active { background: var(--surface); color: var(--accent-strong); border-color: var(--border); box-shadow: 0 1px 3px #20383008; }
.search-row { position: relative; margin-top: 14px; }
.search-row input { width: 100%; height: 46px; padding: 10px 44px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--surface); font-size: 16px; }
input::placeholder { color: var(--text-muted); opacity: 1; }
.search-row input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-clear { position: absolute; right: 2px; top: 2px; height: 42px; width: 40px; border: 0; background: transparent; color: var(--text-muted); }
.progress-row { display: flex; align-items: center; gap: 14px; margin-top: 15px; }
.progress-track { flex: 1; height: 5px; background: var(--border); border-radius: 5px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; border-radius: inherit; }
.progress-label { color: var(--text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.backup-row { display: none; gap: 8px; margin-top: 10px; }
.app.edit-mode .backup-row { display: flex; }
.backup-btn { flex: 1; min-height: 40px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); border-radius: 7px; padding: 8px; font-size: .78rem; }
.danger-btn { color: var(--warn); border-color: var(--warn-border); }
.category-list { flex: 1; padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.category-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.category-header { display: flex; align-items: center; gap: 8px; padding: 14px 16px; }
.category-toggle { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; min-height: 32px; border: 0; padding: 0; background: none; color: var(--text); text-align: left; }
.category-icon { display: inline-flex; color: var(--accent); }
.category-name { font-weight: 700; font-size: .95rem; overflow-wrap: anywhere; }
.chevron { order: 3; color: var(--text-muted); margin-left: auto; transition: transform .15s; }
.chevron .icon { width: 16px; height: 16px; }
.category-card.collapsed .chevron { transform: rotate(-90deg); }
.category-count { padding: 4px 8px; border-radius: 5px; background: var(--surface-2); color: var(--text-muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.category-count.all-done { color: var(--accent); background: var(--ok-bg); }
.category-body { border-top: 1px solid var(--border); padding: 0 16px; display: flex; flex-direction: column; }
.category-card.collapsed .category-body { display: none; }
.item-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.item-row:last-child, .item-row:has(+ .add-item-row) { border-bottom: 0; }
.ingredient-icon { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 36px; height: 36px; border-radius: 8px; color: var(--text-muted); background: var(--surface-2); }
.ingredient-icon .icon { width: 24px; height: 24px; }
.item-name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; line-height: 1.35; }
.item-input { width: 170px; min-width: 0; height: 42px; padding: 8px 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 7px; font-size: 16px; }
.item-input::placeholder { font-size: .78rem; }
.row-ok .item-input { background: var(--ok-bg); border-color: var(--ok-border); }
.row-ok .ingredient-icon { background: var(--ok-bg); color: var(--accent); }
.row-warn .item-input { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.row-warn .ingredient-icon { background: var(--warn-bg); color: var(--warn); }
.chip-finito { min-height: 42px; padding: 8px 11px; flex: none; background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); border-radius: 7px; font-size: .78rem; font-weight: 600; }
.chip-finito.active { background: var(--warn); border-color: var(--warn); color: white; }
.drag-handle, .reorder-btn, .item-delete, .category-delete, .add-item-row, .add-category-row { display: none; }
.app.edit-mode .drag-handle, .app.edit-mode .reorder-btn, .app.edit-mode .item-delete, .app.edit-mode .category-delete { display: inline-flex; align-items: center; justify-content: center; }
.app.edit-mode .chip-finito { display: none; }
.app.edit-mode .ingredient-icon { display: none; }
.drag-handle { flex: none; width: 24px; min-height: 40px; padding: 0; border: 0; color: var(--text-muted); background: none; touch-action: none; cursor: grab; }
.reorder-btn { width: 30px; }
.item-delete, .category-delete { width: 36px; color: var(--warn); }
.category-card.dragging, .item-row.dragging { background: var(--surface); box-shadow: 0 8px 24px #0002; }
.drag-placeholder { border: 2px dashed var(--border); background: var(--surface-2); border-radius: 8px; }
body.no-select, body.no-select * { user-select: none; -webkit-user-select: none; }
.app.edit-mode .add-item-row, .app.edit-mode .add-category-row { display: flex; }
.add-item-row { gap: 8px; padding: 12px 0; }
.add-category-row { gap: 8px; padding: 0 24px 20px; }
.add-item-row input, .add-category-row input { flex: 1; min-width: 0; width: 0; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 7px; padding: 10px; font-size: 16px; }
.add-item-row button, .add-category-row button { border: 1px solid var(--border); background: var(--surface-2); color: var(--accent-strong); border-radius: 7px; font-size: .8rem; font-weight: 650; padding: 10px; }
.empty-hint { color: var(--text-muted); font-size: .8rem; line-height: 1.6; margin: 16px 0; }
.empty-state { text-align: center; color: var(--text-muted); padding: 36px 12px; font-size: .9rem; line-height: 1.7; }
.bottombar { position: sticky; bottom: 0; z-index: 10; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); display: flex; gap: 10px; }
.primary-btn, .whatsapp-btn { display: flex; align-items: center; justify-content: center; gap: 10px; flex: 1; min-height: 50px; border: 0; background: var(--accent); color: var(--accent-contrast); border-radius: 9px; padding: 12px; font-size: .95rem; font-weight: 650; }
.ghost-btn { min-height: 44px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); padding: 12px; font-size: .9rem; }
.modal-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: #10271f66; padding: 20px; }
.modal { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 560px; max-height: 85dvh; padding: 24px; border-radius: 16px; background: var(--surface); box-shadow: 0 24px 80px #0002; }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-header h2 { font-size: 1.15rem; margin: 0; }
.message-preview { min-height: 0; overflow-y: auto; margin: 0; padding: 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font: .9rem/1.7 "Segoe UI", sans-serif; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 10px; }
.copy-feedback { color: var(--accent); margin: 0; min-height: 1em; font-size: .8rem; text-align: center; }
@media (hover: hover) { button:hover { filter: brightness(.96); } }
@media (min-width: 760px) { .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); } }
@media (max-width: 540px) {
  .topbar { padding: 18px 14px 12px; }
  .brand { font-size: .85rem; } .brand strong { font-size: 1.5rem; }
  .dept-switch { margin-top: 16px; }
  .category-list { padding: 14px 12px; gap: 12px; }
  .category-header { padding: 12px; }
  .category-body { padding: 0 12px; }
  .item-row { gap: 8px; flex-wrap: wrap; }
  .ingredient-icon { width: 32px; height: 34px; }
  .item-name { flex-basis: calc(100% - 40px); font-size: .9rem; }
  .item-input { flex: 1; width: 0; margin-left: 40px; }
  .chip-finito { min-width: 66px; }
  .app.edit-mode .item-name { flex-basis: calc(100% - 32px); }
  .app.edit-mode .item-input { margin-left: 32px; }
  .app.edit-mode .category-icon { display: none; }
  .app.edit-mode .category-header { gap: 5px; }
  .app.edit-mode .category-name { font-size: .85rem; }
  .bottombar { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
  .add-category-row { padding: 0 12px 16px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
}
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #14231e; --surface: #1c2e27; --surface-2: #263a31; --border: #354d41; --text: #edf4ef; --text-muted: #adc0b5; --accent: #9bcdb3; --accent-strong: #bce4cb; --accent-contrast: #173c2b; --warn: #ffb4a8; --warn-bg: #432f2a; --warn-border: #795047; --ok-bg: #223d2e; --ok-border: #466852; }
  .chip-finito.active { color: #421b16; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
