:root {
  --canvas: #0b0f17;
  --card-bg: #141a24;
  --card-hover: #19212e;
  --surface: #1b2331;
  --surface-2: #222c3e;
  --surface-border: rgba(255, 255, 255, 0.08);
  --surface-border-strong: rgba(255, 255, 255, 0.16);
  --ink: #f1f5f9;
  --ink-muted: #94a3b8;
  --ink-subtle: #64748b;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.35);
  --blue: #3b82f6;
  --blue-bg: rgba(59, 130, 246, 0.12);
  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.14);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 6px 18px rgba(0, 0, 0, 0.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

img {
  max-width: 100%;
  height: auto;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--canvas);
  background-image: radial-gradient(circle at 50% -20%, rgba(255, 255, 255, 0.035) 0%, transparent 55%);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* =========================================================================
   TOPBAR
   ========================================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(11, 15, 23, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--surface-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: grid;
  place-items: center;
  width: 42px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.2px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 2px 7px;
  border-radius: 999px;
}

.status-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.brand-text small {
  display: block;
  color: var(--ink-subtle);
  font-size: 11px;
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
}

.user-badge .avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.user-badge .user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: rgba(244, 63, 94, 0.3);
  background: var(--danger-bg);
}

/* =========================================================================
   MAIN WRAPPER & BASE CARD
   ========================================================================= */
main {
  width: min(780px, 100%);
  margin: 0 auto;
  padding: 16px 14px 120px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.hidden {
  display: none !important;
}

/* =========================================================================
   TELA DE LOGIN (ESTILO APPGARCOM / NATIVO)
   ========================================================================= */
.login-screen {
  max-width: 400px;
  margin: 36px auto 0;
  text-align: center;
  padding: 0 8px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.login-brand h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 4px;
  letter-spacing: -0.3px;
}

.login-brand p {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0;
}

.login-card {
  text-align: left;
  padding: 24px;
  background: var(--card-bg);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
}

.login-card label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
  margin-top: 14px;
}

.login-card label:first-of-type {
  margin-top: 0;
}

.login-button {
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
}

