/* ═══════════════════════════════════════════════════════════════════════════
   DocGen — Stylesheet (Employer Brand)
   ═══════════════════════════════════════════════════════════════════════════ */

@font-face {
  font-family: 'Montserrat';
  src: url('/static/assets/fonts/Montserrat-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Montserrat';
  src: url('/static/assets/fonts/Montserrat-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

:root[data-theme="dark"] {
  --bg:          #0a0d16;
  --bg-soft:     #0e1021;
  --surface:     #141828;
  --surface-2:   #1c2236;
  --surface-3:   #24304d;
  --border:      #2a3555;
  --border-soft: #1c2540;
  --text:        #e8ecf4;
  --text-mute:   #8d99b8;
  --text-dim:    #5c6a8a;
  --accent:      #1052A0;
  --accent-soft: rgba(16, 82, 160, 0.18);
  --accent-2:    #FDC40A;
  --warning:     #FDC40A;
  --error:       #f87171;
  --shadow:      0 4px 18px rgba(0,0,0,0.4);
  --shadow-lg:   0 12px 48px rgba(0,0,0,0.55);
  --brand-primary: #24304D;
  --brand-gold:    #FDC40A;
}

:root[data-theme="light"] {
  --bg:          #f2f4f8;
  --bg-soft:     #eaecf3;
  --surface:     #ffffff;
  --surface-2:   #f5f7fb;
  --surface-3:   #ebeef5;
  --border:      #d0d7e5;
  --border-soft: #e2e7f0;
  --text:        #1a2038;
  --text-mute:   #5c6a8a;
  --text-dim:    #8d99b8;
  --accent:      #1052A0;
  --accent-soft: rgba(16, 82, 160, 0.08);
  --accent-2:    #b8920a;
  --warning:     #b8920a;
  --error:       #dc2626;
  --shadow:      0 2px 12px rgba(14, 16, 33, 0.08);
  --shadow-lg:   0 12px 32px rgba(14, 16, 33, 0.14);
  --brand-primary: #24304D;
  --brand-gold:    #FDC40A;
}

:root {
  --radius:    10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --font:      'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

i[data-lucide] { width: 16px; height: 16px; stroke-width: 2; }

a { color: inherit; text-decoration: none; }

/* ═══════════════════ TOPBAR ═══════════════════ */
.topbar {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 24px;
  height: 60px;
  background: var(--brand-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.brand:hover { background: rgba(255,255,255,0.08); }

.brand-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--brand-primary);
  color: white;
  border-radius: 9px;
  box-shadow: 0 2px 8px var(--accent-soft);
  overflow: hidden;
}
.brand-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.brand-icon i[data-lucide] { width: 20px; height: 20px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: -0.3px; color: #fff; }
.brand-sub  { color: rgba(255,255,255,0.65); font-size: 0.72rem; }

.tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}
body.password-change-required .tabs .tab:not([data-page="account"]) {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.65);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tab.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.theme-toggle {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s;
}
.theme-toggle:hover { color: #fff; border-color: rgba(255,255,255,0.4); }

.health {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.7);
}
.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  box-shadow: 0 0 0 2px transparent;
}
.health.healthy .health-dot { background: var(--brand-gold); box-shadow: 0 0 0 3px rgba(253, 196, 10, 0.25); }
.health.error   .health-dot { background: var(--error);    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.25); }

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
  color: rgba(255,255,255,0.88);
  max-width: 220px;
}
.user-chip span {
  font-size: 0.78rem;
  font-weight: 600;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip small {
  color: rgba(255,255,255,0.58);
  font-size: 0.68rem;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: var(--brand-primary);
  padding: 24px;
}
.login-panel {
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-panel img { width: 180px; height: auto; margin: 0 auto 12px; }
.login-panel h1 { color: #fff; font-size: 1.35rem; text-align: center; margin-bottom: 8px; }
.login-panel input,
.user-form input,
.user-form select {
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  outline: none;
}
.login-panel input:focus,
.user-form input:focus,
.user-form select:focus { border-color: var(--accent); }
.form-feedback {
  min-height: 20px;
  color: var(--error);
  font-size: 0.82rem;
}

/* ── Banner de Freshness ─────────────────────────────────────────────────── */
.freshness-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: color-mix(in srgb, #f59e0b 10%, var(--surface-2));
  border: 1px solid #f59e0b66;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text);
  position: relative;
}
.freshness-banner-icon { font-size: 1.3rem; flex-shrink: 0; margin-top: 1px; }
.freshness-banner-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.freshness-banner-body strong { color: #f59e0b; }
.freshness-banner-body ul {
  margin: 6px 0 0 0;
  padding-left: 18px;
  color: var(--text-mute);
  font-size: 0.8rem;
}
.freshness-banner-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-mute);
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}
.freshness-banner-close:hover { color: var(--text); background: var(--surface-3); }

/* ═══════════════════ SYNC PAGE ═══════════════════ */
.sync-page { max-width: 900px; margin: 0 auto; }
.sync-header h1 { display: flex; align-items: center; gap: 12px; font-size: 1.5rem; margin-bottom: 4px; }
.sync-header .lead { color: var(--text-mute); margin-bottom: 24px; }

.sync-info {
  display: flex; flex-wrap: wrap; gap: 16px 32px;
  padding: 16px 20px; background: var(--surface-2);
  border-radius: 10px; margin-bottom: 20px; font-size: 0.85rem;
}
.sync-info-item strong { color: var(--text-mute); margin-right: 6px; }

.sync-actions { display: flex; gap: 12px; margin-bottom: 20px; }
.sync-actions .btn-primary,
.sync-actions .btn-secondary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px; font-size: 0.85rem;
  cursor: pointer; border: 1px solid var(--border); transition: all 0.15s;
}
.sync-actions .btn-primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.sync-actions .btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.sync-actions .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.sync-actions .btn-secondary { background: var(--surface-2); color: var(--text-mute); }
.sync-actions .btn-secondary:hover { color: var(--text); border-color: var(--accent); }

.sync-terminal {
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; background: #0d1117;
}
.sync-terminal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: #161b22; border-bottom: 1px solid #30363d;
}
.sync-terminal-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.8rem; color: #8b949e; font-family: monospace;
}
.sync-terminal-status { font-size: 0.75rem; color: #8b949e; }
.sync-terminal-status.syncing { color: #f0c000; }
.sync-terminal-status.success { color: #3fb950; }
.sync-terminal-status.error { color: #f85149; }

.sync-terminal-body {
  padding: 16px; min-height: 300px; max-height: 500px;
  overflow-y: auto; font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem; line-height: 1.6;
}
.sync-line { padding: 2px 0; color: #c9d1d9; white-space: pre-wrap; word-break: break-all; }
.sync-line.sync-muted { color: #6e7681; font-style: italic; }
.sync-line.sync-success { color: #3fb950; font-weight: 600; }
.sync-line.sync-error { color: #f85149; font-weight: 600; }
.sync-line.sync-log { color: #c9d1d9; }

/* Cards de projeto no sync */
.sync-projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sync-card-loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 0.85rem;
  grid-column: 1 / -1;
}

.sync-project-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.sync-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--brand-primary);
  gap: 12px;
}

.sync-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 0.9rem;
  min-width: 0;
}
.sync-card-title i { flex-shrink: 0; }
.sync-card-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sync-branch-badge {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
}

.sync-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.sync-btn:hover:not(:disabled) { background: rgba(255,255,255,0.25); }
.sync-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sync-btn i { width: 13px; height: 13px; }

.sync-not-repo-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(229, 62, 62, 0.08);
  border-bottom: 1px solid rgba(229, 62, 62, 0.2);
  font-size: 0.78rem;
  color: var(--error, #e53e3e);
}

.sync-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.sync-card-section {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid var(--border);
}
.sync-card-section:last-child { border-right: none; }

.sync-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.sync-commit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-commit-hash {
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--accent);
}

.sync-commit-date {
  font-size: 0.78rem;
  color: var(--text);
  font-weight: 500;
}

.sync-commit-msg {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sync-commit-author {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.sync-card-last {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

.sync-card-status {
  font-size: 0.75rem;
  font-weight: 600;
}

/* Log diário */
.sync-daily-log-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.sync-daily-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  gap: 12px;
}
.sync-daily-log-header i { width: 14px; height: 14px; vertical-align: middle; }
.sync-daily-log-header strong { color: var(--text); }

.sync-date-input {
  font-size: 0.8rem;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.sync-daily-log-body {
  padding: 12px 16px;
  min-height: 60px;
  max-height: 220px;
  overflow-y: auto;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.78rem;
  line-height: 1.7;
  background: #0d1117;
}

/* Spinner animation */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ═══════════════════ MAIN / PAGES ═══════════════════ */
main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.page {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 32px 40px;
  animation: fadeIn 0.18s ease-out;
}
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════ INÍCIO (HOME / LAUNCHER) ═══════════════════ */

.welcome {
  text-align: center;
  margin-bottom: 28px;
}
.welcome-logo {
  margin-bottom: 16px;
}
.welcome-brand-img {
  height: 40px;
  width: auto;
  object-fit: contain;
}
.welcome h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin-bottom: 6px;
}
.welcome .accent { color: var(--brand-gold); }
.welcome p { color: var(--text-mute); font-size: 0.95rem; }

.launcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.launcher-col { display: flex; flex-direction: column; gap: 14px; }

.launcher-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.launcher-card:hover { border-color: var(--accent); }

.launcher-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.launcher-btn:hover { background: var(--surface-2); }

.card-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 11px;
  flex-shrink: 0;
}
.card-icon i[data-lucide] { width: 22px; height: 22px; }

.card-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-title { font-weight: 600; font-size: 0.98rem; }
.card-sub   { font-size: 0.78rem; color: var(--text-mute); }

.card-chevron {
  color: var(--text-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.launcher-card.open .card-chevron { transform: rotate(180deg); color: var(--accent); }

.card-tree {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
  border-top: 1px solid transparent;
}
.launcher-card.open .card-tree {
  max-height: 600px;
  overflow-y: auto;
  border-top-color: var(--border-soft);
}

.card-tree ul {
  list-style: none;
  padding: 6px;
}

.card-tree li,
.card-tree .tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.12s;
}
.card-tree li:hover,
.card-tree .tree-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.card-tree li.placeholder,
.card-tree .placeholder {
  color: var(--text-dim);
  font-style: italic;
  cursor: default;
  background: none !important;
}

.card-tree .meta {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 400;
}

.card-tree-foot {
  padding: 8px 14px 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
}

/* Settings form */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
}
.settings-label {
  display: block;
  font-size: 0.82rem; font-weight: 600;
  color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em;
}
.settings-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.92rem;
  font-family: var(--font-mono);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.settings-input:focus { border-color: var(--accent); }
.settings-actions { display: flex; justify-content: flex-end; padding-top: 2px; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; }
.btn-sm i { width: 14px; height: 14px; }
.settings-feedback { font-size: 0.82rem; border-radius: 6px; padding: 8px 12px; margin: 0; }
.settings-feedback.hidden { display: none; }
.settings-feedback--success { background: rgba(34,197,94,.12); color: #4ade80; }
.settings-feedback--warn    { background: rgba(234,179,8,.12);  color: #facc15; }
.settings-feedback--error   { background: rgba(239,68,68,.12);  color: var(--error); }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
}
.btn-link:hover { background: var(--accent-soft); }

.kv-list, .link-list, .kbd-list { padding: 6px 8px !important; }
.kv-list li {
  display: flex !important;
  justify-content: space-between !important;
  cursor: default !important;
  background: none !important;
}
.kv-list li:hover { background: none !important; color: var(--text) !important; }
.kv-list .muted { color: var(--text-mute); font-family: var(--font-mono); font-size: 0.78rem; }

.kbd-list li {
  cursor: default !important;
  background: none !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}
.kbd-list .kbd-keys {
  display: inline-flex;
  gap: 4px;
  min-width: 110px;
}
kbd {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
}

/* ═══════════════════ MENU (MenuMaisOpcoes) ═══════════════════ */

.menu-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto 24px;
}
.menu-head h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.4px;
}
.menu-head p {
  color: var(--text-mute);
  font-size: 0.88rem;
  margin-top: 2px;
}
.menu-head code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent);
}
.menu-head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.menu-col { display: flex; flex-direction: column; gap: 12px; }

/* Card de categoria — espelha MenuMaisOpcoes */
.menu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}
.menu-card:hover { border-color: var(--accent); }

.menu-card-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.menu-card-btn:hover { background: var(--surface-2); }

.menu-card-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  flex-shrink: 0;
}
.menu-card-icon i[data-lucide] { width: 20px; height: 20px; }

