/* ================================================================
   Aprovado — Folha de Estilo Principal
   Design: limpo, minimalista, responsivo
   Temas: claro (padrão) e escuro
   ================================================================ */

/* ---------- VARIÁVEIS DE TEMA ---------- */
:root {
  /* Tema claro (padrão) — paleta Aprovado */
  --bg-primary: #f5f6f8;
  --bg-secondary: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: #eef0f4;
  --bg-input: #ffffff;
  --bg-overlay: rgba(15, 31, 58, 0.55);

  --text-primary: #0f1f3a;
  --text-secondary: #4a5568;
  --text-muted: #8a93a3;
  --text-inverse: #ffffff;

  --border-color: #e1e5ec;
  --border-strong: #c5cad4;

  --accent: #1e3a5f;          /* azul marinho */
  --accent-hover: #0f1f3a;
  --accent-soft: #e7eef5;
  --accent-contrast: #ffffff;

  --gold: #c9a961;            /* dourado chique */
  --gold-soft: #f5edd6;
  --gold-dark: #a08442;

  --success: #2d7a4f;
  --success-soft: #e3f1e9;
  --warning: #b8860b;
  --warning-soft: #fbf3d9;
  --danger: #b83232;
  --danger-soft: #fbe5e5;
  --info: #2c5f8d;
  --info-soft: #e1ecf4;

  --shadow-sm: 0 1px 2px rgba(15, 31, 58, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(15, 31, 58, 0.08), 0 2px 4px -2px rgba(15, 31, 58, 0.04);
  --shadow-lg: 0 12px 16px -4px rgba(15, 31, 58, 0.08), 0 4px 6px -2px rgba(15, 31, 58, 0.03);
  --shadow-xl: 0 20px 24px -4px rgba(15, 31, 58, 0.10), 0 8px 8px -4px rgba(15, 31, 58, 0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-width: 260px;
  --topbar-height: 60px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-primary: #0a0f1c;
  --bg-secondary: #0f1626;
  --bg-elevated: #141d31;
  --bg-hover: #1a2440;
  --bg-input: #141d31;
  --bg-overlay: rgba(0, 0, 0, 0.75);

  --text-primary: #e8ecf2;
  --text-secondary: #a3acba;
  --text-muted: #6b7384;
  --text-inverse: #0a0f1c;

  --border-color: #1f2a40;
  --border-strong: #2f3847;

  --accent: #c9a961;            /* dourado no dark para destaque */
  --accent-hover: #d8b878;
  --accent-soft: #1a1f3a;
  --accent-contrast: #0a0f1c;

  --gold: #c9a961;
  --gold-soft: #2a2418;
  --gold-dark: #a08442;

  --success: #4ade80;
  --success-soft: #0a2a18;
  --warning: #fbbf24;
  --warning-soft: #2a2008;
  --danger: #f87171;
  --danger-soft: #2a0d0d;
  --info: #60a5fa;
  --info-soft: #0a1f3a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 16px -4px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 24px -4px rgba(0, 0, 0, 0.6);
}

/* ---------- RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html, body { height: 100%; max-width: 100%; }
html { overflow-x: hidden; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
  max-width: 100vw;
  overflow-x: hidden;
}

/* Impede scroll horizontal em qualquer elemento */
*, *::before, *::after { max-width: 100%; }

/* Permite scroll horizontal APENAS onde necessário (tabelas, code blocks) */
.table-scroll, pre, code { max-width: none; }
.table-scroll { overflow-x: auto; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

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

/* ---------- SIDEBAR ---------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.logo { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-mark-wrap { width: 36px; height: 36px; flex-shrink: 0; }
.logo-mark { width: 100%; height: 100%; display: block; }
.logo-text h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1;
}
.logo-text p { font-size: 10px; color: var(--text-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }

.sidebar-toggle {
  display: none;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 16px;
  align-items: center; justify-content: center;
}
.sidebar-toggle:hover { background: var(--bg-hover); }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border-color); }

.theme-toggle {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.theme-icon { font-size: 16px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--transition);
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ---------- MAIN ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-btn {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 20px;
  align-items: center; justify-content: center;
}
.menu-btn:hover { background: var(--bg-hover); }

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

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

.global-filter select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  min-width: 200px;
  cursor: pointer;
  transition: border-color var(--transition);
}
.global-filter select:focus { outline: none; border-color: var(--accent); }

.view-container {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- PAGE HEADER ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.page-header p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) { background: #15803d; }

.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 8px; min-width: 32px; }

/* ---------- CARDS ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: box-shadow var(--transition);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- STATS ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.indigo { background: var(--accent-soft); color: var(--accent); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.amber { background: var(--warning-soft); color: var(--warning); }
.stat-icon.sky { background: var(--info-soft); color: var(--info); }
.stat-icon.rose { background: var(--danger-soft); color: var(--danger); }

.stat-content { min-width: 0; flex: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-top: 4px; line-height: 1.1; letter-spacing: -0.02em; }
.stat-hint { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ---------- FORMS ---------- */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }

.range-group { display: flex; align-items: center; gap: 12px; }
.range-group input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-value {
  width: 32px; text-align: center;
  font-weight: 600;
  color: var(--accent);
}

/* Rating stars / levels */
.rating { display: flex; gap: 4px; }
.rating-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.rating-dot:hover { border-color: var(--accent); }
.rating-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- TABLES ---------- */
.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .cell-actions { display: flex; gap: 4px; justify-content: flex-end; }
.data-table .empty-row td { text-align: center; color: var(--text-muted); padding: 40px; }

/* ---------- BADGES ---------- */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-pill.planned { background: var(--info-soft); color: var(--info); }
.badge-pill.progress { background: var(--warning-soft); color: var(--warning); }
.badge-pill.done { background: var(--success-soft); color: var(--success); }
.badge-pill.pending { background: var(--bg-hover); color: var(--text-secondary); }
.badge-pill.overdue { background: var(--danger-soft); color: var(--danger); }
.badge-pill.draft { background: var(--bg-hover); color: var(--text-muted); }

/* ---------- PROGRESS ---------- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-hover);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width var(--transition);
}
.progress-bar-fill.success { background: var(--success); }
.progress-bar-fill.warning { background: var(--warning); }
.progress-bar-fill.danger { background: var(--danger); }

/* ---------- CRONÔMETRO ---------- */
.timer-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  text-align: center;
  max-width: 600px;
  margin: 0 auto 24px;
}
.timer-display {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 16px 0;
  line-height: 1;
}
.timer-display.running { color: var(--accent); }
.timer-display.paused { color: var(--warning); }
.timer-controls { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.timer-meta {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  text-align: left;
}
.timer-meta-item { font-size: 12px; }
.timer-meta-label { color: var(--text-muted); }
.timer-meta-value { color: var(--text-primary); font-weight: 600; margin-top: 2px; }

/* ---------- EMPTY STATES ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.7; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 600; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto 16px; }

/* ---------- LIST ITEMS ---------- */
.list-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
  cursor: pointer;
}
.list-item:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.list-item-content { flex: 1; min-width: 0; }
.list-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.list-item-subtitle { font-size: 12px; color: var(--text-secondary); }
.list-item-actions { display: flex; gap: 6px; }

.list-stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- TAGS ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin: 2px;
}
.tag-remove {
  margin-left: 4px;
  cursor: pointer;
  opacity: 0.7;
}
.tag-remove:hover { opacity: 1; }

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  opacity: 0;
  transition: opacity var(--transition);
}
.modal-overlay[hidden] { display: none; }
.modal-overlay.show { opacity: 1; }

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal.modal-lg { max-width: 800px; }
.modal.modal-sm { max-width: 400px; }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.modal-header h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ---------- TOASTS ---------- */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px;
  animation: slideIn 220ms ease-out;
}
.toast strong { color: var(--accent); }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.toast-message { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- CONFIRM ---------- */
.confirm-overlay {
  position: fixed; inset: 0;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 250; padding: 20px;
}
.confirm-overlay[hidden] { display: none; }
.confirm-dialog {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}
.confirm-dialog h3 { font-size: 16px; color: var(--text-primary); margin-bottom: 8px; }
.confirm-dialog p { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- INSIGHTS ---------- */
.insight-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex; gap: 12px;
  align-items: flex-start;
}
.insight-item.success { border-left-color: var(--success); }
.insight-item.warning { border-left-color: var(--warning); }
.insight-item.danger { border-left-color: var(--danger); }
.insight-item.info { border-left-color: var(--info); }
.insight-icon { font-size: 20px; flex-shrink: 0; }
.insight-content { flex: 1; }
.insight-title { font-weight: 600; font-size: 13px; color: var(--text-primary); margin-bottom: 2px; }
.insight-text { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }

/* ---------- CHART CONTAINERS ---------- */
.chart-container {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.chart-container canvas { max-height: 320px; }

/* ---------- FILTER BAR ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}
.filter-bar .form-control { min-width: 140px; padding: 8px 12px; font-size: 13px; }
.filter-bar .search-input { flex: 1; min-width: 200px; }

/* ---------- MISC ---------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-mono { font-family: var(--font-mono); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .menu-btn { display: flex; }
  .global-filter select { min-width: 140px; }

  .view-container { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .timer-display { font-size: 48px; }
  .stat-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; }

  .topbar-title { font-size: 16px; }
  .modal { max-height: 95vh; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .timer-display { font-size: 40px; }
  .btn { padding: 9px 14px; font-size: 12px; }
}

/* Print */
@media print {
  .sidebar, .topbar, .page-header-actions { display: none; }
  .main-content { margin: 0; }
  .view-container { padding: 0; }
}

/* ---------- LOGIN SCREEN ---------- */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(30, 58, 95, 0.6) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(201, 169, 97, 0.15) 0%, transparent 50%),
    linear-gradient(135deg, #0a1424 0%, #0f1f3a 50%, #0a1424 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  opacity: 0;
  transition: opacity var(--transition);
  /* CRÍTICO: impede QUALQUER scroll ou movimento */
  overflow: hidden;
  touch-action: none;
  -webkit-overflow-scrolling: auto;
  /* Fixa dimensões para evitar "dança" */
  width: 100vw;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height (mobile) */
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  margin: 0;
  inset: 0;
}
.login-overlay[hidden] { display: none; }
.login-overlay.show { opacity: 1; }

/* Pattern sutil de fundo */
.login-bg-pattern {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(201, 169, 97, 0.08) 1px, transparent 0);
  background-size: 32px 32px;
  pointer-events: none;
  opacity: 0.6;
  inset: 0;
}