.login-footer {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.system-tag {
  font-size: 11px;
  color: var(--ink-subtle);
  letter-spacing: 0.3px;
}

.connect-link {
  font-size: 13px;
  color: var(--emerald);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  transition: 0.2s;
}

.connect-link:hover {
  background: rgba(16, 185, 129, 0.2);
}

/* =========================================================================
   FORM ELEMENTS & BUTTONS
   ========================================================================= */
input, select, textarea {
  display: block;
  width: 100%;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 16px; /* 16px evita zoom automático no iOS/Android */
  color: var(--ink);
  outline: none;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  background: var(--surface-2);
}

input::placeholder, textarea::placeholder {
  color: var(--ink-subtle);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

button {
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:active {
  transform: scale(0.97);
}

.primary {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.primary:hover {
  background: linear-gradient(135deg, #059669, #047857);
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--surface-border);
}

.secondary:hover {
  background: var(--card-hover);
  border-color: var(--surface-border-strong);
}

.link {
  background: transparent;
  color: var(--emerald);
  padding: 6px 12px;
}

/* =========================================================================
   TABS DE NAVEGAÇÃO
   ========================================================================= */
.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover {
  color: #fff;
}

.tab.active {
  background: var(--surface-2);
  color: #fff;
  border: 1px solid var(--surface-border-strong);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* =========================================================================
   POS ERGONÔMICO: TOPO CLIENTE & VENDEDOR COMPACTO
   ========================================================================= */
.pos-container {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pos-topbar-compact {
  padding: 12px 14px;
  margin-bottom: 12px;
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
}

.actor-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.actor-clickable-area {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.actor-icon-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 18px;
  flex: none;
}

.customer-avatar {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.seller-avatar {
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
}

.actor-text-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.actor-mini-tag {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.customer-tag,
.seller-tag {
  color: var(--ink-subtle);
}

.actor-text-column strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actor-text-column small {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-compact-pill {
  all: unset !important;
  box-sizing: border-box !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: var(--ink) !important;
  border: 1px solid var(--surface-border-strong) !important;
  padding: 6px 14px !important;
  border-radius: 8px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  flex: none !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.btn-compact-pill:hover {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: var(--emerald) !important;
  color: #fff !important;
}

.actor-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.btn-novo-cliente-pill {
  color: var(--emerald) !important;
  background: rgba(16, 185, 129, 0.1) !important;
  border-color: var(--emerald-border) !important;
}

.btn-novo-cliente-pill:hover {
  background: rgba(16, 185, 129, 0.22) !important;
  border-color: var(--emerald) !important;
  color: #fff !important;
}

.actor-divider {
  height: 1px;
  background: var(--surface-border);
  margin: 10px 0;
}

.seller-card-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seller-inline-select {
  width: 100%;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 2px 28px 2px 0;
  height: 28px;
  outline: none;
}

/* BUSCA & CADASTRO DE CLIENTE (EXPANDÍVEL) */
.client-search-wrapper {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-border);
}

.search-field {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-close-search {
  flex: none;
  background: var(--surface);
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.client-results {
  max-height: 220px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.client-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  text-align: left;
  cursor: pointer;
  transition: 0.15s;
}

.client-item:hover {
  background: var(--surface-2);
  border-color: var(--emerald-border);
}

.client-item strong {
  display: block;
  font-size: 13px;
  color: #fff;
}

.client-item small {
  font-size: 11px;
  color: var(--ink-muted);
}

.select-pill {
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  padding: 4px 10px;
  border-radius: 999px;
  flex: none;
}

.client-actions-bar {
  margin: 6px 0 10px;
}

.btn-cadastrar-cliente {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-md);
  background: rgba(16, 185, 129, 0.08);
  color: var(--emerald);
  border: 1px dashed var(--emerald-border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-cadastrar-cliente:hover {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--emerald);
  color: #fff;
}

.new-client-box {
  margin-top: 12px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--surface-border);
}

.new-client-box .subheading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.btn-voltar-cliente {
  background: none;
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.btn-voltar-cliente:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--surface-border-strong);
}

.new-client-box label {
  font-size: 11px;
  margin-top: 10px;
}

.new-client-submit {
  width: 100%;
  margin-top: 14px;
}

.document-row, .cep-row, .form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.form-row {
  grid-template-columns: 1fr 1fr;
}

.cnpj-status {
  margin-top: 6px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* =========================================================================
   BUSCA ERGONÔMICA DE PRODUTOS
   ========================================================================= */
.pos-search-card {
  padding: 14px;
  margin-bottom: 12px;
}

.search-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 16px;
  color: var(--ink-muted);
  pointer-events: none;
}

#produtoBusca {
  padding-left: 44px;
  padding-right: 44px;
  height: 48px;
  font-size: 15px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1.5px solid var(--surface-border-strong);
}

#produtoBusca::-webkit-search-cancel-button,
#produtoBusca::-webkit-search-decoration {
  -webkit-appearance: none;
  display: none;
}

#produtoBusca:focus {
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
  background: var(--surface-2);
}

.barcode-scanner-icon {
  color: var(--emerald);
  cursor: pointer;
  pointer-events: auto !important;
  transition: transform 0.18s ease, color 0.18s ease;
}

.barcode-scanner-icon:hover {
  color: #34d399;
  transform: scale(1.1);
}

.search-input-group:focus-within .barcode-scanner-icon {
  color: #34d399;
}

.btn-clear {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 16px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
}

.btn-clear:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* RESULTADOS DA BUSCA EM LISTA DINÂMICA */
.search-results-panel {
  margin-top: 12px;
}

.results-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 10px;
  border-bottom: 1px solid var(--surface-border);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
}

.btn-fechar-busca {
  background: var(--surface);
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-fechar-busca:hover {
  color: #fff;
  border-color: var(--surface-border-strong);
}

.product-results-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.product-item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  cursor: pointer;
  transition: all 0.15s ease;
}

.product-item-row:hover {
  background: var(--surface-2);
  border-color: var(--emerald-border);
}

.product-item-row.in-cart {
  border-color: rgba(16, 185, 129, 0.4);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08) 0%, var(--surface) 100%);
}

.product-item-info {
  min-width: 0;
}

.product-item-title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
  margin-bottom: 4px;
}

.product-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.product-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--emerald);
}

