/* ═══════════════════════════════════════════════════════════════
   Salão Manager — Design System
   Dark glassmorphism com acentos dourados
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* Cores base */
  --bg-primary:    #0f0f0f;
  --bg-secondary:  #1a1a1a;
  --bg-tertiary:   #242424;
  --text-primary:  #f0f0f0;
  --text-secondary:#9a9a9a;
  --text-muted:    #666;

  /* Accent */
  --primary:       #D4AF37;
  --primary-light: #F3E5AB;
  --primary-dark:  #A88920;
  --primary-alpha: rgba(212,175,55,0.12);
  --primary-glow:  rgba(212,175,55,0.3);

  /* Semânticas */
  --danger:        #ef4444;
  --danger-alpha:  rgba(239,68,68,0.15);
  --success:       #10b981;
  --success-alpha: rgba(16,185,129,0.15);
  --warning:       #f59e0b;
  --warning-alpha: rgba(245,158,11,0.15);
  --info:          #3b82f6;
  --info-alpha:    rgba(59,130,246,0.15);

  /* Bordas e superfícies */
  --border:        rgba(255,255,255,0.08);
  --border-light:  rgba(255,255,255,0.04);
  --glass-bg:      rgba(26,26,26,0.8);

  /* Raios */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-full:9999px;

  /* Sombras */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 20px rgba(212,175,55,0.15);

  /* Sidebar */
  --sidebar-w: 260px;
  --header-h:  60px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────────── */
.layout-container {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform 0.25s ease;
}
.logo-container {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px 24px 20px;
}
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #FFD700);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  color: #000;
  box-shadow: var(--shadow-gold);
  flex-shrink: 0;
}
.logo-icon svg { width: 18px; height: 18px; }
.logo-text h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.5px; }
.logo-text span { font-size: 0.7rem; color: var(--primary); text-transform: uppercase; letter-spacing: 2px; }

