/* ================================================================= */
/* DESIGN SYSTEM & GLOBAL VARIABLES                                  */
/* ================================================================= */
:root {
  /* Palette: Italian Green & Red (Clean and Minimalist) */
  --primary-dark: #111827;            /* Dark Charcoal text */
  --primary-medium: #007a3d;          /* Brand Green (Italian flag green) */
  --primary-light: #006a38;           /* Darker Green for text/contrast */
  --accent-gold: #ce2b37;             /* Brand Red (Italian flag red) */
  --accent-gold-hover: #b91c1c;       /* Darker Red */
  --accent-gold-light: #fef2f2;       /* Soft Red/Pink background */
  
  /* Neutral Palette */
  --bg-app: #f9fafb;                  /* Clean Light Grey Background */
  --bg-card: #ffffff;                 /* Pure White Card */
  --text-main: #1f2937;               /* Medium-dark charcoal */
  --text-muted: #4b5563;              /* Muted grey text */
  --border-color: #e5e7eb;            /* Light grey border */
  
  /* Status Colors */
  --status-success: #007a3d;          /* Brand Green */
  --status-success-light: #ecfdf5;    /* Soft Green bg */
  --status-warning: #d97706;          /* Clean Amber */
  --status-warning-light: #fef3c7;    /* Soft Amber bg */
  --status-danger: #ce2b37;           /* Brand Red */
  --status-danger-light: #fef2f2;     /* Soft Red bg */
  --status-info: #2563eb;             /* Blue for deliveries */
  --status-info-light: #eff6ff;
  
  /* UI Styling Properties */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: var(--font-family);
}

/* Dark Mode Override - Force Clean Light Theme as requested */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #f9fafb;
    --bg-card: #ffffff;
    --text-main: #1f2937;
    --text-muted: #4b5563;
    --border-color: #e5e7eb;
    --primary-dark: #111827;
    --primary-medium: #007a3d;
    --primary-light: #006a38;
    --accent-gold-light: #fef2f2;
    --status-success-light: #ecfdf5;
    --status-danger-light: #fef2f2;
    --status-warning-light: #fef3c7;
  }
}

/* ================================================================= */
/* RESETS & BASE STYLES                                              */
/* ================================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 60px; /* Safe space for floating layout */
  transition: background-color 0.5s ease;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ================================================================= */
/* CONTAINER & LAYOUT                                                */
/* ================================================================= */
/* Italian flag top stripe */
.italian-stripe {
  display: flex;
  height: 4px;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
}
.stripe-green {
  flex: 1;
  background-color: #007a3d;
}
.stripe-white {
  flex: 1;
  background-color: #ffffff;
}
.stripe-red {
  flex: 1;
  background-color: #ce2b37;
}

.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 4px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

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

.logo-icon-circular {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ffffff;
  padding: 2px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.logo-icon-circular img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.brand-text h1 {
  font-size: 1.3rem;
  line-height: 1.1;
  color: var(--primary-dark);
  font-weight: 800;
}

@media (prefers-color-scheme: dark) {
  .brand-text h1 {
    color: var(--text-main);
  }
}

.sub-brand {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-gold);
  display: block;
}

.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================================================================= */
/* COMPONENT: ROLE SELECTOR (HEADER SWITCH)                          */
/* ================================================================= */
.role-selector {
  display: flex;
  background: var(--bg-app);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

.role-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}

.role-btn .icon {
  transition: transform 0.3s ease;
}

.role-btn:hover {
  color: var(--text-main);
}

.role-btn.active {
  background: var(--bg-card);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

@media (prefers-color-scheme: dark) {
  .role-btn.active {
    color: var(--text-main);
    background: var(--primary-light);
  }
}

.role-btn.active .icon {
  transform: scale(1.1);
  color: var(--accent-gold);
}

/* ================================================================= */
/* VIEW SECTIONS (SPA CONTROL)                                       */
/* ================================================================= */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: tabSlide 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes tabSlide {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ================================================================= */
/* DASHBOARD CARDS (KPIS)                                            */
/* ================================================================= */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-md);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-gold), var(--primary-light));
  opacity: 0.8;
}

.kpi-card.total-comodato::before { background: linear-gradient(90deg, var(--accent-gold), var(--primary-light)); }
.kpi-card.total-receber::before { background: linear-gradient(90deg, var(--accent-gold), var(--status-warning)); }
.kpi-card.total-recebido::before { background: linear-gradient(90deg, var(--status-success), var(--accent-gold)); }

