* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #0d1117; color: #e6edf3; line-height: 1.5; }

/* Nav */
nav { background: #161b22; padding: 0 24px; display: flex; align-items: center; border-bottom: 1px solid #30363d; height: 48px; gap: 4px; overflow-x: auto; }
.nav-brand { color: #f0f6fc; font-weight: 700; font-size: 15px; margin-right: 16px; white-space: nowrap; }
nav a { color: #8b949e; text-decoration: none; padding: 12px 10px; font-size: 13px; white-space: nowrap; border-bottom: 2px solid transparent; transition: all .15s; }
nav a.active { color: #58a6ff; border-bottom-color: #58a6ff; }
nav a:hover { color: #c9d1d9; }
.nav-logout { margin-left: auto; }
.nav-right + .nav-logout { margin-left: 8px; }
.nav-right { margin-left: auto; color: #484f58; font-size: 12px; white-space: nowrap; }

/* Container */
.container { max-width: 1400px; margin: 24px auto; padding: 0 24px; }
h1 { font-size: 22px; margin-bottom: 20px; color: #f0f6fc; font-weight: 600; }
h2 { font-size: 16px; margin: 24px 0 12px; color: #c9d1d9; font-weight: 600; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 16px; }
.card h3 { font-size: 11px; text-transform: uppercase; color: #8b949e; margin-bottom: 6px; letter-spacing: 0.8px; font-weight: 600; }
.metric { font-size: 24px; font-weight: 700; color: #f0f6fc; margin-bottom: 4px; }

/* Bars */
.bar { background: #21262d; height: 6px; border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.bar-fill { height: 100%; background: #3fb950; border-radius: 3px; transition: width 0.3s; min-width: 2px; }
.bar-warn { background: #d29922; }
.bar-danger { background: #f85149; }
small { color: #8b949e; font-size: 12px; }

/* Progress */
.progress-bar { background: #21262d; height: 28px; border-radius: 14px; overflow: hidden; margin: 8px 0; position: relative; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #238636, #3fb950); border-radius: 14px; transition: width 0.5s; min-width: 28px; }
.progress-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 12px; font-weight: 700; color: #f0f6fc; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* Tables */
.table-scroll { overflow-x: auto; margin-bottom: 16px; }
table { width: 100%; border-collapse: collapse; background: #161b22; border: 1px solid #30363d; border-radius: 8px; overflow: hidden; font-size: 13px; }
thead { background: #1c2128; position: sticky; top: 0; z-index: 1; }
th { text-align: left; padding: 8px 12px; font-size: 11px; text-transform: uppercase; color: #8b949e; letter-spacing: 0.5px; font-weight: 600; white-space: nowrap; }
td { padding: 6px 12px; border-top: 1px solid #21262d; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr:hover { background: #1c212899; }
code { background: #1c2128; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: #79c0ff; font-family: "SF Mono", "Fira Code", "JetBrains Mono", monospace; }

/* Editable cells */
.cell[contenteditable] { cursor: text; min-width: 60px; }
.cell[contenteditable]:focus { outline: 2px solid #58a6ff; background: #0d1117; border-radius: 3px; white-space: normal; }
.cell-saved { animation: flash-green 1.5s; }
.cell-error { animation: flash-red 1.5s; }
@keyframes flash-green { 0% { background: #238636; } 100% { background: transparent; } }
@keyframes flash-red { 0% { background: #f85149; } 100% { background: transparent; } }

/* Badges */
.badge { padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-running, .badge-ok { background: #0d311740; color: #3fb950; border: 1px solid #3fb95030; }
.badge-down, .badge-error { background: #3d111440; color: #f85149; border: 1px solid #f8514930; }
.badge-info { background: #1c212880; color: #8b949e; border: 1px solid #30363d; }
.pk-icon { color: #d29922; font-size: 10px; font-weight: 700; }

/* Status */
.status-ok { color: #3fb950; }
.status-falhou { color: #f85149; }
.status-desconhecido { color: #d29922; }
.text-muted { color: #8b949e; }
.text-accent { color: #58a6ff; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid #30363d; }
.tab { color: #8b949e; text-decoration: none; padding: 10px 16px; font-size: 13px; border-bottom: 2px solid transparent; transition: all .15s; }
.tab.active { color: #f0f6fc; border-bottom-color: #58a6ff; }
.tab:hover { color: #c9d1d9; }

/* Filters */
.filters { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.filters a { color: #8b949e; text-decoration: none; padding: 4px 12px; border-radius: 20px; border: 1px solid #30363d; font-size: 12px; transition: all .15s; }
.filters a.active, .filters a:hover { color: #58a6ff; border-color: #58a6ff; background: #58a6ff10; }

/* Buttons */
.btn-primary { padding: 6px 16px; background: #238636; color: #fff; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; font-weight: 600; }
.btn-primary:hover { background: #2ea043; }
.btn-secondary { padding: 6px 16px; background: #21262d; color: #c9d1d9; border: 1px solid #30363d; border-radius: 6px; font-size: 13px; cursor: pointer; text-decoration: none; }
.btn-back { color: #58a6ff; text-decoration: none; font-size: 14px; }
.btn-danger-sm { padding: 2px 8px; background: #3d1114; color: #f85149; border: 1px solid #f8514930; border-radius: 4px; font-size: 11px; cursor: pointer; }
.btn-danger-sm:hover { background: #f8514930; }

/* Forms */
.form-label { display: block; font-size: 11px; color: #8b949e; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.search-input { padding: 6px 12px; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #f0f6fc; font-size: 13px; }
.search-input:focus { outline: none; border-color: #58a6ff; box-shadow: 0 0 0 3px #58a6ff20; }
.insert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 12px; margin: 16px 0; font-size: 13px; }
.pagination a { color: #58a6ff; text-decoration: none; padding: 4px 12px; border: 1px solid #30363d; border-radius: 6px; }
.pagination a:hover { background: #58a6ff10; }

/* Logs */
.log-output { background: #010409; border: 1px solid #30363d; border-radius: 8px; padding: 12px; font-family: "SF Mono", "Fira Code", monospace; font-size: 12px; max-height: 500px; overflow-y: auto; }
.log-line { padding: 3px 8px; border-radius: 3px; margin-bottom: 1px; line-height: 1.6; }
.log-ok { color: #3fb950; border-left: 3px solid #3fb950; padding-left: 10px; }
.log-error { color: #f85149; border-left: 3px solid #f85149; padding-left: 10px; background: #f8514908; font-weight: 500; }
.log-warn { color: #d29922; border-left: 3px solid #d29922; padding-left: 10px; }
.log-info { color: #8b949e; border-left: 3px solid #21262d; padding-left: 10px; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #161b22; border: 1px solid #30363d; border-radius: 12px; padding: 40px; text-align: center; width: 360px; }
.login-card h1 { font-size: 28px; margin-bottom: 4px; }
.login-card p { color: #8b949e; margin-bottom: 24px; font-size: 14px; }
.login-card input { width: 100%; padding: 10px 14px; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #f0f6fc; font-size: 15px; margin-bottom: 16px; }
.login-card input:focus { outline: none; border-color: #58a6ff; box-shadow: 0 0 0 3px #58a6ff20; }
.login-card button { width: 100%; padding: 10px; background: #238636; color: #fff; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; font-weight: 600; }
.login-card button:hover { background: #2ea043; }
.alert.error { background: #3d111440; color: #f85149; padding: 8px 12px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; border: 1px solid #f8514930; }

/* Mermaid */
.mermaid { background: #0d1117; border-radius: 8px; padding: 16px; overflow-x: auto; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #0d1117; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* Responsive */
@media (max-width: 768px) {
  nav { padding: 0 12px; }
  .container { padding: 0 12px; }
  .cards { grid-template-columns: 1fr 1fr; }
  table { font-size: 12px; }
  td, th { padding: 6px 8px; }
}

/* SQL Editor */
.sql-editor { width: 100%; padding: 12px; background: #010409; border: 1px solid #30363d; border-radius: 8px; color: #79c0ff; font-family: "SF Mono", "Fira Code", monospace; font-size: 13px; resize: vertical; }
.sql-editor:focus { outline: none; border-color: #58a6ff; box-shadow: 0 0 0 3px #58a6ff20; }

/* Sub-nav (dentro de seções como Banco) */
.subnav { background: #1c2128; padding: 0 24px; display: flex; gap: 0; border-bottom: 1px solid #30363d; overflow-x: auto; }
.subnav a { color: #8b949e; text-decoration: none; padding: 8px 14px; font-size: 12px; white-space: nowrap; border-bottom: 2px solid transparent; transition: all .15s; }
.subnav a.active { color: #58a6ff; border-bottom-color: #58a6ff; background: #58a6ff08; }
.subnav a:hover { color: #c9d1d9; }

/* Acesso (login por pessoa, sair por POST, fluxograma em texto até o mermaid desenhar) */
.nav-logout-form { display: inline; margin-left: 8px; }
.nav-logout-btn { background: none; border: 0; color: inherit; font: inherit; font-size: 13px; cursor: pointer; padding: 12px 10px; opacity: .8; }
.nav-logout-btn:hover { opacity: 1; text-decoration: underline; }
pre.mermaid-src { white-space: pre-wrap; font-size: 12px; opacity: .8; }

/* navegador confiável */
.login-card label.confiar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 6px; font-size: 14px; color: #f0f6fc; cursor: pointer; }
.login-card label.confiar input { width: auto; margin: 0; }
.login-card p.confiar-ajuda { font-size: 12px; margin-bottom: 16px; }
.secao-confiaveis { margin-top: 32px; }
.form-esquecer-todos { margin-top: 12px; }
dialog.reauth-dialogo { background: #161b22; color: #f0f6fc; border: 1px solid #30363d; border-radius: 12px; padding: 24px; width: min(360px, calc(100vw - 32px)); }
dialog.reauth-dialogo::backdrop { background: #0008; }
dialog.reauth-dialogo p { margin-bottom: 12px; font-size: 14px; }
dialog.reauth-dialogo input { width: 100%; padding: 10px 14px; background: #0d1117; border: 1px solid #30363d; border-radius: 6px; color: #f0f6fc; font-size: 15px; margin-bottom: 12px; }
dialog.reauth-dialogo .botoes { display: flex; gap: 8px; justify-content: flex-end; }
dialog.reauth-dialogo button { padding: 8px 14px; border-radius: 6px; border: 1px solid #30363d; background: #21262d; color: #f0f6fc; cursor: pointer; }
dialog.reauth-dialogo button[value="ok"] { background: #238636; border-color: #238636; }
