html, body, .mud-typography, .mud-button-root, .mud-input {
    font-family: "Open Sans", "Segoe UI", sans-serif;
}

h1:focus { outline: none; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    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: 10000;
    color: #333;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---- shared bits ---- */
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--mud-palette-text-secondary); }
.small { font-size: .8rem; }
.apex-host { width: 100%; }
.apex-host .apexcharts-tooltip { box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.clickable { cursor: pointer; }
.nowrap { white-space: nowrap; }
.sw-section { font-size: 1.05rem; font-weight: 700; margin: 0 0 2px; }
.sw-sub { font-size: .8rem; color: var(--mud-palette-text-secondary); margin: 0 0 8px; }
.sw-pre { white-space: pre-wrap; font-family: Consolas, "Courier New", monospace; font-size: .78rem; line-height: 1.35; margin: 0; max-height: 420px; overflow: auto; }

/* ---- NOAA scale badges (R / S / G) ---- */
.sw-scale { display: flex; align-items: stretch; border-radius: 8px; overflow: hidden; border: 1px solid var(--mud-palette-lines-default); background: var(--mud-palette-surface); min-width: 210px; flex: 1 1 210px; }
.sw-scale .letter { display: flex; align-items: center; justify-content: center; width: 76px; font-size: 1.8rem; font-weight: 800; letter-spacing: .02em; }
.sw-scale .body { padding: 8px 12px; line-height: 1.25; min-width: 0; }
.sw-scale .title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--mud-palette-text-secondary); }
.sw-scale .level { font-size: 1.05rem; font-weight: 700; }
.sw-scale .outlook { display: flex; gap: 4px; margin-top: 4px; }
.sw-pip { font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 10px; font-variant-numeric: tabular-nums; }

