:root {
    --sev-critical: #b42318;
    --sev-high: #dc6803;
    --sev-medium: #b08800;
    --sev-low: #475467;
    --border: #e4e7ec;
    --muted: #667085;
    --bg: #f8f9fb;
}

html { font-size: 15px; }
body { background: var(--bg); color: #101828; }
.mono, pre, code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: .75rem 0; margin-bottom: 1.25rem; }
.brand { font-weight: 700; font-size: 1.15rem; color: #101828; text-decoration: none; }
.nav-link-plain { color: #344054; text-decoration: none; font-weight: 500; }
.nav-link-plain:hover { color: #101828; text-decoration: underline; }

.auth-card { max-width: 400px; margin: 3rem auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 2rem; }
.auth-card h1 { font-size: 1.35rem; margin-bottom: 1rem; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .75rem 1rem; display: flex; flex-direction: column; text-decoration: none; color: inherit; border-left-width: 4px; }
.tile:hover { border-color: #98a2b3; }
.tile-selected { box-shadow: 0 0 0 2px #101828 inset; }
.tile-count { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile-count.small-count { font-size: 1.05rem; padding-top: .35rem; }
.tile-label { color: var(--muted); font-size: .85rem; }
.tile.sev-critical { border-left-color: var(--sev-critical); }
.tile.sev-high { border-left-color: var(--sev-high); }
.tile.sev-medium { border-left-color: var(--sev-medium); }
.tile.sev-low { border-left-color: var(--sev-low); }

/* Filters */
.filters { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters input[type=search] { flex: 1 1 280px; }
.filters select { width: auto; }

/* Severity badges */
.badge.sev { font-weight: 600; letter-spacing: .02em; }
.badge.sev-critical { background: var(--sev-critical); }
.badge.sev-high { background: var(--sev-high); }
.badge.sev-medium { background: var(--sev-medium); }
.badge.sev-low { background: var(--sev-low); }

/* Groups table */
.table.groups { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table.groups th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fcfcfd; }
.table.groups th a { color: inherit; text-decoration: none; }
.table.groups th a.sort-active { color: #101828; }
.table.groups th a.sort-active::after { content: " ▼"; font-size: .7em; }
.table td, .table th { vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.err { max-width: 0; width: 100%; }
.err-title { display: block; color: #101828; text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-title:hover { text-decoration: underline; }
.err-type { font-weight: 700; }
.err-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; color: var(--muted); font-size: .82rem; margin-top: .15rem; overflow: hidden; }
.err-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

.empty { background: #fff; border: 1px dashed var(--border); border-radius: 10px; padding: 2.5rem; text-align: center; }

/* Group page */
.back { display: inline-block; margin-bottom: .75rem; color: var(--muted); text-decoration: none; }
.group-head { display: flex; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.group-head > div:first-child { min-width: 0; flex: 1 1 400px; }
.group-title { font-size: 1.35rem; margin: .5rem 0 .25rem; word-break: break-word; }
.group-message { font-size: 1.05rem; margin-bottom: .35rem; word-break: break-word; }
.group-actions { display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; }
/* minmax(0, …) lets columns shrink below their content's width instead of overflowing. */
.group-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 1.25rem; margin-bottom: 1.25rem; }
.user-table { margin-bottom: 0; }
.user-table td:first-child { overflow-wrap: anywhere; }
.user-table th { white-space: nowrap; }
.group-grid section, .occurrences { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1rem; min-width: 0; }
h2 { font-size: 1rem; font-weight: 700; margin-bottom: .75rem; }

.stack { font-size: .78rem; background: #0c111d; color: #98a2b3; padding: .75rem 1rem; border-radius: 8px; max-height: 480px; overflow: auto; white-space: pre; margin: 0; }
.stack .frame-app { color: #fff; font-weight: 600; }
.stack.raw { color: #d0d5dd; white-space: pre-wrap; word-break: break-word; }

.occ { border-bottom: 1px solid var(--border); padding: .5rem 0; }
.occ:last-child { border-bottom: 0; }
.occ summary { display: flex; gap: 1rem; cursor: pointer; font-size: .9rem; }
.occ summary time { min-width: 110px; color: var(--muted); }
.occ-user { font-weight: 500; }
.occ-url { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.occ[open] summary { margin-bottom: .5rem; }

@media (max-width: 900px) {
    .group-grid { grid-template-columns: 1fr; }
    .group-actions { align-items: flex-start; }
}