.login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(201, 169, 97, 0.2);
  border-radius: var(--radius-xl);
  padding: 32px 24px 20px;
  max-width: 440px;
  width: 100%;
  box-sizing: border-box;
  box-shadow: 0 30px 60px -10px rgba(0, 0, 0, 0.4), 0 18px 36px -18px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: loginCardIn 400ms cubic-bezier(0.16, 1, 0.3, 1);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Impede o card de causar scroll horizontal */
  overflow-x: hidden;
  /* Usa margem automática para centralizar sem causar overflow */
  margin: auto;
}
@keyframes loginCardIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.login-brand {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}
.login-mark-wrap { width: 64px; height: 64px; margin-bottom: 16px; }
.login-mark { width: 100%; height: 100%; display: block; }
.login-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 8px;
}
.login-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

.login-features {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 28px;
  text-align: left;
}
.login-feature {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  border-left: 2px solid var(--gold);
  transition: all var(--transition);
}
.login-feature:hover {
  background: var(--accent-soft);
  transform: translateY(-1px);
}
.login-feature-icon {
  font-size: 18px;
  line-height: 1.2;
  flex-shrink: 0;
}
.login-feature strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.login-feature span:not(.login-feature-icon) {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.btn-google {
  width: 100%;
  background: #fff;
  color: #3c4043;
  border: 1px solid #dadce0;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
  letter-spacing: 0.01em;
  box-sizing: border-box;
}
.btn-google:hover:not(:disabled) {
  background: #f8f9fa;
  box-shadow: 0 2px 8px rgba(60,64,67,0.2);
  border-color: #c5cad4;
}
.btn-google:disabled {
  opacity: 0.5; cursor: not-allowed;
}

/* Container que segura botão Google + loading na MESMA posição (substituem um ao outro) */
.login-action-area {
  position: relative;
  width: 100%;
  margin-bottom: 16px;
  min-height: 46px; /* altura do botão Google */
}
.login-action-area .btn-google {
  margin: 0;
}
.login-action-area .btn-google[style*="display: none"] ~ .login-loading,
.login-action-area .btn-google[hidden] ~ .login-loading {
  display: flex;
}

.login-loading {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: none; /* controlado via JS */
  align-items: center; justify-content: center; gap: 10px;
  padding: 13px 20px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-sizing: border-box;
  min-height: 46px;
}
.login-loading:not([hidden]) {
  display: flex;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-disclaimer {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--accent-soft);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-size: 11px;
  line-height: 1.5;
  border-left: 2px solid var(--accent);
}

.login-error {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-size: 12px;
  border-left: 3px solid var(--danger);
  text-align: left;
}
.login-error strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}
.login-error ol, .login-error ul {
  margin: 8px 0 0 16px;
  padding: 0;
  font-weight: normal;
  line-height: 1.7;
}
.login-error a {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 14px;
  background: var(--accent);
  color: #fff !important;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: background var(--transition);
}
.login-error a:hover { background: var(--accent-hover); }

