:root {
  --ink: #16213a;
  --ink-soft: #4b5567;
  --muted: #7b8597;
  --line: #e3e7ef;
  --paper: #f5f7fb;
  --card: #ffffff;
  --brand: #1f2a44;
  --brand-2: #26345a;
  --accent: #f0a21b;
  --accent-ink: #5a3a00;
  --ok: #1e8e5a;
  --ok-bg: #e4f5ec;
  --warn: #b7791f;
  --warn-bg: #fff4dc;
  --bad: #c53030;
  --bad-bg: #fde8e8;
  --info: #2b6cb0;
  --info-bg: #e6f0fb;
  --neutral: #5c6577;
  --neutral-bg: #eef1f6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(22, 33, 58, 0.06), 0 6px 20px -12px rgba(22, 33, 58, 0.18);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html, body {
  height: 100%;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 14.5px;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 0.92em; }

h1:focus { outline: none; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #d9deea;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 18px 14px 24px;
}

.brand { padding: 4px 8px 16px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 10px; }
.brand-link { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-link:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 12px; letter-spacing: 0.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: #aab4c8; font-size: 11.5px; }

.nav-section { margin-top: 10px; }
.nav-heading { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px; color: #8e9ab4; padding: 10px 10px 4px; }
.nav-item {
  display: block; padding: 7px 10px; margin: 1px 0; border-radius: 8px;
  color: #d9deea; font-size: 13.5px; text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(240,162,27,0.18); color: #ffd58a; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 28px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 600; color: var(--ink-soft); font-size: 13px; letter-spacing: 0.2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { color: var(--ink-soft); font-size: 13px; }

.run-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; text-decoration: none; border: 1px solid transparent;
}
.run-chip:hover { text-decoration: none; filter: brightness(0.97); }
.run-chip .chip-progress, .run-chip .chip-more { font-weight: 500; opacity: 0.85; }
.run-chip .pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
.run-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.5; }
@keyframes pulse { 0% { opacity: 1; transform: scale(1);} 50% { opacity: 0.4; transform: scale(0.8);} 100% { opacity: 1; transform: scale(1);} }

.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }

