:root {
  /* Tipografia — escala estrita, sem exceções */
  --text-hero: 26px;       /* títulos de página */
  --text-title: 18px;      /* títulos de seção */
  --text-body: 14px;       /* texto padrão */
  --text-meta: 12px;       /* labels, badges, timestamps */
  --text-micro: 11px;      /* all-caps labels, versão, status */

  --weight-normal: 400;
  --weight-medium: 500;

  /* Cores de texto — apenas dois níveis */
  --text-primary: rgba(255,255,255,0.92);
  --text-secondary: rgba(255,255,255,0.45);
  --text-faint: rgba(255,255,255,0.22);

  /* Gold — restrito */
  --gold: #C8A96E;

  /* Superfícies */
  --bg: #0D0D0D;
  --surface: #141414;
  --surface-raised: #1A1A1A;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.13);

  /* Espaçamento — escala generosa */
  --space-xs: 6px;
  --space-sm: 12px;
  --space-md: 20px;
  --space-lg: 32px;
  --space-xl: 48px;

  /* Legado (manter para compatibilidade inicial) */
  --ink: var(--bg);
  --deep: var(--bg);
  --surface2: var(--surface-raised);
  --surface3: var(--surface-raised);
  --border2: var(--border-strong);
  --sand: var(--gold);
  --sand2: var(--gold);
  --dust: var(--text-faint);
  --mist: var(--text-faint);
  --text2: var(--text-secondary);
  --text3: var(--text-faint);
  --red: #E24B4A;
  --warning: #c4a46a;
  --success: #6a9e7a;
  --danger: #E24B4A;
  --warm: var(--gold);
  --warm-dim: rgba(200,169,110,0.6);
  --info: #7a9cc4;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  font-size: var(--text-body);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  overflow-wrap: anywhere;
}

/* ── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* ── LAYOUT ESTRUTURAL ──────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#sidebar-wrapper {
  display: flex;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 100;
}

.col1-nav {
  width: 48px; min-width: 48px;
  background: var(--bg);
  border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-md) 0; gap: 8px;
}

.col2-submenu {
  width: 160px; min-width: 160px;
  max-width: 160px;
  background: var(--bg);
  border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column;
  padding: var(--space-md) 0;
  transition: transform 0.3s ease;
}

.col3-content {
  flex: 1;
  margin-left: 208px; /* 48 + 160 */
  min-width: 0;
  width: calc(100% - 208px);
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  transition: all 0.3s ease;
}

.content {
  padding: var(--space-md) var(--space-lg);
  flex: 1;
  min-width: 0;
  max-width: 100%;
}

/* ── SIDEBAR COMPONENTS ──────────────────────────────────── */
.logo-area {
  padding: 0 16px var(--space-md);
  margin-bottom: var(--space-sm);
}

.logo-wordmark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px;
  font-weight: 300;
  letter-spacing: 3px;
  color: var(--text-faint);
  text-transform: uppercase;
}

.logo-wordmark .e { font-style: italic; }

.logo-tagline {
  display: none; /* Removido conforme prompt */
}

.nav-section {
  padding: var(--space-sm) 16px 4px;
  font-family: 'DM Mono', monospace;
  font-size: var(--text-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: var(--weight-normal);
}

.nav-icon-item {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-faint);
  font-size: 16px;
  transition: color .15s;
}

.nav-icon-item:hover { color: var(--text-secondary); }
.nav-icon-item.active { color: var(--gold); }

.col2-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-meta);
  font-weight: var(--weight-normal);
  transition: color .15s;
}

.col2-item:hover { color: var(--text-primary); }
.col2-item.active { color: var(--text-primary); }

/* ── TOPBAR ──────────────────────────────────── */
.topbar {
  height: 56px;
  border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--bg);
  position: sticky; top: 0;
  z-index: 50;
}

#topbar-section {
  font-size: var(--text-body);
  color: var(--text-secondary);
  font-weight: var(--weight-normal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.topbar-right-actions { display: flex; align-items: center; gap: 16px; }

/* ── PAGES & CARDS ──────────────────────────────────── */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.page-header { margin-bottom: var(--space-lg); }
.page-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: var(--text-hero);
  font-weight: var(--weight-normal);
  color: var(--text-primary);
  margin-bottom: 4px;
}
.page-header p {
  font-family: 'Outfit', sans-serif;
  font-size: var(--text-meta);
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.section-title {
  font-size: var(--text-micro);
  font-weight: var(--weight-medium);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-sm);
  border-bottom: none;
}

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-sm); margin-bottom: var(--space-lg); }

.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: var(--space-md);
}

.card-label {
  font-size: var(--text-micro);
  font-weight: var(--weight-medium);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: var(--space-xs);
}

.card-value {
  font-size: 28px;
  font-weight: var(--weight-normal);
  font-family: 'Cormorant Garamond', serif;
  color: var(--text-primary);
  line-height: 1;
}

.card-sub {
  font-size: var(--text-micro);
  color: var(--text-faint);
  margin-top: 4px;
}

/* ── MODAIS ──────────────────────────────────── */
.modal-overlay {
  display: none; /* Escondido por padrão */
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 9000;
  align-items: center; justify-content: center;
  padding: var(--space-md);
}
.modal-overlay.active { display: flex; } /* Nova classe exigida pelo prompt */
.modal-overlay.open { display: flex; } /* Legado para o js atual */

.modal {
  background: var(--surface-raised);
  border: 0.5px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  display: flex; flex-direction: column;
}

.modal-header {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 0.5px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.modal-header h3 { font-size: var(--text-title); font-family: 'Cormorant Garamond', serif; color: var(--text-primary); font-weight: var(--weight-normal); }
.modal-header p { font-size: var(--text-meta); color: var(--text-faint); margin-top: 4px; }
.modal-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 16px; }