.product-item-unit {
  font-size: 11px;
  color: var(--ink-subtle);
  background: rgba(255, 255, 255, 0.05);
  padding: 1px 6px;
  border-radius: 4px;
}

.product-item-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.product-item-barcode {
  font-size: 11px;
  font-weight: 600;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.product-item-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  padding: 2px 8px;
  border-radius: 999px;
}

.btn-add-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btn-add-circle:active {
  transform: scale(0.92);
}

.no-results {
  text-align: center;
  padding: 24px 12px;
  color: var(--ink-muted);
}

.no-results strong {
  display: block;
  font-size: 14px;
  color: #fff;
  margin-bottom: 4px;
}

.no-results small {
  font-size: 12px;
}

/* =========================================================================
   CARRINHO DE ITENS / ITENS ADICIONADOS
   ========================================================================= */
.pos-cart-card {
  padding: 16px;
  margin-bottom: 12px;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.cart-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.count-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--emerald);
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  padding: 2px 8px;
  border-radius: 999px;
}

.btn-clear-cart {
  background: none;
  border: none;
  color: var(--ink-muted);
  transition: color 0.18s ease;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
}

.btn-clear-cart:hover {
  color: var(--danger);
}

.cart.empty {
  text-align: center;
  padding: 28px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--surface-border);
  border-radius: var(--radius-md);
}

.empty-icon {
  display: block;
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.cart.empty strong {
  display: block;
  font-size: 14px;
  color: #fff;
  margin-bottom: 4px;
}

.cart.empty small {
  font-size: 12px;
  color: var(--ink-muted);
}

.cart-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.cart-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.cart-item-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  line-height: 1.35;
}

.cart-item-price-unit {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.btn-remove-item {
  background: none;
  border: none;
  color: var(--ink-subtle);
  font-size: 16px;
  padding: 4px;
  cursor: pointer;
  flex: none;
}

.btn-remove-item:hover {
  color: var(--danger);
}

/* Grade fixa em vez de flex com quebra: os tres blocos somavam mais que a
   largura da linha num celular, e o subtotal caia sozinho para a linha de
   baixo encostado a esquerda. Aqui os controles ficam empilhados a esquerda e
   o subtotal ocupa a coluna da direita inteira, sempre alinhado. */
.cart-card-bottom {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "stepper  subtotal"
    "desconto subtotal";
  align-items: center;
  column-gap: 12px;
  row-gap: 10px;
}

/* Na tela do PC os tres cabem lado a lado sem apertar. */
@media (min-width: 681px) {
  .cart-card-bottom {
    grid-template-columns: auto auto 1fr;
    grid-template-areas: "stepper desconto subtotal";
  }
}

.stepper-group {
  grid-area: stepper;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  background: var(--card-bg);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper-btn {
  width: 40px;
  height: 38px;
  background: transparent;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  border-radius: 0;
  padding: 0;
}

.stepper-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.stepper-input {
  width: 50px;
  height: 38px;
  background: transparent;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  padding: 0;
  border-radius: 0;
  box-shadow: none !important;
}

.discount-group {
  grid-area: desconto;
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 8px;
}

.discount-group label {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.4px;
  color: var(--ink-muted);
  margin: 0;
  text-transform: uppercase;
}

.discount-input-wrap {
  position: relative;
  width: 72px;
}

/* Mesma altura do stepper para os dois controles baterem na vertical. */
.discount-input-wrap input {
  height: 38px;
  padding: 0 22px 0 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  border-radius: var(--radius-sm);
}

.pct-sign {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--ink-subtle);
  pointer-events: none;
}

.cart-item-subtotal {
  grid-area: subtotal;
  align-self: center;
  justify-self: end;
  text-align: right;
  white-space: nowrap;
}

.cart-item-subtotal small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--ink-subtle);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.cart-item-subtotal strong {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* RESUMO DO CARRINHO */
.cart-summary {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--surface-border);
}