.menu-card-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.menu-card-title { font-weight: 600; font-size: 0.95rem; }
.menu-card-sub   { font-size: 0.74rem; color: var(--text-mute); }

.menu-card .card-chevron { color: var(--text-dim); }
.menu-card.open .card-chevron { transform: rotate(180deg); color: var(--accent); }

.menu-card-shortcut {
  background: var(--surface-3);
  color: var(--text-mute);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.menu-card-tree {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out;
}
.menu-card.open .menu-card-tree {
  max-height: 800px;
  overflow-y: auto;
  border-top: 1px solid var(--border-soft);
}

.menu-card-tree ul {
  list-style: none;
  padding: 4px 6px;
}

.menu-tree-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.menu-tree-item:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.menu-tree-item .item-marker {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}
.menu-tree-item:hover .item-marker { background: var(--accent); }
.menu-tree-item .item-doc-mark {
  font-size: 0.7rem;
  color: var(--accent-2);
  margin-left: auto;
  flex-shrink: 0;
}
.menu-tree-item.dynamic {
  color: var(--text-dim);
  cursor: not-allowed;
}
.menu-tree-item.dynamic:hover {
  background: none;
  color: var(--text-dim);
}
.menu-tree-item.dynamic .item-marker { background: transparent; border: 1px dashed var(--text-dim); }

.menu-tree-group {
  padding: 6px 0;
}
.menu-tree-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.menu-tree-group ul {
  margin-left: 12px;
  border-left: 1px solid var(--border-soft);
  padding-left: 4px;
}

/* ═══════════════════ DOCS GRID ═══════════════════ */

.docs-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto 24px;
}
.docs-head h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.4px; }
.docs-head p  { color: var(--text-mute); font-size: 0.88rem; margin-top: 2px; }

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto;
}

