/* ============================================================
   SerPleno Saúde — Design System
   Cores: Azul #1a3f7a | Verde #2d7a2d | Ouro #c47a22
   ============================================================ */

:root {
  --azul:        #1a3f7a;
  --azul-medio:  #2a5298;
  --azul-claro:  #e8eef7;
  --azul-hover:  #153268;
  --verde:       #2d7a2d;
  --verde-claro: #e8f5e8;
  --ouro:        #c47a22;
  --ouro-claro:  #fef3e0;
  --ouro-hover:  #a86519;

  --bg:          #f0f4f8;
  --superficie:  #ffffff;
  --superficie2: #f8fafc;
  --borda:       #dde3ed;
  --borda-forte: #c4cdd9;

  --texto:       #1a2535;
  --texto2:      #4a5568;
  --texto3:      #8896a8;

  --sucesso:     #16a34a;
  --sucesso-bg:  #dcfce7;
  --alerta:      #d97706;
  --alerta-bg:   #fef3c7;
  --erro:        #dc2626;
  --erro-bg:     #fee2e2;
  --info:        #0284c7;
  --info-bg:     #e0f2fe;

  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   18px;
  --radius-xl:   24px;
  --sombra:      0 2px 12px rgba(26,63,122,.08);
  --sombra-md:   0 4px 20px rgba(26,63,122,.12);
  --sombra-lg:   0 8px 40px rgba(26,63,122,.18);
  --trans:       0.18s ease;

  --sidebar-w:   240px;
  --topbar-h:    64px;
  --bottomnav-h: 64px;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Plus Jakarta Sans', 'Sora', system-ui, sans-serif;
  background: var(--bg);
  color: var(--texto);
  line-height: 1.55;
  min-height: 100vh;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--borda-forte); border-radius: 99px; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--azul) 0%, var(--azul-medio) 50%, var(--verde) 100%);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 20%, rgba(196,122,34,.18) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 80% 80%, rgba(45,122,45,.2) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--superficie);
  border-radius: var(--radius-xl);
  box-shadow: var(--sombra-lg);
  padding: 48px 40px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 1;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo img {
  height: 80px;
  object-fit: contain;
}

.login-logo-mark {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--azul), var(--verde));
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  box-shadow: var(--sombra-md);
}

.login-brand h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--azul);
  line-height: 1;
}

.login-brand p {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--ouro);
  text-transform: uppercase;
}

.login-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--texto2);
  text-align: center;
  margin-bottom: 28px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label, .field-group > span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--texto2);
  letter-spacing: 0.02em;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--borda);
  border-radius: var(--radius-sm);
  background: var(--superficie2);
  color: var(--texto);
  font-size: 0.95rem;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(42,82,152,.15);
  background: var(--superficie);
}

.field-group input[readonly] {
  background: var(--bg);
  color: var(--texto2);
  cursor: default;
}

.field-group select {
  cursor: pointer;
  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='%234a5568' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.login-alert {
  background: var(--erro-bg);
  color: var(--erro);
  border: 1px solid rgba(220,38,38,.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  display: none;
}
.login-alert.visible { display: block; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--azul);
  color: #fff;
  border-color: var(--azul);
}
.btn-primary:hover { background: var(--azul-hover); border-color: var(--azul-hover); }

.btn-secondary {
  background: var(--verde);
  color: #fff;
  border-color: var(--verde);
}
.btn-secondary:hover { background: #236023; border-color: #236023; }

.btn-ouro {
  background: var(--ouro);
  color: #fff;
  border-color: var(--ouro);
}
.btn-ouro:hover { background: var(--ouro-hover); border-color: var(--ouro-hover); }

.btn-outline {
  background: transparent;
  color: var(--azul);
  border-color: var(--azul);
}
.btn-outline:hover { background: var(--azul-claro); }

.btn-ghost {
  background: transparent;
  color: var(--texto2);
  border-color: var(--borda);
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger {
  background: transparent;
  color: var(--erro);
  border-color: rgba(220,38,38,.3);
}
.btn-danger:hover { background: var(--erro-bg); }

.btn-full { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
}

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn.loading .spinner { display: block; }
.btn.loading .btn-label { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   APP SHELL — LAYOUT
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--azul);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform var(--trans);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--ouro), #e8952a);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand-text h2 {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}

.sidebar-brand-text p {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item svg { flex-shrink: 0; opacity: .8; }

.nav-item:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.nav-item.active {
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ouro), #e8952a);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-info strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  font-size: 0.7rem;
  color: rgba(255,255,255,.5);
}

.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,.5);
  padding: 4px;
  border-radius: 6px;
  transition: all var(--trans);
  display: flex;
}
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── Main ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--sombra);
}

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

.topbar-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--texto);
}

