@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --bg: #f5f0e8;
  --card: #fffdf9;
  --accent: #5c2e2e;
  --accent-hover: #3d1f1f;
  --accent-soft: #f3e8e8;
  --muted: #6b6560;
  --border: #e0d5c8;
  --ok: #2d6a4f;
  --ok-bg: #e8f5ee;
  --warn: #b5651d;
  --warn-bg: #fef3e8;
  --danger: #9b2226;
  --sidebar-w: 220px;
  --shadow: 0 4px 24px rgba(92, 46, 46, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: #2a2520;
  min-height: 100vh;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--accent);
  color: #fff;
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 0.5rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand p {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  opacity: 0.75;
}

.nav { list-style: none; margin: 0; padding: 0.5rem 0; flex: 1; }

.nav button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.85);
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}

.nav button:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav button.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 600; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  font-size: 0.72rem;
  opacity: 0.65;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.main { padding: 1.5rem 1.75rem 2rem; overflow-x: auto; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.page-header h2 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: 700;
}

.page-header p { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.9rem; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--card);
  border: 1px solid var(--border);
}

.status-pill.ok { background: var(--ok-bg); color: var(--ok); border-color: #b7dfc9; }
.status-pill.err { background: #fde8e8; color: var(--danger); border-color: #f5c2c2; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}

.stat label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.stat strong { font-size: 1.75rem; color: var(--accent); font-weight: 700; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: var(--accent);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; padding: 0.75rem; }
  .brand { border: none; padding: 0 1rem; margin: 0; }
  .nav { display: flex; flex-wrap: wrap; padding: 0; }
  .nav button { width: auto; padding: 0.5rem 0.85rem; border-radius: 8px; }
  .sidebar-footer { display: none; }
  .grid-2 { grid-template-columns: 1fr; }
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-btn {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.ticket-list { display: flex; flex-direction: column; gap: 0.65rem; }

.ticket-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.ticket-row:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.ticket-row.selected { border-color: var(--accent); background: var(--accent-soft); }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge.open { background: var(--warn-bg); color: var(--warn); }
.badge.closed { background: #eee; color: var(--muted); }
.badge.review { background: #fde8e8; color: var(--danger); }
.badge.wazuh { background: #ede9fe; color: #5b21b6; }
.badge.onboard { background: #e8f5ee; color: var(--ok); }
.badge.sev-critical { background: #fde8e8; color: #9b2226; }
.badge.sev-high { background: #fef3e8; color: var(--warn); }
.badge.sev-med { background: #fff8e6; color: #a16207; }
.badge.sev-low { background: #eee; color: var(--muted); }
.toolbar-sep { color: var(--border); padding: 0 0.25rem; }

.ticket-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.ticket-subject { font-weight: 600; font-size: 0.92rem; color: #2a2520; }

.detail-panel { position: sticky; top: 1rem; }

.detail-panel .empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 1rem;
}

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 0.35rem 0.75rem; font-size: 0.88rem; margin-bottom: 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }

.event-list { list-style: none; margin: 0; padding: 0; }
.event-list li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.event-list li:last-child { border-bottom: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }

.hidden { display: none !important; }
.loading { color: var(--muted); font-size: 0.9rem; padding: 1rem; }

.infra-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

pre.raw {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.85rem;
  border-radius: 8px;
  font-size: 0.75rem;
  overflow: auto;
  max-height: 200px;
}

.view { display: none; }
.view.active { display: block; }

.funnel-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 2rem;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
}

.funnel-label { color: var(--muted); }
.funnel-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #8b4513);
  border-radius: 999px;
  min-width: 4px;
}
.funnel-count { text-align: right; font-size: 0.85rem; }

.funnel-sessions { margin-top: 0.5rem; }
.funnel-session {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
}
.funnel-session.stale { opacity: 0.65; }

.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.5rem;
  border-left: 2px solid var(--border);
}
.timeline-item {
  position: relative;
  padding: 0 0 1rem 1.25rem;
}
.timeline-dot {
  position: absolute;
  left: -0.45rem;
  top: 0.35rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.health-card {
  border-left: 4px solid var(--border);
}
.health-card.health-healthy { border-left-color: var(--ok); }
.health-card.health-degraded { border-left-color: var(--warn); }
.health-card.health-critical { border-left-color: var(--danger); }

.health-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.health-score {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.35rem 0;
}

.issue-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}