.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.doc-card .doc-card-title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.doc-card .doc-card-tag {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
}
.doc-card .doc-card-meta {
  font-size: 0.74rem;
  color: var(--text-mute);
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

/* ═══════════════════ USERS ═══════════════════ */
.users-page { max-width: 1180px; margin: 0 auto; }
.account-page { max-width: 720px; margin: 0 auto; }
.users-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
}
.user-form,
.account-form,
.users-list-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.user-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.account-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.account-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.34);
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--text);
  font-size: 0.84rem;
}
.user-form h2,
.account-form h2,
.users-list-panel h2 {
  font-size: 1rem;
  margin-bottom: 6px;
}
.user-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-mute);
  font-size: 0.78rem;
  font-weight: 600;
}
.account-form input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.account-form input:focus { border-color: var(--accent); }
.users-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.users-list-head h2 { margin-bottom: 0; }
.user-search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(320px, 100%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
}
.user-search-box svg {
  width: 16px;
  height: 16px;
  color: var(--text-mute);
  flex: 0 0 auto;
}
.user-search-box input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  color: var(--text);
  font-family: inherit;
  outline: none;
  padding: 10px 0;
}
.users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 560px;
  overflow-y: auto;
  padding-right: 6px;
}
.group-create-form {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr auto;
  gap: 10px;
  align-items: start;
  margin: 10px 0 16px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.group-create-form input[type="text"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.group-create-form .form-feedback {
  grid-column: 1 / -1;
  margin: 0;
}
.permissions-panel { grid-column: 1 / -1; }
.permission-profiles-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.permission-profile {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 14px;
}
.permission-profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.permission-profile-head strong { display: block; font-size: 0.95rem; }
.permission-profile-head span { color: var(--text-mute); font-size: 0.76rem; }
.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}
.permission-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text);
}
.permission-check.disabled { opacity: 0.7; }
.permission-check input { width: auto; }
.user-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.user-row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.user-row strong { display: block; font-size: 0.9rem; }
.user-row span { color: var(--text-mute); font-size: 0.76rem; }
.user-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-row-meta .warning {
  border-color: rgba(245, 158, 11, 0.36);
  color: #f59e0b;
}
.user-row-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.user-edit-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.user-edit-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-mute);
  font-size: 0.72rem;
  font-weight: 600;
}
.user-edit-row select {
  min-width: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.user-active-toggle {
  align-items: center;
  flex-direction: row !important;
  height: 36px;
}
.user-active-toggle input { width: auto; }
.reset-password-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 1px solid var(--border-soft);
  padding-left: 12px;
}
.reset-password-row input {
  width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.reset-password-row input:focus,
.user-edit-row select:focus,
.group-create-form input[type="text"]:focus { border-color: var(--accent); }

/* ═══════════════════ CHAT (página completa) ═══════════════════ */

#page-chat { padding: 0; }

.chat-app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100%;
  background: var(--bg);
}

