:root {
  --ink: #211f1d;
  --muted: #68635f;
  --paper: #ffffff;
  --canvas: #f6f5f2;
  --line: #dedbd5;
  --line-strong: #c7c2ba;
  --primary: #a33b2b;
  --primary-dark: #7d2b1f;
  --primary-soft: #f6e8e4;
  --green: #216a49;
  --green-soft: #e9f4ee;
  --red: #a32929;
  --red-soft: #faeaea;
  --yellow: #83570f;
  --yellow-soft: #fff2cf;
  --radius: 14px;
  --content: 1180px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-dark); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.45rem; font-size: clamp(2rem, 5vw, 2.8rem); line-height: 1.06; letter-spacing: -0.035em; }
h2 { margin-bottom: 0; font-size: 1.15rem; line-height: 1.25; }
small { color: var(--muted); }

.topbar {
  min-height: 72px;
  padding: 0.75rem max(1rem, calc((100vw - var(--content)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; min-width: 0; align-items: center; gap: 0.75rem; color: var(--ink); text-decoration: none; }
.brand-logo { width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%; object-fit: cover; background: white; border: 1px solid var(--line); }
.brand-copy, .user-name { display: grid; min-width: 0; line-height: 1.15; }
.brand-copy strong { overflow: hidden; font-size: 0.98rem; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small, .user-name small { margin-top: 0.2rem; font-size: 0.74rem; }
.user-menu { display: flex; align-items: center; gap: 0.9rem; }
.user-menu form { margin: 0; }
.user-name { text-align: right; font-size: 0.85rem; }

.nav-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem max(1rem, calc((100vw - var(--content)) / 2));
  overflow-x: auto;
  background: rgba(246, 245, 242, 0.97);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
  backdrop-filter: blur(10px);
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-link {
  position: relative;
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0.7rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #514d49;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 750;
}
.nav-link:hover { color: var(--ink); background: white; border-color: var(--line); }
.nav-link.is-active {
  color: white;
  background: var(--ink);
  border-color: var(--ink);
  box-shadow: inset 0 -4px 0 var(--primary);
}

.container { width: min(var(--content), calc(100% - 2rem)); margin: 0 auto; padding: 2.25rem 0 4rem; }
.footer { display: flex; justify-content: space-between; gap: 1rem; width: min(var(--content), calc(100% - 2rem)); margin: 0 auto; padding: 1.4rem 0 2.5rem; color: var(--muted); border-top: 1px solid var(--line); font-size: 0.8rem; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.25rem; margin-bottom: 1.5rem; }
.page-heading-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.65rem; }
.page-heading-actions form { margin: 0; }
.page-intro { max-width: 680px; margin: 0.35rem 0 0; color: var(--muted); font-size: 1.05rem; }
.eyebrow { margin-bottom: 0.45rem; color: var(--primary); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem; font-weight: 900; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin: 2.25rem 0 1rem; }
.section-heading .eyebrow { margin-bottom: 0.25rem; }
.helper { color: var(--muted); }

.panel, .auth-card, .metric-card, .stock-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel { padding: 1.35rem; margin-bottom: 1.25rem; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading.compact { margin-top: 0.5rem; }
.panel-danger { border-color: #dfaaa5; }
.subpanel { min-width: 0; padding: 1.15rem; background: #faf9f7; border: 1px solid var(--line); border-radius: 12px; }
.report-table { margin-top: 1rem; }
.auth-card { width: min(470px, 100%); margin: 5vh auto; padding: clamp(1.5rem, 5vw, 2.5rem); }
.auth-card > p { color: var(--muted); }
.error-card { text-align: center; }
.error-symbol, .empty-symbol { display: grid; width: 64px; height: 64px; place-items: center; margin: 0 auto 1rem; border-radius: 50%; color: white; background: var(--red); font-size: 1.6rem; font-weight: 900; }
.empty-state { padding: 3rem 1.5rem; text-align: center; }
.empty-state p { margin: 0.45rem auto 0; color: var(--muted); }
.empty-state .empty-symbol { color: var(--muted); background: #eeece8; }

.form-stack { display: grid; gap: 1.1rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 0.45rem; color: #494540; font-size: 0.92rem; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: 52px;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(163, 59, 43, 0.12); }
.check-label { display: flex; align-items: center; gap: 0.7rem; min-height: 52px; }
.check-label input { width: 22px; min-height: 22px; }
.narrow-form { width: min(700px, 100%); }
.payment-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.payment-fieldset legend { margin-bottom: 0.55rem; color: #494540; font-size: 0.92rem; font-weight: 800; }
.payment-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
.payment-option { position: relative; display: block; cursor: pointer; }
.payment-option input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.payment-option span { display: grid; min-height: 52px; place-items: center; padding: 0.7rem; border: 1px solid var(--line-strong); border-radius: 10px; background: white; text-align: center; }
.payment-option input:checked + span { color: var(--primary-dark); background: var(--primary-soft); border: 2px solid var(--primary); }
.payment-option input:focus-visible + span { box-shadow: 0 0 0 4px rgba(163, 59, 43, 0.14); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.05rem;
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 800;
  cursor: pointer;
}
.button:disabled { opacity: 0.42; cursor: not-allowed; }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: var(--ink); background: white; border-color: var(--line-strong); }
.button-secondary:hover, .button-quiet:hover { background: #eeece8; }
.button-quiet { min-height: 42px; color: #514d49; background: transparent; border-color: var(--line); }
.button-danger { color: white; background: var(--red); }
.button-large { min-height: 58px; font-size: 1.05rem; }
.button-small { min-height: 38px; padding: 0.45rem 0.7rem; font-size: 0.82rem; }
.button-full { width: 100%; margin-top: 1rem; }
.link-button { padding: 0.4rem; border: 0; color: var(--primary-dark); background: transparent; font-weight: 800; cursor: pointer; }
.icon-button { align-self: end; width: 46px; height: 52px; border: 0; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: 1.5rem; cursor: pointer; }

.alert { margin-bottom: 1rem; padding: 1rem 1.1rem; border-radius: 10px; font-weight: 750; }
.alert-success { color: var(--green); background: var(--green-soft); border: 1px solid #b4d9c4; }
.alert-error { color: var(--red); background: var(--red-soft); border: 1px solid #e5b6b6; }
.notice { padding: 1rem; color: var(--yellow); background: var(--yellow-soft); border-radius: 10px; }
.status-line { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.25rem; padding: 0.95rem 1rem; border: 1px solid transparent; border-radius: 10px; }
.status-open { color: var(--green); background: var(--green-soft); border-color: #c0ddcb; }
.status-closed { color: #615c57; background: #eae8e4; border-color: #d9d5cf; }
.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }

.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.85rem; }
.quick-action {
  display: flex;
  min-height: 120px;
  align-items: center;
  gap: 0.9rem;
  padding: 1.15rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-decoration: none;
}
.quick-action:hover { border-color: var(--primary); }
.quick-action > span:last-child { display: grid; gap: 0.2rem; }
.quick-action strong { font-size: 1.08rem; }
.quick-action small { line-height: 1.25; }
.quick-number { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 1.1rem; font-weight: 900; }
.quick-primary { color: white; background: var(--primary); border-color: var(--primary); }
.quick-primary small { color: #f8dcd6; }
.quick-primary .quick-number { color: var(--primary-dark); background: white; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85rem; margin-bottom: 1.25rem; }
.metric-card { display: grid; gap: 0.3rem; min-width: 0; padding: 1.2rem; }
.metric-card span { color: var(--muted); font-size: 0.88rem; font-weight: 750; }
.metric-card strong { overflow-wrap: anywhere; font-size: clamp(1.35rem, 4vw, 2rem); line-height: 1.2; }
.metric-main { color: white; background: var(--ink); border-color: var(--ink); }
.metric-main span, .metric-main small { color: #dedbd5; }
.metric-warning { color: var(--red); background: var(--red-soft); border-color: #e7c1c1; }
.report-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 1.2rem; }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.two-columns > .panel { min-width: 0; }

.disclosure > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; list-style: none; font-size: 1rem; font-weight: 850; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after { content: "+"; display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 50%; font-size: 1.3rem; }
.disclosure[open] > summary::after { content: "−"; }
.disclosure > summary > span { display: grid; }
.disclosure > summary small { font-weight: 500; }
.disclosure[open] > summary { margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.report-panel { margin-top: 1.5rem; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2rem; }
.admin-grid section { min-width: 0; }
.admin-grid h2 { margin-bottom: 0.45rem; }
.recipe-section { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.recipe-list { display: grid; }
.recipe-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.recipe-row:last-child { border-bottom: 0; }
.recipe-row > div { display: grid; }
.recipe-builder { display: grid; gap: 0.75rem; padding: 0.9rem; background: #faf9f7; border: 1px solid var(--line); border-radius: 12px; }
.recipe-lines { display: grid; gap: 0.65rem; }
.recipe-line { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(130px, 0.75fr) 46px; gap: 0.65rem; align-items: end; }
.recipe-line .icon-button:disabled { color: var(--muted); background: #eceae6; cursor: not-allowed; }

.stock-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
.stock-card { display: grid; gap: 0.85rem; min-width: 0; padding: 1.2rem; }
.stock-card.is-low { background: var(--yellow-soft); border-color: #e2c987; }
.stock-card-copy h2 { margin: 0.2rem 0 0.1rem; }
.stock-card-copy p { margin: 0; }
.stock-card-copy p strong { font-size: 2rem; line-height: 1; }
.stock-state { color: var(--green); font-size: 0.76rem; font-weight: 850; }
.stock-card.is-low .stock-state { color: var(--yellow); }
.stock-controls { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 0.5rem; }
.stock-controls form { margin: 0; }
.stock-controls button { width: 56px; height: 56px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--primary-dark); background: white; font-size: 1.7rem; font-weight: 900; cursor: pointer; }
.stock-controls span { color: var(--muted); text-align: center; font-size: 0.8rem; font-weight: 800; }
.stock-delete { margin: 0; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.stock-delete .button { width: 100%; color: var(--red); }

.badge { display: inline-flex; width: fit-content; padding: 0.28rem 0.6rem; border-radius: 999px; color: #58534e; background: #eceae6; font-size: 0.74rem; font-weight: 850; }
.badge-success { color: var(--green); background: var(--green-soft); }
.badge-warning { color: var(--yellow); background: var(--yellow-soft); }
.badge-danger { color: var(--red); background: var(--red-soft); }
.danger-text { color: var(--red); font-weight: 800; }
.empty { margin: 0; padding: 1.25rem 0; color: var(--muted); text-align: center; }
.list { display: grid; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row > div { display: grid; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { color: var(--muted); text-align: left; font-size: 0.73rem; text-transform: uppercase; letter-spacing: 0.055em; }
th, td { padding: 0.8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-subtitle { display: block; }
.row-muted { opacity: 0.58; }
.catalog-product { display: flex; min-width: 210px; align-items: center; gap: 0.75rem; }
.catalog-product > img { width: 64px; height: 46px; flex: 0 0 auto; object-fit: cover; border-radius: 8px; background: #eceae6; }

.pos-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(330px, 0.75fr); gap: 1rem; align-items: start; }
.cart-panel { position: sticky; top: 5.25rem; }
.step-number { display: inline-grid; width: 30px; height: 30px; place-items: center; margin-right: 0.25rem; color: white; background: var(--primary); border-radius: 50%; font-size: 0.85rem; }
.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.7rem; }
.product-button { display: grid; gap: 0; min-width: 0; padding: 0; overflow: hidden; text-align: left; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: white; cursor: pointer; }
.product-button:hover { border-color: var(--primary); }
.product-button:active { transform: scale(0.98); }
.product-button:focus-visible { outline: 4px solid rgba(163, 59, 43, 0.2); outline-offset: 2px; }
.product-button:disabled { cursor: not-allowed; filter: grayscale(0.35); opacity: 0.58; }
.product-image { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; background: #eceae6; }
.product-copy { display: grid; gap: 0.24rem; min-width: 0; padding: 0.85rem; }
.product-name { min-height: 2.35em; font-weight: 850; line-height: 1.18; }
.product-button strong { color: var(--primary-dark); font-size: 1.1rem; }
.product-button small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-list { display: grid; }
.cart-empty { padding: 1.4rem 0; color: var(--muted); text-align: center; }
.cart-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.8rem 0; border-bottom: 1px solid var(--line); }
.cart-row > div:first-child { display: grid; }
.quantity-control { display: flex; align-items: center; gap: 0.65rem; }
.quantity-control button { width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 10px; color: var(--primary-dark); background: var(--primary-soft); font-size: 1.35rem; font-weight: 900; cursor: pointer; }
.quantity-control span { min-width: 22px; text-align: center; font-size: 1.1rem; font-weight: 850; }
.cart-total { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; padding-top: 1rem; border-top: 2px solid var(--ink); font-size: 1.15rem; }
.cart-total strong { font-size: 1.65rem; }
.mobile-cart-bar { display: none; }

.purchase-lines { display: grid; gap: 0.75rem; }
.purchase-line { display: grid; grid-template-columns: 1.5fr 0.65fr 0.75fr 0.8fr 1fr 46px; gap: 0.65rem; align-items: end; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #faf9f7; }
.create-panel summary { font-size: 1.05rem; }
.create-panel summary + form { margin-top: 1.2rem; }
.cash-actions { align-items: start; }

.void-form { display: flex; gap: 0.4rem; align-items: center; }
.void-form input[name="reason"] { width: 160px; min-width: 0; min-height: 38px; padding: 0.4rem 0.55rem; font-size: 0.82rem; }
.audit-detail { max-width: 340px; color: var(--muted); font-size: 0.85rem; }
.row-muted td { opacity: 0.62; text-decoration: line-through; }
.row-muted td:last-child, .row-muted td .badge { text-decoration: none; }

@media (max-width: 980px) {
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stock-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-layout { grid-template-columns: minmax(0, 1.4fr) minmax(310px, 0.8fr); }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purchase-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .purchase-line .icon-button { grid-column: 2; justify-self: end; }
}

@media (max-width: 760px) {
  body { font-size: 17px; }
  .container { padding-top: 1.5rem; }
  .two-columns, .pos-layout, .admin-grid { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .form-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-cart-bar:not([hidden]) {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: max(0.75rem, env(safe-area-inset-left));
    z-index: 30;
    display: flex;
    min-height: 66px;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    color: white;
    background: var(--ink);
    border: 0;
    border-radius: 13px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
    font-weight: 850;
  }
  .mobile-cart-bar > span:first-child { display: grid; text-align: left; }
  .mobile-cart-bar small { color: #d9d5cf; }
  .mobile-cart-bar strong { font-size: 1.15rem; }
}

@media (max-width: 560px) {
  .topbar { min-height: 66px; padding-inline: 0.7rem; }
  .brand-logo { width: 42px; height: 42px; }
  .brand-copy small, .user-name { display: none; }
  .brand-copy strong { max-width: 155px; font-size: 0.9rem; }
  .nav-tabs { padding-inline: 0.55rem; }
  .nav-link { min-height: 48px; padding: 0.72rem 0.95rem; }
  .container { width: min(100% - 1rem, var(--content)); padding-bottom: 5rem; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading > .button { width: 100%; }
  .date-filter { display: grid; grid-template-columns: 1fr auto; }
  .quick-actions { grid-template-columns: 1fr; gap: 0.65rem; }
  .quick-action { min-height: 94px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .metric-card { padding: 1rem; }
  .metric-card strong { font-size: 1.3rem; }
  .home-metrics .metric-main { grid-column: 1 / -1; }
  .stock-grid { grid-template-columns: 1fr; gap: 0.65rem; }
  .stock-card { padding: 1.05rem; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .payment-options { grid-template-columns: 1fr 1fr; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .product-copy { padding: 0.7rem; }
  .product-name { min-height: 2.55em; font-size: 0.9rem; }
  .product-button strong { font-size: 1rem; }
  .panel { padding: 1rem; border-radius: 12px; }
  .disclosure > summary { align-items: flex-start; }
  .disclosure > summary small { display: block; margin-top: 0.2rem; line-height: 1.3; }
  .purchase-line { grid-template-columns: 1fr; }
  .purchase-line .icon-button { grid-column: 1; }
  .recipe-line { grid-template-columns: 1fr 46px; }
  .recipe-line label:first-child { grid-column: 1 / -1; }
  .footer { display: none; }
  .recipe-row { align-items: flex-start; flex-direction: column; }
  .recipe-row form, .recipe-row .button { width: 100%; }
  .void-form { align-items: stretch; flex-direction: column; }
  .void-form input[name="reason"] { width: 100%; }
}

/* Escaneo de facturas */
.scan-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 0.75fr); gap: 1.5rem; align-items: center; padding: clamp(1.2rem, 4vw, 2rem); border-color: #d7c6c0; }
.scan-hero-copy { display: flex; align-items: center; gap: 1rem; }
.scan-hero-copy h2 { margin-bottom: 0.35rem; font-size: clamp(1.4rem, 3vw, 2rem); }
.scan-hero-copy p, .privacy-note { margin: 0; color: var(--muted); }
.scan-symbol { display: grid; width: 64px; height: 64px; flex: 0 0 auto; place-items: center; color: white; background: var(--primary); border-radius: 16px; font-size: 2rem; }
.scan-upload { display: grid; gap: 0.65rem; }
.scan-file-button { display: block; cursor: pointer; }
.scan-file-button input { position: absolute; width: 1px; height: 1px; min-height: 0; opacity: 0; }
.scan-file-button span { display: grid; min-height: 58px; place-items: center; padding: 0.8rem; color: var(--primary-dark); background: var(--primary-soft); border: 2px dashed #c77f72; border-radius: 11px; text-align: center; font-weight: 850; }
.scan-file-button input:focus-visible + span { box-shadow: 0 0 0 4px rgba(163, 59, 43, 0.14); }
.privacy-note { grid-column: 1 / -1; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 0.82rem; text-align: center; }
.scan-recent { margin-bottom: 1.5rem; }
.scan-recent .section-heading { margin: 1.6rem 0 0.75rem; }
.scan-list { display: grid; gap: 0.55rem; }
.scan-list-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 70px; padding: 0.75rem 0.8rem 0.75rem 1rem; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 11px; }
.scan-list-row:hover { border-color: var(--primary); }
.scan-list-link { display: block; flex: 1 1 auto; min-width: 0; padding: 0.25rem 0; color: var(--ink); text-decoration: none; }
.scan-list-link > span { display: grid; }
.scan-list-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 0.6rem; }
.scan-list-actions form { margin: 0; }
.manual-purchase { margin-top: 1.5rem; }
.processing-card, .error-state, .success-state { display: grid; justify-items: center; max-width: 720px; margin-inline: auto; padding: clamp(2rem, 8vw, 4rem); text-align: center; }
.processing-card p, .error-state p, .success-state p { max-width: 540px; color: var(--muted); }
.processing-card progress { width: min(420px, 100%); height: 13px; margin-top: 0.75rem; accent-color: var(--primary); }
.processing-spinner { width: 60px; height: 60px; margin-bottom: 1rem; border: 6px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: scan-spin 1s linear infinite; }
@keyframes scan-spin { to { transform: rotate(360deg); } }
.success-symbol { display: grid; width: 64px; height: 64px; place-items: center; margin-bottom: 1rem; color: white; background: var(--green); border-radius: 50%; font-size: 2rem; font-weight: 900; }
.review-banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: 1rem 1.15rem; color: var(--yellow); background: var(--yellow-soft); border: 1px solid #e4ca89; border-radius: 11px; }
.review-banner span { color: #6a5630; }
.warning-list { margin-top: 1rem; padding: 1rem; color: var(--yellow); background: var(--yellow-soft); border-radius: 10px; }
.warning-list ul { margin: 0.4rem 0 0; padding-left: 1.3rem; }
.conversion-guide { margin: 0 0 1rem; padding: 0.9rem 1rem; color: #365845; background: var(--green-soft); border-radius: 10px; }
.scan-lines .scan-line { position: relative; padding-bottom: 2.3rem; }
.scan-lines .scan-line { grid-template-columns: minmax(180px, 1.4fr) 0.65fr 0.8fr minmax(170px, 1.1fr) 0.8fr 46px; }
.scan-lines [data-stock-help] { min-height: 2.8em; color: var(--green); font-weight: 750; line-height: 1.3; }
.line-confidence { position: absolute; right: 1rem; bottom: 0.65rem; left: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-confidence.is-high { color: var(--green); }
.line-confidence.is-low { color: var(--yellow); font-weight: 800; }
.scan-totals { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; margin-top: 1rem; padding: 1rem; background: #faf9f7; border: 1px solid var(--line); border-radius: 10px; }
.raw-ocr pre { max-height: 360px; margin: 0; padding: 1rem; overflow: auto; background: #f2f0ec; border-radius: 9px; white-space: pre-wrap; font: 0.78rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 760px) {
  .scan-hero { grid-template-columns: 1fr; }
  .privacy-note { grid-column: 1; }
  .review-banner { align-items: flex-start; flex-direction: column; }
  .scan-totals { align-items: stretch; flex-direction: column; }
  .scan-lines .scan-line { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .scan-hero-copy { align-items: flex-start; }
  .scan-symbol { width: 52px; height: 52px; border-radius: 13px; font-size: 1.5rem; }
  .scan-list-row { align-items: flex-start; flex-direction: column; }
  .scan-list-link, .scan-list-actions { width: 100%; }
  .scan-list-actions { justify-content: space-between; }
  .page-heading-actions, .page-heading-actions .button, .page-heading-actions form { width: 100%; }
  .scan-lines .scan-line { grid-template-columns: 1fr; }
}
