:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --ink: #18212b;
    --muted: #5b6875;
    --line: #dce2e8;
    --accent: #1f5fad;
    --accent-soft: #e6eef8;
    --ok: #2e7d32;
    --ok-soft: #e7f3e8;
    --warn: #9a5b00;
    --warn-soft: #fdf1dc;
    --danger: #c62828;
    --danger-soft: #fdeaea;
    --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1 { font-size: 26px; margin: 4px 0 8px; text-wrap: balance; }
/* FocusOnNavigate đặt focus vào h1 cho trình đọc màn hình; không cần viền. */
h1:focus { outline: none; }
h2 { font-size: 17px; margin: 0; }
p { margin: 0; }

.muted { color: var(--muted); }
.num, td.num { font-variant-numeric: tabular-nums; text-align: right; }
.nowrap { white-space: nowrap; }

/* Header */
.topbar { background: var(--ink); color: #fff; }
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 12px 20px;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 16px; }
.topnav { margin-left: auto; display: flex; gap: 18px; }
.topnav a { color: #c9d3dd; text-decoration: none; }
.topnav a.active, .topnav a:hover { color: #fff; }

.env {
    font: 600 12px/1 var(--mono); letter-spacing: .08em;
    padding: 5px 10px; border-radius: 4px;
}
.env-prod { background: var(--danger); color: #fff; }
.env-beta { background: #f0a020; color: #1b1300; }
.env-other { background: #6b7785; color: #fff; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; display: flex; flex-direction: column; gap: 14px; }
.crumb { color: var(--muted); font-size: 13px; }
.lede { color: var(--muted); max-width: 75ch; }
.section-title { margin-top: 18px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; }
.tool-card { display: flex; flex-direction: column; gap: 10px; color: inherit; text-decoration: none; }
.tool-card:hover { border-color: var(--accent); }
.tool-card p { color: var(--muted); font-size: 14px; }
.card-head, .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-foot { margin-top: auto; font-size: 13px; }
.warn-text { color: var(--warn); }

/* Actions */
.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.action { display: flex; flex-direction: column; gap: 10px; }
.action .btn { align-self: flex-start; margin-top: auto; }
.fields { display: flex; flex-direction: column; gap: 6px; }
.fields label { font-size: 13px; font-weight: 600; }
.fields input[type=text], .fields input[type=number], .login input {
    font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; width: 100%;
}
.fields small { margin-top: -2px; font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500 !important; }
.check.commit { color: var(--danger); margin-top: 6px; }

/* Buttons */
.btn {
    font: 600 14px/1 inherit; font-family: inherit; padding: 9px 16px; border-radius: 6px;
    border: 1px solid transparent; cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }

/* Pills & tags */
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill-running { background: var(--accent-soft); color: var(--accent); }
.pill-succeeded { background: var(--ok-soft); color: var(--ok); }
.pill-failed, .pill-interrupted { background: var(--danger-soft); color: var(--danger); }
.pill-cancelled { background: var(--warn-soft); color: var(--warn); }
.tag { margin-left: 6px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; }
.tag-commit { background: var(--danger-soft); color: var(--danger); }

/* Notices */
.notice { padding: 11px 14px; border-radius: 6px; border-left: 4px solid; }
.notice-info { background: var(--accent-soft); border-color: var(--accent); }
.notice-warn { background: var(--warn-soft); border-color: var(--warn); }
.notice-error { background: var(--danger-soft); border-color: var(--danger); }
.notice-summary { background: var(--surface); border-color: var(--ok); font-weight: 600; }
.form-error { color: var(--danger); font-size: 14px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
.grid th.num { text-align: right; }
.grid th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.grid td { padding: 8px 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.clip { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Run page */
.run-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.run-head h1 { margin: 0; }
.run-head .btn { margin-left: auto; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; font-size: 14px; }
.meta dt { color: var(--muted); font-size: 12px; }
.meta dd { margin: 0; }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width .4s; }

/* Log bám đáy: column-reverse giữ khung cuộn ở dòng mới nhất mà không cần JS. */
.log {
    background: #111820; color: #d6dee6; border-radius: 8px; max-height: 480px; overflow: auto;
    display: flex; flex-direction: column-reverse;
}
.log-lines { padding: 12px 14px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
.log-warn { color: #f5c26b; }
.log-error { color: #ff8a80; }

/* Login */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 26px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login .brand { color: var(--ink); font-size: 20px; }
.login-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack label { font-size: 13px; font-weight: 600; }
.stack .btn { margin-top: 6px; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 10px 20px;
    background: var(--warn-soft); border-top: 1px solid var(--warn); z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
    .progress-bar { transition: none; }
}