.topbar-subtitle {
  font-size: 0.8rem;
  color: var(--texto3);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-admin { background: var(--ouro-claro); color: var(--ouro-hover); }
.badge-secretaria { background: var(--azul-claro); color: var(--azul); }
.badge-vendedor { background: var(--verde-claro); color: var(--verde); }

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--texto2);
  transition: all var(--trans);
}
.hamburger-btn:hover { background: var(--bg); }

/* ── Page Content ─────────────────────────────────────────── */
.page-content {
  padding: 28px 28px 40px;
  flex: 1;
}

.panel { display: none; }
.panel.active { display: block; }

/* ── Panel Header ─────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.panel-header h2 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--texto);
}

.panel-header p {
  font-size: 0.85rem;
  color: var(--texto3);
  margin-top: 2px;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  box-shadow: var(--sombra);
}

.card-body { padding: 20px; }
.card-body + .card-body { border-top: 1px solid var(--borda); }

.card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--texto);
  margin-bottom: 16px;
}

/* ── Metrics ──────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--sombra);
}

.metric-card .label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--texto3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.metric-card .value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--azul);
  line-height: 1;
}

.metric-card.green .value { color: var(--verde); }
.metric-card.gold .value { color: var(--ouro); }

/* ── Search Section ───────────────────────────────────────── */
.search-bar-wrap {
  position: relative;
  margin-bottom: 16px;
}

.search-bar-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--texto3);
  pointer-events: none;
}

.search-bar-wrap input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  border: 1.5px solid var(--borda);
  border-radius: var(--radius-sm);
  background: var(--superficie);
  color: var(--texto);
  font-size: 1rem;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}

.search-bar-wrap input:focus {
  border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(42,82,152,.12);
}

.discount-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.result-info {
  font-size: 0.82rem;
  color: var(--texto3);
  margin-bottom: 10px;
}

/* ── Table ────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--borda);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
}

thead {
  background: var(--superficie2);
  border-bottom: 1px solid var(--borda);
}

thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--texto3);
}

tbody tr {
  border-bottom: 1px solid var(--borda);
  transition: background var(--trans);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

tbody td {
  padding: 12px 14px;
  color: var(--texto2);
  white-space: nowrap;
}

tbody td:first-child { color: var(--texto); font-weight: 500; }

.td-value {
  font-weight: 600;
  color: var(--azul) !important;
}

.td-discount {
  font-weight: 700;
  color: var(--verde) !important;
}

.td-actions { width: 80px; }

.placeholder-row td {
  padding: 32px 14px;
  text-align: center;
  color: var(--texto3);
  font-size: 0.875rem;
}

/* ── Status Badge ─────────────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-pill.aguardando { background: var(--alerta-bg); color: var(--alerta); }
.status-pill.agendado   { background: var(--info-bg);   color: var(--info);   }
.status-pill.realizado  { background: var(--sucesso-bg); color: var(--sucesso); }

/* ── Sale Panel ───────────────────────────────────────────── */
.sale-panel {
  background: var(--superficie);
  border: 1.5px solid var(--azul-claro);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
}

.sale-panel h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--azul);
  margin-bottom: 16px;
}

.sale-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status-text {
  font-size: 0.82rem;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  display: none;
}

.status-text.ok   { display: block; background: var(--sucesso-bg); color: var(--sucesso); }
.status-text.warn { display: block; background: var(--alerta-bg);  color: var(--alerta); }
.status-text.erro { display: block; background: var(--erro-bg);    color: var(--erro); }

/* ── Clients Panel ────────────────────────────────────────── */
.clients-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  align-items: start;
}

.client-list-card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--sombra);
}

.client-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--borda);
  background: var(--superficie2);
}

.client-list-header h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texto);
}

.client-list {
  max-height: 400px;
  overflow-y: auto;
}

.client-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--borda);
  cursor: pointer;
  transition: background var(--trans);
}

.client-item:last-child { border-bottom: none; }
.client-item:hover { background: var(--bg); }
.client-item.selected { background: var(--azul-claro); }

.client-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--azul-claro);
  color: var(--azul);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.client-item.selected .client-avatar {
  background: var(--azul);
  color: #fff;
}

.client-name { font-size: 0.85rem; font-weight: 500; color: var(--texto); }
.client-phone { font-size: 0.75rem; color: var(--texto3); }

.client-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--texto3);
}

.client-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.client-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

/* ── Post-sale Filters ────────────────────────────────────── */
.postsale-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
}

.postsale-filters .field-group { min-width: 130px; flex: 1; }

/* ── Users Management ─────────────────────────────────────── */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.user-card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--sombra);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.user-card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--azul), var(--azul-medio));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-card-info { flex: 1; min-width: 0; }
.user-card-info strong { display: block; font-weight: 700; color: var(--texto); margin-bottom: 3px; }
.user-card-info .email { font-size: 0.78rem; color: var(--texto3); margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

.inactive-overlay { opacity: 0.5; }

/* ── Clinics / Upload ─────────────────────────────────────── */
.clinics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.clinic-card {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--sombra);
}

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