.summary-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.discount-line {
  color: var(--warn);
}

.discount-val {
  color: var(--warn);
}

/* DESCONTO GLOBAL NO TOTAL */
.discount-global-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 8px 0 !important;
  border-top: 1px dashed var(--surface-border) !important;
  border-bottom: 1px dashed var(--surface-border) !important;
  margin: 6px 0 !important;
}

.discount-global-label {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--ink) !important;
}

.discount-pill-toggle {
  display: inline-flex !important;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid var(--surface-border) !important;
  border-radius: 6px !important;
  padding: 2px !important;
  gap: 2px !important;
}

.pill-btn {
  all: unset !important;
  box-sizing: border-box !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 22px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  color: var(--ink-muted) !important;
  border-radius: 4px !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.pill-btn.active {
  background: var(--emerald) !important;
  color: #fff !important;
  box-shadow: none !important;
}

.discount-input-pill {
  display: inline-flex !important;
  align-items: center !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border: 1px solid var(--surface-border) !important;
  border-radius: 8px !important;
  padding: 2px 8px !important;
  width: 100px !important;
  box-sizing: border-box !important;
}

.discount-input-pill:focus-within {
  border-color: var(--emerald) !important;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2) !important;
}

.discount-simbolo {
  font-size: 12px !important;
  font-weight: 700 !important;
  color: var(--ink-muted) !important;
  margin-right: 4px !important;
}

.discount-input-pill input {
  all: unset !important;
  box-sizing: border-box !important;
  width: 100% !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  text-align: right !important;
  padding: 3px 0 !important;
}

.total-line {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--surface-border);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.total-line strong {
  font-size: 18px;
  color: var(--emerald);
}

/* =========================================================================
   PAGAMENTO E FINALIZAÇÃO
   ========================================================================= */
.pos-checkout-card {
  padding: 16px;
}

.checkout-header {
  margin-bottom: 14px;
}

.checkout-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 2px;
}

.checkout-sub {
  font-size: 12px;
  color: var(--ink-muted);
}

.pay-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.pay-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink-subtle);
}

.client-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.client-type-badge.cadastrado {
  background: rgba(16, 185, 129, 0.12);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.3);
}

.payment-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.pay-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 14px 8px 12px;
  background: var(--surface);
  border: 1.5px solid var(--surface-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.pay-card:hover {
  background: var(--surface-2);
  border-color: var(--surface-border-strong);
}

.pay-card.active {
  border-color: var(--emerald);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.16) 0%, rgba(16, 185, 129, 0.04) 100%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.pay-card-icon {
  font-size: 24px;
  margin-bottom: 6px;
}

.pay-card-body strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.pay-card-body small {
  font-size: 10px;
  color: var(--ink-muted);
}

.pay-check {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--emerald);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
}

.pay-card.active .pay-check {
  display: flex;
}

/* CONDIÇÕES A PRAZO (CLIENTE CADASTRADO) */
.a-prazo-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--surface-border);
}

.prazo-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.prazo-divider span {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #f59e0b;
  text-transform: uppercase;
}

.prazo-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.prazo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.prazo-card:hover {
  background: rgba(245, 158, 11, 0.14);
  border-color: rgba(245, 158, 11, 0.5);
}

.prazo-card.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.prazo-card-body strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.prazo-card-body small {
  display: block;
  font-size: 10px;
  color: #fbbf24;
}

.prazo-check {
  display: none;
  font-size: 12px;
  font-weight: 700;
  color: #f59e0b;
}

.prazo-card.active .prazo-check {
  display: inline;
}