.nav-menu { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
}
.nav-item:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }
.nav-item.active { color: var(--primary); background: var(--primary-alpha); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.user-profile {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #000;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.75rem; color: var(--text-secondary); }

/* Mobile sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ── Main Content ─────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 36px 40px;
  overflow-y: auto;
  background:
    radial-gradient(circle at 80% 10%, rgba(212,175,55,0.04) 0%, transparent 40%),
    radial-gradient(circle at 20% 90%, rgba(212,175,55,0.03) 0%, transparent 40%);
}

/* ── Mobile header ─────────────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  padding: 0 16px;
  align-items: center;
  gap: 12px;
}
.mobile-logo { display: flex; align-items: center; gap: 10px; flex: 1; }
.menu-toggle {
  background: none; border: none;
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--r-sm);
}

/* ── Page header ─────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 4px; }
.page-header p.text-secondary { font-size: 0.875rem; }

/* ── Glassmorphism card ─────────────────────────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-header { padding: 18px 22px; border-bottom: 1px solid var(--border); }
.card-body { padding: 22px; }

/* ── Grid stats ─────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  padding: 22px;
  border-radius: var(--r-lg);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--primary-dark); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), transparent);
}
.stat-label { font-size: 0.78rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-sub { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }
.stat-icon { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); opacity: 0.08; }
.stat-icon svg { width: 48px; height: 48px; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: 0.875rem;
  transition: all 0.2s;
  border: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.btn-primary {
  background: var(--primary); color: #000;
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-light); transform: translateY(-1px); }
.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.06); }
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-outline:hover:not(:disabled) { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.15); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #dc2626; transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-xs { padding: 5px 10px; font-size: 0.75rem; }
.btn-icon { padding: 9px; }
.btn-full { width: 100%; }

/* Icon buttons */
.icon-btn-small {
  background: none; border: none;
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--r-sm);
  transition: all 0.2s;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn-small:hover { color: var(--primary); background: var(--primary-alpha); }
.icon-btn-small.danger:hover { color: var(--danger); background: var(--danger-alpha); }

/* ── Inputs ─────────────────────────────────────────────────────────── */
.input-group { margin-bottom: 18px; }
.input-label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 7px;
  font-weight: 500;
}
.input-field {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.2s;
}
.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-alpha);
}
.input-field::placeholder { color: var(--text-muted); }
.input-field option { background: var(--bg-secondary); }
.input-error { border-color: var(--danger) !important; }
.field-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }
.input-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Table ─────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  padding: 13px 18px;
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 14px 18px; border-bottom: 1px solid var(--border-light); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.action-buttons { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Badges / Status ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: 0.75rem; font-weight: 600;
}
.badge-gold    { background: var(--primary-alpha); color: var(--primary); }
.badge-success { background: var(--success-alpha); color: var(--success); }
.badge-danger  { background: var(--danger-alpha);  color: var(--danger); }
.badge-warning { background: var(--warning-alpha); color: var(--warning); }
.badge-info    { background: var(--info-alpha);    color: var(--info); }
.badge-gray    { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.status-badge { @extend .badge; }
.status-AGENDADO  { background: var(--info-alpha);    color: var(--info); }
.status-CONCLUIDO { background: var(--success-alpha); color: var(--success); }
.status-CANCELADO { background: var(--danger-alpha);  color: var(--danger); }
.status-PENDENTE  { background: var(--warning-alpha); color: var(--warning); }
.status-SOLICITADO{ background: var(--info-alpha);    color: var(--info); }
.status-PAGO      { background: var(--success-alpha); color: var(--success); }
.status-DESCONTADO{ background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.status-RECUSADO  { background: var(--danger-alpha);  color: var(--danger); }

/* ── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 0.2s ease-out;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px 0;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-body  { padding: 0 28px 22px; }
.modal-footer{
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 18px 28px;
  border-top: 1px solid var(--border);
}
.modal-close {
  background: none; border: none;
  color: var(--text-secondary);
  padding: 4px;
  border-radius: var(--r-sm);
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text-primary); }

/* ── Alert ─────────────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 18px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-warning { background: var(--warning-alpha); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.alert-danger  { background: var(--danger-alpha);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.alert-success { background: var(--success-alpha); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.alert-info    { background: var(--info-alpha);    color: var(--info);    border: 1px solid rgba(59,130,246,0.2); }

/* ── Toast notifications ─────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  min-width: 280px;
  max-width: 420px;
  animation: toast-in 0.3s ease-out;
  pointer-events: all;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-out { animation: toast-out 0.3s ease-in forwards; }

/* ── Loader ─────────────────────────────────────────────────────────── */
.loader {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.loader-lg { width: 40px; height: 40px; border-width: 3px; }
.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  gap: 16px;
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-secondary);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; margin-bottom: 16px; }
.empty-state p { font-size: 0.9rem; }

/* ── Agenda ─────────────────────────────────────────────────────────── */
.calendar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.calendar-day-header {
  text-align: center;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary);
  padding: 8px 0;
  text-transform: uppercase;
}
.calendar-cell {
  aspect-ratio: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 6px 4px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  border: 1px solid transparent;
}
.calendar-cell:hover { background: rgba(255,255,255,0.04); border-color: var(--border); }
.calendar-cell.selected { background: var(--primary-alpha); border-color: var(--primary); }
.calendar-cell.today .day-number {
  background: var(--primary); color: #000;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.calendar-cell.faded { opacity: 0.3; }
.day-number { font-size: 0.85rem; font-weight: 500; line-height: 1; }
.day-dots { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; justify-content: center; }
.dot { width: 5px; height: 5px; background: var(--primary); border-radius: 50%; }

/* Appointment cards */
.appointment-card {
  padding: 18px 20px; margin-bottom: 12px;
  display: flex; gap: 20px; align-items: flex-start;
  border-radius: var(--r-lg);
  transition: border-color 0.2s;
}
.appointment-card:hover { border-color: rgba(255,255,255,0.12); }
.app-time {
  font-size: 1rem; font-weight: 700; color: var(--primary);
  min-width: 52px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.app-time svg { width: 14px; height: 14px; opacity: 0.7; }
.app-details { flex: 1; min-width: 0; }
.app-details h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.app-phone { font-size: 0.8rem; color: var(--text-secondary); font-weight: 400; }
.app-service-item {
  font-size: 0.82rem; color: var(--text-secondary);
  padding: 6px 0; border-top: 1px solid var(--border-light);
  margin-top: 4px;
}
.app-service-item:first-child { border-top: none; }
.srv-name { color: var(--text-primary); font-weight: 500; }
.srv-employees { display: flex; gap: 5px; margin-top: 4px; flex-wrap: wrap; }
.emp-badge {
  background: rgba(212,175,55,0.1);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 0.72rem;
  font-weight: 500;
}
.app-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.app-total { font-size: 1.1rem; font-weight: 700; color: var(--success); }

/* Service item in modal */
.service-item-box {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
}
.service-item-box:hover { border-color: rgba(255,255,255,0.12); }
.employees-list { margin-top: 12px; }
.emp-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }

/* Filter pills */
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-pill {
  padding: 6px 14px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.filter-pill:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); }