.kpi-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.kpi-icon {
  background: var(--accent-gold-light);
  color: var(--accent-gold);
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.total-recebido .kpi-icon {
  background: var(--status-success-light);
  color: var(--status-success);
}

.kpi-content h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.kpi-content p {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ================================================================= */
/* MERCHANTS LIST (ADMIN)                                            */
/* ================================================================= */
.section-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  margin-top: 10px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-actions h2 {
  font-size: 1.4rem;
  color: var(--primary-dark);
}

@media (prefers-color-scheme: dark) {
  .section-actions h2 {
    color: var(--text-main);
  }
}

.merchants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.merchant-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.merchant-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(212, 163, 115, 0.3);
}

.merchant-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 12px;
}

.merchant-title h3 {
  font-size: 1.2rem;
  color: var(--primary-dark);
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .merchant-title h3 {
    color: var(--text-main);
  }
}

.merchant-contact {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.status-badge.active {
  background-color: var(--status-success-light);
  color: var(--status-success);
}

.status-badge.empty {
  background-color: var(--status-warning-light);
  color: var(--status-warning);
}

/* Merchant Stock details inside card */
.merchant-stock-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  flex-grow: 1;
}

.stock-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
}

.stock-item-name {
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stock-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-p1 { background-color: #f5f5dc; border: 1px solid #d1d5db; } /* Coco */
.dot-p2 { background-color: #ce2b37; } /* Goiabada */
.dot-p3 { background-color: #4b3621; } /* Chocolate */

.stock-item-qty {
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--border-color);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.8rem;
}

@media (prefers-color-scheme: dark) {
  .stock-item-qty {
    color: var(--text-main);
  }
}

.merchant-last-visit {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 10px;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

/* Card Button Group */
.merchant-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

/* ================================================================= */
/* STYLISH BUTTONS                                                   */
/* ================================================================= */
.btn {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  text-decoration: none;
}

.btn-icon {
  flex-shrink: 0;
}

.btn-primary {
  background-color: var(--primary-medium);
  color: white;
  border-color: var(--primary-medium);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--bg-app);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--primary-dark);
}

@media (prefers-color-scheme: dark) {
  .btn-secondary {
    background-color: var(--primary-medium);
    color: var(--text-main);
  }
  .btn-secondary:hover {
    background-color: var(--primary-light);
  }
}

.btn-success {
  background-color: var(--status-success);
  color: white;
  border-color: var(--status-success);
}

.btn-success:hover:not(:disabled) {
  background-color: hsl(142, 68%, 22%);
  border-color: hsl(142, 68%, 22%);
  transform: translateY(-1px);
}

.btn-success:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ================================================================= */
/* TABLES (HISTÓRICO)                                                */
/* ================================================================= */
.logs-section {
  margin-top: 30px;
}

.section-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-title-bar h2 {
  font-size: 1.4rem;
  color: var(--primary-dark);
}

@media (prefers-color-scheme: dark) {
  .section-title-bar h2 {
    color: var(--text-main);
  }
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.data-table th {
  background-color: var(--accent-gold-light);
  color: var(--primary-dark);
  font-family: var(--font-display);
  font-weight: 700;
  padding: 14px 18px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .data-table th {
    background-color: var(--primary-light);
    color: var(--text-main);
  }
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover {
  background-color: rgba(212, 163, 115, 0.03);
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.text-muted { color: var(--text-muted); }
.small { font-size: 0.78rem; }

.badge-type {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-type.entrega {
  background-color: var(--status-info-light);
  color: var(--status-info);
}

.badge-type.acerto {
  background-color: var(--status-success-light);
  color: var(--status-success);
}

.action-btn-danger {
  color: var(--status-danger);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.action-btn-danger:hover {
  background-color: var(--status-danger-light);
}

/* ================================================================= */
/* VIEW: MERCHANT INTERFACE                                          */
/* ================================================================= */
.merchant-login-card {
  max-width: 440px;
  margin: 60px auto;
  padding: 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  border-top: 4px solid var(--accent-gold);
}

.login-logo {
  color: var(--accent-gold);
  margin-bottom: 16px;
  display: inline-flex;
  padding: 16px;
  border-radius: 50%;
  background: var(--accent-gold-light);
}

.login-header h2 {
  font-size: 1.6rem;
  color: var(--primary-dark);
  margin-bottom: 8px;
}

@media (prefers-color-scheme: dark) {
  .login-header h2 {
    color: var(--text-main);
  }
}

.login-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-family: var(--font-display);
}

.form-control {
  width: 100%;
  padding: 11px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(212, 163, 115, 0.15);
}

.merchant-dashboard {
  animation: fadeIn 0.4s ease-out;
}

.dashboard-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.dashboard-header-bar h2 {
  font-size: 1.8rem;
  color: var(--primary-dark);
  font-weight: 800;
}

@media (prefers-color-scheme: dark) {
  .dashboard-header-bar h2 {
    color: var(--text-main);
  }
}

.subsection-title {
  font-size: 1.2rem;
  color: var(--primary-dark);
  margin-bottom: 2px;
}

@media (prefers-color-scheme: dark) {
  .subsection-title {
    color: var(--text-main);
  }
}

.subsection-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.stock-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stock-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  transition: var(--transition);
}

.stock-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(212, 163, 115, 0.25);
}

.stock-card-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
  box-shadow: inset 0 -4px 10px rgba(0,0,0,0.05);
}

/* Customized card backgrounds per flavor */
.card-p1 { border-left: 5px solid #d8af87; }
.card-p1 .stock-card-icon { background: #faf0e6; }
.card-p2 { border-left: 5px solid #e07a5f; }
.card-p2 .stock-card-icon { background: #ffeae5; }
.card-p3 { border-left: 5px solid #3d2f2d; }
.card-p3 .stock-card-icon { background: #efebe9; }

.stock-card-info {
  flex-grow: 1;
}

.stock-card-info h4 {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.stock-card-qty {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary-dark);
  font-family: var(--font-display);
  line-height: 1.2;
}

@media (prefers-color-scheme: dark) {
  .stock-card-qty {
    color: var(--text-main);
  }
}

.stock-card-price {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.merchant-summary-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
  margin-bottom: 40px;
}

@media (max-width: 768px) {
  .merchant-summary-grid {
    grid-template-columns: 1fr;
  }
}

.summary-info-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.info-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-display);
  margin-bottom: 8px;
}

.info-card-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-gold);
  font-family: var(--font-display);
}

.info-card-footer {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.help-card {
  background: var(--accent-gold-light);
  border-color: rgba(212, 163, 115, 0.2);
}

.help-text {
  font-size: 0.82rem;
  color: var(--primary-medium);
  line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
  .help-text {
    color: var(--text-main);
  }
}

/* ================================================================= */
/* MODALS (FORM OVERLAYS)                                            */
/* ================================================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(30, 20, 18, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  overflow: hidden;
}

.modal-lg {
  max-width: 680px;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--accent-gold-light);
}

@media (prefers-color-scheme: dark) {
  .modal-header {
    background-color: var(--primary-light);
  }
}

.modal-header h2 {
  font-size: 1.25rem;
  color: var(--primary-dark);
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .modal-header h2 {
    color: var(--text-main);
  }
}

.close-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.close-btn:hover {
  color: var(--primary-dark);
}

@media (prefers-color-scheme: dark) {
  .close-btn:hover {
    color: var(--text-main);
  }
}

.modal-body {
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-subtitle {
  font-size: 1rem;
  margin-bottom: 2px;
  color: var(--text-main);
}

/* Qty Adjustment Controls */
.product-input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.product-input-row:last-of-type {
  border-bottom: none;
}

.product-info {
  display: flex;
  flex-direction: column;
}

.product-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.product-price {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.product-qty-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-btn {
  background-color: var(--bg-app);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-main);
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:hover {
  background-color: var(--border-color);
  border-color: var(--text-muted);
}

.qty-input {
  width: 50px;
  height: 32px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.9rem;
  -webkit-appearance: none;
  margin: 0 4px;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* ================================================================= */
/* ACERTO (SETTLEMENT) MODAL SPECIFICS                               */
/* ================================================================= */
.settlement-products-table {
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-header-row, .table-body-row {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1.2fr 1fr 1.2fr;
  align-items: center;
  gap: 8px;
}

.table-header-row {
  background-color: var(--accent-gold-light);
  color: var(--primary-dark);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.8rem;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
}

@media (prefers-color-scheme: dark) {
  .table-header-row {
    background-color: var(--primary-light);
    color: var(--text-main);
  }
}

.table-body-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.table-body-row:last-child {
  border-bottom: none;
}

.col-prod { display: flex; flex-direction: column; }
.inline-input {
  max-width: 70px;
  padding: 6px;
  text-align: center;
  font-weight: 700;
  border-radius: 6px;
  margin: 0 auto;
}

.highlight-sold {
  font-weight: 700;
  color: var(--status-warning);
}

.settlement-financials {
  background: var(--bg-app);
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border-color);
}

.total-highlight {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.total-highlight span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.total-highlight strong {
  font-size: 1.8rem;
  font-family: var(--font-display);
  color: var(--accent-gold);
  font-weight: 800;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-grid-3 {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 576px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

.stock-action-box {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.checkbox-container {
  display: flex;
  align-items: center;
  position: relative;
  padding-left: 28px;
  cursor: pointer;
  font-size: 0.88rem;
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 2px;
  left: 0;
  height: 20px;
  width: 20px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  transition: var(--transition);
}

.checkbox-container:hover input ~ .checkmark {
  border-color: var(--accent-gold);
}

.checkbox-container input:checked ~ .checkmark {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.checkmark::after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark::after {
  display: block;
}

.checkbox-container .checkmark::after {
  left: 6px;
  top: 2px;
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.help-text-check {
  margin-left: 28px;
  margin-top: 4px;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-top: 15px;
  font-weight: 500;
}

.alert-danger {
  background-color: var(--status-danger-light);
  color: var(--status-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ================================================================= */
/* TOAST ALERTS & NOTIFICATIONS                                      */
/* ================================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 320px;
  width: 90%;
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-gold);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: toastSlide 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition: opacity 0.3s ease;
}

@keyframes toastSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.success { border-left-color: var(--status-success); }
.toast.info { border-left-color: var(--status-info); }
.toast.warning { border-left-color: var(--status-warning); }
.toast.danger { border-left-color: var(--status-danger); }

/* ================================================================= */
/* RESPONSIVE BREAKPOINTS                                            */
/* ================================================================= */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }
  .role-selector {
    width: 100%;
    justify-content: stretch;
  }
  .role-btn {
    flex: 1;
    justify-content: center;
  }
  .app-main {
    padding: 16px 12px;
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .kpi-card {
    padding: 18px;
  }
  .merchants-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  /* Settlement modal grid adjustment for small screens */
  .table-header-row, .table-body-row {
    grid-template-columns: 1.8fr 0.8fr 1.2fr 0.8fr 1fr;
    font-size: 0.78rem;
    gap: 4px;
    padding: 10px 8px;
  }
  .inline-input {
    max-width: 50px;
  }
}

/* ================================================================= */
/* BRAND LOGO & FOOTER ADDITIONS                                     */
/* ================================================================= */
.login-logo-circle {
  margin-bottom: 20px;
  display: inline-flex;
  padding: 8px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.app-footer {
  background-color: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 30px 20px;
  margin-top: 50px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.footer-brand-info h3 {
  color: var(--primary-medium);
  font-size: 1.1rem;
  margin-bottom: 6px;
  font-family: var(--font-display);
}

.footer-brand-info p {
  margin: 3px 0;
}

.footer-links a.instagram-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #ffffff;
}

.footer-links a.instagram-link:hover {
  color: #ce2b37;
  border-color: #ce2b37;
  background-color: #fef2f2;
}

.footer-icon {
  flex-shrink: 0;
}

/* ================================================================= */
/* STEPPER & APPROVAL FLOW                                           */
/* ================================================================= */
.approval-stepper {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 25px;
  background-color: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.approval-stepper .step {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.3s ease;
}

.approval-stepper .step.active {
  color: white;
  background-color: var(--primary-dark);
}

.approval-stepper .step-divider {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.approval-box {
  background-color: rgba(0, 122, 61, 0.08);
  border: 1.5px dashed var(--primary-dark);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.4s ease;
}

.approval-box p {
  margin-bottom: 15px;
  color: var(--primary-dark);
  font-size: 0.95rem;
}

.approval-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.payment-extra-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 12px;
  animation: slideDown 0.3s ease;
}

.highlight-sold-input {
  font-weight: 700;
  color: var(--accent-gold-dark);
  border-color: var(--accent-gold);
  background-color: var(--accent-gold-light);
  text-align: center;
}

.highlight-sold-input:focus {
  border-color: var(--accent-gold-dark);
  box-shadow: 0 0 0 3px rgba(181, 143, 81, 0.2);
}

/* ================================================================= */
/* PDF RECEIPT STYLES                                                */
/* ================================================================= */
#receipt-pdf-template {
  background-color: #ffffff;
  color: #333333;
}

.pdf-container {
  font-family: 'Inter', sans-serif;
  padding: 40px;
  background-color: #ffffff;
  position: relative;
  box-sizing: border-box;
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #eaeaea;
  padding-bottom: 15px;
  margin-bottom: 30px;
  position: relative;
}

.pdf-logo-wrapper {
  z-index: 10;
}

.pdf-logo {
  height: 70px;
  width: auto;
}

.pdf-header-waves {
  position: absolute;
  top: 0;
  right: 0;
  width: 250px;
  height: 80px;
  opacity: 0.8;
}

.pdf-title {
  font-family: var(--font-family);
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 35px;
  color: #111111;
}

.pdf-metadata {
  margin-bottom: 35px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.pdf-metadata p {
  margin: 5px 0;
}

.pdf-section-title {
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 2px solid #333333;
  padding-bottom: 8px;
  margin-bottom: 15px;
  letter-spacing: 0.5px;
}

.pdf-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 40px;
}

.pdf-table th {
  background-color: #f7f7f7;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  padding: 12px;
  border-bottom: 2px solid #eaeaea;
  text-align: left;
}

.pdf-table td {
  padding: 12px;
  border-bottom: 1px solid #eaeaea;
  font-size: 0.88rem;
}

.pdf-table th.text-center, .pdf-table td.text-center {
  text-align: center;
}

.pdf-table th.text-right, .pdf-table td.text-right {
  text-align: right;
}

.pdf-table tfoot td {
  border-bottom: none;
  padding-top: 15px;
  font-size: 0.95rem;
}

.pdf-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 70px;
  margin-bottom: 60px;
}

.pdf-signature-line {
  width: 45%;
  text-align: center;
}

.pdf-signature-line .line {
  border-top: 1px solid #777777;
  margin-bottom: 8px;
}

.pdf-signature-line p {
  font-size: 0.82rem;
  color: #555555;
  margin: 0;
}

.pdf-footer {
  border-top: 1px solid #eaeaea;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.pdf-footer-info {
  font-size: 0.72rem;
  color: #777777;
  line-height: 1.5;
}

.pdf-footer-info strong {
  color: #333333;
}

.pdf-footer-info p {
  margin: 2px 0;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* VIABILITY STATUS BADGES & UTILITIES */
.status-badge.warning-badge {
  background-color: #fffbeb;
  color: #b45309;
}
.status-badge.danger-badge {
  background-color: #fef2f2;
  color: #b91c1c;
}
.block {
  display: block;
}
.performance-panel {
  transition: transform var(--transition), box-shadow var(--transition);
}
.performance-panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ================================================================= */
/* TELA DE LOGIN GLASSMORPHIC & BRANDING ADJUSTMENTS                */
/* ================================================================= */

.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 64px);
  padding: 40px 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 30px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  text-align: center;
}

.login-logo-container {
  margin-bottom: 24px;
  display: flex;
  justify-content: center;
}

#login-logo-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  transition: var(--transition);
}

#login-logo-img:hover {
  transform: scale(1.05);
}

.login-header h2 {
  font-size: 1.8rem;
  color: var(--primary-dark);
  font-weight: 800;
  margin-bottom: 6px;
}

.login-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 12px;
  margin-bottom: 32px;
}

.login-actions-row {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.forgot-pass-link {
  font-size: 0.82rem;
  color: var(--primary-medium);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.forgot-pass-link:hover {
  color: var(--accent-gold);
  text-decoration: underline;
}

.social-login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-display);
}

.social-login-divider::before,
.social-login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color);
}

.social-login-divider::before {
  margin-right: 12px;
}

.social-login-divider::after {
  margin-left: 12px;
}

.social-login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-social {
  background-color: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-display);
}

.btn-social:hover {
  background-color: var(--bg-app);
  border-color: var(--text-muted);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-social svg {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
}

