:root {
  --hueso: #F7F3EE;
  --arena: #D7C1A7;
  --cafe: #533C2C;
  --grafito: #2B2623;
  --contract: #1E2F42;
  --arcilla: #A55B3C;
  --white: #FFFFFF;
  --muted: #7A6A5D;
  --border: rgba(83, 60, 44, 0.16);
  --shadow: 0 18px 55px rgba(43, 38, 35, 0.12);
  --radius-xl: 28px;
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Poppins, Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top left, rgba(215,193,167,0.45), transparent 34rem), var(--hueso);
  color: var(--grafito);
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.shell { min-height: 100svh; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(14px, 2.8vw, 30px);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 243, 238, 0.88);
  backdrop-filter: blur(18px);
}
.brand-logo { height: 43px; width: auto; object-fit: contain; }
.topbar-copy { display: flex; flex-direction: column; min-width: 0; }
.topbar-copy strong { color: var(--cafe); letter-spacing: -0.01em; }
.topbar-copy span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.status-dot { font-size: 12px; padding: 8px 10px; border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,0.65); color: var(--muted); }
.status-dot.online::before { content: '● '; color: #2c7a3f; }
.status-dot.offline::before { content: '● '; color: #b64235; }

.btn, .icon-btn {
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 750;
  letter-spacing: -0.01em;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:active, .icon-btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { color: var(--white); background: var(--cafe); box-shadow: 0 14px 28px rgba(83,60,44,.20); }
.btn.secondary { color: var(--cafe); background: #efe5da; border: 1px solid var(--border); }
.btn.ghost { color: var(--cafe); background: rgba(255,255,255,.55); border: 1px solid var(--border); }
.btn.danger { color: #7f1d1d; background: #fff0ed; border: 1px solid rgba(127,29,29,.20); }
.btn.small { min-height: 38px; padding: 0 13px; font-size: 13px; }
.btn.wide { width: 100%; }
.icon-btn { width: 42px; height: 42px; padding: 0; color: var(--cafe); background: rgba(255,255,255,.72); border: 1px solid var(--border); font-size: 21px; }

.pin-screen { min-height: 100svh; display: grid; place-items: center; padding: 22px; }
.pin-card { max-width: 480px; width: 100%; background: rgba(255,255,255,.78); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 34px; box-shadow: var(--shadow); text-align: center; }
.pin-logo { max-height: 82px; max-width: 240px; object-fit: contain; }
.pin-card h1 { color: var(--cafe); margin: 10px 0; font-size: clamp(30px, 5vw, 44px); line-height: 1; }
.pin-card p { color: var(--muted); }
.pin-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 20px; }
.pin-row input, .field input, .field select, .field textarea, .search-box input, .settings-strip input, .settings-strip select, .cart-qty input, .cart-price input {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.92);
  min-height: 46px;
  padding: 0 14px;
  color: var(--grafito);
  outline: none;
}
textarea { padding-top: 12px !important; min-height: 92px !important; resize: vertical; }
.field-error { color: #b64235 !important; font-weight: 700; }

.view { width: min(1500px, 100%); margin: 0 auto; padding: clamp(16px, 2.6vw, 30px); }
.home-view { display: grid; gap: 18px; }
.hero-card { border-radius: var(--radius-xl); border: 1px solid var(--border); background: linear-gradient(135deg, rgba(255,255,255,.80), rgba(215,193,167,.34)); padding: clamp(24px, 4vw, 48px); box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 8px; text-transform: uppercase; letter-spacing: .12em; font-size: 11px; font-weight: 850; color: var(--muted); }
h1, h2, h3 { margin: 0; color: var(--cafe); letter-spacing: -0.04em; }
.hero-card h1 { max-width: 860px; font-size: clamp(38px, 5vw, 72px); line-height: .92; }
.hero-card p:not(.eyebrow) { max-width: 720px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode-card { text-align: left; min-height: 245px; padding: 28px; border-radius: var(--radius-xl); border: 1px solid var(--border); background: rgba(255,255,255,.75); box-shadow: var(--shadow); color: var(--grafito); display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.mode-card span { border-radius: 999px; padding: 8px 12px; color: var(--white); font-weight: 850; font-size: 13px; }
.mode-card.hogar span { background: var(--arcilla); }
.mode-card.restaurantes span { background: var(--contract); }
.mode-card strong { color: var(--cafe); font-size: clamp(24px, 3vw, 38px); line-height: 1.02; letter-spacing: -0.04em; max-width: 560px; }
.mode-card em { margin-top: auto; font-style: normal; color: var(--muted); }
.quick-help { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quick-help div { background: rgba(255,255,255,.68); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.quick-help strong { color: var(--cafe); }
.quick-help p { color: var(--muted); margin-bottom: 0; line-height: 1.45; }

.quote-view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 440px); gap: 18px; align-items: start; }
.catalog-panel, .summary-card { background: rgba(255,255,255,.72); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); }
.catalog-panel { padding: 18px; min-height: calc(100svh - 118px); }
.summary-panel { position: sticky; top: 90px; }
.summary-card { padding: 18px; max-height: calc(100svh - 112px); overflow: auto; }
.quote-head, .summary-title-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.quote-head h2, .summary-title-row h2 { font-size: 28px; }
.quote-head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar { position: sticky; top: 72px; z-index: 20; margin: 16px -18px 18px; padding: 12px 18px; background: rgba(247,243,238,.86); backdrop-filter: blur(12px); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.search-box { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.search-box input { font-size: 17px; text-transform: none; letter-spacing: normal; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border-radius: 999px; border: 1px solid var(--border); background: rgba(255,255,255,.75); color: var(--cafe); padding: 9px 12px; font-weight: 800; font-size: 13px; }
.chip.active { color: var(--white); background: var(--cafe); border-color: var(--cafe); }
.quote-view.segment-hogar .chip.active, .quote-view.segment-hogar .btn.primary { background: var(--arcilla); }
.quote-view.segment-restaurantes .chip.active, .quote-view.segment-restaurantes .btn.primary { background: var(--contract); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.product-card { overflow: hidden; border: 1px solid var(--border); background: rgba(255,255,255,.88); border-radius: 22px; display: flex; flex-direction: column; min-height: 315px; }
.product-img-wrap { position: relative; aspect-ratio: 1 / .82; background: #eee4d8; overflow: hidden; }
.product-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .24s ease; }
.product-card:hover .product-img-wrap img { transform: scale(1.025); }
.product-badge { position: absolute; top: 10px; left: 10px; border-radius: 999px; padding: 6px 9px; background: rgba(255,255,255,.86); color: var(--cafe); font-size: 11px; font-weight: 850; max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product-body { padding: 13px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-body h3 { font-size: 21px; line-height: 1.05; }
.product-meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px; }
.price-line { color: var(--cafe); font-weight: 900; font-size: 18px; }
.tier-line { color: var(--muted); font-size: 12px; }
.quick-add { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.quick-add button { flex: 1 1 auto; min-width: 48px; border-radius: 999px; min-height: 36px; border: 1px solid var(--border); color: var(--cafe); background: #f8f1ea; font-weight: 850; }
.quick-add .add-main { flex-basis: 100%; color: #fff; background: var(--cafe); border-color: transparent; }
.segment-hogar .quick-add .add-main { background: var(--arcilla); }
.segment-restaurantes .quick-add .add-main { background: var(--contract); }

.count-badge { align-self: flex-start; border-radius: 999px; padding: 8px 10px; background: #f2e7dc; color: var(--cafe); font-size: 12px; font-weight: 850; }
.cart-items { display: grid; gap: 10px; margin: 16px 0; }
.empty-state { color: var(--muted); background: rgba(247,243,238,.65); border: 1px dashed var(--border); border-radius: 18px; padding: 18px; text-align: center; }
.cart-item { border: 1px solid var(--border); border-radius: 18px; background: rgba(255,255,255,.82); padding: 12px; display: grid; grid-template-columns: 60px 1fr; gap: 10px; }
.cart-thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 14px; background: #efe5da; }
.cart-info { min-width: 0; display: grid; gap: 8px; }
.cart-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.cart-main strong { color: var(--cafe); font-size: 16px; }
.cart-main span { color: var(--muted); font-size: 12px; display: block; }
.cart-controls { display: grid; grid-template-columns: 92px 1fr; gap: 8px; }
.cart-qty, .cart-price { display: grid; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.cart-qty input, .cart-price input { min-height: 38px; border-radius: 12px; padding: 0 9px; }
.cart-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cart-actions .btn { min-height: 32px; padding: 0 10px; font-size: 12px; }
.extras-mini { color: var(--muted); font-size: 12px; line-height: 1.35; }
.item-subtotal { font-weight: 900; color: var(--cafe); }

.settings-strip { display: grid; grid-template-columns: 1fr 110px; gap: 10px; margin: 12px 0; }
.settings-strip label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.adjustments { margin-top: 12px; display: grid; gap: 8px; }
.adjustment-row { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--border); background: rgba(247,243,238,.56); border-radius: 14px; font-size: 13px; }
.adjustment-row b { color: var(--cafe); }
.adjustment-row span { color: var(--muted); }
.adjustment-row button { border: 0; background: transparent; color: #8b2d20; font-weight: 900; }
.totals { margin-top: 16px; display: grid; gap: 8px; }
.total-row { display: flex; justify-content: space-between; gap: 14px; color: var(--muted); }
.total-row strong { color: var(--grafito); }
.total-row.final { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; color: var(--cafe); font-size: 23px; font-weight: 950; }
.total-row.final strong { color: var(--cafe); }
.summary-actions { display: grid; gap: 8px; margin-top: 16px; padding-bottom: calc(4px + var(--safe-bottom)); }

.modal-layer { position: fixed; inset: 0; z-index: 100; display: grid; place-items: end center; padding: 16px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(43,38,35,.36); backdrop-filter: blur(10px); }
.sheet { position: relative; z-index: 1; width: min(860px, calc(100vw - 24px)); max-height: min(88svh, 820px); overflow: auto; border-radius: 28px; border: 1px solid var(--border); background: var(--hueso); box-shadow: 0 28px 85px rgba(0,0,0,.28); padding: clamp(18px, 3vw, 28px); }
.sheet.compact { width: min(560px, calc(100vw - 24px)); }
.preview-sheet { width: min(980px, calc(100vw - 24px)); }
.sheet-close { position: absolute; top: 14px; right: 14px; }
.sheet-head { padding-right: 50px; margin-bottom: 16px; }
.sheet-head h2 { font-size: 32px; line-height: 1.02; }
.sheet-head p { color: var(--muted); margin: 8px 0 0; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .06em; }
.field.full { grid-column: 1 / -1; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.extra-preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin: 10px 0 16px; }
.extra-preset-grid button { border: 1px solid var(--border); border-radius: 14px; padding: 11px; text-align: left; background: rgba(255,255,255,.74); color: var(--cafe); font-weight: 800; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.toggle-row label { display: inline-flex; align-items: center; gap: 7px; text-transform: none; letter-spacing: normal; font-size: 13px; }
.preview-doc { background: white; border: 1px solid var(--border); border-radius: 24px; padding: 24px; }
.preview-doc .preview-logo { max-height: 52px; width: auto; }
.preview-doc h2 { font-size: 32px; }
.preview-table { width: 100%; border-collapse: collapse; margin-top: 18px; font-size: 14px; }
.preview-table th, .preview-table td { padding: 10px; border-bottom: 1px solid #eaded4; text-align: left; vertical-align: top; }
.preview-table th { color: var(--cafe); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.preview-total { margin-left: auto; margin-top: 16px; width: min(390px, 100%); }
.preview-note { color: var(--muted); font-size: 13px; line-height: 1.5; }
.toast-status { border-radius: 18px; padding: 14px; margin-top: 10px; background: rgba(255,255,255,.72); border: 1px solid var(--border); color: var(--muted); overflow-wrap: anywhere; }
.draft-list { display: grid; gap: 8px; }
.draft-row { border: 1px solid var(--border); border-radius: 16px; padding: 12px; background: rgba(255,255,255,.75); display: grid; gap: 8px; }
.draft-row strong { color: var(--cafe); }
.draft-row small { color: var(--muted); }
.draft-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 1050px) {
  .quote-view { grid-template-columns: 1fr; }
  .summary-panel { position: static; }
  .summary-card { max-height: none; }
  .catalog-panel { min-height: auto; }
}

@media (max-width: 760px) {
  .topbar { min-height: 64px; }
  .brand-logo { height: 34px; }
  .topbar-copy span { display: none; }
  .topbar-actions .status-dot, .topbar-actions #draftsBtn { display: none; }
  .mode-grid, .quick-help, .form-grid { grid-template-columns: 1fr; }
  .mode-card { min-height: 210px; }
  .hero-card h1 { font-size: 42px; }
  .quote-head { align-items: flex-start; flex-direction: column; }
  .quote-head-actions { justify-content: flex-start; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .product-card { min-height: 285px; border-radius: 18px; }
  .product-body h3 { font-size: 18px; }
  .cart-item { grid-template-columns: 52px 1fr; }
  .cart-thumb { width: 52px; height: 52px; }
  .cart-controls { grid-template-columns: 82px 1fr; }
  .settings-strip, .action-grid { grid-template-columns: 1fr; }
  .sheet { padding: 18px; border-radius: 24px 24px 0 0; width: 100%; max-height: 92svh; }
  .modal-layer { padding: 0; align-items: end; }
  .pin-card { padding: 24px; }
}

@media (max-width: 470px) {
  .view { padding: 12px; }
  .product-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .topbar, .catalog-panel, .summary-panel, .modal-scrim, .sheet-close, .modal-actions { display: none !important; }
  .modal-layer, .sheet, .preview-sheet { position: static; display: block !important; width: 100%; max-height: none; padding: 0; border: 0; box-shadow: none; }
  .preview-doc { border: 0; }
}