.filter-pill.active { background: var(--primary-alpha); color: var(--primary); border-color: var(--primary); }

/* ── Acertos ─────────────────────────────────────────────────────────── */
.acerto-card { padding: 22px; margin-bottom: 16px; border-radius: var(--r-lg); }
.acerto-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.acerto-avatar {
  width: 44px; height: 44px;
  background: var(--primary-alpha);
  color: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
}
.acerto-totals { display: flex; gap: 20px; flex-wrap: wrap; }
.acerto-total-item { text-align: center; }
.acerto-total-item .value { font-size: 1.25rem; font-weight: 700; }
.acerto-total-item .label { font-size: 0.75rem; color: var(--text-secondary); }

/* ── Search box ─────────────────────────────────────────────────────── */
.search-box {
  position: relative;
  max-width: 320px;
}
.search-box svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-secondary);
  pointer-events: none;
}
.search-box .input-field { padding-left: 38px; }

/* ── Forms layout ─────────────────────────────────────────────────────── */
.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

/* ── Utility ─────────────────────────────────────────────────────────── */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-gold      { color: var(--primary); }
.text-success   { color: var(--success); }
.text-danger    { color: var(--danger); }
.text-warning   { color: var(--warning); }
.text-right     { text-align: right; }
.text-center    { text-align: center; }
.font-bold      { font-weight: 700; }
.font-semibold  { font-weight: 600; }
.font-medium    { font-weight: 500; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-none { display: none !important; }
.d-flex { display: flex !important; }

/* ── Animations ─────────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(-10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.animate-fade-in { animation: fadeIn 0.25s ease-out; }

/* ── Financeiro ─────────────────────────────────────────────────────── */
.finance-card { padding: 20px; border-radius: var(--r-lg); margin-bottom: 12px; }
.progress-bar-wrap { height: 6px; background: rgba(255,255,255,0.06); border-radius: var(--r-full); margin-top: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: var(--r-full); transition: width 0.4s ease; }

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }



/* ═══════════════════════════════════════════════════════════════
   BOTTOM NAV — Barra inferior estilo app nativo (iOS/Android)
   ═══════════════════════════════════════════════════════════════ */

/* Oculta sidebar no mobile (navegação fica na barra inferior) */
.sidebar-overlay { display: none; } /* não usamos mais overlay */

/* Top bar mobile */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    z-index: 300;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.mobile-header-left  { display: flex; align-items: center; gap: 10px; }
.mobile-header-right { display: flex; align-items: center; gap: 4px; }
.mobile-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .92rem; }
.mobile-logo .logo-icon {
    width: 28px; height: 28px; border-radius: 7px;
    background: linear-gradient(135deg, var(--primary), #FFD700);
    display: flex; align-items: center; justify-content: center;
}
.mobile-page-title { font-size: .92rem; font-weight: 600; color: var(--text-primary); }
.mobile-icon-btn {
    width: 36px; height: 36px; border-radius: 10px;
    background: none; border: none; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background .15s;
}
.mobile-icon-btn:active { background: rgba(255,255,255,.08); }

/* Barra de navegação inferior */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 300;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.bottom-nav-inner {
    display: flex;
    height: 60px;
    align-items: stretch;
}
.bn-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 2px;
    border-radius: 10px;
    transition: color .15s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}
.bn-tab:active { background: rgba(255,255,255,.05); }
.bn-tab.active { color: var(--primary); }
.bn-tab.active::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 32px; height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}
.bn-tab svg, .bn-tab i { width: 22px; height: 22px; font-size: 22px; flex-shrink: 0; }
.bn-label { font-size: 10px; font-weight: 500; letter-spacing: .01em; line-height: 1; }