.chat-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  padding: 14px;
  gap: 10px;
  overflow: hidden;
}

.btn-new-chat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-new-chat:hover { opacity: 0.9; }

.conversations-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-mute);
  transition: background 0.12s;
}
.conv-item:hover { background: var(--surface-2); color: var(--text); }
.conv-item.active { background: var(--accent-soft); color: var(--accent); }
.conv-item .conv-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .conv-date { font-size: 0.7rem; opacity: 0.7; }

.chat-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-main-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
#conversation-title {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  outline: none;
}
#conversation-title:hover  { background: var(--surface-2); }
#conversation-title:focus  { background: var(--surface-2); border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-mute);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-ghost.btn-danger:hover { color: var(--error); border-color: var(--error); }

.chat-messages-full {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-mute);
  max-width: 420px;
}
.chat-empty .empty-icon i { width: 38px; height: 38px; opacity: 0.5; }
.chat-empty h3 { margin: 12px 0 6px; font-weight: 600; color: var(--text); }
.chat-empty p { font-size: 0.88rem; }

.chat-msg {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: white;
}
.chat-msg.bot {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.chat-msg.bot p { margin-bottom: 8px; }
.chat-msg.bot p:last-child { margin-bottom: 0; }
.chat-msg.bot ul, .chat-msg.bot ol { margin: 6px 0 6px 22px; }
.chat-msg.bot code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
}
.chat-msg.bot pre { background: var(--surface-2); padding: 10px; border-radius: 6px; overflow-x: auto; }