/* ---------- page header ---------- */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }
.page-subtitle { margin: 4px 0 0; color: var(--muted); max-width: 820px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--card); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); font-weight: 600; padding: 12px 16px; }
.card-body { padding: 16px; }
.card + .card, .card-stack > * + * { margin-top: 16px; }
.section-title { font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.help { color: var(--muted); font-size: 13px; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); border-left: 4px solid var(--neutral); }
.stat-card.stat-link:hover { border-color: #c9d2e3; }
.stat-overlay { position: absolute; inset: 0; border-radius: var(--radius); }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; margin-top: 4px; letter-spacing: -0.5px; }
.stat-hint { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.stat-extra { margin-top: 8px; }
.stat-card.tone-ok { border-left-color: var(--ok); }
.stat-card.tone-warn { border-left-color: var(--warn); }
.stat-card.tone-bad { border-left-color: var(--bad); }
.stat-card.tone-info { border-left-color: var(--info); }
.stat-card.tone-muted { border-left-color: #b9c1d0; }
.stat-card.tone-accent { border-left-color: var(--accent); }

/* ---------- pills and tones ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill.tone-ok, .run-chip.tone-ok { background: var(--ok-bg); color: var(--ok); }
.pill.tone-warn, .run-chip.tone-warn { background: var(--warn-bg); color: var(--warn); }
.pill.tone-bad, .run-chip.tone-bad { background: var(--bad-bg); color: var(--bad); }
.pill.tone-info, .run-chip.tone-info { background: var(--info-bg); color: var(--info); }
.pill.tone-muted, .run-chip.tone-muted { background: var(--neutral-bg); color: var(--neutral); }
.pill.tone-neutral, .run-chip.tone-neutral { background: var(--neutral-bg); color: var(--ink-soft); }
.pill.tone-accent { background: #fff1d6; color: var(--accent-ink); }
span.tone-ok { color: var(--ok); } span.tone-warn { color: var(--warn); } span.tone-bad { color: var(--bad); } span.tone-muted { color: var(--muted); } span.tone-info { color: var(--info); }

/* ---------- run panel ---------- */
.run-panel { border-left: 4px solid var(--neutral); }
.run-panel.tone-info { border-left-color: var(--info); }
.run-panel.tone-ok { border-left-color: var(--ok); }
.run-panel.tone-warn { border-left-color: var(--warn); }
.run-panel.tone-bad { border-left-color: var(--bad); }
.run-progress { height: 10px; border-radius: 999px; background: #e9edf5; }
.run-progress .progress-bar { background: var(--info); border-radius: 999px; }
.run-panel.tone-ok .progress-bar { background: var(--ok); }
.run-panel.tone-warn .progress-bar { background: var(--warn); }
.run-panel.tone-bad .progress-bar { background: var(--bad); }
.run-counters { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
.log-tail { background: #0f172a; color: #cbd5e1; border-radius: 10px; padding: 10px 12px; font-family: var(--mono); font-size: 12px; max-height: 280px; overflow-y: auto; }
.log-line { display: flex; gap: 8px; padding: 2px 0; align-items: baseline; }
.log-time { color: #64748b; flex: 0 0 auto; }
.log-case { color: #93c5fd; flex: 0 0 auto; }
.log-msg { white-space: pre-wrap; word-break: break-word; }
.log-warning .log-msg { color: #fcd34d; }
.log-error .log-msg { color: #fca5a5; }
.log-debug .log-msg { color: #94a3b8; }

.log-table td { font-family: var(--mono); font-size: 12.5px; vertical-align: top; }
.log-table .lvl-Warning { color: var(--warn); }
.log-table .lvl-Error { color: var(--bad); }

/* ---------- tables ---------- */
.table { font-size: 13.5px; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-tight td, .table-tight th { padding: 6px 8px; }
.row-blocked { background: #fff8f0; }
.key-link { font-family: var(--mono); font-weight: 600; }

/* ---------- forms ---------- */
.form-label { font-weight: 600; color: var(--ink-soft); font-size: 13px; }
.form-control, .form-select { border-color: #d5dbe7; border-radius: 8px; font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,162,27,0.2); }
.btn { border-radius: 8px; font-weight: 600; font-size: 13.5px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: #e09613; border-color: #e09613; color: var(--accent-ink); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters > * { min-width: 160px; }
.filters .wide { min-width: 280px; flex: 1; }

.result-details { white-space: pre-wrap; font-size: 12px; margin-top: 6px; max-height: 220px; overflow: auto; background: rgba(0,0,0,0.04); padding: 8px; border-radius: 6px; }

.confirm-box { border: 1px dashed #e0a3a3; background: #fff8f8; border-radius: 10px; padding: 14px; }
.confirm-text { color: var(--ink-soft); }

.empty-state { padding: 36px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: #fbfcfe; }
.empty-title { font-weight: 700; color: var(--ink-soft); }
.empty-text { margin-top: 4px; font-size: 13px; }

.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; word-break: break-word; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.check-ok::before { content: "✔"; color: var(--ok); font-weight: 700; }
.check-bad::before { content: "✖"; color: var(--bad); font-weight: 700; }
.check-warn::before { content: "!"; color: var(--warn); font-weight: 800; }

.bar-row { display: grid; grid-template-columns: 180px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.bar-track { height: 10px; background: #edf0f6; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--info); border-radius: 999px; }
.bar-fill.ok { background: var(--ok); } .bar-fill.warn { background: var(--warn); } .bar-fill.bad { background: var(--bad); } .bar-fill.muted { background: #b9c1d0; }

.wiki-preview { background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; max-height: 420px; overflow: auto; }

.event-card { border-left: 3px solid #d5dbe7; padding: 8px 12px; margin-bottom: 10px; background: #fff; border-radius: 0 8px 8px 0; }
.event-card.is-email { border-left-color: var(--info); }
.event-card.is-public { border-left-color: var(--ok); }
.event-meta { font-size: 12px; color: var(--muted); }
.event-body { white-space: pre-wrap; font-size: 13px; margin-top: 4px; max-height: 260px; overflow: auto; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { padding: 8px 14px; border: 0; background: transparent; color: var(--ink-soft); font-weight: 600; border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand); border-bottom-color: var(--accent); }

/* ---------- account ---------- */
.account-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 10% -10%, #2b3c66 0%, var(--brand) 45%, #141c30 100%); padding: 24px; }
.account-card { width: 100%; max-width: 440px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 30px 80px -30px rgba(0,0,0,0.6); }
.account-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }

/* ---------- misc ---------- */
#blazor-error-ui { color-scheme: light only; background: #fff3cd; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,0.2); box-sizing: border-box; display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: var(--bad-bg); padding: 1rem; color: var(--bad); border-radius: 8px; }
.blazor-error-boundary::after { content: "An error has occurred."; }

@media (max-width: 960px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .content { padding: 16px; }
  .kv { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 120px 1fr 50px; }
}
