:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --ok: #16a34a;
    --warn: #d97706;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", "Assistant", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex; align-items: center; gap: 24px;
    background: var(--card); padding: 0 24px; height: 58px;
    border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; }
.topbar nav { display: flex; gap: 4px; margin-inline-start: 12px; }
.topbar nav a { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active { color: var(--primary); background: #eef2ff; }
.topbar .user { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 24px auto; padding: 0 20px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; margin: 0; }
.footer { text-align: center; color: var(--muted); padding: 30px; font-size: .85rem; }

.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 14px; font-size: 1.15rem; }
.card h3 { margin: 16px 0 10px; font-size: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 12px; }
@media (max-width: 720px){ .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: .95rem; }
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
    width: 100%; padding: 9px 11px; margin-top: 5px;
    border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { resize: vertical; font-family: ui-monospace, "Consolas", monospace; font-size: .85rem; }
label.checkbox input { width: auto; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; color: var(--text); cursor: pointer; font: inherit; font-weight: 500;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { padding: 5px 10px; font-size: .82rem; }
.btn.active { background: #eef2ff; border-color: var(--primary); color: var(--primary); }
.btn.block, .block { width: 100%; }
.inline { display: inline; }
button.link { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; }
button.link:hover { color: var(--text); }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 1rem; }

.row-actions { display: flex; gap: 12px; align-items: center; }
.filters { display: flex; gap: 8px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.table tbody tr:hover { background: #fafbff; }
.table.compact th, .table.compact td { padding: 6px 10px; }
.row-fail { background: #fef2f2; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: ui-monospace, "Consolas", monospace; font-size: .85rem; }
.muted { color: var(--muted); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600;
    background: #eef2ff; color: var(--primary-dark);
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-failed  { background: #fee2e2; color: #991b1b; }
.badge-running { background: #fef9c3; color: #854d0e; }
.sev-low      { background: #f1f5f9; color: #475569; }
.sev-medium   { background: #fef3c7; color: #92400e; }
.sev-high     { background: #ffedd5; color: #9a3412; }
.sev-critical { background: #fee2e2; color: #991b1b; }

.stat-pills { display: flex; gap: 10px; }
.pill { background: var(--card); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; font-size: .9rem; }
.pill-danger { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.pill-ok { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .92rem; }
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ---------- Screens ---------- */
.screen-block { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 16px; background: #fcfcfd; }
.screen-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.screen-head .muted { margin-inline-start: 8px; }
.assertion-add, .screen-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-top: 8px; }
.assertion-add input, .assertion-add select { width: auto; flex: 1; min-width: 140px; margin: 0; }
.screen-add { border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 8px; }

/* ---------- Snapshot ---------- */
.snapshot { margin-top: 6px; }
.snapshot summary { cursor: pointer; color: var(--primary); font-size: .8rem; }
.snapshot pre {
    margin: 8px 0 0; padding: 10px; max-height: 320px; overflow: auto;
    background: #0f172a; color: #e2e8f0; border-radius: 8px;
    font-family: ui-monospace, "Consolas", monospace; font-size: .78rem;
    white-space: pre-wrap; word-break: break-word;
}

/* ---------- Auth ---------- */
body.guest { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-box { width: 100%; max-width: 380px; padding: 20px; }
.auth-card { text-align: center; }
.auth-card h1 { margin: 0 0 4px; }
.auth-card form { text-align: start; margin-top: 20px; }