.chat-msg.thinking {
  align-self: flex-start;
  color: var(--text-mute);
  font-style: italic;
  background: none;
  padding: 4px 0;
  font-size: 0.85rem;
}

.docs-used {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-mute);
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
}

.suggest-gen-actions { margin-top: 12px; display: flex; gap: 8px; }
.btn-suggest-yes {
  background: var(--brand-primary);
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
}
.btn-suggest-yes:hover { opacity: 0.85; }
.btn-suggest-no {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-mute);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}
.btn-suggest-no:hover { background: var(--surface-2); }

.chat-composer {
  padding: 10px 22px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.chat-composer-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

/* Context bar */
.chat-context-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}
.chat-context-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}
.chat-context-pick:hover { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
.chat-context-pick.has-context { border-color: var(--accent); color: var(--accent); background: var(--surface-2); font-weight: 600; }
.chat-context-pick i { width: 13px; height: 13px; flex-shrink: 0; }
.chat-context-clear {
  background: none;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-context-clear:hover { color: var(--error); background: var(--surface-2); }
.chat-context-clear i { width: 13px; height: 13px; }

#chat-input-full {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  padding: 12px 14px;
  border-radius: var(--radius);
  resize: none;
  outline: none;
  max-height: 200px;
  line-height: 1.5;
  transition: border-color 0.15s;
}
#chat-input-full:focus { border-color: var(--accent); }

.btn-send {
  width: 42px;
  height: 42px;
  background: var(--brand-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.btn-send:hover { opacity: 0.9; }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-send i { width: 18px; height: 18px; }

/* ═══════════════════ AJUDA ═══════════════════ */

.help-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 32px;
  max-width: 1100px;
  margin: 0 auto;
}

.help-toc {
  position: sticky;
  top: 32px;
  align-self: start;
  font-size: 0.88rem;
}
.help-toc h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-mute);
  margin-bottom: 10px;
}
.help-toc ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.help-toc a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-mute);
  transition: background 0.12s, color 0.12s;
}
.help-toc a:hover, .help-toc a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.help-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  font-size: 0.95rem;
  line-height: 1.7;
}
.help-content h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.help-content .lead {
  font-size: 1.02rem;
  color: var(--text-mute);
  margin-bottom: 28px;
}
.help-content section { margin: 32px 0; }
.help-content h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.help-content h3 {
  font-size: 1.0rem;
  font-weight: 600;
  margin: 22px 0 6px;
}
.help-content p { margin-bottom: 10px; }
.help-content ol, .help-content ul {
  padding-left: 22px;
  margin-bottom: 12px;
}
.help-content li { margin-bottom: 6px; }
.help-content code {
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--accent);
}

