:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #172033;
    --muted: #697386;
    --line: #e4e9f0;
    --primary: #245f9e;
    --primary-dark: #194a7d;
    --sidebar-bg: #f0f1f2;
    --sidebar-text: #20252a;
    --sidebar-muted: #7d878f;
    --sidebar-active: #1683f8;
    --danger-bg: #fff0f0;
    --danger: #a92b2b;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
a { color: inherit; }
button, input { font: inherit; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-shell { width: 100%; max-width: 430px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 12px 35px rgba(23,32,51,.07); }
.login-card { padding: 36px; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; min-width: 72px; height: 38px; padding: 0 14px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 800; letter-spacing: .08em; }
.eyebrow { margin: 22px 0 4px; color: var(--primary); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 800; }
h1 { margin: 0; font-size: 2rem; line-height: 1.1; }
h2 { margin-top: 0; }
.muted { color: var(--muted); line-height: 1.55; }
label { display: block; margin: 18px 0 7px; font-weight: 700; font-size: .9rem; }
input[type=text], input[type=password] { width: 100%; border: 1px solid #cfd7e3; border-radius: 10px; padding: 12px 13px; background: #fff; outline: none; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(36,95,158,.12); }
button { width: 100%; border: 0; border-radius: 10px; padding: 12px 16px; margin-top: 22px; background: var(--primary); color: white; font-weight: 800; cursor: pointer; }
button:hover { background: var(--primary-dark); }
.alert { margin: 18px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-weight: 700; }

.admin-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    transition: grid-template-columns 180ms ease;
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: 100vh;
    min-width: 0;
    padding: 18px 12px 16px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    border-right: 1px solid #e1e4e7;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.sidebar-header {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
}

.sidebar-brand {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    text-decoration: none;
}

.brand-symbol {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border: 1px solid #1f2428;
    border-radius: 50%;
    background: #272b2f;
    color: #fff;
    font-size: .86rem;
    font-weight: 800;
}

.brand-copy {
    min-width: 0;
    display: grid;
    line-height: 1.1;
    white-space: nowrap;
}

.brand-copy strong { font-size: .93rem; letter-spacing: .015em; }
.brand-copy small { margin-top: 3px; color: var(--sidebar-muted); font-size: .67rem; font-weight: 600; }

.sidebar-toggle {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--sidebar-muted);
}

.sidebar-toggle:hover { background: #e5e7e9; color: var(--sidebar-text); }
.sidebar-toggle:focus-visible,
.sidebar-nav a:focus-visible,
.sidebar-action:focus-visible { outline: 2px solid var(--sidebar-active); outline-offset: 2px; }

.sidebar-toggle svg,
.nav-icon svg {
    width: 20px;
    height: 20px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
}

.sidebar-nav a,
.sidebar-action {
    position: relative;
    width: 100%;
    min-height: 44px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    padding: 2px 8px 2px 2px;
    margin: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--sidebar-muted);
    text-align: left;
    text-decoration: none;
    font-size: .84rem;
    font-weight: 650;
    line-height: 1;
}

.sidebar-nav a:hover,
.sidebar-action:hover { background: #e6e8ea; color: var(--sidebar-text); }

.sidebar-nav a.active {
    background: #fff;
    color: var(--sidebar-text);
    box-shadow: 0 1px 3px rgba(20, 27, 33, .08);
}

.sidebar-nav a.active .nav-icon { color: var(--sidebar-active); }

.nav-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
}

.nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 120ms ease;
}

.logout { margin-top: auto; }