.clinic-card-name { font-weight: 700; color: var(--texto); }
.clinic-card-count { font-size: 0.8rem; color: var(--texto3); margin-bottom: 10px; }

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--borda-forte);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: var(--superficie2);
  cursor: pointer;
  transition: all var(--trans);
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--azul-medio);
  background: var(--azul-claro);
}

.upload-zone svg { color: var(--texto3); margin: 0 auto 10px; }
.upload-zone p { font-size: 0.875rem; color: var(--texto2); font-weight: 500; }
.upload-zone span { font-size: 0.78rem; color: var(--texto3); }

/* ── Reports ──────────────────────────────────────────────── */
.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,20,40,.55);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  z-index: 200;
  padding: 16px;
}

.modal-overlay.open { display: grid; }

.modal {
  background: var(--superficie);
  border-radius: var(--radius-lg);
  box-shadow: var(--sombra-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--texto); }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--texto3);
  padding: 4px;
  border-radius: 6px;
  transition: all var(--trans);
  display: flex;
}
.modal-close:hover { background: var(--bg); color: var(--texto); }

.modal-body { padding: 20px 24px; }
.modal-body .field-group + .field-group { margin-top: 14px; }

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

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--texto);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--sombra-lg);
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.25s ease;
  pointer-events: auto;
}

.toast.success { background: var(--sucesso); }
.toast.error   { background: var(--erro); }
.toast.warn    { background: var(--alerta); }

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

/* ── Loading Screen ───────────────────────────────────────── */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--azul);
  display: grid;
  place-items: center;
  z-index: 999;
  transition: opacity 0.4s ease;
}

.loading-screen.hidden { opacity: 0; pointer-events: none; }

.loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  color: #fff;
}

.loading-logo-mark {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}

.loading-inner p { font-size: 0.875rem; opacity: .6; }

.loading-bar {
  width: 180px;
  height: 3px;
  background: rgba(255,255,255,.2);
  border-radius: 99px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: var(--ouro);
  border-radius: 99px;
  animation: loadBar 1.4s ease-in-out infinite;
}

@keyframes loadBar {
  0%   { width: 0%; margin-left: 0; }
  50%  { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

/* ── Sidebar overlay (mobile) ─────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--texto3);
  text-align: center;
}

.empty-state svg { opacity: .4; }
.empty-state p { font-size: 0.875rem; max-width: 280px; }

/* ── Recent list ──────────────────────────────────────────── */
.recent-list { display: flex; flex-direction: column; gap: 8px; }

.recent-item {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all var(--trans);
}

.recent-item:hover { border-color: var(--azul-medio); background: var(--azul-claro); }

.recent-item-icon {
  width: 36px;
  height: 36px;
  background: var(--azul-claro);
  color: var(--azul);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.recent-item-name { font-weight: 600; font-size: 0.875rem; color: var(--texto); }
.recent-item-meta { font-size: 0.75rem; color: var(--texto3); }
.recent-item-value { margin-left: auto; font-weight: 700; color: var(--azul); font-size: 0.875rem; }

/* ── Guia impressão ───────────────────────────────────────── */
@media print {
  .app-shell, .loading-screen, .toast-container { display: none !important; }
  .print-page { display: block !important; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet + Mobile */
@media (max-width: 1023px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--sombra-lg);
  }

  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }

  .hamburger-btn { display: flex; }

  .page-content { padding: 20px 16px 96px; }

  /* Bottom nav on mobile */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-h);
    background: var(--superficie);
    border-top: 1px solid var(--borda);
    box-shadow: 0 -4px 20px rgba(26,63,122,.1);
    z-index: 80;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .bottom-nav::-webkit-scrollbar { display: none; }

  .bottom-nav-item {
    flex: 1;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--texto3);
    font-size: 0.62rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    transition: all var(--trans);
  }

  .bottom-nav-item svg { flex-shrink: 0; }

  .bottom-nav-item.active { color: var(--azul); }
  .bottom-nav-item.active svg path,
  .bottom-nav-item.active svg rect,
  .bottom-nav-item.active svg circle { fill: rgba(26,63,122,.12); }
}

@media (min-width: 1024px) {
  .bottom-nav { display: none !important; }
}

/* Mobile small */
@media (max-width: 600px) {
  .login-card { padding: 32px 24px 28px; }
  .topbar { padding: 0 16px; }
  .panel-header h2 { font-size: 1.2rem; }
  .clients-grid { grid-template-columns: 1fr; }
  .client-list-card { max-height: 260px; }
  .discount-row { grid-template-columns: 1fr; }
  .sale-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; border-radius: var(--radius) var(--radius) 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .postsale-filters .field-group { min-width: 100%; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .toast-container { bottom: 80px; right: 12px; left: 12px; }
}