/* ---- KPI tiles ---- */
.sw-kpi { display: block; height: 100%; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--mud-palette-lines-default); border-left: 4px solid var(--mud-palette-primary); background: var(--mud-palette-surface); color: inherit; text-decoration: none; }
.sw-kpi .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--mud-palette-text-secondary); }
.sw-kpi .value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.sw-kpi .unit { font-size: .8rem; font-weight: 400; color: var(--mud-palette-text-secondary); margin-left: 3px; }
.sw-kpi .note { font-size: .75rem; color: var(--mud-palette-text-secondary); line-height: 1.3; }
.sw-kpi.warn { border-left-color: #f29d1f; }
.sw-kpi.alarm { border-left-color: #d6403f; }
.sw-kpi.good { border-left-color: #1e9e6a; }

/* ---- the cause-and-effect chain ---- */
.chain { display: flex; align-items: stretch; flex-wrap: wrap; gap: 6px 0; }
.chain-node { position: relative; min-width: 128px; max-width: 190px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--mud-palette-lines-default); border-top: 4px solid var(--kind, #9aa3b2); background: var(--mud-palette-surface); color: inherit; text-decoration: none; line-height: 1.25; }
.chain-node:hover { box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.chain-node.focus { box-shadow: 0 0 0 2px var(--kind, #9aa3b2); }
.chain-node.future { border-style: dashed; border-top-style: solid; opacity: .92; }
.chain-node .kind { font-size: .66rem; text-transform: uppercase; letter-spacing: .07em; color: var(--kind, #9aa3b2); font-weight: 700; }
.chain-node .what { font-size: .9rem; font-weight: 700; }
.chain-node .when { font-size: .72rem; color: var(--mud-palette-text-secondary); }
.chain-arrow { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 64px; padding: 0 4px; font-size: .68rem; color: var(--mud-palette-text-secondary); text-align: center; }
.chain-arrow .line { width: 100%; height: 2px; background: var(--mud-palette-lines-default); position: relative; margin: 2px 0; }
.chain-arrow .line::after { content: ""; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left: 8px solid var(--mud-palette-lines-default); }
.chain-arrow.derived .line { background: repeating-linear-gradient(90deg, var(--mud-palette-lines-default) 0 6px, transparent 6px 10px); }
.chain-branch { display: flex; flex-direction: column; gap: 6px; }
.chain-card { border-radius: 8px; border: 1px solid var(--mud-palette-lines-default); background: var(--mud-palette-surface); padding: 12px 14px; }
.chain-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.chain-card.g-0 { border-left: 5px solid #2f7fb8; }

/* ---- effects by domain ---- */
.impact { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--mud-palette-lines-default); }
.impact:last-child { border-bottom: 0; }
.impact .dom { flex: 0 0 150px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.impact .txt { flex: 1 1 auto; font-size: .88rem; }
.impact .sev { flex: 0 0 auto; }
.sw-chip { display: inline-block; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- probability bars ---- */
.pbar { display: flex; align-items: center; gap: 8px; font-size: .8rem; margin: 3px 0; }
.pbar .name { flex: 0 0 34px; font-weight: 700; }
.pbar .track { flex: 1 1 auto; height: 10px; border-radius: 5px; background: rgba(128,128,128,.2); overflow: hidden; }
.pbar .fill { height: 100%; border-radius: 5px; }
.pbar .val { flex: 0 0 44px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- the arrival window: P10 to P90 on a timeline ---- */
.window-track { position: relative; height: 22px; border-radius: 4px; background: rgba(128,128,128,.18); margin: 4px 0; }
.window-track .band { position: absolute; top: 0; bottom: 0; background: rgba(33,150,200,.35); border-radius: 4px; }
.window-track .pt { position: absolute; top: -3px; bottom: -3px; width: 3px; margin-left: -1px; background: #F5A623; border-radius: 2px; }
.window-track .now { position: absolute; top: -5px; bottom: -5px; width: 2px; background: #d6403f; }
.window-labels { display: flex; justify-content: space-between; font-size: .68rem; color: var(--mud-palette-text-secondary); }

.sw-table td, .sw-table th { white-space: nowrap; }
.sw-table td.wrap { white-space: normal; min-width: 200px; }
.sw-kv { display: grid; grid-template-columns: minmax(130px, 40%) 1fr; gap: 5px 14px; margin: 0; }
.sw-kv dt { color: var(--mud-palette-text-secondary); font-size: .85rem; }
.sw-kv dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---- SiteAnalyst shell ---- */
.sa-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--mud-palette-background); color: var(--mud-palette-text-primary); }
.sa-topbar { background: #333; color: #ccc; font-size: 13px; padding: 8px 16px; text-align: center; position: relative; }
.sa-topbar a { color: #ccc; text-decoration: none; margin: 0 12px; }
.sa-topbar a:hover { color: #F5A623; }
.sa-divider { color: #666; }
.sa-topbar { position: relative; }
.sa-auth { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); display: flex; align-items: center; gap: 10px; }
.sa-auth form { margin: 0; }
.sa-user { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #ccc; }
.sa-topbar a.sa-login, .sa-login {
    display: inline-block;
    margin: 0;
    padding: 3px 14px;
    border: 1px solid #F5A623;
    border-radius: 4px;
    background: transparent;
    color: #F5A623;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.sa-topbar a.sa-login:hover, .sa-login:hover { background: #F5A623; color: #fff; }
@media (max-width: 1000px) {
    .sa-auth { position: static; transform: none; justify-content: center; margin-top: 6px; }
}
.sa-nav {
    background: var(--mud-palette-appbar-background);
    color: var(--mud-palette-appbar-text);
    border-bottom: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 1px 6px rgba(0,0,0,.12);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 1100;
}
.sa-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: 0 0 auto; }
.sa-brand img { height: 42px; width: auto; }
.sa-brand span { font-size: 20px; font-weight: 700; color: #2196C8; letter-spacing: -0.3px; }
.sa-badge { background: #F5A623; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; padding: 4px 10px; border-radius: 50px; }
.sa-nav-main { display: flex; align-items: center; gap: 18px; margin-left: auto; min-width: 0; }
.sa-links { display: flex; align-items: center; gap: 20px; }
.sa-links a { text-decoration: none; color: inherit; font-size: 14px; font-weight: 600; padding: 6px 0; white-space: nowrap; }
.sa-links a:hover, .sa-links a.active { color: #2196C8; }
.sa-links a.active { box-shadow: inset 0 -2px 0 #2196C8; }
.sa-tools { display: flex; align-items: center; gap: 4px; }
.sa-burger { display: none; margin-left: auto; width: 40px; height: 36px; border: 1px solid #d7e6f0; border-radius: 6px; background: transparent; padding: 8px; flex-direction: column; justify-content: space-between; cursor: pointer; }
.sa-burger span { display: block; height: 2px; background: #2196C8; border-radius: 1px; }
.sa-main { flex: 1 0 auto; }
.sa-family { background: var(--mud-palette-background); text-align: center; padding: 56px 24px 48px; border-top: 1px solid var(--mud-palette-lines-default); }
.sa-family h2 { font-size: 28px; font-weight: 800; margin: 0 0 36px; }
.sa-family-grid { display: flex; justify-content: center; gap: 56px; flex-wrap: wrap; }
.sa-family-item { text-decoration: none; color: inherit; width: 180px; }
.sa-family-item:hover { transform: translateY(-4px); }
.sa-family-item img { height: 88px; width: auto; max-width: 160px; object-fit: contain; }
.sa-family-item h4 { margin: 12px 0 4px; color: #2196C8; font-size: 16px; font-weight: 700; }
.sa-family-item p { margin: 0; font-size: 14px; font-weight: 600; }
.sa-footer { background: #2a2a2a; color: #bbb; padding: 40px 24px 24px; }
.sa-footer-mark { max-width: 1000px; margin: 0 auto 28px; }
.sa-footer-mark img { height: 46px; width: auto; }
.sa-footer-inner { max-width: 1000px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 36px; }
.sa-footer h5 { color: #fff; font-size: 15px; font-weight: 700; margin: 0 0 16px; }
.sa-footer a { display: block; color: #bbb; text-decoration: none; font-size: 13px; margin-bottom: 8px; }
.sa-footer a:hover { color: #F5A623; }
.sa-footer-bottom { max-width: 1000px; margin: 28px auto 0; padding-top: 20px; border-top: 1px solid #444; text-align: center; font-size: 12px; color: #888; }
.sa-source-note { max-width: 1000px; margin: 12px auto 0; font-size: 12px; color: #888; text-align: center; }
.sa-source-note a { display: inline; }

@media (max-width: 1250px) {
    .sa-burger { display: flex; }
    .sa-nav-main { display: none; width: 100%; flex-direction: column; align-items: stretch; margin-left: 0; }
    .sa-nav.open { flex-wrap: wrap; }
    .sa-nav.open .sa-nav-main { display: flex; }
    .sa-links { flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 8px; }
    .sa-tools { justify-content: flex-start; flex-wrap: wrap; }
    .sa-footer-inner { grid-template-columns: repeat(2, 1fr); }
    .impact .dom { flex-basis: 110px; }
}
