:root {
  --green-600: #2e7d32;
  --green-500: #388e3c;
  --green-400: #43a047;
  --green-50:  #e8f5e9;
  --gray-900: #0f172a;
  --gray-800: #1f2937;
  --gray-700: #334155;
  --gray-600: #475569;
  --gray-500: #64748b;
  --gray-300: #cbd5e1;
  --gray-200: #e2e8f0;
  --gray-100: #f1f5f9;
  --white:     #ffffff;
  --shadow-1:  0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
  --shadow-2:  0 10px 15px rgba(16, 24, 40, 0.1), 0 4px 6px rgba(16, 24, 40, 0.06);

  --header-h: 64px;
  --sidebar-w: 264px;
  --radius: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(67, 160, 71, 0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  color: var(--gray-800);
  background: var(--gray-100);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  line-height: 1.5;
}

/* Cabeçalho */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  z-index: 50;
}

.app-loading .panel,
.app-loading .hero {
  opacity: .5;
  pointer-events: none;
  filter: grayscale(0.1);
}

.backup-indicator {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-500);
  box-shadow: var(--shadow-1);
  font-size: .85rem;
}
.backup-indicator.is-pending { color: #b45309; border-color: #fde68a; background: #fffbeb; }
.backup-indicator.is-ok { color: #1f8b2a; border-color: #c8e6c9; background: #e8f5e9; }
.backup-indicator.is-error { color: #b42318; border-color: #f5c2c2; background: #fff1f1; }

/* Backup indicator icons */
.backup-indicator .bi-icon { display:inline-flex; width:16px; height:16px; }
.backup-indicator .bi-icon svg { width:16px; height:16px; display:block; }
@keyframes spin { to { transform: rotate(360deg); } }
.backup-indicator .bi-icon--spinner svg { animation: spin 1s linear infinite; transform-origin: 50% 50%; }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 12px; height: 24px; border-radius: 2px;
  background: linear-gradient(180deg, var(--green-400), var(--green-600));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}
.brand-name { font-weight: 700; letter-spacing: .2px; color: var(--green-600); }

.icon-button {
  display: inline-flex; justify-content: center; align-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  box-shadow: var(--shadow-1);
  cursor: pointer;
}
.icon-button:hover { background: var(--gray-100); }
.icon-button:focus-visible { outline: none; box-shadow: var(--focus); }

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  bottom: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  box-shadow: var(--shadow-1);
  z-index: 40;
}
.sidebar-inner { height: 100%; display: flex; flex-direction: column; }

.menu { padding: 16px 12px; display: grid; gap: 6px; }
.menu-item {
  display: grid; grid-template-columns: 24px 1fr; align-items: center;
  gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: var(--gray-700); text-decoration: none; font-weight: 500;
  border: 1px solid transparent;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .06s ease;
}
.menu-item:hover { background: var(--green-50); color: var(--green-600); border-color: var(--gray-200); }
.menu-item.is-active { background: #eefcf0; color: var(--green-600); border-color: #d7f5db; }
.menu-icon { display: inline-flex; justify-content: center; align-items: center; color: currentColor; }

.sidebar-footer { margin-top: auto; padding: 12px 16px; color: var(--gray-500); border-top: 1px solid var(--gray-200); }

/* Main */
.app-main {
  padding: calc(var(--header-h) + 20px) 24px 24px calc(var(--sidebar-w) + 24px);
  min-height: 100vh;
}

.hero {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-1);
}
.hero h1 { margin: 0 0 8px; font-size: 1.6rem; color: var(--gray-900); }
.hero p { margin: 0 0 16px; color: var(--gray-600); }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; padding: 0 16px; border-radius: 10px;
  text-decoration: none; font-weight: 600; letter-spacing: .2px;
  border: 1px solid var(--gray-300);
  color: var(--gray-800); background: var(--white);
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .06s ease;
}
.btn:hover { background: var(--gray-100); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }

.btn-primary { background: var(--green-500); border-color: var(--green-500); color: var(--white); }
.btn-primary:hover { background: var(--green-600); border-color: var(--green-600); }

