:root {
  font-family: "Montserrat", system-ui, sans-serif;
  color: #0d1b2a;
  background: #faf9f6;
  --accent: #0d1b2a;
  --electric: #00b4d8;
  --success: #06d6a0;
  --muted: #4a5568;
  --border: #e9e7e2;
  --page-width: 1200px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.3; font-weight: 600; }
p { line-height: 1.5; }

/* The JPG keeps its proportions; only its empty margins are visually contained. */
.brand-header { background: var(--accent); border-bottom: 1px solid #203348; }
.brand-header-content {
  width: 100%; max-width: var(--page-width); margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.lacoca-wordmark { width: 136px; height: 44px; overflow: hidden; display: flex; align-items: center; flex: 0 0 auto; }
.lacoca-logo {
  display: block; width: 136px; height: auto; flex: 0 0 auto;
  filter: grayscale(1) contrast(1.5) brightness(1.4); mix-blend-mode: screen;
}
.header-caption { color: #c2cdd9; font-size: 0.75rem; font-weight: 500; text-align: right; }

main { width: 100%; max-width: var(--page-width); margin: 0 auto; padding: 30px 24px 24px; flex: 1; }
.query-panel {
  padding: 0; margin-bottom: 28px;
}
.page-header { margin-bottom: 22px; }
h1 { margin-bottom: 8px; font-size: 1.8rem; letter-spacing: -0.03em; }
.page-header p { margin-bottom: 0; font-size: 0.88rem; color: var(--muted); }
.reference-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.reference-field { flex: 1 1 240px; min-width: 0; }
label { display: block; margin-bottom: 7px; font-size: 0.78rem; font-weight: 600; }
input, select, textarea {
  width: 100%; min-width: 0; padding: 11px 12px; font: inherit; color: inherit;
  background: white; border: 1px solid #c7c9c8; border-radius: 7px;
}
input, select { min-height: 46px; font-size: 0.9rem; }
input::placeholder { color: var(--muted); }
.reference-combobox { position: relative; }
.reference-suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 10;
  margin: 0; padding: 5px; list-style: none; background: white;
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 12px 28px rgba(13, 27, 42, 0.12); max-height: 300px; overflow-y: auto;
}
.reference-suggestions li {
  padding: 11px 12px; border-radius: 5px; cursor: pointer;
  display: flex; gap: 10px; align-items: baseline; min-width: 0;
}
.reference-suggestions li.is-active { background: #eaf7fb; box-shadow: inset 3px 0 var(--electric); }
.reference-suggestions li[role="option"]:hover { background: #eaf7fb; }
.suggestion-sku { font-weight: 600; white-space: nowrap; }
.suggestion-name { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-suggestions li.suggestion-message { color: var(--muted); cursor: default; font-size: 0.85rem; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 11px 18px; border: 1px solid var(--accent); border-radius: 8px;
  font: inherit; font-size: 0.82rem; font-weight: 600; color: white; background: var(--accent);
  cursor: pointer; text-align: center; text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease;
}
#query-inventory { min-width: 140px; min-height: 46px; flex: 0 0 auto; }
.secondary-button { background: white; color: var(--accent); }
button:not(:disabled):hover, .button:hover { background: #20364c; }
.secondary-button:not(:disabled):hover { background: #eef4f8; }
button:disabled, select:disabled, input:disabled { opacity: 0.6; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; box-shadow: 0 0 0 2px var(--electric); }
#inventory-status { margin: 14px 0 0; font-size: 0.85rem; }
#inventory-status:empty { margin: 0; }
#inventory-status.error, #report-status.error { color: #9b2525; }

/* A single product card: product summary on the left, availability on the right. */
#inventory-result {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px 36px;
  padding: 32px; border: 1px solid var(--border); border-radius: 12px; background: white;
  box-shadow: 0 6px 24px rgba(36, 31, 24, 0.045);
}
.product-overview { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-content: start; min-width: 0; }
.product-picture {
  min-height: 270px; align-self: start; display: flex; align-items: center; justify-content: center;
  background: #f7f5f1; border-radius: 8px; overflow: hidden;
}
#product-image { display: block; width: 100%; height: auto; max-height: 340px; object-fit: contain; }
#image-unavailable { padding: 16px 10px; margin: 0; text-align: center; color: var(--muted); font-size: 0.75rem; }
.product-information { min-width: 0; }
h2 { margin-bottom: 10px; font-size: 1.25rem; letter-spacing: -0.025em; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 0.78rem; }
#product-reference { margin-bottom: 0; font-weight: 400; }
.product-attributes { display: flex; flex-direction: column; gap: 12px; margin: 24px 0; }
.attribute-field { min-width: 0; }
.attribute-field p { margin: 0; font-size: 0.85rem; overflow-wrap: anywhere; }
.attribute-field select { font-size: 0.8rem; padding: 9px; }
.total-block { padding: 18px; background: #f3f6f8; border-radius: 8px; }
.total-block > p:first-child { margin-bottom: 6px; font-size: 0.8rem; font-weight: 500; }
.total-block > p:last-child { margin-bottom: 0; line-height: 1.2; }
#inventory-total { font-size: 2.8rem; font-weight: 700; letter-spacing: -0.045em; }
.total-block span { color: var(--muted); font-size: 0.8rem; }

.color-chart { min-width: 0; }
.deposit-filter { margin-bottom: 14px; }
.deposit-filter label { margin-bottom: 6px; }
.deposit-filter select { font-size: 0.82rem; }
#deposit-status { margin: 0 0 12px; }
#deposit-status.error { color: #9b2525; }
h3 { font-size: 0.95rem; margin-bottom: 24px; }
#color-bars, .color-row, .color-heading, .color-name, .color-quantity, .size-detail { min-width: 0; }
.bar-track { width: 100%; }
#color-bars { list-style: none; margin: 0; padding: 0; }
.color-row { margin-bottom: 20px; }
.color-row:last-child { margin-bottom: 0; }
.color-heading { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 0.85rem; }
.color-name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.color-quantity { white-space: nowrap; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar-track { height: 12px; overflow: hidden; border-radius: 4px; background: #f0f0ee; }
.bar-fill { height: 100%; border-radius: 4px; background: #9aa0a6; box-shadow: inset 0 0 0 1px rgba(20, 30, 25, 0.10); }
.size-detail { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; padding: 0; margin: 6px 0 0; color: var(--muted); font-size: 0.75rem; }

.product-column { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.product-actions { border: 1px solid var(--border); border-radius: 10px; padding: 18px; background: #fbfbfa; min-width: 0; }
.product-actions h3 { margin-bottom: 14px; }
.report-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.report-actions button { min-width: 0; }
.inventory-footer { display: flex; gap: 12px; align-items: center; justify-content: space-between; margin-top: 14px; }
.inventory-footer p { margin: 0; flex: 1 1 auto; text-align: left; font-size: 0.72rem; }
.icon-button { width: 44px; min-width: 44px; min-height: 44px; padding: 0; flex: 0 0 auto; }
.icon-button svg { display: block; }
.movement-primary { width: 100%; min-height: 54px; margin-top: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-size: 0.95rem; }
.movement-primary svg { display: block; }
#report-status, #report-fallback { margin: 0; }
#report-status:not([hidden]), #report-fallback:not([hidden]) { margin-top: 14px; margin-bottom: 0; }
#report-status:not(.error) { color: var(--accent); border-left: 3px solid var(--success); padding-left: 10px; }
#report-text { font-size: 0.8rem; resize: vertical; }

#connection-panel { margin-top: 16px; border: 1px solid var(--border); border-radius: 10px; background: white; font-size: 0.8rem; }
summary { cursor: pointer; color: var(--muted); padding: 14px 20px; font-weight: 500; }
#connection-panel[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 14px; }
#connection-panel > p { margin: 0 20px 12px; }
#connection-panel .button { margin: 0 20px 12px; }

.brand-footer { width: 100%; max-width: var(--page-width); margin: 0 auto; padding: 0 24px; }
.brand-footer-content {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
  color: var(--muted); font-size: 0.625rem;
}
.retsolver-logo { display: block; width: 88px; max-width: 100%; height: auto; mix-blend-mode: multiply; }

@media (max-width: 1100px) {
  #inventory-result { padding: 26px; gap: 24px; }
  .product-overview { grid-template-columns: 160px minmax(0, 1fr); gap: 20px; }
  .product-picture { min-height: 240px; }
}

@media (max-width: 960px) {
  #inventory-result { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  /* Reorder on mobile: overview -> total -> colors -> actions -> movement. */
  .product-column { display: contents; }
  .product-overview { order: 1; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
  .color-chart { order: 2; padding-top: 4px; }
  .product-actions { order: 3; }
  .movement-panel { order: 4; }
  .product-picture { min-height: 270px; }
}

@media (max-width: 560px) {
  .brand-header-content { padding: 10px 16px; gap: 16px; }
  .lacoca-wordmark { width: 116px; height: 40px; }
  .lacoca-logo { width: 116px; }
  .header-caption { max-width: 130px; font-size: 0.65rem; }
  main { padding: 24px 16px 16px; }
  .query-panel { margin-bottom: 24px; }
  h1 { font-size: 1.45rem; }
  .page-header { margin-bottom: 18px; }
  .page-header p { font-size: 0.82rem; }
  .reference-form { gap: 10px; flex-wrap: wrap; }
  .reference-field { flex-basis: 100%; }
  #query-inventory { min-width: 0; padding-inline: 12px; }
  #query-inventory { width: 100%; }
  #inventory-result { padding: 22px 20px; gap: 24px; }
  .product-overview { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .product-picture { width: 100%; max-width: 240px; min-height: 240px; justify-self: center; }
  #product-image { max-height: 300px; }
  h2 { font-size: 1.2rem; }
  .product-attributes { margin: 20px 0; gap: 12px; }
  .total-block { padding: 16px 18px; }
  #inventory-total { font-size: 2.6rem; }
  .report-actions button { padding-inline: 8px; }
  .inventory-footer { align-items: center; }
  summary { padding: 13px 16px; }
  #connection-panel > p { margin-inline: 16px; }
  #connection-panel .button { margin-inline: 16px; }
  .brand-footer { padding: 0 16px; }
  .brand-footer-content { min-height: 42px; }
}

@media (max-width: 360px) {
  #inventory-result { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  button, .button { transition: none; }
}

.movement-button { background: #0f5132; border-color: #0f5132; }
.movement-button:not(:disabled):hover { background: #0b3d26; }
#movement-status.error { color: #9b2525; }
.movement-panel { grid-column: 1 / -1; border-top: 1px solid var(--border); padding-top: 24px; margin-top: 4px; min-width: 0; }
.movement-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.movement-header h3 { margin-bottom: 0; }
#movement-status { margin: 10px 0 0; }
#movement-status ul { margin: 8px 0 0; padding-left: 18px; }
.movement-step { margin: 20px 0 0; padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px; background: #fbfaf8; }
.movement-step legend { padding: 0 8px; font-size: 0.8rem; font-weight: 600; }
.operation-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.operation-button { background: white; color: var(--accent); }
.operation-button.is-selected { background: var(--accent); color: white; }
.deposit-fields { display: flex; flex-wrap: wrap; gap: 16px; }
.deposit-field { flex: 1 1 220px; min-width: 0; }
.quantity-table { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; background: white; overflow: hidden; }
.quantity-head, .quantity-row {
  display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr) 120px;
  gap: 12px; align-items: center; padding: 10px 14px;
}
.quantity-head { background: #f3f6f8; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.quantity-action-label { display: block; }
.quantity-head small { display: block; margin-top: 2px; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 0.62rem; color: var(--muted); }
.quantity-rows { list-style: none; margin: 0; padding: 0; }
.quantity-row { border-top: 1px solid var(--border); font-size: 0.85rem; }
.quantity-color { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; overflow-wrap: break-word; }
.color-swatch { width: 14px; height: 14px; border-radius: 50%; background: #9aa0a6; box-shadow: inset 0 0 0 1px rgba(20, 30, 25, 0.15); flex: 0 0 auto; }
.quantity-balance { color: var(--accent); font-size: 0.9rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.quantity-input { width: 100%; text-align: right; font-variant-numeric: tabular-nums; }
.quantity-input.is-invalid { border-color: #9b2525; box-shadow: 0 0 0 2px rgba(155, 37, 37, 0.15); }
#movement-total { margin: 12px 0 0; font-weight: 500; }
.movement-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.movement-review { margin-top: 22px; padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: white; }
.movement-review h4, .movement-result h4 { margin-bottom: 8px; font-size: 0.95rem; }
#review-summary { margin-bottom: 14px; }
.movement-notice { padding: 12px 14px; border-left: 4px solid #b45309; background: #fff7ed; color: #7c2d12; border-radius: 6px; font-size: 0.82rem; margin-bottom: 16px; }
.review-lines { list-style: none; margin: 0 0 12px; padding: 0; }
.review-line { padding: 10px 0; border-bottom: 1px solid var(--border); }
.review-line:last-child { border-bottom: 0; }
.review-line-heading { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.review-line-color { font-weight: 600; }
.review-line-detail { margin: 4px 0 0; color: var(--muted); font-size: 0.78rem; }
.status-chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 600; white-space: nowrap; background: #eef2f5; color: var(--muted); }
.status-planned, .status-confirmed { background: #dcfce7; color: #166534; }
.status-omitted, .status-unchanged, .status-skipped, .status-pending { background: #eef2f5; color: var(--muted); }
.status-failed { background: #fee2e2; color: #991b1b; }
.status-uncertain, .status-in_progress { background: #fef3c7; color: #92400e; }
.movement-warnings { margin: 12px 0; }
.movement-warning { margin: 0 0 6px; padding-left: 10px; border-left: 3px solid #d97706; color: var(--muted); font-size: 0.75rem; }
.review-steps { list-style: none; margin: 8px 0 0; padding: 0; color: var(--muted); font-size: 0.75rem; }
.review-steps li { padding: 3px 0; }
.confirm-button { background: #0f5132; border-color: #0f5132; }
.confirm-button:disabled { background: #94a3b8; border-color: #94a3b8; opacity: 1; cursor: not-allowed; }
.movement-result { margin-top: 22px; padding: 20px; border: 1px solid var(--border); border-radius: 10px; background: white; }
.movement-result-status { font-weight: 600; }
.movement-result-completed { color: #166534; }
.movement-result-partial, .movement-result-uncertain { color: #92400e; }
.movement-result-failed { color: #991b1b; }
#movement-result-steps { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.8rem; }
#movement-result-steps li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#movement-result-steps .movement-warning { flex-basis: 100%; margin: 0; }
.movement-report { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.movement-report h5 { margin: 0 0 10px; font-size: 0.9rem; font-weight: 600; }
.movement-report-preview {
  margin: 0 0 14px; padding: 14px; background: #f7f6f3; border: 1px solid var(--border);
  border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
.movement-report-actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.whatsapp-button { background: #128c7e; border-color: #128c7e; }
.whatsapp-button:not(:disabled):hover { background: #0b6b60; }
#movement-report-status { margin: 10px 0 0; }
#movement-report-status.error { color: #9b2525; }
#movement-report-fallback { margin-top: 12px; }
#movement-report-text { font-size: 0.8rem; resize: vertical; }
.movement-dialog { width: min(520px, 92vw); padding: 22px 24px; border: 1px solid var(--border); border-radius: 12px; background: white; box-shadow: 0 18px 48px rgba(13, 27, 42, 0.22); }
.movement-dialog::backdrop { background: rgba(13, 27, 42, 0.45); }
.movement-dialog h4 { margin-bottom: 10px; }
.movement-dialog .movement-notice { margin-bottom: 14px; }
.movement-dialog label { margin-top: 10px; }
#confirm-dialog-error { margin: 8px 0 0; }
#review-status { margin: 14px 0 0; }
#review-status:not(.error) { color: var(--accent); border-left: 3px solid var(--success); padding-left: 10px; }
#review-status.error { color: #9b2525; }

@media (max-width: 560px) {
  .operation-button { flex: 1 1 calc(50% - 5px); }
  .deposit-field { flex-basis: 100%; }
  /* Keep the three columns visible and legible from 320px up. */
  .quantity-head, .quantity-row {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr) 78px;
    gap: 6px; padding: 8px 10px;
  }
  .quantity-head { font-size: 0.6rem; letter-spacing: 0.02em; }
  .quantity-head small { font-size: 0.56rem; margin-top: 1px; }
  .quantity-balance { font-size: 0.85rem; }
  .quantity-input { padding: 8px 6px; font-size: 0.9rem; }
  .color-swatch { width: 12px; height: 12px; }
}

/* Stage 8 — login screen and header logout action. */
.header-caption { margin-left: auto; }
.logout-button {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 8px; cursor: pointer;
  background: transparent; color: #ffffff; border: 1px solid #3a4a5e;
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
}
.logout-button:hover { border-color: var(--electric); color: var(--electric); }
.logout-button:disabled { opacity: 0.6; cursor: default; }

.login-body { background: var(--accent); }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: #ffffff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(13, 27, 42, 0.18); padding: 32px 28px;
}
.login-card h1 { font-size: 1.6rem; margin-bottom: 6px; }
.login-subtitle { color: var(--muted); font-size: 0.85rem; margin-bottom: 20px; }
.login-card label { display: block; font-size: 0.78rem; font-weight: 600; margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 16px; font-family: inherit; font-size: 0.95rem;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: inherit;
}
.login-card input:focus { outline: none; border-color: var(--electric); box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.18); }
.login-card button[type="submit"] {
  width: 100%; min-height: 46px; border: none; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #ffffff; font-family: inherit; font-size: 0.95rem; font-weight: 600;
}
.login-error {
  background: #fdecec; border: 1px solid #f3c2c2; color: #8a1f1f;
  border-radius: 8px; padding: 10px 12px; font-size: 0.82rem; margin-bottom: 16px;
}