/* ═══════════════════ MODAIS ═══════════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn 0.18s ease-out;
}
.modal-panel.modal-narrow { width: min(520px, 100%); }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-head-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.modal-eyebrow {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  font-weight: 600;
}
.modal-title { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.modal-path { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-mute); margin-top: 4px; }
.modal-actions { display: flex; gap: 8px; align-items: center; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-mute);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.12s, color 0.12s;
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

/* Doc-type buttons (no modal) */
.doc-type-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-primary);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.derived-docs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.derived-label {
  font-size: 0.78rem;
  color: var(--text-mute);
  padding-left: 8px;
  border-left: 2px solid var(--border);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Agent log */
#agent-log {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 240px;
}
.log-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  color: var(--text-mute);
}
.log-header span { display: inline-flex; align-items: center; gap: 8px; }
#log-entries {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
}
.log-entry { margin-bottom: 2px; }
.log-entry.status { color: var(--text-mute); }
.log-entry.tool_call { color: var(--accent); }
.log-entry.tool_result { color: var(--accent-2); }
.log-entry.error { color: var(--error); }
.log-entry.done { color: var(--accent-2); font-weight: 600; }
.log-entry.saved { color: var(--warning); }

/* Resultado */
#result-area {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 600px;
}
.result-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#result-title { font-weight: 600; font-size: 0.9rem; }
.result-actions { display: flex; gap: 6px; }

.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.btn-action:hover { border-color: var(--accent); background: var(--accent-soft); }
.btn-action.btn-pdf {
  border-color: rgba(220, 38, 38, 0.4);
  color: #ef4444;
}
.btn-action.btn-pdf:hover { background: rgba(220, 38, 38, 0.1); border-color: #dc2626; }
.btn-action:disabled { opacity: 0.5; cursor: wait; }

#result-tabs {
  padding: 6px 16px 0;
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.tab-pill {
  background: none;
  border: none;
  color: var(--text-mute);
  padding: 6px 14px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
}
.tab-pill.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pill:hover:not(.active) { color: var(--text); }

.tab-content { display: none; padding: 16px; overflow-y: auto; max-height: 480px; }
.tab-content.active { display: block; }

#result-preview { line-height: 1.7; font-size: 0.88rem; }
#result-preview h1 { font-size: 1.3rem; color: var(--accent); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
#result-preview h2 { font-size: 1.05rem; margin: 16px 0 6px; }
#result-preview h3 { font-size: 0.95rem; color: var(--text-mute); margin: 14px 0 4px; }
#result-preview p  { margin-bottom: 8px; }
#result-preview ul, #result-preview ol { padding-left: 22px; margin-bottom: 8px; }
#result-preview li { margin-bottom: 4px; }
#result-preview code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent); }
#result-preview pre { background: var(--surface-2); padding: 10px; border-radius: 6px; overflow-x: auto; }
#result-preview pre code { background: none; padding: 0; color: var(--text); }
#result-preview table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.82rem; }
#result-preview th { background: var(--surface-2); padding: 8px 10px; border: 1px solid var(--border); text-align: left; color: var(--accent); }
#result-preview td { padding: 6px 10px; border: 1px solid var(--border); }
#result-preview blockquote { border-left: 3px solid var(--accent); padding-left: 12px; color: var(--text-mute); margin: 8px 0; }

#result-raw {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-mute);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

/* Lista de telas (modal de busca) */
.screen-list {
  margin-top: 12px;
  max-height: 60vh;
  overflow-y: auto;
}
.screen-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background 0.12s;
}
.screen-item:hover { background: var(--accent-soft); }
.screen-item.active { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.screen-item.active .name { color: var(--accent); }
.screen-item .name { font-weight: 500; font-size: 0.88rem; color: var(--text); }
.screen-item .meta { font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-mute); }