.btn-outline { background: var(--white); border-color: var(--green-400); color: var(--green-600); }
.btn-outline:hover { background: #f4fbf5; }

.panel {
  margin-top: 20px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.panel:not(.is-active) { display: none; }
/* Fallback: exibe a seção ancorada via hash quando JS não atuar */
.panel:target { display: block; }
.panel:target ~ .panel { /* noop to keep specificity parity */ }
.hero.is-hidden { display: none; }
/* Esconde o hero quando qualquer .panel está em :target (browsers que suportam :has) */
body:has(.panel:target) .hero { display: none; }
.hero.is-hidden { display: none; }

/* Produtos: formulário e tabela */
.product-form { margin-top: 12px; padding-bottom: 16px; border-bottom: 1px solid var(--gray-200); }
.form-grid { display: grid; grid-template-columns: 1fr 240px 220px auto; gap: 12px; align-items: end; }
/* Comprar: formulario e tabela */
.purchase-form { margin-top: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-200); }
.form-grid--buy { grid-template-columns: 1fr 1fr; column-gap: 10px; row-gap: 8px; align-items: end; }
.form-grid--buy > .field:first-child { grid-column: 1 / -1; }
.input-qty { text-align: right; }
/* Compacta inputs e botões apenas na seção Comprar */
#comprar .input { height: 36px; border-radius: 8px; }
#comprar .input-lg { height: 44px; }
#comprar .btn-lg { height: 38px; padding-inline: 12px; }
#comprar #compra-subtotal { text-align: right; }
#comprar .field { gap: 4px; }
#comprar .field.actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-self: end; gap: 6px; }
#comprar .btn-with-icon .btn-icon { margin-right: 8px; }
/* Autocomplete (typeahead) */
#comprar .field { position: relative; }
.typeahead { position: absolute; top: calc(100% + 4px); left: 0; right: 0; max-height: 220px; overflow: auto; background: var(--white); border: 1px solid var(--gray-300); border-radius: 8px; box-shadow: var(--shadow-1); z-index: 20; }
.typeahead__item { padding: 8px 10px; cursor: pointer; color: var(--gray-800); }
.typeahead__item:hover, .typeahead__item.is-active { background: var(--gray-100); }

/* Inline suggestion (dentro do campo) */
.inline-suggest { position: relative; height: 44px; }
.inline-suggest .input-ghost { display: none !important; }
.inline-suggest .input-real { position: relative; inset: auto; width: 100%; background: var(--white); }
#comprar .field label { font-size: .9rem; color: var(--gray-700); }
#comprar .purchase-table { margin-top: 10px; }
#comprar .table-header h3 { font-size: 1rem; }

@media (max-width: 980px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid--buy { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid--buy { grid-template-columns: 1fr; }
}

.field { display: grid; gap: 6px; }
.field .label, .field label { font-weight: 600; color: var(--gray-800); }
.input {
  height: 40px; padding: 0 12px; border-radius: 10px; width: 100%;
  border: 1px solid var(--gray-300); background: var(--white); color: var(--gray-900);
}
.input:focus-visible { outline: none; box-shadow: var(--focus); }
/* Caixa alta visual para campos */
.input--upper { text-transform: uppercase; }
/* Dinheiro: alinhamento à direita (opcional) */
.input-money { text-align: right; }

/* Select com visual consistente */
select.input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%2364748b'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  padding-right: 36px;
}
.input:focus-visible { outline: none; box-shadow: var(--focus); }
.radio-group { display: inline-flex; gap: 12px; align-items: center; height: 40px; }
.radio { display: inline-flex; align-items: center; gap: 8px; color: var(--gray-800); }
.radio input { width: 16px; height: 16px; }
/* Rádio simples em lista (vertical) */
.radio-list { display: grid; gap: 6px; }
.radio-item { display: flex; align-items: center; gap: 8px; color: var(--gray-800); }
.radio-item input[type="radio"] { width: 16px; height: 16px; }
.field.actions { display: flex; align-items: center; gap: 8px; justify-content: flex-start; grid-column: 1 / -1; margin-top: 4px; }
.error { color: #b30028; min-height: 1em; }

.product-table { margin-top: 16px; }
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.table-header h3 { margin: 0; font-size: 1.05rem; color: var(--gray-900); }
/* Modal */
.modal-backdrop{position:fixed;inset:0;background:rgba(15,23,42,.35);display:flex;align-items:center;justify-content:center;padding:20px;z-index:100}
.modal{background:var(--white);border:1px solid var(--gray-200);border-radius:12px;max-width:520px;width:100%;box-shadow:var(--shadow-2);padding:16px;display:flex;flex-direction:column;gap:12px}
.modal h3{margin:0 0 4px;font-size:1.1rem;color:var(--gray-900)}
.modal-body{display:grid;gap:10px}
.modal-actions{display:flex;gap:8px;align-items:center;justify-content:flex-end}

/* Receipt preview (visualização da notinha) */
.receipt-preview { border: 1px solid var(--gray-200); border-radius: 10px; background: var(--white); overflow: hidden; }
#receipt-frame { width: 100%; height: 420px; border: 0; display: block; background: var(--white); }

/* Receipt preview inside print modal */

/* Profile menu */
.profile-menu { margin-left: auto; position: relative; }
.avatar-btn { display:inline-flex; align-items:center; justify-content:center; width:40px; height:40px; border-radius:50%; border:1px solid var(--gray-200); background: var(--white); color: var(--gray-700); box-shadow: var(--shadow-1); cursor:pointer; }
.avatar-btn:hover { background: var(--gray-100); }
.avatar-btn:focus-visible { outline:none; box-shadow: var(--focus); }
.dropdown { position:absolute; right:0; top:calc(100% + 8px); min-width: 180px; background: var(--white); border:1px solid var(--gray-200); border-radius: 10px; box-shadow: var(--shadow-2); padding:6px; z-index: 110; }
.dropdown-item { display:block; width:100%; text-align:left; background:none; border:none; padding:8px 10px; border-radius:8px; color: var(--gray-800); cursor:pointer; }
.dropdown-item:hover { background: var(--gray-100); }
.table-header .table-actions { display: inline-flex; gap: 6px; align-items: center; }
.table-search { width: 280px; }
.input-search {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 16px 16px;
  padding-left: 36px;
}
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.table-wrapper { overflow: auto; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--white); overscroll-behavior: auto; }
.table-wrapper--fixed { height: 260px; }
/* Produtos: alinhar coluna de valor à direita */
#produtos .table thead th:nth-child(2),
#produtos .table tbody td:nth-child(2) { text-align: right; width: 140px; }
/* Tabela da compra: alinhar números à direita e reduzir padding */
#comprar .table thead th:nth-child(2),
#comprar .table thead th:nth-child(3),
#comprar .table thead th:nth-child(4),
#comprar .table tbody td:nth-child(2),
#comprar .table tbody td:nth-child(3),
#comprar .table tbody td:nth-child(4) { text-align: right; }
#comprar .table thead th, #comprar .table tbody td { padding-top: 4px; padding-bottom: 4px; }
#comprar .table thead th:nth-child(2), #comprar .table tbody td:nth-child(2) { width: 100px; }
#comprar .table thead th:nth-child(3), #comprar .table tbody td:nth-child(3) { width: 100px; }
#comprar .table thead th:nth-child(4), #comprar .table tbody td:nth-child(4) { width: 120px; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--gray-100);
  text-align: left; padding: 6px 10px; color: var(--gray-700); font-weight: 600; border-bottom: 1px solid var(--gray-200);
}
.table tbody td { padding: 6px 10px; border-bottom: 1px solid var(--gray-200); color: var(--gray-800); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table .col-acoes { width: 152px; text-align: right; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; width: 32px; border-radius: 8px; border: 1px solid var(--gray-300);
  background: var(--white); color: var(--gray-700); cursor: pointer; margin-left: 6px;
}
.icon-btn:hover { background: var(--gray-100); }
.icon-btn--save { background: var(--green-500); border-color: var(--green-500); color: var(--white); }
.icon-btn--save:hover { background: var(--green-600); border-color: var(--green-600); }
.icon-btn--cancel { color: var(--gray-600); }
.icon-btn--danger { color: #b42318; border-color: #f1b4b4; }
.icon-btn--danger:hover { background: #fff1f1; }

.row-editing { background: #f4fbf5; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--gray-300); font-size: .85em; color: var(--gray-700); }
.badge--green { border-color: #b7e0bb; color: var(--green-600); background: #eefcf0; }
/* Total da compra */
.purchase-total { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px; margin-top: 0; border: 1px solid var(--gray-200); border-top: none; border-radius: 0 0 var(--radius) var(--radius); background: var(--white); font-weight: 700; color: var(--gray-900); }
#comprar .purchase-total .btn { font-weight: 700; }
.card-footer.subtotal-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--gray-200); font-weight: 700; color: var(--gray-900); }
/* Header e tabela mais compactos na compra */
#comprar .table-header { margin-bottom: 8px; }

/* Scrollbars finos e modernos */
/* Firefox */
* { scrollbar-width: thin; scrollbar-color: rgba(15,23,42,0.35) rgba(0,0,0,0.06); }
/* WebKit */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: rgba(0,0,0,0.04); border-radius: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(15,23,42,0.35); border-radius: 8px; border: 2px solid rgba(0,0,0,0); background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: rgba(15,23,42,0.5); }
@media (prefers-color-scheme: dark) {
  * { scrollbar-color: rgba(203,213,225,0.5) rgba(255,255,255,0.08); }
  *::-webkit-scrollbar-track { background: rgba(255,255,255,0.06); }
  *::-webkit-scrollbar-thumb { background: rgba(203,213,225,0.5); }
  *::-webkit-scrollbar-thumb:hover { background: rgba(203,213,225,0.7); }
}

/* Mostrar ícones de ação apenas na linha em foco */
/* Esconde botões de ação em todas as células do corpo da tabela */
#comprar .table tbody .icon-btn { transition: opacity .15s ease; }
#comprar .table tbody tr:not(:hover):not(.row-editing) .icon-btn {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
#comprar .table tbody tr:hover .icon-btn,
#comprar .table tbody tr.row-editing .icon-btn { opacity: 1; visibility: visible; pointer-events: auto; }
/* Fora do hover da tabela, mantém visíveis os ícones da primeira linha */
#comprar .table:not(:hover) tbody tr:first-child .icon-btn {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}
.table tbody tr .col-acoes,
.table tbody tr .cell-acoes { white-space: nowrap; }

/* Destaque leve para a linha em foco */
.table tbody tr:hover { background: #f8fafc; }
.table tbody tr.row-editing { background: #f4fbf5; }
.table tbody tr.row-editing:hover { background: #f4fbf5; }

/* Segmented (sobrou para compatibilidade, mas não usado) */
.segmented {
  display: inline-grid; grid-auto-flow: column; gap: 6px; align-items: center;
  background: var(--gray-100); border: 1px solid var(--gray-300); border-radius: 12px; padding: 6px;
}
.segmented input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented label { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; cursor: pointer; user-select: none; color: var(--gray-800); font-weight: 600; letter-spacing: .2px; }
.segmented .seg-text { display: grid; line-height: 1.1; }
.segmented .seg-text strong { font-weight: 700; }
.segmented .seg-text small { color: var(--gray-500); font-weight: 500; }
.segmented input[type="radio"]:checked + label { background: var(--green-50); color: var(--green-600); box-shadow: inset 0 0 0 1px var(--green-400); }
.segmented input[type="radio"]:focus-visible + label { outline: none; box-shadow: var(--focus); }

/* Botão maior + ícone */
.btn-lg { height: 44px; padding-inline: 18px; font-size: 1rem; }
.btn-icon { display: inline-flex; margin-right: 8px; }
@media (max-width: 640px) {
  .btn-submit { width: 100%; justify-content: center; }
  .table-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .table-search { width: 100%; }
}

/* Barra de aviso de edição */
.edit-guard {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 60;
  background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #9a3412;
  padding: 8px 16px; text-align: center; font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .edit-guard { background: #1f1305; border-bottom-color: #5b3413; color: #fdba74; }
}
.panel h2 { margin: 0 0 8px; color: var(--gray-900); font-size: 1.25rem; }
.panel p { margin: 0; color: var(--gray-600); }

/* Responsividade */
@media (max-width: 1024px) {
  :root { --sidebar-w: 248px; }
}

@media (max-width: 880px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-main { padding: calc(var(--header-h) + 20px) 16px 20px 16px; }
}

/* Preferências de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Dark mode (opcional) */
@media (prefers-color-scheme: dark) {
  body { background: #0b1220; color: #e5e7eb; }
  .app-header { background: #0f172a; border-bottom-color: #0b1220; }
  .icon-button { background: #0f172a; border-color: #1f2937; color: #cbd5e1; }
  .icon-button:hover { background: #111a33; }
  .app-sidebar { background: #0f172a; border-right-color: #0b1220; }
  .menu-item { color: #cbd5e1; border-color: transparent; }
  .menu-item:hover { background: rgba(67,160,71,0.12); color: #a7f3d0; }
  .menu-item.is-active { background: rgba(67,160,71,0.18); color: #86efac; border-color: rgba(134,239,172,0.24); }
  .sidebar-footer { color: #94a3b8; border-top-color: #0b1220; }
  .app-main .hero, .panel { background: #0f172a; border-color: #0b1220; }
  .btn { color: #e5e7eb; background: #0f172a; border-color: #1f2937; }
  .btn:hover { background: #111a33; }
}

/* ----------------------- */
/* Comprar: layout estilo caixa */
/* ----------------------- */
.box, .card { background: var(--white); border: 1px solid var(--gray-300); border-radius: 10px; box-shadow: var(--shadow-1); padding: 12px; }
.box-title { margin: 0 0 8px; font-size: 1rem; color: var(--gray-800); letter-spacing: .5px; }
.box-flow .flow-stats { display: grid; gap: 4px; font-weight: 600; color: var(--gray-700); }
.box-flow .flow-stats .neg { color: #b42318; }
.box-flow .flow-list { height: 130px; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--gray-100); margin: 8px 0; }
.box-flow .flow-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.box-purchases .purchases-header { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; margin-bottom: 8px; }
.box-purchases .purchases-total { font-weight: 700; color: var(--gray-800); }
.btn-sm { height: 30px; padding: 0 10px; border-radius: 8px; font-weight: 600; }
.purchases-footer { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }

.front { padding: 0; overflow: hidden; max-width: 920px; margin: 0 auto; }
.front-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-bottom: 1px solid var(--gray-200); background: #f8fafc; }
.front-window-controls { display: inline-flex; gap: 6px; }
.win-btn { height: 24px; width: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; border: 1px solid var(--gray-300); background: var(--white); color: var(--gray-700); }
.win-btn:hover { background: var(--gray-100); }
.front-form { padding: 10px; }
.front-label { font-weight: 800; color: var(--gray-700); font-size: .92rem; align-self: center; }
.input--mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
.input--sm { height: 32px; }
.btn-block { width: 100%; justify-content: center; }
.front-total { text-align: center; font-weight: 800; padding: 8px; border-top: 1px solid var(--gray-200); }

/* Layout clássico da frente de caixa */
.front-classic {
  display: grid; gap: 8px;
  grid-template-columns: 90px 120px 1fr;
  grid-template-rows: 32px 32px 32px 1fr;
  grid-template-areas:
    "lab-cod cod produto"
    "lab-val val panel"
    "lab-qty qty panel"
    ".      ops panel";
}
.front-classic .lab-cod { grid-area: lab-cod; }
.front-classic .lab-val { grid-area: lab-val; }
.front-classic .lab-qty { grid-area: lab-qty; }
.front-classic .area-cod { grid-area: cod; }
.front-classic .area-produto { grid-area: produto; }
.front-classic .area-val { grid-area: val; }
.front-classic .area-qty { grid-area: qty; text-align: right; }
.front-classic .area-panel { grid-area: panel; min-height: 180px; border: 1px solid var(--gray-300); border-radius: 8px; background: #f3f4f6; }
.front-classic .area-ops { grid-area: ops; align-self: start; }
.front-ops-vert { display: grid; gap: 6px; }
.front-ops-vert .ops-label { font-size: .8rem; color: var(--gray-600); text-transform: lowercase; }

@media (max-width: 1100px) {
  .cash-layout { grid-template-columns: 1fr; }
  .cash-main { order: -1; }
}

/* ----------------------- */
/* Comprar: meu layout limpo */
/* ----------------------- */
.buy-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .buy-layout { grid-template-columns: 1fr; } }

/* --- Auth Modal (login obrigatório) --- */
.auth-modal { position: fixed; inset: 0; display: none; z-index: 10000; }
.auth-modal[hidden] { display: none !important; }
.auth-modal:not([hidden]) { display: block; }
.auth-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
.auth-modal__dialog { position: relative; margin: 8vh auto; max-width: 520px; background: #fff; color: #222; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; border: 1px solid rgba(0,0,0,.06); animation: popIn .16s ease-out; }
@media (prefers-color-scheme: dark) {
  .auth-modal__dialog { background: #0f172a; color: #e5e7eb; border-color: rgba(255,255,255,.06); box-shadow: 0 20px 60px rgba(0,0,0,.45); }
}
.auth-modal__header { padding: 16px 20px; border-bottom: 1px solid rgba(0,0,0,.06); }
.auth-modal__body { padding: 18px 20px 22px; display: grid; gap: 14px; }
.auth-modal__body p { margin: 0 0 6px; color: var(--gray-700, #555); }

/* Auth card */
.auth-card { display: grid; gap: 18px; }
.auth-brand { display: flex; gap: 12px; align-items: center; }
.auth-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.auth-title { font-size: 1.05rem; font-weight: 800; letter-spacing: .2px; }
.auth-desc { color: var(--gray-700, #555); font-size: .92rem; margin-top: 2px; }
.auth-actions { display: grid; gap: 10px; justify-items: start; }
.auth-hint { color: var(--gray-600, #666); }

/* Lock the app while modal is open */
body.auth-locked .app-header,
body.auth-locked .app-sidebar,
body.auth-locked .app-main { filter: blur(1.5px) saturate(.95); pointer-events: none; user-select: none; }

/* Fallback for browsers supporting inert */
[inert] { pointer-events: none; user-select: none; }

@keyframes popIn { from { transform: translateY(6px) scale(.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

/* --- Company Modal --- */
.company-modal { position: fixed; inset: 0; display: none; z-index: 10001; }
.company-modal[hidden] { display: none !important; }
.company-modal:not([hidden]) { display: block; }
.company-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); }
.company-modal__dialog { position: relative; margin: 8vh auto; max-width: 640px; background: #fff; color: #222; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; border: 1px solid rgba(0,0,0,.06); animation: popIn .16s ease-out; }
@media (prefers-color-scheme: dark) { .company-modal__dialog { background: #0f172a; color: #e5e7eb; border-color: rgba(255,255,255,.06); } }
.company-modal__header { padding: 18px 20px 8px; border-bottom: 1px solid rgba(0,0,0,.06); }
.company-modal__header .company-sub { margin: 6px 0 0; color: var(--gray-600); font-size: .92rem; }
.company-modal__body { padding: 18px 20px; display: grid; gap: 10px; }
.company-modal__actions { padding: 12px 20px 18px; border-top: 1px solid rgba(0,0,0,.06); display: flex; justify-content: flex-end; gap: 8px; }
.company-modal .label { font-weight: 700; color: var(--gray-700); }
.company-modal .error { color: #b42318; font-size: .82rem; min-height: 1em; }

/* Cards - Minhas compras */
.cards-header { display:flex; justify-content:flex-end; margin-bottom:10px; }
.cards-grid { display:grid; grid-template-columns: repeat( auto-fill, minmax(240px, 1fr) ); gap: 12px; }
.purchase-card { border:1px solid var(--gray-200); border-radius:12px; background: var(--white); box-shadow: var(--shadow-1); padding:12px; display:grid; gap:8px; }
.purchase-card__header { display:flex; align-items:center; justify-content:space-between; }
.purchase-card__header .pc-logo { width:22px; height:22px; border-radius:6px; object-fit:cover; box-shadow: var(--shadow-1); }
.purchase-card__ns { font-weight:800; color: var(--green-600); letter-spacing:.5px; background:#eefcf0; border:1px solid #d7f5db; padding:4px 8px; border-radius:999px; }
.pc-logo { width:28px; height:28px; border-radius:8px; object-fit:cover; box-shadow: 0 2px 6px rgba(0,0,0,.12); }
.purchase-card__total { font-size:1.2rem; font-weight:900; text-align:right; color: var(--gray-900); }
.purchase-card__meta { color: var(--gray-600); font-size:.9rem; display:flex; justify-content:space-between; align-items:center; }
.purchase-card__meta .pc-date { opacity:.9; }
.purchase-card__actions { display:flex; justify-content:flex-end; align-items:center; gap:8px; }
.purchase-card .btn-sm { height:30px; padding:0 10px; border-radius:8px; }
/* Itens preview dentro do card */
.pc-items { margin: 4px 0 6px; padding: 0; list-style: none; display: grid; gap: 4px; }
.pc-item { display:flex; justify-content:space-between; font-size:.9rem; color: var(--gray-800); }
.pc-item small { color: var(--gray-600); }
.pc-header { display:flex; align-items:center; gap:8px; }
.pc-header .pc-recycle { width:18px; height:18px; color: var(--green-600); opacity:.9; }

.cd-meta { display:flex; justify-content:space-between; font-weight:700; margin-bottom:6px; }

/* Address suggest dropdown (fallback) */
.addr-suggest { background: #fff; color: #111; border: 1px solid var(--gray-300); border-radius: 10px; box-shadow: var(--shadow-2); max-height: 260px; overflow: auto; }
.addr-suggest__item { padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--gray-200); }
.addr-suggest__item:last-child { border-bottom: 0; }
.addr-suggest__item:hover, .addr-suggest__item.is-active { background: var(--green-50); }
@media (prefers-color-scheme: dark) { .addr-suggest { background: #0f172a; color: #e5e7eb; border-color: #1f2937; } .addr-suggest__item { border-bottom-color: #1f2937; } .addr-suggest__item:hover, .addr-suggest__item.is-active { background: rgba(67,160,71,0.18); } }
/* Garantir ocultação de elementos com atributo [hidden] */
:where([hidden]) { display: none !important; }