/* Sheet "Mais" — aparece da parte inferior */
.more-sheet-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.more-sheet-overlay.open { display: block; }
.more-sheet {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    border-radius: 22px 22px 0 0;
    padding: 12px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.more-sheet-overlay.open .more-sheet { transform: translateY(0); }
.more-sheet-handle {
    width: 40px; height: 4px;
    background: rgba(255,255,255,.15);
    border-radius: 2px;
    margin: 0 auto 16px;
}
.more-sheet-title {
    font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-secondary);
    padding: 0 20px 8px;
}
.more-sheet-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 0 10px 12px;
}
.more-item {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; padding: 14px 6px;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text-primary);
    background: none;
    border: none;
    cursor: pointer;
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}
.more-item:active { background: rgba(255,255,255,.06); }
.more-item.active { background: var(--primary-alpha); color: var(--primary); }
.more-item-icon {
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary);
    transition: all .15s;
}
.more-item.active .more-item-icon {
    background: var(--primary-alpha);
    border-color: rgba(212,175,55,.2);
    color: var(--primary);
}
.more-item-label { font-size: 11px; font-weight: 500; text-align: center; }
.more-sheet-divider { height: 1px; background: var(--border); margin: 8px 20px 12px; }
.more-sheet-actions { padding: 0 12px; }
.more-action-btn {
    width: 100%;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: none; border: none;
    color: var(--text-primary);
    cursor: pointer; font-family: inherit; font-size: .92rem;
    transition: background .15s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.more-action-btn:active { background: rgba(255,255,255,.06); }
.more-action-btn.danger { color: var(--danger); }
.more-action-icon {
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--bg-tertiary); border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.more-action-btn.danger .more-action-icon { background: var(--danger-alpha); border-color: rgba(239,68,68,.2); }

/* ── Tablet ≤ 1024px ─────────────────────────────────────────── */
@media (max-width: 1024px) {
    :root { --sidebar-w: 240px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .dash-grid  { grid-template-columns: 1fr !important; }
}

/* ── Mobile ≤ 768px ──────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Ativa header e barra inferior */
    .mobile-header { display: flex; }
    .bottom-nav    { display: block; }

    /* Sidebar some completamente no mobile (navegação é a barra inferior) */
    .sidebar { display: none !important; }

    /* Main: espaço para o header (56px) e barra inferior (60px + safe area) */
    .main-content {
        margin-left: 0 !important;
        padding: 68px 14px calc(72px + env(safe-area-inset-bottom, 0px));
    }

    /* Page header: empilha em telas pequenas */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .page-header h2 { font-size: 1.25rem; }
    .page-header .btn { width: 100%; justify-content: center; }

    /* Stats: 2 colunas */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card  { padding: 13px; }
    .stat-value { font-size: 1.25rem; }
    .stat-label { font-size: .75rem; }

    /* Tabelas: scroll horizontal sem quebrar layout */
    .glass-panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 440px; font-size: .8rem; white-space: nowrap; }
    .data-table th, .data-table td { padding: 10px 10px; }

    /* Oculta colunas opcionais em mobile */
    .col-hide-mobile { display: none !important; }

    /* Modal: sobe da parte inferior como sheet */
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-content {
        width: 100%; max-width: 100%;
        max-height: 90vh;
        border-radius: 22px 22px 0 0;
        padding: 8px 18px calc(20px + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .modal-content::before {
        content: '';
        display: block;
        width: 40px; height: 4px;
        background: rgba(255,255,255,.15);
        border-radius: 2px;
        margin: 8px auto 18px;
    }

    /* Formulários: coluna única */
    .form-row { flex-direction: column; gap: 0; }

    /* Grids: coluna única */
    .plans-grid, .features-grid, .testimonials-grid { grid-template-columns: 1fr; }

    /* Appointment cards */
    .appointment-card { flex-direction: column; gap: 12px; }
    .app-actions { flex-direction: row; align-items: center; justify-content: space-between; }

    /* Acertos: coluna única */
    #usersList { grid-template-columns: 1fr !important; }

    /* Financeiro: 2 colunas */
    .finance-summary-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }

    /* Glass panels: padding menor */
    .glass-panel { padding: 14px; }

    /* Evita overflow horizontal global */
    body { overflow-x: hidden; }
    .layout-container { overflow-x: hidden; }

    /* Corrige inputs e elementos que podem transbordar */
    input, select, textarea { max-width: 100%; }
    img { max-width: 100%; }
    .page-content, .main-content > * { max-width: 100%; }

    /* Agenda: empilha calendário e lista */
    #agendaLayout { flex-direction: column !important; }
    #calendarPanel, #agendaList { min-width: unset !important; width: 100% !important; }

    /* Filtros com scroll horizontal */
    .filter-pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
    .filter-pill  { flex-shrink: 0; white-space: nowrap; }
}

/* ── Phones pequenos ≤ 480px ─────────────────────────────────── */
@media (max-width: 480px) {
    .main-content { padding: 66px 10px calc(70px + env(safe-area-inset-bottom, 0px)); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card  { padding: 11px; }
    .stat-value { font-size: 1.1rem; }
    .btn { padding: 10px 14px; font-size: .84rem; }
    .page-header h2 { font-size: 1.1rem; }
    .data-table { font-size: .76rem; }
    .data-table th, .data-table td { padding: 8px 8px; }
    .glass-panel { padding: 12px; }
}

/* ── Touch: sem hover effects ────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    .btn:hover:not(:disabled) { transform: none; box-shadow: none; }
    .btn:active { opacity: .82; }
}

/* ── PWA standalone ──────────────────────────────────────────── */
@media (display-mode: standalone) {
    .mobile-header {
        padding-top: env(safe-area-inset-top, 0px);
        height: calc(56px + env(safe-area-inset-top, 0px));
    }
    ::-webkit-scrollbar { width: 0; height: 0; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
    .sidebar, .mobile-header, .bottom-nav, .more-sheet-overlay,
    .page-header button, .action-buttons, .modal-overlay { display: none !important; }
    .main-content { margin-left: 0; padding: 0; }
    body { background: #fff; color: #000; }
    .glass-panel { border: 1px solid #ccc; box-shadow: none; }
}

/* ═══════════════════════════════════════════════════════════════
   AUTO-FIT — Regras defensivas para qualquer tamanho de tela
   Aplicadas globalmente para garantir que nada transborde
   ═══════════════════════════════════════════════════════════════ */

/* Previne overflow horizontal em qualquer elemento */
*, *::before, *::after {
    max-width: 100%;
    word-break: break-word;
}

/* Imagens e mídias sempre fluidas */
img, video, iframe, svg { max-width: 100%; height: auto; }

/* Inputs e selects nunca ultrapassam o container */
input, select, textarea, button {
    max-width: 100%;
    min-width: 0;
}

/* Textos de valores monetários: fonte fluida */
.stat-value, .fin-value {
    font-size: clamp(1rem, 4vw, 1.8rem) !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controles do financeiro: empilha no mobile */
.fin-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
.fin-dates {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.fin-date {
    flex: 1;
    min-width: 120px;
    max-width: 160px;
}
.fin-actions {
    display: flex;
    gap: 8px;
}
.fin-actions .btn { flex: 1; justify-content: center; }

@media (min-width: 769px) {
    .fin-controls { flex-direction: row; align-items: center; }
    .fin-date { max-width: 150px; }
    .fin-actions .btn { flex: none; }
}

/* Page header: nunca transborda */
.page-header {
    flex-wrap: wrap;
    gap: 12px;
    min-width: 0;
}
.page-header > div { min-width: 0; }
.page-header h2 {
    font-size: clamp(1.1rem, 4vw, 1.6rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Glass panels: nunca ultrapassam o viewport */
.glass-panel {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tabelas: scroll suave sem quebrar layout */
.data-table {
    width: 100%;
    min-width: 0;
    table-layout: auto;
}

/* Cards de stats: texto fluido */
.stat-card h3, .stat-card .stat-value {
    font-size: clamp(1rem, 4vw, 1.8rem);
    line-height: 1.2;
}

/* Botões de ação: nunca ultrapassam */
.action-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: flex-end;
    min-width: 0;
}

/* Badges e spans: não quebram layout */
.badge, .status-badge {
    white-space: nowrap;
    flex-shrink: 0;
}

/* Alertas: texto flui */
.alert {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Inputs de data: largura mínima garantida */
input[type="date"] {
    min-width: 120px;
    max-width: 160px;
}

/* Modais: sempre dentro da tela */
.modal-overlay { overflow-y: auto; }
.modal-content {
    max-height: 90vh;
    max-width: min(600px, calc(100vw - 24px));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Corrige h3 nos cards de dashboard e financeiro */
.glass-panel h3 {
    font-size: clamp(1rem, 4vw, 1.75rem);
    line-height: 1.2;
    word-break: break-all;
}

/* Corrige grade do financeiro para 2 colunas garantidas no mobile */
@media (max-width: 768px) {
    .finance-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }
    .finance-summary-grid .glass-panel {
        padding: 12px !important;
        overflow: hidden;
    }
    .finance-summary-grid h3 {
        font-size: clamp(.95rem, 5vw, 1.3rem) !important;
    }
    .fin-controls {
        flex-direction: column;
    }
    .fin-date {
        max-width: 100%;
        flex: 1;
        min-width: 100px;
    }
    /* Botões de filtro lado a lado */
    .fin-actions { width: 100%; }
    .fin-actions .btn { flex: 1; }

    /* Page header buttons: largura completa */
    .page-header > div:last-child {
        width: 100%;
    }
    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    /* Não deixa nenhum texto ultrapassar a tela */
    h2, h3, h4, p, span, td, th, label {
        max-width: 100%;
        overflow-wrap: break-word;
    }
}