/* Search box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box i {
  position: absolute;
  left: 12px;
  pointer-events: none;
  color: var(--text-mute);
}
.search-box input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 36px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  width: 280px;
  outline: none;
  transition: border-color 0.15s;
}
.search-box input:focus { border-color: var(--accent); }

/* Empty state genérico */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}
.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--surface-2);
  margin-bottom: 16px;
}
.empty-icon i { width: 28px; height: 28px; color: var(--text-dim); }
.empty-state h3 { font-size: 1.05rem; margin-bottom: 6px; color: var(--text); }
.empty-state p { font-size: 0.88rem; }
.empty-state code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-family: var(--font-mono); font-size: 0.82rem; color: var(--accent); }

/* Loading / placeholder */
.loading {
  color: var(--text-mute);
  font-size: 0.85rem;
  padding: 14px 12px;
  text-align: center;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  transform: translateY(8px);
  z-index: 1000;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateY(0); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Utilities */
.hidden { display: none !important; }

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 99px;
}

/* Responsive */
@media (max-width: 920px) {
  .launcher, .menu-grid, .users-layout { grid-template-columns: 1fr; }
  .group-create-form { grid-template-columns: 1fr; }
  .users-list-head { align-items: stretch; flex-direction: column; }
  .user-search-box { width: 100%; }
  .user-row-controls { flex-direction: column; align-items: stretch; }
  .user-edit-row { flex-direction: column; align-items: stretch; }
  .reset-password-row { border-left: none; padding-left: 0; border-top: 1px solid var(--border-soft); padding-top: 8px; }
  .user-row-main { flex-direction: column; align-items: stretch; }
  .help-layout { grid-template-columns: 1fr; }
  .help-toc { position: static; }
  .chat-app { grid-template-columns: 1fr; }
  .chat-sidebar { display: none; }
  .tab span { display: none; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 12px; gap: 12px; }
  .brand-text { display: none; }
  .page { padding: 18px; }
  .search-box input { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Seletor de Projetos
   ═══════════════════════════════════════════════════════════════════════════ */

#project-selector {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.project-selector-inner {
  text-align: center;
  max-width: 700px;
  width: 100%;
  padding: 40px 24px;
}

.project-selector-logo {
  width: 160px;
  margin-bottom: 16px;
}

.project-selector-header h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.project-selector-header p {
  margin: 0 0 32px;
}

.project-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.project-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.2s;
}

.project-card:hover {
  border-color: var(--project-color, var(--accent));
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  transform: translateY(-2px);
}

.project-card i { color: var(--project-color, var(--accent)); width: 32px; height: 32px; }
.project-card-name { font-size: 1.1rem; font-weight: 600; }
.project-card-desc { font-size: 0.8rem; color: var(--muted); }
.project-card-stats { font-size: 0.75rem; color: var(--muted); opacity: 0.7; }

/* ═══════════════════════════════════════════════════════════════════════════
   Indicador de projeto ativo no header
   ═══════════════════════════════════════════════════════════════════════════ */

.project-indicator { display: flex; align-items: center; }

.project-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  color: var(--topbar-fg, #fff);
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s;
}

.project-chip:hover { background: rgba(255,255,255,0.2); }
.project-switch-hint { font-size: 0.65rem; opacity: 0.6; margin-left: 4px; }

/* ═══════════════════════════════════════════════════════════════════════════
   Indicador de jobs + painel lateral
   ═══════════════════════════════════════════════════════════════════════════ */