.modal-body {
  padding: var(--space-md) var(--space-lg);
  overflow-y: auto;
}

.modal-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 0.5px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ── BOTÕES ──────────────────────────────────── */
.btn-warm, .btn.btn-warm {
  background: var(--gold);
  color: #0D0D0D;
  border: none;
  font-size: var(--text-meta);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-warm:hover { opacity: 0.85; }

.btn {
  background: transparent;
  color: var(--text-secondary);
  border: 0.5px solid var(--border-strong);
  font-size: var(--text-meta);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--surface-raised); color: var(--text-primary); }

.btn-danger { background: transparent; color: #E24B4A; border: 0.5px solid rgba(226,75,74,0.3); }
.btn-danger:hover { background: rgba(226,75,74,0.08); }

/* ── FORMULÁRIOS ──────────────────────────────────── */
.form-input, .form-select, .form-textarea {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: var(--text-body);
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--gold); }

.form-label {
  font-size: var(--text-micro);
  font-weight: var(--weight-medium);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: block;
  margin-bottom: var(--space-xs);
}
.form-group { margin-bottom: var(--space-md); }

/* ── LISTA DE CLIENTES (Tabela) ──────────────────────────────────── */
.client-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.client-info-wrap { display: flex; align-items: center; gap: 12px; }
.client-initials {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-raised); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-meta); font-weight: var(--weight-medium);
}
.client-name { font-size: var(--text-body); font-weight: var(--weight-medium); color: var(--text-primary); }
.client-meta { font-size: var(--text-meta); color: var(--text-faint); margin-top: 2px; }
.client-actions { display: flex; gap: 8px; }

/* ── BADGES ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: var(--text-micro);
  font-weight: var(--weight-medium);
  background: var(--surface-raised);
  color: var(--text-secondary);
}

/* Utils e legacy */
.empty { padding: 40px; text-align: center; color: var(--text-faint); font-size: var(--text-meta); border: 1px dashed var(--border-strong); border-radius: 8px; }
#login-screen { display: none; }
#auth-loading { display: none; }
.toast { display: none; }

/* ── TABS DE SERVIÇO ── */
.service-tabs {
  display: flex;
  gap: var(--space-md);
  border-bottom: 0.5px solid var(--border);
  margin-bottom: var(--space-md);
  overflow-x: auto;
  scrollbar-width: none;
}
.service-tab {
  padding: 8px 4px;
  font-size: var(--text-meta);
  color: var(--text-faint);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}
.service-tab:hover { color: var(--text-secondary); }
.service-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  font-weight: var(--weight-medium);
}

/* ── CHECKBOXES CUSTOM ── */
input[type="checkbox"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  background: var(--surface);
  vertical-align: middle;
}
input[type="checkbox"]:checked {
  background: var(--gold);
  border-color: var(--gold);
}
input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: #0D0D0D;
  font-size: 11px;
  font-weight: bold;
}

/* ── AJUSTE PSE JOVEM ── */
#torneio-sub-content {
  background: var(--surface);
  border: 0.5px solid var(--border-strong);
  border-radius: 12px;
  padding: var(--space-lg);
  margin-top: var(--space-md);
}

/* ── RESPONSIVIDADE MOBILE — ESTILO APP ── */

@media (max-width: 1024px) {
  #sidebar-wrapper {
    display: none !important;
  }

  .col3-content {
    margin-left: 0 !important;
    width: 100%;
    padding-bottom: 80px; /* Espaço para o bottom nav */
    padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    padding: 0 var(--space-sm);
    height: 60px;
    width: 100%;
  }

  .content {
    padding: var(--space-sm);
    width: 100%;
    overflow-x: hidden;
    max-width: 100%;
    padding-bottom: calc(170px + env(safe-area-inset-bottom, 0px));
  }

  .page,
  .card,
  .modal,
  .form-input,
  .form-select,
  .form-textarea {
    max-width: 100%;
  }

  img,
  canvas,
  video,
  table {
    max-width: 100%;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .two-col {
    flex-direction: column;
    gap: var(--space-md);
  }

  .two-col > div {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }

  /* Bottom Nav */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    min-height: calc(70px + env(safe-area-inset-bottom, 0px));
    background: rgba(13, 13, 13, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-strong);
    z-index: 2000;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
  }

  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-faint);
    text-decoration: none;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex: 1;
    padding: 10px 0;
    transition: all 0.2s;
  }

  .mobile-nav-item i {
    font-size: 22px;
    line-height: 1;
  }

  .mobile-nav-item.active {
    color: var(--gold);
    transform: translateY(-2px);
  }

  /* Toque Amigável */
  .btn, .btn-warm {
    padding: 16px 20px;
    width: 100%;
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 15px;
  }

  .form-input, .form-select, .form-textarea {
    font-size: 16px; /* Evita zoom automático no iOS */
    padding: 14px;
  }

  .modal {
    max-height: 90vh;
    border-radius: 24px 24px 0 0;
    position: fixed;
    bottom: 0;
    margin: 0;
    animation: slideUp 0.3s ease-out;
  }
  
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .page-header h2 {
    font-size: 24px;
  }
  
  .page-header p {
    font-size: 13px;
  }

  .card-value {
    font-size: 22px;
  }
  
  .card {
    padding: var(--space-sm);
  }

  /* Esconde logout na topbar mobile para não poluir */
  .topbar-right {
    display: none;
  }
}

/* Telas muito pequenas */
@media (max-width: 480px) {
  .content {
    padding: var(--space-sm);
  }
  
  .cards-grid {
    grid-template-columns: 1fr;
  }
  
  .card-value {
    font-size: 20px;
  }
}

@media (min-width: 1025px) {
  .mobile-bottom-nav {
    display: none !important;
  }
}

