/* Cabeçalhos de modal: padrão amarelo aprovado no histórico de estoque. */
.stock-modal-header,
.sale-detail-web > header,
.category-manager-header,
.customer-form-head {
  border-bottom: 1px solid rgba(8, 38, 95, .12);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.modal-box:has(#product-editor) #modal-body > h2 {
  border-bottom-color: rgba(8, 38, 95, .12);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.modal-box:has(#product-editor) #modal-body > h2::before {
  background: var(--navy);
}

.modal-box:has(#product-editor) > .modal-close {
  border-color: rgba(8, 38, 95, .18);
  background: rgba(255, 255, 255, .72);
  color: var(--navy);
}

.modal-box:has(#product-editor) > .modal-close:hover {
  background: var(--navy);
  color: #fff;
}

.product-modal-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 15px 72px 14px 18px;
  border-bottom: 1px solid rgba(8, 38, 95, .14);
  border-radius: 17px 17px 0 0;
  background: var(--yellow);
  color: var(--navy);
}

.product-modal-header > span {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--navy);
  color: #fff;
  font-size: 22px;
  font-weight: 950;
}

.product-modal-header small {
  display: block;
  color: var(--navy);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .13em;
}

.product-modal-header h2 {
  margin: 2px 0 1px;
  color: var(--navy);
  font-size: 20px;
  line-height: 1.15;
}

.product-modal-header p {
  margin: 0;
  color: #4e5c74;
  font-size: 11px;
  font-weight: 650;
}

