:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a1f2e;
    --bg-card: #212836;
    --text-primary: #e4e8f0;
    --text-secondary: #8892a4;
    --accent: #4f8cff;
    --critical: #ff4757;
    --high: #ff8c42;
    --warning: #ffd93d;
    --ok: #2ed573;
    --border: #2a3244;
    --sidebar-width: 220px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg-primary); color: var(--text-primary); display: flex; min-height: 100vh; }

.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border); padding: 1.5rem 0; position: fixed; height: 100vh; overflow-y: auto; }
.sidebar .logo { padding: 0 1.5rem; margin-bottom: 2rem; }
.sidebar .logo h2 { font-size: 1.1rem; }
.sidebar ul { list-style: none; }
.sidebar li { margin: 2px 0; }
.sidebar li a { display: block; padding: 0.75rem 1.5rem; color: var(--text-secondary); text-decoration: none; font-size: 0.9rem; transition: all 0.2s; }
.sidebar li a:hover { background: var(--bg-card); color: var(--text-primary); }
.sidebar li.active a { background: var(--accent); color: white; border-radius: 0 4px 4px 0; margin-right: 8px; }

.content { margin-left: var(--sidebar-width); flex: 1; padding: 2rem; }
.content header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.content header h1 { font-size: 1.5rem; }
.refresh-info { font-size: 0.8rem; color: var(--text-secondary); }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.metric-card { background: var(--bg-card); border-radius: 8px; padding: 1.2rem; border-left: 4px solid var(--border); }
.metric-card.critical { border-left-color: var(--critical); }
.metric-card.high { border-left-color: var(--high); }
.metric-card.warning { border-left-color: var(--warning); }
.metric-card.info { border-left-color: var(--accent); }
.metric-card.resolved { border-left-color: var(--ok); }
.metric-card.mttr, .metric-card.mtta { border-left-color: #a855f7; }
.metric-card.chronic { border-left-color: #f59e0b; }
.metric-value { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.3rem; }
.metric-label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; }

.panel { background: var(--bg-card); border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.panel-header h2 { font-size: 1.1rem; }

.trend-panel { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.trend-icon { font-size: 1.2rem; }

.incidents-table { width: 100%; border-collapse: collapse; }
.incidents-table th { text-align: left; padding: 0.6rem; font-size: 0.75rem; text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.incidents-table td { padding: 0.7rem; font-size: 0.85rem; border-bottom: 1px solid var(--border); }
.incidents-table tr { cursor: pointer; transition: background 0.1s; }
.incidents-table tr:hover { background: rgba(79, 140, 255, 0.05); }

.sev { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.sev-disaster { background: var(--critical); }
.sev-high     { background: var(--high); }
.sev-average  { background: var(--warning); }
.sev-info     { background: var(--accent); }
/* legado — mantidos para compatibilidade com incident.html */
.sev-critical { background: var(--critical); }
.sev-warning  { background: var(--warning); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.7rem; font-weight: 600; }
.badge-root { background: rgba(255, 71, 87, 0.2); color: var(--critical); }
.badge-symptom { background: rgba(255, 140, 66, 0.2); color: var(--high); }
.badge-chronic { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-status { padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }
.badge-open { background: rgba(255, 71, 87, 0.2); color: var(--critical); }
.badge-acknowledged { background: rgba(79, 140, 255, 0.2); color: var(--accent); }
.badge-resolved { background: rgba(46, 213, 115, 0.2); color: var(--ok); }

select, input[type="text"], input[type="number"], input[type="password"], textarea {
    background: var(--bg-primary); border: 1px solid var(--border); border-radius: 4px;
    color: var(--text-primary); padding: 0.5rem 0.8rem; font-size: 0.85rem; margin: 0.3rem 0 0.8rem;
}
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); }
button { background: var(--accent); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
button:hover { opacity: 0.9; }

.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: var(--bg-secondary); border-radius: 8px; padding: 2rem; max-width: 700px; width: 90%; max-height: 80vh; overflow-y: auto; position: relative; }
.modal-large { max-width: 900px; }
.close { position: absolute; right: 1rem; top: 0.5rem; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }

.search-input { width: 250px; }
.header-actions { display: flex; gap: 0.5rem; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 1.5rem; }
.settings-panel { padding: 1.5rem; }
.settings-panel h2 { margin-bottom: 1rem; font-size: 1rem; }
.settings-panel h3 { margin: 1rem 0 0.5rem; font-size: 0.9rem; color: var(--text-secondary); }
.settings-panel label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.5rem; }
.settings-panel input[type="text"], .settings-panel input[type="number"], .settings-panel input[type="password"] { width: 100%; }

.pm-card { background: var(--bg-primary); border-radius: 6px; padding: 1rem; margin-bottom: 0.8rem; cursor: pointer; border: 1px solid var(--border); transition: border-color 0.2s; }
.pm-card:hover { border-color: var(--accent); }
.pm-card h3 { font-size: 0.95rem; margin: 0.5rem 0; }
.pm-card p { font-size: 0.8rem; color: var(--text-secondary); }
.pm-header { display: flex; justify-content: space-between; }
.pm-status { font-size: 0.7rem; text-transform: uppercase; font-weight: 600; }
.status-draft { color: var(--warning); }
.status-published { color: var(--ok); }
.pm-date { font-size: 0.75rem; color: var(--text-secondary); }
.pm-detail section { margin: 1rem 0; padding: 0.8rem; background: var(--bg-primary); border-radius: 4px; }
.pm-detail h3 { font-size: 0.85rem; color: var(--accent); margin-bottom: 0.5rem; }

.tag { display: inline-block; background: rgba(79,140,255,0.15); color: var(--accent); padding: 2px 6px; border-radius: 3px; font-size: 0.7rem; margin: 2px; }

.kb-category { margin-bottom: 1.5rem; }
.kb-category h3 { font-size: 0.9rem; color: var(--accent); text-transform: uppercase; margin-bottom: 0.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.kb-item { padding: 0.6rem; margin: 0.3rem 0; border-radius: 4px; cursor: pointer; display: flex; align-items: center; gap: 1rem; }
.kb-item:hover { background: var(--bg-primary); }
.kb-item.disabled { opacity: 0.5; }
.kb-item-info { flex: 1; display: flex; flex-direction: column; }
.kb-title { font-size: 0.85rem; }
.kb-desc { display: block; font-size: 0.7rem; color: var(--text-secondary); margin-top: 2px; }
.kb-source { font-size: 0.7rem; color: var(--text-secondary); }

.empty { text-align: center; padding: 3rem; color: var(--text-secondary); }

/* ─── Incident Detail Page ─── */
.incident-header { padding: 1.5rem; border-radius: 8px; margin-bottom: 1.5rem; }
.incident-header.sev-critical { background: linear-gradient(135deg, rgba(255,71,87,0.15), rgba(255,71,87,0.05)); border-left: 4px solid #ff4757; }
.incident-header.sev-high { background: linear-gradient(135deg, rgba(255,140,66,0.15), rgba(255,140,66,0.05)); border-left: 4px solid #ff8c42; }
.incident-header.sev-warning { background: linear-gradient(135deg, rgba(255,217,61,0.15), rgba(255,217,61,0.05)); border-left: 4px solid #ffd93d; }
.incident-header.sev-info { background: linear-gradient(135deg, rgba(79,140,255,0.15), rgba(79,140,255,0.05)); border-left: 4px solid var(--accent); }
.incident-header h1 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.incident-header .meta { font-size: 0.85rem; color: var(--text-secondary); display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; }
.incident-header .meta span { display: inline-flex; align-items: center; gap: 0.3rem; }

.incident-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.incident-card { background: var(--bg-card); border-radius: 8px; padding: 1.5rem; }
.incident-card h2 { font-size: 0.95rem; margin-bottom: 1rem; color: var(--accent); }
.incident-card p { font-size: 0.85rem; line-height: 1.6; }
.incident-card .solution-box { background: var(--bg-primary); border-radius: 6px; padding: 1rem; margin-top: 0.8rem; border-left: 3px solid var(--ok); }
.incident-card .cause-box { background: var(--bg-primary); border-radius: 6px; padding: 1rem; margin-top: 0.8rem; border-left: 3px solid var(--high); }
.incident-card .profile-box { background: var(--bg-primary); border-radius: 6px; padding: 0.8rem; margin-top: 0.8rem; font-size: 0.8rem; color: var(--text-secondary); }

.timeline-item { padding: 0.6rem 0; border-left: 2px solid var(--border); padding-left: 1rem; margin-left: 0.5rem; }
.timeline-item .time { font-size: 0.7rem; color: var(--text-secondary); }
.timeline-item .desc { font-size: 0.8rem; margin-top: 0.2rem; }
.timeline-item .desc .state-badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 0.7rem; font-weight: 600; }

.metric-inline { display: inline-block; background: var(--bg-primary); padding: 4px 10px; border-radius: 4px; font-size: 0.8rem; margin: 2px; }

.correlation-item { padding: 0.5rem 0.8rem; margin: 0.3rem 0; background: var(--bg-primary); border-radius: 4px; font-size: 0.8rem; display: flex; align-items: center; gap: 0.5rem; }
.correlation-item .corr-icon { font-size: 0.9rem; }
.correlation-item .corr-state { width: 8px; height: 8px; border-radius: 50%; }
.correlation-item .corr-state.problem { background: var(--critical); }
.correlation-item .corr-state.ok { background: var(--ok); }

.back-link { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-secondary); text-decoration: none; font-size: 0.85rem; margin-bottom: 1rem; }
.back-link:hover { color: var(--text-primary); }

@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { margin-left: 0; }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-grid { grid-template-columns: 1fr; }
    .incident-grid { grid-template-columns: 1fr; }
}
