:root {
    --bg: #0b1020;
    --sidebar: #10152a;
    --card: #ffffff;
    --content-bg: #f4f6fb;
    --text: #1a2233;
    --muted: #7a869a;
    --accent: #3b82f6;
    --accent-2: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --border: #e5e9f2;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--content-bg);
    color: var(--text);
    font-size: 14px;
}

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

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

/* Sidebar */
.app-nav {
    width: 220px;
    background: var(--sidebar);
    color: #cdd5e6;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: #fff; margin-bottom: 24px; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px var(--accent); }
.nav-item { display: block; padding: 10px 12px; border-radius: 8px; color: #cdd5e6; margin-bottom: 4px; }
.nav-item:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-footer { margin-top: auto; display: flex; flex-direction: column; gap: 2px; font-size: 11px; }

/* Main */
.app-main { flex: 1; min-width: 0; }
.app-content { padding: 28px 34px; max-width: 1200px; }

h1 { font-size: 24px; margin: 0 0 4px; }
h1:focus { outline: none; }
h2 { font-size: 17px; margin: 26px 0 12px; }
.page-sub { color: var(--muted); margin: 0 0 22px; }

/* Cards / stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat .stat-value { font-size: 30px; font-weight: 700; }
.stat .stat-label { color: var(--muted); font-size: 13px; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
th { background: #fafbfe; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafcff; }
.table-wrap { overflow-x: auto; border-radius: 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.online { background: #dcfce7; color: #166534; }
.badge.offline { background: #f1f5f9; color: #64748b; }
.badge.raw { background: #fee2e2; color: #991b1b; }
.badge.aggregate { background: #fef3c7; color: #92400e; }
.badge.off { background: #f1f5f9; color: #64748b; }
.badge.on { background: #dbeafe; color: #1e40af; }

/* Bars for usage */
.bar-track { background: #eef2f9; border-radius: 6px; height: 10px; width: 100%; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.truncate { max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Buttons & forms */
button, .btn {
    background: var(--accent); color: #fff; border: none; border-radius: 8px;
    padding: 9px 16px; font-size: 14px; cursor: pointer; font-weight: 600;
}
button:hover { filter: brightness(1.05); }
button.secondary { background: #eef2f9; color: var(--text); }
button:disabled { opacity: .5; cursor: default; }
input, select {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-row { margin-bottom: 14px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.notice { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13px; }
.pill-link { padding: 6px 12px; border-radius: 8px; background: #eef2f9; }

/* Login landing */
.login-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; width: 100%; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 40px 44px; width: 380px; max-width: 90vw; box-shadow: 0 10px 40px rgba(0,0,0,0.06); }
/* The brand style is white for the dark sidebar; on the light login card it must be dark. */
.login-card .brand, .login-card .brand-name { color: var(--text); }
.ms-signin { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 16px; background: #2f2f2f; color: #fff; border-radius: 8px; font-weight: 600; }
.ms-signin:hover { background: #1f1f1f; text-decoration: none; }
.nav-signout { display: inline-block; margin: 6px 0; color: #cdd5e6; font-size: 12px; }
.nav-signout:hover { color: #fff; }

/* Blazor default error ui */
#blazor-error-ui {
    background: #fee2e2; color: #991b1b; bottom: 0; display: none;
    left: 0; padding: 0.8rem 1.4rem; position: fixed; width: 100%; z-index: 1000;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: 0.6rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