.login-footer {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.login-footer-dot { margin: 0 6px; opacity: 0.5; }

/* ---------- BANNER INSTALAR PWA (mobile-first elegante) ---------- */
.pwa-install-banner {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 12px 12px 12px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 12px 32px rgba(15, 31, 58, 0.25), 0 4px 12px rgba(15, 31, 58, 0.15);
  animation: pwaBannerIn 400ms cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 480px;
  margin: 0 auto;
}
@keyframes pwaBannerIn {
  from { transform: translateY(120%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.pwa-install-banner[hidden] { display: none; }

.pwa-banner-icon {
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #1e3a5f, #0a1424);
  display: flex; align-items: center; justify-content: center;
}
.pwa-banner-icon img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.pwa-banner-content {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.pwa-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.pwa-banner-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pwa-banner-btn {
  flex-shrink: 0;
  background: var(--gold);
  color: #0f1f3a;
  border: none;
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.01em;
}
.pwa-banner-btn:hover {
  background: var(--gold-dark);
  color: #fff;
  transform: scale(1.05);
}
.pwa-banner-btn:active {
  transform: scale(0.96);
}

.pwa-banner-close {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.pwa-banner-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Desktop: banner vira botão compacto no canto */
@media (min-width: 769px) {
  .pwa-install-banner {
    bottom: 20px;
    left: auto;
    right: 20px;
    max-width: 380px;
    padding: 10px 10px 10px 12px;
  }
}

/* Mobile pequeno: compacta ainda mais */
@media (max-width: 380px) {
  .pwa-install-banner {
    bottom: 12px;
    left: 12px;
    right: 12px;
    padding: 10px;
    gap: 10px;
  }
  .pwa-banner-icon { width: 38px; height: 38px; }
  .pwa-banner-title { font-size: 13px; }
  .pwa-banner-desc { font-size: 10px; }
  .pwa-banner-btn { padding: 7px 14px; font-size: 12px; }
}

@media (max-width: 768px) {
  .login-features { grid-template-columns: 1fr; }
  .login-card { padding: 26px 20px 18px; }
  .login-title { font-size: 24px; }
  .login-mark-wrap { width: 50px; height: 50px; margin-bottom: 10px; }
  .login-brand { margin-bottom: 20px; padding-bottom: 16px; }
  .login-features { margin-bottom: 20px; gap: 8px; }
  .login-feature { padding: 9px 11px; gap: 8px; }
  .login-tagline { font-size: 11px; }
  .login-overlay { padding: 12px; }
}

@media (max-width: 480px) {
  .login-overlay { padding: 10px; }
  .login-card { padding: 22px 16px 16px; border-radius: 16px; }
  .login-title { font-size: 22px; }
  .login-mark-wrap { width: 44px; height: 44px; margin-bottom: 8px; }
  .login-brand { margin-bottom: 18px; padding-bottom: 14px; }
  .login-feature-icon { font-size: 16px; }
  .login-feature strong { font-size: 11px; }
  .login-feature span:not(.login-feature-icon) { font-size: 10px; }
  .btn-google { padding: 11px 14px; font-size: 13px; }
  .login-loading { padding: 11px 14px; font-size: 12px; }
  .login-action-area { min-height: 42px; margin-bottom: 12px; }
  .login-disclaimer { font-size: 10px; padding: 10px; }
  .login-footer { font-size: 10px; margin-top: 18px; padding-top: 14px; }
}

/* ---------- USER CARD NO SIDEBAR ---------- */
.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-top: 12px;
  background: var(--bg-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: all var(--transition);
}
.user-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.user-avatar {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.user-info {
  flex: 1; min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.01em;
}
.user-email {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  margin-top: 1px;
}

/* Botão de logout elegante */
.logout-btn {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.logout-btn:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  transform: scale(1.05);
}
.logout-btn:active {
  transform: scale(0.95);
}

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