.jobs-indicator {
  position: relative;
  display: flex;
  align-items: center;
  background: none;
  border: none;
  color: var(--topbar-fg, #fff);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}
.jobs-indicator:hover { background: rgba(255,255,255,0.1); }

.jobs-count {
  position: absolute;
  top: -4px;
  right: -2px;
  background: var(--accent, #e74c3c);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.jobs-panel {
  position: fixed;
  top: var(--topbar-height, 54px);
  right: 0;
  width: 360px;
  max-width: 100vw;
  bottom: 0;
  z-index: 150;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.jobs-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.jobs-panel-header h3 { margin: 0; font-size: 0.95rem; }

.jobs-panel-body {
  flex: 1;
  overflow-y: auto;
}

.job-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.job-row:last-child { border-bottom: none; }

.job-icon { width: 22px; text-align: center; font-size: 1rem; }
.job-icon.running { color: var(--accent); }
.job-icon.done { color: var(--success, #27ae60); }
.job-icon.error { color: var(--error, #e74c3c); }
.job-icon.pending { color: var(--muted); }

.spinner-sm {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.job-info { flex: 1; min-width: 0; }
.job-name { display: block; font-size: 0.85rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { display: block; font-size: 0.72rem; color: var(--muted); }

.job-actions { display: flex; gap: 6px; }

.btn-xs {
  padding: 2px 8px;
  font-size: 0.72rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}
.btn-xs:hover { background: var(--bg); }
.btn-xs.btn-danger { color: var(--error, #e74c3c); border-color: var(--error, #e74c3c); }
.btn-xs.btn-danger:hover { background: var(--error, #e74c3c); color: #fff; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--fg);
  padding: 4px;
  border-radius: 4px;
}
.btn-icon:hover { background: var(--bg); }

/* ═══════════════════════════════════════════════════════════════════════════
   Acesso a projetos (admin)
   ═══════════════════════════════════════════════════════════════════════════ */

.project-access-panel { min-width: 280px; }

.project-access-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-access-row {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.project-access-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.project-access-head i { width: 18px; height: 18px; }

.project-access-profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  cursor: pointer;
  user-select: none;
}
.chip-check input[type="checkbox"] { margin: 0; }
.chip-check:has(input:checked) { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip-check:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

/* Booting indicator */
body.booting main, body.booting #main-tabs { opacity: 0.4; pointer-events: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   Admin stats panel
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-stats-panel {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}
.stat-card-title i { width: 14px; height: 14px; }

.stat-badges { display: flex; flex-wrap: wrap; gap: 5px; }

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.stat-badge strong { color: var(--text); }
.stat-badge i { width: 11px; height: 11px; }

.stat-done    { border-color: #48bb78; color: #276749; }
.stat-running { border-color: var(--accent); color: var(--accent); }
.stat-pending { border-color: #ed8936; color: #c05621; }
.stat-error   { border-color: var(--error); color: var(--error); }
.stat-cancelled { border-color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   Botão hamburger ☰
   ═══════════════════════════════════════════════════════════════════════════ */

.btn-hamburger {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.btn-hamburger:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}
.btn-hamburger i { width: 18px; height: 18px; }
.btn-hamburger.in-drawer-page {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Drawer lateral
   ═══════════════════════════════════════════════════════════════════════════ */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.drawer-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 88vw;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.18);
}
.drawer.open {
  transform: translateX(0);
}

/* Header do drawer — avatar + nome + botão fechar */
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--brand-primary);
  gap: 12px;
}

.drawer-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.drawer-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.35);
}

.drawer-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.drawer-user-info strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drawer-user-info small {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.drawer-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.drawer-close i { width: 18px; height: 18px; }

/* Navegação do drawer */
.drawer-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 8px;
  gap: 2px;
  overflow-y: auto;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.13s, color 0.13s;
}
.drawer-item:hover {
  background: var(--surface-hover, rgba(0,0,0,0.06));
  color: var(--accent);
}
.drawer-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.drawer-item i { width: 18px; height: 18px; flex-shrink: 0; }

/* Footer do drawer — tema + sair */
.drawer-footer {
  border-top: 1px solid var(--border);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-logout {
  color: var(--error, #e53e3e);
}
.drawer-logout:hover {
  background: rgba(229, 62, 62, 0.08);
  color: var(--error, #e53e3e);
}

/* Impede scroll do body quando drawer está aberto */
body.drawer-open { overflow: hidden; }