.field-wrap {
  margin-top: 12px;
}

.field-wrap label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

textarea {
  min-height: 60px;
  resize: vertical;
}

.checkout-footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--surface-border);
  display: grid;
  gap: 12px;
}

.checkout-total-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius-md);
}

.total-caption {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--emerald);
  text-transform: uppercase;
}

.checkout-grand-total {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}

.actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
}

.btn-validar {
  padding: 14px 18px;
}

.btn-salvar {
  padding: 15px 22px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* =========================================================================
   BARRA FLUTUANTE DE CHECKOUT (MOBILE DOCK)
   ========================================================================= */
.mobile-checkout {
  display: none;
}

/* =========================================================================
   HISTÓRICO E ACESSOS
   ========================================================================= */
.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.step-number {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: var(--emerald);
  font-size: 16px;
  font-weight: 700;
  flex: none;
}

.section-heading h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.section-heading p {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 2px 0 0;
}

.access-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.access-form label {
  margin: 0;
}

.permission-note {
  margin: 14px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--blue-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  font-size: 12px;
}

.access-list {
  display: grid;
  gap: 8px;
}

.access-user {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
}

.access-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  margin-right: 10px;
}

/* =========================================================================
   TOAST NOTIFICATION
   ========================================================================= */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 140px);
  width: min(92%, 460px);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #1e293b;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--surface-border-strong);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  text-align: center;
}

#toast.show {
  transform: translate(-50%, 0);
}

#toast.error {
  background: #881337;
  border-color: #be123c;
  color: #ffe4e6;
}

/* A barra fixa de total tem 72px. Sem isso o aviso "+1 produto" caía em cima
   dela justamente quando o vendedor quer conferir o valor. */
@media (max-width: 680px) {
  #toast {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

/* =========================================================================
   PÁGINA DE CONEXÃO / QR CODE
   ========================================================================= */
.connect-page {
  max-width: 440px;
  margin: 20px auto 0;
  padding: 0 16px;
}

.connect-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px;
}

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--emerald);
  margin-bottom: 8px;
}

.connect-card h1 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
  line-height: 1.3;
}

.connect-card .muted {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0 0 20px;
}

.qr-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 14px;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  margin: 0 auto 18px;
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
}

.qr-frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.connection-url {
  display: inline-block;
  font-family: monospace;
  font-size: 15px;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--emerald-border);
  padding: 8px 18px;
  border-radius: 999px;
  margin-bottom: 20px;
  word-break: break-all;
}

.connection-steps {
  text-align: left;
  padding-left: 20px;
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
  display: grid;
  gap: 8px;
}

.connection-steps li {
  line-height: 1.4;
}

/* =========================================================================
   MODAL DE SUCESSO PÓS-VENDA (WHATSAPP & FINALIZAÇÃO)
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.success-card {
  width: min(440px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  text-align: center;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.success-header {
  margin-bottom: 18px;
}

.success-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
}

.success-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 6px;
}

.success-sub {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0;
}

.success-details-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.success-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.success-detail-row span {
  color: var(--ink-muted);
  font-weight: 600;
}

.success-detail-row strong {
  color: #fff;
  font-weight: 700;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.success-detail-row .highlight-total {
  font-size: 16px;
  font-weight: 700;
  color: var(--emerald);
}

.success-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-whatsapp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #25D366;
  color: #062b13;
  border: none;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btn-whatsapp:hover {
  background: #20bd5a;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.btn-whatsapp .btn-icon {
  font-size: 18px;
}

.secondary-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-copy-summary {
  font-size: 13px;
  padding: 10px;
}

.btn-new-budget {
  font-size: 13px;
  padding: 10px;
}

/* =========================================================================
   RESPONSIVIDADE E OTIMIZAÇÕES MOBILE
   ========================================================================= */


/* Linha que substitui a seção "A Prazo" quando o cliente é consumidor de
   balcão: informa por que sumiu e oferece o caminho, sem exibir nenhuma
   condição que não pode ser usada. */