.category-editor-layer { position:absolute; inset:0; z-index:12; display:grid; place-items:center; padding:22px; border-radius:inherit; background:rgba(4,17,42,.58); backdrop-filter:blur(2px); }
.category-editor-dialog { width:min(570px,100%); overflow:hidden; border:1px solid rgba(8,38,95,.14); border-radius:18px; background:#fff; box-shadow:0 24px 70px rgba(0,0,0,.3); }
.category-editor-dialog > header { position:relative; padding:16px 62px 14px 22px; border-bottom:1px solid rgba(8,38,95,.14); background:var(--yellow); color:var(--navy); }
.category-editor-dialog header small { font-size:9px; font-weight:950; letter-spacing:.13em; }
.category-editor-dialog header h2 { margin:2px 0; color:var(--navy); font-size:21px; }
.category-editor-dialog header p { margin:0; color:#4e5c74; font-size:11px; font-weight:650; }
.category-editor-dialog form { padding:18px 22px 22px; }
.category-editor-dialog input { width:100%; }
.category-editor-close { position:absolute; top:14px; right:16px; width:34px; height:34px; display:grid; place-items:center; padding:0; border:1px solid rgba(8,38,95,.16); border-radius:50%; background:rgba(255,255,255,.78); color:var(--navy); font-size:23px; cursor:pointer; }

.modal-box:has(.pending-sales-web) { width:min(680px,100%); padding:0; overflow:hidden; }
.pending-sales-web { display:block; }
.pending-sales-web > small { display:block; margin:0; padding:17px 64px 0 26px; background:var(--yellow); color:var(--navy); font-size:9px; font-weight:950; letter-spacing:.13em; }
.pending-sales-web > h2 { margin:0; padding:3px 64px 16px 26px; border-bottom:1px solid rgba(8,38,95,.14); background:var(--yellow); color:var(--navy); font-size:22px; }
.pending-sales-web > p { margin:0; padding:20px 26px 16px; color:#526078; font-size:14px; }
.pending-sales-web > div { margin:0; padding:0 26px 18px; background:#fff; }
.pending-sales-web > div:empty { display:none; }
.pending-sales-web > footer { display:flex; grid-template-columns:none; align-items:center; justify-content:flex-end; gap:9px; margin:0; padding:14px 26px 20px; border-top:1px solid var(--line); background:#fff; color:var(--navy); }
.pending-sales-web > footer .button { min-height:40px; padding:0 18px; }

/* Finalização do PDV: cabeçalho amarelo e corpo branco no padrão do Painel com altura estável. */
.modal-box:has(.checkout-form) {
  display: flex;
  flex-direction: column;
  width: min(880px, calc(100vw - 36px));
  height: min(640px, calc(100dvh - 36px));
  min-height: min(640px, calc(100dvh - 36px));
  max-height: calc(100dvh - 36px);
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 18px;
  background: #fff;
}

.modal-box:has(.checkout-form) > .modal-close {
  top: 15px;
  right: 17px;
  z-index: 4;
  border: 1px solid rgba(8, 38, 95, .18);
  background: rgba(255, 255, 255, .78);
  color: var(--navy);
}

.modal-box:has(.checkout-form) .checkout-head {
  flex: 0 0 auto;
  min-height: 84px;
  margin: 0;
  padding: 17px 76px 15px 26px;
  border-bottom: 1px solid rgba(8, 38, 95, .14);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.modal-box:has(.checkout-form) .checkout-head span,
.modal-box:has(.checkout-form) .checkout-head h2,
.modal-box:has(.checkout-form) .checkout-head > strong {
  color: var(--navy);
}

.modal-box:has(.checkout-form) .checkout-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 26px 24px;
  background: #fff;
  overflow: visible;
}

.modal-box:has(.checkout-form) .optional-customer {
  position: relative;
  z-index: 50;
}

.modal-box:has(.checkout-form) .customer-combobox {
  position: relative;
  z-index: 60;
}

.modal-box:has(.checkout-form) .customer-options {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: 280px;
  z-index: 9999;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 18px 50px rgba(8, 38, 95, .28);
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.modal-box:has(.checkout-form) .checkout-form > .form-actions {
  position: static;
  z-index: 1;
  margin-top: auto;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  background: transparent;
  box-shadow: none;
}

/* Confirmação da venda também usa cabeçalho amarelo, sem alterar o fluxo. */
.modal-box:has(.sale-success) {
  width: min(640px, calc(100vw - 36px));
  padding: 0;
  overflow: hidden;
}

.modal-box:has(.sale-success) > .modal-close {
  top: 15px;
  right: 17px;
  z-index: 4;
  border: 1px solid rgba(8, 38, 95, .18);
  background: rgba(255, 255, 255, .78);
  color: var(--navy);
}

.modal-box:has(.sale-success) .sale-success {
  position: relative;
  isolation: isolate;
  padding: 16px 0 0;
  background: #fff;
}

.modal-box:has(.sale-success) .sale-success::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0 0 auto;
  height: 188px;
  border-bottom: 1px solid rgba(8, 38, 95, .12);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
}

.modal-box:has(.sale-success) .sale-success > * {
  position: relative;
  z-index: 1;
}

.modal-box:has(.sale-success) .sale-success-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 6px;
  background: var(--navy);
  color: #fff;
  font-size: 28px;
  box-shadow: 0 8px 22px rgba(8, 38, 95, .18);
}

.modal-box:has(.sale-success) .sale-success > small,
.modal-box:has(.sale-success) .sale-success h2,
.modal-box:has(.sale-success) .sale-success > strong {
  color: var(--navy);
}

.modal-box:has(.sale-success) .sale-success h2 {
  margin-top: 3px !important;
  font-size: 22px;
}

.modal-box:has(.sale-success) .sale-success > strong {
  margin: 3px 0 10px;
  font-size: 28px;
}

.modal-box:has(.sale-success) .sale-success-details {
  margin: 14px 26px 0;
  border: 1px solid #e6eaf0;
  background: #f4f6f9;
}

.modal-box:has(.sale-success) .sale-success > p {
  margin: 0;
  padding: 14px 26px 10px;
  background: #fff;
}

.modal-box:has(.sale-success) .sale-success-actions {
  margin: 0;
  padding: 8px 26px 24px;
  background: #fff;
}

/* Detalhes da venda: cabeçalho e rodapé fixos; somente os itens rolam. */
.modal-box:has(.sale-detail-web) {
  height: min(760px, calc(100dvh - 40px));
  max-height: none;
  overflow: hidden;
}

.modal-box:has(.sale-detail-web) #modal-body {
  height: 100%;
  min-height: 0;
}

.sale-detail-web {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.sale-detail-items {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.sale-detail-items.is-loading {
  display: grid;
  place-items: center;
}

.sale-items-loading {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 21px;
  border: 1px solid #dce3ed;
  border-radius: 13px;
  background: #f7f9fc;
  color: var(--navy);
  box-shadow: 0 5px 16px rgba(8, 38, 95, .045);
}

.sale-items-loading .spinner {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  margin: 0;
  border-width: 3px;
}

.sale-items-loading b,
.sale-items-loading small,
.sale-items-error b,
.sale-items-error small { display: block; }
.sale-items-loading small,
.sale-items-error small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.sale-items-error { margin: auto; padding: 18px; color: var(--navy); text-align: center; }

.sale-origin-tag { display:inline-flex; align-items:center; width:max-content; margin-top:5px; padding:3px 7px; border:1px solid #ccd8ea; border-radius:99px; background:#edf3fb; color:#245997; font-size:8px; font-weight:900; line-height:1.2; white-space:nowrap; }
.sale-origin-tag.mobile { border-color:#c8e8d8; background:#e8f7ef; color:#087847; }
.sale-origin-tag.web { border-color:#cbd9ee; background:#edf3fb; color:#245997; }
.sale-origin-tag.unknown { border-color:#dde1e7; background:#f3f5f8; color:#68758c; }
.sale-detail-badges { display:grid; justify-items:end; gap:5px; flex:0 0 auto; }
.sale-detail-badges .sale-origin-tag { margin-top:0; }

.sale-detail-web > footer {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  margin: 0;
  box-shadow: 0 -7px 18px rgba(8, 38, 95, .06);
}

@media (max-height: 680px) {
  .modal-box:has(.sale-detail-web) { height: calc(100dvh - 20px); }
  .sale-detail-web > header { padding-top: 15px; padding-bottom: 14px; }
  .sale-detail-summary { padding-top: 11px; padding-bottom: 11px; }
}

.modal-box:has(#business-settings-form) {
  padding: 0;
  overflow: auto;
}

.business-settings-head {
  padding: 18px 68px 16px 24px;
  border-bottom: 1px solid rgba(8, 38, 95, .12);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.business-settings-head h2 {
  color: var(--navy);
}

.business-settings-head p {
  margin-bottom: 0;
  color: #4e5c74;
  font-weight: 650;
}

.modal-box:has(#business-settings-form) .business-settings-form {
  padding: 16px 24px 24px;
}

.modal-box:has(#storefront-settings-form) {
  padding: 0;
}

.modal-box:has(#storefront-settings-form) > #modal-body > h2 {
  margin: 0;
  padding: 17px 64px 3px 22px;
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.modal-box:has(#storefront-settings-form) > #modal-body > p {
  margin: 0;
  padding: 0 64px 15px 22px;
  border-bottom: 1px solid rgba(8, 38, 95, .12);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: #4e5c74;
  font-weight: 650;
}

.modal-box:has(#storefront-settings-form) #storefront-settings-form {
  padding: 14px 22px 20px;
}

.modal-box:has(#profile-settings-form) {
  padding: 0;
}

.modal-box:has(#profile-settings-form) > #modal-body > h2 {
  margin: 0;
  padding: 18px 64px 16px 22px;
  border-bottom: 1px solid rgba(8, 38, 95, .12);
  border-radius: 18px 18px 0 0;
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.modal-box:has(#profile-settings-form) #profile-settings-form {
  padding: 14px 22px 20px;
}

.modal-box:has(#printer-settings-form) {
  padding: 0;
}

.modal-box:has(#printer-settings-form) > #modal-body > h2 {
  margin: 0;
  padding: 18px 64px 3px 26px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: var(--navy);
}

.modal-box:has(#printer-settings-form) > #modal-body > p {
  margin: 0;
  padding: 0 64px 16px 26px;
  border-bottom: 1px solid rgba(8, 38, 95, .12);
  background: linear-gradient(135deg, var(--yellow), #ffd85e);
  color: #4e5c74;
  font-weight: 650;
}

.modal-box:has(#printer-settings-form) #printer-settings-form {
  padding: 14px 26px 26px;
}

.stock-modal-header small,
.sale-detail-web > header small,
.category-manager-header small,
.customer-form-head small {
  color: var(--navy);
}

.stock-modal-header h2,
.sale-detail-web > header h2,
.category-manager-header h2,
.customer-form-head h2 {
  color: var(--navy);
}

.stock-modal-header p,
.sale-detail-web > header p,
.category-manager-header p,
.customer-form-head p {
  color: #4e5c74;
  font-weight: 650;
}

.stock-modal-header .stock-modal-icon,
.category-manager-header > span {
  border: 1px solid rgba(255, 255, 255, .28);
  background: var(--navy);
  color: #fff;
  box-shadow: 0 6px 14px rgba(8, 38, 95, .16);
}

.category-manager-header .button {
  background: var(--navy);
  color: #fff;
}

.sale-detail-web > header .badge {
  border: 1px solid rgba(8, 38, 95, .12);
  background: rgba(255, 255, 255, .72);
  color: var(--navy);
}

.sale-detail-web > header .badge.red {
  border-color: #e9aaa5;
  background: #fff0ef;
  color: #b3261e;
}

.customer-form-head .customer-deactivate {
  border-color: rgba(8, 38, 95, .24);
  color: var(--navy);
}

/* Diálogos de confirmação e exclusão (appConfirm / app-dialog) */
.app-dialog-layer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 26, 57, .48);
  backdrop-filter: blur(4px);
}

.app-dialog {
  width: min(450px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  background: #ffffff !important;
  color: var(--navy);
  box-shadow: 0 24px 70px rgba(3, 18, 47, .22);
  animation: appDialogIn .2s ease;
}

.app-dialog.danger {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  column-gap: 16px;
  border: 1px solid #fecaca;
  background: #ffffff !important;
}

.app-dialog-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 14px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #b45309;
  font-size: 22px;
  font-weight: 950;
}

.app-dialog-icon.danger {
  margin: 0;
  width: 48px;
  height: 48px;
  border: 1px solid #fecaca !important;
  border-radius: 14px;
  background: #fef2f2 !important;
  color: #dc2626 !important;
  font-size: 24px;
}

.app-dialog small {
  display: block;
  color: var(--blue, #294584);
  font-size: 9px;
  font-weight: 950;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.app-dialog.danger small {
  color: #dc2626;
}

.app-dialog h2 {
  margin: 2px 0 8px;
  color: var(--navy, #182b55);
  font-size: 21px;
  font-weight: 850;
  line-height: 1.25;
}

.app-dialog p {
  margin: 0;
  color: #59677e;
  font-size: 14px;
  line-height: 1.5;
}

.app-dialog.danger p {
  padding: 11px 14px;
  border: 1px solid #fee2e2;
  border-radius: 11px;
  background: #fff8f8;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}

.app-dialog footer,
.app-dialog.danger footer {
  grid-column: 1 / -1;
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  margin: 20px 0 0 !important;
  padding: 16px 0 0 !important;
  border: 0 !important;
  border-top: 1px solid #f1f5f9 !important;
  background: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
}

.app-dialog.danger footer {
  border-top: 1px solid #fee2e2 !important;
}

.app-dialog footer button {
  min-height: 42px;
  min-width: 105px;
  padding: 0 18px;
  border: 1px solid #d1d5db;
  border-radius: 11px;
  background: #ffffff;
  color: #374151;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s ease;
}

.app-dialog footer button:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.app-dialog footer button.primary {
  border-color: var(--yellow, #fec005);
  background: var(--yellow, #fec005);
  color: var(--navy, #182b55);
  font-weight: 900;
}

.app-dialog footer button.primary:hover {
  background: #eab308;
  border-color: #eab308;
}

.app-dialog footer button.primary.danger {
  border-color: #dc2626 !important;
  background: #dc2626 !important;
  color: #ffffff !important;
  font-weight: 900;
  box-shadow: 0 4px 14px rgba(220, 38, 38, .28) !important;
}

.app-dialog footer button.primary.danger:hover {
  background: #b91c1c !important;
  border-color: #b91c1c !important;
}

@media (max-width: 520px) {
  .app-dialog, .app-dialog.danger {
    padding: 18px;
    border-radius: 18px;
  }
  .app-dialog.danger {
    grid-template-columns: 44px minmax(0, 1fr);
    column-gap: 12px;
  }
  .app-dialog.danger .app-dialog-icon {
    width: 44px;
    height: 44px;
  }
  .app-dialog footer,
  .app-dialog.danger footer {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .app-dialog footer button {
    min-width: 0;
    width: 100%;
  }
}