.sidebar-action { cursor: pointer; }
.sidebar-action:hover { background: #e6e8ea; }

html.sidebar-is-collapsed .admin-layout { grid-template-columns: 72px minmax(0, 1fr); }
html.sidebar-is-collapsed .sidebar { padding-right: 9px; padding-left: 9px; }
html.sidebar-is-collapsed .sidebar-header { justify-content: center; }
html.sidebar-is-collapsed .sidebar-brand { display: none; }
html.sidebar-is-collapsed .sidebar-toggle { width: 44px; flex-basis: 44px; }
html.sidebar-is-collapsed .sidebar-nav a,
html.sidebar-is-collapsed .sidebar-action {
    grid-template-columns: 44px 0;
    justify-content: center;
    padding: 0;
}
html.sidebar-is-collapsed .nav-icon { width: 44px; }
html.sidebar-is-collapsed .nav-label { width: 0; opacity: 0; }

html.sidebar-is-collapsed [data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    z-index: 30;
    top: 50%;
    left: 54px;
    min-width: max-content;
    padding: 7px 9px;
    border: 1px solid #e1e4e7;
    border-radius: 5px;
    background: #fff;
    color: var(--sidebar-text);
    box-shadow: 0 6px 18px rgba(24, 31, 37, .12);
    font-size: .75rem;
    font-weight: 650;
    pointer-events: none;
    opacity: 0;
    transform: translate(3px, -50%);
    transition: opacity 100ms ease, transform 100ms ease;
}

html.sidebar-is-collapsed [data-tooltip]:hover::after,
html.sidebar-is-collapsed [data-tooltip]:focus-visible::after {
    opacity: 1;
    transform: translate(0, -50%);
}

.content { min-width: 0; padding: 34px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 28px; }
.topbar .eyebrow { margin-top: 0; }
.user-chip { padding: 9px 13px; border-radius: 999px; background: #e9f0f7; color: var(--primary-dark); font-weight: 800; }
.placeholder-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.panel { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(23,32,51,.055); }
.panel span, .panel small { display: block; color: var(--muted); }
.panel strong { display: block; font-size: 2rem; margin: 10px 0 4px; }
.status-panel { display: flex; flex-direction: column; gap: 14px; }
.status-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.status-panel .panel-title { color: var(--muted); }
.status-panel .status-value {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    font-size: .78rem;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
}
.status-panel .status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: currentColor; color: inherit; }
.status-panel.status-operational .status-value { color: #168447; }
.status-panel.status-degraded .status-value { color: #ad6800; }
.status-panel.status-outage .status-value { color: #b42318; }
.status-panel.status-unknown .status-value { color: var(--muted); }
.availability-summary { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.status-panel .availability-value { margin: 0 0 2px; color: var(--text); font-size: 1.75rem; line-height: 1; }
.availability-summary small { font-size: .71rem; }
.availability-durations { display: flex; gap: 14px; margin: 0; text-align: right; }
.availability-durations div { min-width: 52px; }
.availability-durations dt { color: var(--muted); font-size: .66rem; }
.availability-durations dd { margin: 3px 0 0; color: var(--text); font-size: .74rem; font-weight: 750; white-space: nowrap; }
.availability-timeline {
    width: 100%;
    height: 30px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #edf0f4;
}
.status-panel .availability-segment { display: block; min-width: 0; height: 100%; flex: 0 0 auto; }
.status-panel .segment-operational { background: #20a55a; }
.status-panel .segment-degraded { background: #e29a24; }
.status-panel .segment-outage { background: #d43c32; }
.status-panel .segment-unknown { background: #d9dee6; }
.availability-axis { display: flex; justify-content: space-between; margin-top: -9px; color: #8a93a2; font-size: .63rem; }
.availability-axis span { color: inherit; }
.availability-legend { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: -3px; }
.availability-legend > span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .66rem; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; }
.legend-online { background: #20a55a; }
.legend-degraded { background: #e29a24; }
.legend-outage { background: #d43c32; }
.legend-unknown { background: #d9dee6; border: 1px solid #c5cbd4; }
.status-panel .availability-incident { color: var(--text); font-size: .72rem; font-weight: 650; }
.status-panel .availability-coverage { margin-top: -9px; color: #8a6414; font-size: .68rem; }
.status-panel .status-detail { padding-top: 10px; border-top: 1px solid var(--line); font-size: .68rem; }
.large-panel { margin-top: 18px; min-height: 270px; }

@media (max-width: 820px) {
    .admin-layout,
    html.sidebar-is-collapsed .admin-layout { grid-template-columns: 72px minmax(0, 1fr); }
    .sidebar { position: fixed; left: 0; width: 232px; box-shadow: 8px 0 22px rgba(24, 31, 37, .12); }
    html.sidebar-is-collapsed .sidebar { width: 72px; box-shadow: none; }
    .content { grid-column: 2; padding: 22px; }
    .placeholder-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .content { padding: 18px 14px; }
    .topbar { align-items: flex-start; }
    .user-chip { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-layout,
    .nav-label,
    html.sidebar-is-collapsed [data-tooltip]::after { transition: none; }
}