.prazo-locked {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--surface-border);
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--ink-subtle);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--emerald);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: #34d399;
}

/* =========================================================================
   ÍCONES SVG

   Substituem os emojis que a interface usava. Todos herdam a cor do elemento
   em que estão, então basta pintar o container para o ícone acompanhar.
   ========================================================================= */
.ui-icon {
  width: 20px;
  height: 20px;
  flex: none;
  display: block;
}

.ui-icon-sm {
  width: 16px;
  height: 16px;
}

/* Containers que antes eram dimensionados pelo font-size do emoji. */
.pay-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  color: var(--ink-muted);
  transition: color 0.18s ease;
}

.pay-card-icon .ui-icon {
  width: 22px;
  height: 22px;
}

.pay-card.active .pay-card-icon {
  color: var(--emerald);
}

.search-icon {
  display: flex;
  align-items: center;
}

.search-icon .ui-icon {
  width: 18px;
  height: 18px;
}

.empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  color: var(--ink-subtle);
  opacity: 1;
}

.empty-icon .ui-icon {
  width: 30px;
  height: 30px;
}

.actor-icon-avatar .ui-icon {
  width: 19px;
  height: 19px;
}

.pay-check {
  padding: 0;
}

.pay-check .ui-icon {
  width: 11px;
  height: 11px;
  stroke-width: 3.2;
}

.success-icon-circle .ui-icon {
  width: 26px;
  height: 26px;
  stroke-width: 2.4;
}

.btn-close-search,
.btn-clear,
.btn-remove-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-item .ui-icon,
.btn-clear .ui-icon {
  width: 17px;
  height: 17px;
}

.btn-close-search .ui-icon {
  width: 16px;
  height: 16px;
}

/* Botões que passaram a ter ícone junto do texto. */
.btn-validar,
.btn-salvar,
.modal-action-btn,
/* BANNER DE ORÇAMENTO EM EDIÇÃO */
.editing-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg);
  animation: fadeIn 0.2s ease;
}

.editing-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.editing-banner-badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--warn);
  color: #0b0f17;
}

.editing-banner-text strong {
  display: block;
  font-size: 14px;
  color: #fff;
}

.editing-banner-text small {
  display: block;
  font-size: 11px;
  color: var(--ink-muted);
}

.btn-cancel-edit {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid var(--surface-border-strong);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s;
}

.btn-cancel-edit:hover {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--danger);
  color: #fff;
}

/* HISTÓRICO DE ORÇAMENTOS */
.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.btn-refresh-history {
  padding: 6px 12px !important;
  font-size: 12px !important;
  border-radius: var(--radius-sm) !important;
  gap: 6px !important;
  flex: none;
}

.history-list {
  display: grid;
  gap: 10px;
}

.budget-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  transition: 0.15s ease;
}

.budget-card:hover {
  background: var(--surface-2);
  border-color: var(--surface-border-strong);
}

.budget-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.budget-card-title strong {
  display: block;
  font-size: 14px;
  color: #fff;
  line-height: 1.3;
}

.budget-card-title small {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 3px;
}

.budget-status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  flex: none;
  white-space: nowrap;
}

.budget-status-pill.open {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warn);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.budget-status-pill.billed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.budget-status-pill.cancelled {
  background: rgba(244, 63, 94, 0.15);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.35);
}

.budget-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--surface-border);
}

.budget-card-total {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
}

.budget-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-edit-budget {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: rgba(59, 130, 246, 0.14);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-edit-budget:hover {
  background: rgba(59, 130, 246, 0.3);
  border-color: #60a5fa;
  color: #fff;
}

/* Três ações no rodapé do cartão: em tela estreita elas quebram em vez de
   espremer o texto. */
.budget-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.btn-share-budget,
.btn-pdf-budget {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  border: 1px solid var(--surface-border);
  font-size: 12px;
  cursor: pointer;
  transition: 0.15s;
}

.btn-share-budget:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--emerald-border);
  color: var(--emerald);
}

