:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #747780;
  --subtle: #9699a1;
  --line: #e7e8eb;
  --surface: #fff;
  --canvas: #f7f7f8;
  --brand: #c8202f;
  --brand-soft: #fff1f2;
  --status-ok: #25864b;
  --status-ok-soft: #edf7f0;
  --status-warning: #a66a0e;
  --status-warning-soft: #fff6e4;
  --status-critical: #bd2635;
  --status-critical-soft: #fff0f1;
  font-family: 'Sora', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 15px; }
button, input, select { font: inherit; }
button { color: inherit; }
.app-shell { width: min(100% - 48px, 1200px); margin: 0 auto; padding: 36px 0 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 0 30px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.logout-form { margin: 0; }
.logout-button { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.logout-button:hover { border-color: #d8b4b7; color: var(--brand); }
.brand-lockup { display: flex; align-items: center; gap: 24px; min-width: 0; }
.brand-logo { display: block; width: 142px; height: auto; max-width: none; flex: 0 0 auto; }
.eyebrow { margin: 0 0 7px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(28px, 3vw, 36px); line-height: 1.16; letter-spacing: -.05em; text-transform: uppercase; }
.subtitle { margin: 0; color: var(--muted); font-size: 14px; }
.shopping-trigger { display: inline-flex; align-items: center; gap: 11px; min-height: 48px; border: 1px solid var(--line); border-radius: 13px; padding: 10px 15px; background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color .18s, transform .18s; white-space: nowrap; }
.shopping-trigger:hover { border-color: #d8b4b7; transform: translateY(-1px); }
.shopping-trigger img { width: 20px; height: 20px; object-fit: contain; }
.shopping-count { display: grid; min-width: 24px; height: 24px; padding: 0 6px; place-items: center; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700; }
.toolbar { margin-bottom: 16px; }
.search-box { display: flex; align-items: center; gap: 13px; width: 100%; height: 56px; border: 1px solid var(--line); border-radius: 15px; padding: 0 17px; background: var(--surface); box-shadow: 0 2px 8px rgb(20 20 25 / 3%); }
.search-box:focus-within { border-color: #d7a0a5; box-shadow: 0 0 0 3px rgb(200 32 47 / 8%); }
.search-box img { width: 21px; height: 21px; opacity: .65; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 15px; }
.search-box input::placeholder { color: #9699a1; }
.summary { display: flex; align-items: stretch; gap: 9px; margin-bottom: 39px; border: 1px solid var(--line); border-radius: 16px; padding: 10px; background: var(--surface); }
.summary-item { display: flex; flex: 0 0 auto; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 140px; border: 1px solid transparent; border-radius: 11px; padding: 10px 15px; background: transparent; text-align: center; cursor: pointer; transition: background .16s, border-color .16s, color .16s; }
.summary-item:hover { background: #f8f8f9; }
.summary-item.is-selected { border-color: #f0d5d8; background: var(--brand-soft); }
.summary-value { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.055em; }
.summary-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.summary-attention .summary-value { color: #F2CE00; }
.summary-attention.is-selected { border-color: #f4e99d; background: #fffdf1; }
.summary-critical .summary-value { color: var(--status-critical); }
.summary-critical.is-selected { border-color: #f0c9ce; background: var(--status-critical-soft); }
.summary-note { align-self: center; margin: 0 13px 0 auto; color: var(--subtle); font-size: 12px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 17px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.section-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.045em; }
.items-caption { padding-bottom: 4px; color: var(--muted); font-size: 13px; }
.category-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 17px; }
.category-group { overflow: hidden; border: 1px solid var(--line); border-top: 3px solid var(--category-color, var(--brand)); border-radius: 16px; background: var(--surface); box-shadow: 0 3px 12px rgb(20 20 25 / 2%); }
.category-group[hidden] { display: none; }
.category-header { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 63px; border: 0; padding: 0 18px; background: #fff; text-align: left; cursor: pointer; }
.category-title-wrap { display: flex; align-items: center; gap: 12px; min-width: 0; }
.category-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--category-color, var(--brand)); box-shadow: 0 0 0 5px rgb(32 33 36 / 4%); flex: 0 0 auto; }
.category-icon { display: inline-grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; font-size: 18px; line-height: 1; }
.category-title { overflow: hidden; font-size: 16px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.category-count { display: grid; min-width: 26px; height: 26px; padding: 0 6px; place-items: center; border-radius: 8px; background: #f3f3f5; color: var(--muted); font-size: 12px; font-weight: 600; }
.category-chevron { color: #777a82; font-size: 19px; line-height: 1; transition: transform .16s ease; }
.category-header[aria-expanded="true"] .category-chevron { transform: rotate(90deg); }
.product-list { max-height: 0; overflow: hidden; padding: 0 14px; opacity: 0; transition: max-height .18s ease, padding .18s ease, opacity .14s ease; }
.category-header[aria-expanded="true"] + .product-list { padding-bottom: 13px; opacity: 1; }
.product-card { border-top: 1px solid #eff0f2; padding: 15px 5px 13px; }
.product-card.is-critical { background: linear-gradient(90deg, #fff 0%, rgba(200, 32, 47, .03) 45%, rgba(200, 32, 47, .1) 100%); }
.product-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.product-info { min-width: 0; }
.product-name { overflow-wrap: anywhere; margin: 0 0 5px; font-size: 16px; font-weight: 600; line-height: 1.35; }
.product-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.product-brand { color: var(--muted); }
.meta-separator { color: #c3c4c9; }
.product-unit-label { color: var(--subtle); }
.edit-button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; flex: 0 0 auto; border: 1px solid #ececef; border-radius: 9px; padding: 0 9px; background: #fff; color: #555862; font-size: 12px; font-weight: 600; cursor: pointer; }
.edit-button:hover { border-color: #d8b4b7; color: var(--brand); }
.edit-button img { width: 16px; height: 16px; opacity: .75; }
.product-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; }
.quantity-display { display: flex; align-items: center; gap: 7px; min-width: 0; }
.quantity-indicator { display: inline-block; width: 17px; height: 17px; flex: 0 0 auto; background-color: currentColor; mask: var(--quantity-icon) center / contain no-repeat; -webkit-mask: var(--quantity-icon) center / contain no-repeat; }
.quantity-indicator-zero { color: var(--status-critical); }
.quantity-indicator-low { color: #F2CE00; }
.quantity-indicator-adequate { color: var(--status-ok); }
.quantity-value { color: var(--ink); font-size: 18px; font-weight: 700; letter-spacing: -.035em; }
.quantity-caption { color: var(--subtle); font-size: 12px; }
.stock-control { display: flex; align-items: center; gap: 7px; }
.quantity-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid #e9eaed; border-radius: 11px; background: #fff; cursor: pointer; transition: background .15s, border-color .15s, transform .12s; }
.quantity-button:hover { border-color: #d8b4b7; background: #fffafa; }
.quantity-button:active { transform: scale(.95); }
.quantity-button img { width: 18px; height: 18px; }
.quantity-button-plus { border-color: #eddadd; background: #fffafa; }
.product-status { display: flex; align-items: center; gap: 7px; min-height: 21px; margin-top: 10px; font-size: 12px; font-weight: 700; letter-spacing: .035em; }
.status-icon { display: inline-block; width: 17px; height: 17px; flex: 0 0 auto; background-color: currentColor; mask: var(--status-icon) center / contain no-repeat; -webkit-mask: var(--status-icon) center / contain no-repeat; }
.product-status.status-ok { color: var(--status-ok); }
.product-status.status-attention { color: var(--status-warning); }
.product-status.status-critical { color: var(--status-critical); }
.empty-state { border: 1px dashed #dfe0e4; border-radius: 15px; padding: 42px 18px; background: #fff; color: var(--muted); text-align: center; font-size: 14px; }
.page-footer { display: flex; align-items: center; justify-content: center; gap: 8px; padding-top: 33px; color: #9a9ca3; font-size: 10px; font-weight: 700; letter-spacing: .12em; }
.footer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgb(200 32 47 / 32%); outline-offset: 2px; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); border: 1px solid var(--line); border-radius: 20px; padding: 34px; background: var(--surface); box-shadow: 0 12px 40px rgb(24 24 28 / 7%); }
.login-logo { display: block; width: 150px; height: auto; margin: 0 auto 24px; }
.login-card > .eyebrow { text-align: center; }
.login-card > h1 { margin: 0 0 27px; font-size: 25px; text-align: center; }
.setup-title { margin: -14px 0 21px; color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; }
.login-form { display: grid; gap: 17px; }
.login-form .form-field input { height: 50px; }
.login-error { margin: 0; }
.login-submit { width: 100%; min-height: 48px; margin-top: 3px; }

.shopping-dialog, .edit-dialog { width: min(560px, calc(100% - 28px)); max-height: min(88vh, 780px); overflow-y: auto; border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 24px 80px rgb(24 24 28 / 22%); }
.shopping-dialog::backdrop, .edit-dialog::backdrop { background: rgb(24 24 28 / 40%); backdrop-filter: blur(2px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px 15px; }
.dialog-header h2 { margin: 0; font-size: 23px; letter-spacing: -.04em; }
.shopping-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.shopping-action { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 0; border-radius: 9px; padding: 0; background: transparent; color: var(--brand); cursor: pointer; transition: background-color .15s ease; }
.shopping-action:hover { background: var(--brand-soft); }
.shopping-action-icon { display: block; width: 19px; height: 19px; background-color: currentColor; mask-position: center; mask-size: contain; mask-repeat: no-repeat; -webkit-mask-position: center; -webkit-mask-size: contain; -webkit-mask-repeat: no-repeat; }
.shopping-icon-pdf { mask-image: url('../icons/order.svg'); -webkit-mask-image: url('../icons/order.svg'); }
.shopping-icon-whatsapp { mask-image: url('../icons/send.svg'); -webkit-mask-image: url('../icons/send.svg'); }
.shopping-actions .shopping-action-close { width: 36px; height: 36px; border: 0; background: transparent; color: var(--brand); font-size: 25px; }
.shopping-actions .shopping-action-close:hover { background: var(--brand-soft); }
.icon-button { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.dialog-close { color: #686a72; font-size: 27px; line-height: 1; }
.dialog-description { margin: 0; padding: 0 24px 17px; color: var(--muted); font-size: 13px; }
.shopping-items { max-height: 49vh; overflow-y: auto; padding: 0 24px; }
.shopping-row { display: flex; align-items: center; gap: 13px; border-top: 1px solid #eff0f2; padding: 15px 0; }
.shopping-row input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--brand); }
.shopping-row label { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.shopping-product { display: grid; gap: 5px; font-size: 13px; }
.shopping-product strong { font-weight: 600; }
.shopping-product > span { color: var(--muted); font-size: 11px; }
.shopping-amount { color: var(--status-critical); font-size: 12px; font-weight: 700; white-space: nowrap; }
.shopping-row.is-checked .shopping-product, .shopping-row.is-checked .shopping-amount { color: #999ba2; text-decoration: line-through; }
.shopping-empty { padding: 30px 24px; color: var(--muted); text-align: center; font-size: 13px; }
.dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 17px 24px 21px; color: var(--muted); font-size: 12px; }
.button-primary, .button-secondary { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 0; border-radius: 11px; padding: 0 18px; font-size: 13px; font-weight: 700; cursor: pointer; }
.button-primary { background: var(--brand); color: white; }
.button-primary:hover { background: #aa1927; }
.button-secondary { border: 1px solid var(--line); background: #fff; color: #565861; }
.button-secondary:hover { background: #f7f7f8; }
.edit-form { margin: 0; }
.edit-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 5px 24px 22px; }
.form-field { display: grid; align-content: start; gap: 8px; color: #4e5058; font-size: 13px; font-weight: 600; }
.form-field-full { grid-column: 1 / -1; }
.field-optional { margin-left: 4px; color: var(--subtle); font-size: 11px; font-weight: 400; }
.form-field input, .form-field select { width: 100%; height: 48px; border: 1px solid #dedfe3; border-radius: 11px; padding: 0 12px; background: #fff; color: var(--ink); font-size: 15px; font-weight: 400; }
.form-field input[readonly] { background: #f7f7f8; color: #676a72; }
.form-field input::placeholder { color: #a0a2a9; }
.custom-unit-field[hidden] { display: none; }
.form-error { grid-column: 1 / -1; margin: 0; border-radius: 9px; padding: 10px 12px; background: var(--status-critical-soft); color: var(--status-critical); font-size: 12px; }
.form-error[hidden] { display: none; }
.edit-actions { justify-content: flex-end; }
.print-sheet { display: none; }

@page { size: A4; margin: 14mm; }
@media print {
  html, body { display: block !important; width: auto !important; height: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; background: #fff !important; }
  body > :not(#print-sheet) { display: none !important; }
  #print-sheet { position: static !important; inset: auto !important; display: block !important; width: auto !important; height: auto !important; min-height: 0 !important; max-height: none !important; margin: 0 !important; padding: 0 !important; overflow: visible !important; visibility: visible !important; background: #fff; color: #202124; font-family: Arial, sans-serif; }
  #print-sheet * { visibility: visible !important; }
  .print-header { margin-bottom: 20px; border-bottom: 2px solid #202124; padding-bottom: 12px; break-after: avoid-page; page-break-after: avoid; }
  .print-brand { margin: 0 0 4px; color: #c8202f; font-size: 16px; font-weight: 800; letter-spacing: .16em; }
  .print-header h1 { margin: 0 0 10px; font-size: 25px; letter-spacing: 0; text-transform: none; }
  .print-header p:last-child { margin: 0; color: #555; font-size: 11px; }
  .print-list { display: block; height: auto; min-height: 0; overflow: visible; }
  .print-item { break-inside: avoid; page-break-inside: avoid; border-bottom: 1px solid #d8d8d8; padding: 0 0 10px; margin: 0 0 12px; }
  .print-item h2 { margin: 0 0 7px; font-size: 14px; }
  .print-item p { margin: 3px 0; color: #333; font-size: 11px; }
  .print-item .print-buy { margin-top: 6px; color: #c8202f; font-weight: 700; }
  .print-empty { padding: 24px 0; font-size: 13px; }
  .print-footer { margin-top: 12px; border-top: 2px solid #202124; padding-top: 10px; font-size: 12px; font-weight: 700; break-inside: avoid; page-break-inside: avoid; }
}

@media (max-width: 700px) {
  .app-shell { width: min(100% - 28px, 500px); padding-top: 20px; }
  .topbar { align-items: flex-start; gap: 10px; padding-bottom: 22px; }
  .topbar-actions { gap: 6px; }
  .logout-button { min-height: 44px; padding: 0 10px; font-size: 11px; }
  .brand-lockup { align-items: center; gap: 12px; }
  .brand-logo { width: 84px; height: auto; }
  .eyebrow { margin-bottom: 5px; font-size: 8px; }
  h1 { font-size: clamp(17px, 4.7vw, 22px); }
  .subtitle { font-size: 11px; }
  .shopping-trigger { position: relative; width: 44px; min-height: 44px; height: 44px; justify-content: center; gap: 0; border-radius: 12px; padding: 0; }
  .shopping-trigger img { width: 20px; height: 20px; }
  .shopping-trigger > span:not(.shopping-count) { display: none; }
  .shopping-count { position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 4px; font-size: 10px; }
  .search-box { height: 52px; }
  .search-box input { font-size: 14px; }
  .summary { gap: 4px; margin-bottom: 28px; padding: 6px; }
  .summary-item { flex: 1 1 0; align-items: center; justify-content: center; gap: 1px; min-width: 0; min-height: 66px; padding: 7px 9px; text-align: center; }
  .summary-value { font-size: 23px; }
  .summary-label { font-size: 10px; }
  .summary-note { display: none; }
  .section-heading { margin-bottom: 12px; }
  .section-heading h2 { font-size: 22px; }
  .items-caption { font-size: 12px; }
  .category-list { grid-template-columns: 1fr; gap: 11px; }
  .category-header { min-height: 57px; padding: 0 15px; }
  .category-title { font-size: 15px; }
  .category-title-wrap { gap: 9px; }
  .product-list { padding: 0 12px; }
  .category-header[aria-expanded="true"] + .product-list { padding-bottom: 10px; }
  .product-card { padding: 14px 3px 13px; }
  .product-name { font-size: 15px; }
  .product-meta { font-size: 12px; }
  .quantity-value { font-size: 17px; }
  .quantity-button { width: 42px; height: 42px; }
  .edit-button { min-height: 39px; }
  .product-status { font-size: 12px; }
  .shopping-dialog, .edit-dialog { width: calc(100% - 20px); max-height: min(90dvh, 820px); border-radius: 18px; }
  .dialog-header { padding: 19px 18px 13px; }
  .dialog-header h2 { font-size: 21px; }
  .shopping-actions { gap: 3px; }
  .shopping-action, .shopping-actions .shopping-action-close { width: 36px; height: 36px; }
  .dialog-description { padding: 0 18px 14px; }
  .shopping-items { padding: 0 18px; }
  .shopping-row label { align-items: flex-start; flex-direction: column; gap: 7px; }
  .dialog-footer { align-items: stretch; padding: 14px 18px 18px; }
  .edit-fields { grid-template-columns: 1fr; gap: 14px; padding: 5px 18px 19px; }
  .form-field-full { grid-column: auto; }
  .form-field input, .form-field select { height: 50px; }
  .edit-actions { justify-content: stretch; }
  .edit-actions button { flex: 1; }
}

@media (max-width: 380px) {
  .app-shell { width: calc(100% - 22px); }
  .brand-lockup { gap: 8px; }
  .brand-logo { width: 68px; height: auto; }
  .subtitle { font-size: 10px; }
  .summary-item { padding-inline: 7px; }
  .summary-label { font-size: 9px; }
  .edit-button { padding-inline: 7px; }
  .login-card { padding: 26px 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