.btn-pdf-budget:hover {
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(203, 213, 225, 0.45);
  color: #e2e8f0;
}

@media (max-width: 680px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand-text small {
    display: none;
  }

  /* A barra fixa de baixo tem 72px: 80px deixava so 8px de folga e o ultimo
     campo do formulario ficava colado nela. */
  main {
    padding: 12px 10px calc(100px + env(safe-area-inset-bottom));
  }

  .card {
    padding: 14px 12px;
    border-radius: 14px;
  }

  .hidden-mobile {
    display: none !important;
  }

  /* Como no AppGarçom, a lista de produtos flui junto com a página. O painel
     com rolagem própria criava rolagem dentro de rolagem, que no celular faz o
     dedo mover a lista errada. No PC o limite continua, para o carrinho não
     sumir da tela. */
  .product-results-list {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
  }

  .payment-cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .prazo-cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .btn-salvar {
    font-size: 15px;
    padding: 14px;
  }

  .mobile-checkout {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(11, 15, 23, 0.95);
    border-top: 1px solid var(--surface-border-strong);
    backdrop-filter: blur(18px);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.6);
  }

  .mobile-total-info small {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-muted);
    text-transform: uppercase;
  }

  .mobile-total-info strong {
    font-size: 20px;
    font-weight: 700;
    color: var(--emerald);
  }

  .mobile-action-btn {
    padding: 10px 18px;
    font-size: 13px;
    border-radius: 999px;
  }

  /* CRÍTICO: oculta qualquer dock flutuante quando o teclado virtual abrir */
  body:has(input:focus) .mobile-checkout,
  body:has(select:focus) .mobile-checkout,
  body:has(textarea:focus) .mobile-checkout {
    display: none !important;
  }
}

/* =========================================================================
   CONFIGURAÇÕES (LOGIN E GERAL)
   ========================================================================= */
.login-footer-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.btn-login-config {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-login-config:hover {
  background: var(--surface-2);
  color: #fff;
  border-color: var(--surface-border-strong);
  transform: translateY(-1px);
}

.config-card {
  width: min(480px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--surface-border-strong);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.config-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--surface-border);
}

.config-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.config-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.config-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0 0 2px;
}

.config-sub {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: 0.15s;
}

.btn-close-modal:hover {
  color: #fff;
  background: var(--surface);
}

.config-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.config-item-info {
  flex: 1;
}

.config-item-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.config-item-label strong {
  font-size: 14px;
  color: #fff;
  font-weight: 700;
}

.status-pill-mini {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-muted);
  border: 1px solid var(--surface-border);
}

.status-pill-mini.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border-color: var(--emerald-border);
}

.config-item-info p {
  font-size: 12px;
  color: var(--ink-muted);
  margin: 0;
  line-height: 1.45;
}

.config-item-info code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 4px;
  color: #fff;
  font-size: 11px;
}

/* Switch Toggle */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex: none;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-toggle .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface-2);
  border: 1px solid var(--surface-border-strong);
  transition: 0.25s;
  border-radius: 34px;
}

.switch-toggle .slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: #fff;
  transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.switch-toggle input:checked + .slider {
  background-color: var(--emerald);
  border-color: var(--emerald-dark);
}

.switch-toggle input:checked + .slider:before {
  transform: translateX(24px);
}

.config-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--surface-border);
}

.config-remote-item {
  align-items: stretch;
}

.config-remote-info {
  width: 100%;
}

.remote-config-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.remote-config-grid label {
  display: grid;
  gap: 6px;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.remote-config-grid input {
  text-transform: none;
}

#remoteCode {
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.remote-config-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.remote-status-detail {
  display: block;
  margin-top: 10px;
  color: var(--ink-muted);
}

@media (max-width: 680px) {
  .remote-config-grid { grid-template-columns: 1fr; }
  .remote-config-actions { flex-direction: column; }
}

.budget-status-pill.pre-fat {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
