:root {
  color-scheme: dark;
  --bg: #0a1017;
  --sidebar: #0d141d;
  --panel: #111b25;
  --panel-raised: #15212d;
  --panel-hover: #1a2936;
  --line: #253543;
  --line-soft: #1b2935;
  --text: #e9f1f6;
  --text-muted: #93a5b4;
  --text-subtle: #6d8190;
  --green: #58d5a0;
  --green-soft: #18382f;
  --red: #ff6876;
  --red-soft: #3a2029;
  --amber: #efbd63;
  --blue: #75b8ee;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  width: 236px;
  padding: 24px 16px 18px;
  border-right: 1px solid var(--line-soft);
  background: var(--sidebar);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 7px; color: inherit; text-decoration: none; }
.brand-symbol, .login-brand-mark { display: grid; place-items: center; color: var(--green); background: #15332c; border: 1px solid #225444; }
.brand-symbol { width: 38px; height: 38px; border-radius: 11px; }
.brand-symbol svg { width: 25px; height: 25px; }
.brand-copy { display: grid; gap: 3px; }
.brand-copy strong { font-size: 12px; letter-spacing: .14em; }
.brand-copy small { color: var(--text-subtle); font-family: var(--mono); font-size: 9px; letter-spacing: .1em; }

.nav-caption { margin: 42px 8px 11px; color: #607383; font-size: 10px; font-weight: 650; letter-spacing: .1em; }
.sidebar-nav { display: grid; gap: 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 0 12px; border: 1px solid transparent; border-radius: 8px; color: #a2b2bf; font-size: 13px; text-decoration: none; transition: color 160ms ease, background 160ms ease, border-color 160ms ease; }
.nav-item svg { width: 19px; height: 19px; color: #8094a3; }
.nav-item:hover { color: var(--text); background: #131f29; }
.nav-item.is-active { color: #dff8ee; background: #15332c; border-color: #1f4c3f; }
.nav-item.is-active svg { color: var(--green); }
.nav-indicator { width: 5px; height: 5px; margin-left: auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px #58d5a080; }
.sidebar-spacer { flex: 1; }
.sidebar-host { display: flex; align-items: center; gap: 10px; padding: 12px 9px; border: 1px solid var(--line-soft); border-radius: 9px; background: #101a23; }
.host-avatar { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 8px; color: #87b9dc; background: #1a2b38; }
.host-avatar svg { width: 20px; height: 20px; }
.sidebar-host-copy { display: grid; gap: 4px; min-width: 0; }
.sidebar-host-copy strong { max-width: 126px; overflow: hidden; color: #d8e3ea; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-host-copy small { color: var(--text-subtle); font-size: 10px; }
.status-dot, .network-device-dot, .footer-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-dot { margin-left: auto; box-shadow: 0 0 9px #58d5a060; }
.status-dot.is-stale { background: var(--amber); box-shadow: none; }
.status-dot.is-error { background: var(--red); box-shadow: none; }
.sidebar-foot { padding: 17px 4px 0; color: #556875; font-family: var(--mono); font-size: 9px; letter-spacing: .04em; }
.sidebar-foot span { padding: 0 4px; color: #3d505e; }

.main-content { min-width: 0; width: calc(100% - 236px); margin-left: 236px; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 0 34px; border-bottom: 1px solid var(--line-soft); background: #0b121ae8; backdrop-filter: blur(14px); }
.breadcrumb { display: flex; align-items: center; gap: 9px; color: #738796; font-size: 11px; }
.breadcrumb svg { width: 13px; height: 13px; color: #526674; }
.breadcrumb strong { color: #cbd7df; font-weight: 550; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-clock { color: #8ca0ae; font-family: var(--mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.topbar-divider { width: 1px; height: 19px; background: var(--line); }
.topbar-actions form { margin: 0; }
.logout-button { display: inline-flex; align-items: center; gap: 7px; padding: 7px 9px; border: 0; border-radius: 6px; color: #9eafbb; background: transparent; font-size: 11px; cursor: pointer; transition: color 150ms ease, background 150ms ease; }
.logout-button svg { width: 16px; height: 16px; }
.logout-button:hover { color: var(--text); background: #17232d; }

.page-content { width: min(100%, 1450px); margin: 0 auto; padding: 33px 34px 22px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 23px; }
.eyebrow { margin: 0; color: #6e8795; font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .13em; }
.heading-eyebrow { margin-bottom: 9px; color: #67ad90; }
.page-heading h1 { margin: 0; color: var(--text); font-size: 25px; font-weight: 650; letter-spacing: -.04em; }
.page-subtitle { margin: 8px 0 0; color: var(--text-muted); font-size: 12px; }
.live-status { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 3px; padding: 0 11px; border: 1px solid #24473d; border-radius: 99px; color: #8dddb9; background: #12271f; font-size: 10px; white-space: nowrap; }
.live-status[data-state="warning"] { border-color: #62343a; color: #ff9aa2; background: #2b1b22; }
.live-status[data-state="stale"] { border-color: #51452c; color: #edc779; background: #251f16; }
.live-status[data-state="error"] { border-color: #62343a; color: #ff9aa2; background: #2b1b22; }
.live-status[data-state="loading"] { border-color: #34424d; color: #9baeb9; background: #151f28; }
.live-pulse { position: relative; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.live-status[data-state="live"] .live-pulse::after { position: absolute; inset: -4px; border: 1px solid currentColor; border-radius: 50%; content: ""; opacity: .45; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { from { transform: scale(.5); opacity: .55; } to { transform: scale(1.7); opacity: 0; } }

.host-strip { display: flex; align-items: center; gap: 14px; min-height: 69px; margin-bottom: 17px; padding: 12px 17px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(100deg, #13212b, #111a23 63%, #111a23); }
.host-strip-icon { display: grid; place-items: center; width: 39px; height: 39px; border: 1px solid #2b4552; border-radius: 9px; color: #8bc4e6; background: #192b37; }
.host-strip-icon svg { width: 21px; height: 21px; }
.host-strip-copy { display: grid; gap: 4px; min-width: 0; }
.host-strip-copy span, .meta-label { color: var(--text-subtle); font-size: 10px; }
.host-strip-copy strong { max-width: 280px; overflow: hidden; color: #e1edf3; font-family: var(--mono); font-size: 12px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.host-strip-meta { display: grid; gap: 5px; margin-left: auto; padding-left: 22px; border-left: 1px solid var(--line); }
.host-strip-meta + .host-strip-meta { margin-left: 2px; }
.host-strip-meta strong { color: #d0dce4; font-family: var(--mono); font-size: 11px; font-weight: 500; }
.host-strip-live { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; color: #79cda7; font-family: var(--mono); font-size: 9px; letter-spacing: .07em; }
.host-strip-live i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.host-strip-live[data-state="warning"], .host-strip-live[data-state="partial"], .host-strip-live[data-state="stale"] { color: var(--amber); }
.host-strip-live[data-state="warning"] i, .host-strip-live[data-state="partial"] i, .host-strip-live[data-state="stale"] i { background: var(--amber); }
.host-strip-live[data-state="error"] { color: var(--red); }
.host-strip-live[data-state="error"] i { background: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.metric-card { min-width: 0; min-height: 169px; padding: 16px 17px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); transition: border-color 160ms ease, background 160ms ease; }
.metric-card:hover { border-color: #344957; background: #13202a; }
.metric-card.is-alert { border-color: #673841; background: linear-gradient(145deg, #211820, #151a23 70%); }
.metric-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-label { color: #9bacb8; font-size: 11px; font-weight: 520; }
.metric-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; }
.metric-icon svg { width: 18px; height: 18px; }
.icon-cpu { color: #72d8ad; background: #19352f; }
.icon-memory { color: #86bdf0; background: #1b2d3c; }
.icon-disk { color: #edc477; background: #352e20; }
.icon-network { color: #ae9be8; background: #2b2540; }
.metric-value-row { display: flex; align-items: baseline; gap: 4px; margin-top: 12px; min-width: 0; }
.metric-value { color: #eaf3f7; font-family: var(--mono); font-size: 27px; font-weight: 550; font-variant-numeric: tabular-nums; letter-spacing: -.07em; }
.metric-card.is-alert .metric-value { color: #ff8b93; }
.metric-unit { color: #8497a5; font-family: var(--mono); font-size: 12px; }
.metric-state { overflow: hidden; margin-left: auto; color: #75c9a2; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.metric-card.is-alert .metric-state { color: #ff9199; }
.metric-card.is-unavailable .metric-state { color: var(--amber); }
.metric-detail { min-height: 17px; margin-top: 5px; overflow: hidden; color: #778b99; font-family: var(--mono); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.metric-progress { display: block; width: 100%; height: 5px; margin: 12px 0 8px; appearance: none; border: 0; border-radius: 99px; background: #22313d; }
.metric-progress::-webkit-progress-bar { border-radius: 99px; background: #22313d; }
.metric-progress::-webkit-progress-value { border-radius: 99px; background: linear-gradient(90deg, #398d6d, #5ad5a0); transition: width 300ms ease; }
.metric-progress::-moz-progress-bar { border-radius: 99px; background: linear-gradient(90deg, #398d6d, #5ad5a0); }
.metric-card.is-alert .metric-progress::-webkit-progress-value { background: linear-gradient(90deg, #c74b5c, #ff6876); }
.metric-card.is-alert .metric-progress::-moz-progress-bar { background: linear-gradient(90deg, #c74b5c, #ff6876); }
.metric-card.is-unavailable .metric-progress::-webkit-progress-value, .metric-card.is-unavailable .metric-progress::-moz-progress-bar { background: #687985; }
.metric-foot { display: flex; align-items: center; justify-content: space-between; color: #6f8290; font-size: 9px; }
.metric-foot strong { color: #a7b7c2; font-family: var(--mono); font-size: 9px; font-weight: 500; }
.network-card { padding-bottom: 12px; }
.network-rate-row { display: grid; grid-template-columns: 14px 1fr 14px 1fr; align-items: center; gap: 5px; margin-top: 17px; }
.network-rate-row > div { display: grid; gap: 5px; }
.network-rate-row > div span { color: #708390; font-size: 9px; }
.network-rate-row > div strong { overflow: hidden; color: #e5eef3; font-family: var(--mono); font-size: 13px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.rate-arrow { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.rate-down { color: #75b8ee; }
.rate-up { color: #bd9fee; }
.network-device { display: flex; align-items: center; gap: 7px; margin-top: 21px; padding-top: 10px; border-top: 1px solid var(--line-soft); color: #758997; font-family: var(--mono); font-size: 9px; }
.network-device-dot { width: 5px; height: 5px; background: #a895dc; }

.charts-section { margin-top: 27px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.section-heading h2 { margin: 0; color: #e3edf2; font-size: 14px; font-weight: 600; letter-spacing: -.02em; }
.section-heading p { margin: 5px 0 0; color: var(--text-subtle); font-size: 10px; }
.trend-legend { display: inline-flex; align-items: center; gap: 7px; color: #9dabb5; font-size: 9px; }
.trend-legend i, .threshold-key { display: inline-block; width: 17px; height: 0; border-top: 1px dashed var(--red); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.chart-card { min-width: 0; overflow: hidden; padding: 15px 16px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.chart-card:first-child { grid-column: span 2; }
.chart-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chart-kicker { color: #6d8290; font-family: var(--mono); font-size: 8px; letter-spacing: .12em; }
.chart-card h3 { margin: 5px 0 0; color: #d9e5eb; font-size: 11px; font-weight: 550; }
.chart-current { display: flex; align-items: baseline; gap: 3px; color: #8fe0bb; font-family: var(--mono); }
.chart-current.is-alert, .chart-current.is-alert span { color: #ff8b93; }
.chart-current strong { font-size: 17px; font-weight: 550; }
.chart-current span { color: #79928e; font-size: 9px; }
.trend-sync { color: #758997; font-size: 9px; white-space: nowrap; }
.chart-plot { position: relative; height: 170px; margin-top: 10px; }
.chart-card:first-child .chart-plot { height: 192px; }
.chart-plot canvas { display: block; width: 100%; height: 100%; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #738693; font-size: 10px; pointer-events: none; }
.chart-empty[hidden] { display: none; }
.chart-card-foot { display: flex; align-items: center; gap: 7px; min-height: 20px; color: #80919e; font-size: 9px; }
.chart-card-foot strong { color: #c1cdd5; font-family: var(--mono); font-size: 9px; font-weight: 500; }
.chart-foot-spacer { flex: 1; }
.series-key { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.series-cpu { background: #58d5a0; }
.series-memory { background: #75b8ee; }
.series-disk { background: #efbd63; }

.page-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 2px 0; color: #607481; font-size: 9px; }
.page-footer > span:last-child { display: inline-flex; align-items: center; gap: 6px; }
.footer-dot { width: 5px; height: 5px; }

/* Login */
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(ellipse at 50% 35%, #13251f 0%, #0c151c 38%, #080e14 80%); }
.login-shell { width: min(100%, 390px); }
.login-card { padding: 34px 34px 24px; border: 1px solid #2a3b46; border-radius: 14px; background: #111b25; box-shadow: 0 24px 70px #0005; }
.login-brand-mark { width: 42px; height: 42px; margin-bottom: 24px; border-radius: 12px; }
.login-brand-mark svg { width: 27px; height: 27px; }
.login-card h1 { margin: 9px 0 0; color: var(--text); font-size: 23px; font-weight: 650; letter-spacing: -.04em; }
.login-copy { margin: 9px 0 24px; color: var(--text-muted); font-size: 11px; line-height: 1.6; }
.login-message { margin: -9px 0 17px; padding: 10px 12px; border: 1px solid #60353c; border-radius: 7px; color: #ff9da4; background: #2b1b22; font-size: 10px; line-height: 1.5; }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 5px; color: #a6b6c0; font-size: 10px; font-weight: 550; }
.login-form input { width: 100%; height: 41px; padding: 0 12px; border: 1px solid #2b3b47; border-radius: 7px; color: var(--text); background: #0c141c; font-size: 12px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.login-form input:hover { border-color: #3c5260; }
.login-form input:focus { border-color: #479b79; box-shadow: 0 0 0 3px #58d5a018; outline: none; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; border: 1px solid transparent; border-radius: 7px; font-size: 11px; font-weight: 600; cursor: pointer; transition: background 160ms ease, transform 160ms ease; }
.button-primary { margin-top: 15px; color: #072016; background: #58d5a0; }
.button-primary:hover { background: #70e0b2; }
.button-primary:active { transform: translateY(1px); }
.button-primary svg { width: 16px; height: 16px; }
.login-secure-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 21px; color: #708390; font-size: 9px; }
.login-secure-note svg { width: 14px; height: 14px; color: #6cab8e; }
.login-footer { margin: 18px 0 0; color: #566a78; font-family: var(--mono); font-size: 8px; letter-spacing: .13em; text-align: center; }

@media (min-width: 1500px) {
  .page-content { padding-right: 44px; padding-left: 44px; }
  .metric-card { min-height: 177px; padding: 18px 20px 14px; }
  .chart-plot { height: 190px; }
  .chart-card:first-child .chart-plot { height: 215px; }
}

@media (max-width: 1150px) {
  .sidebar { width: 210px; }
  .main-content { width: calc(100% - 210px); margin-left: 210px; }
  .topbar { padding-right: 25px; padding-left: 25px; }
  .page-content { padding-right: 25px; padding-left: 25px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { position: sticky; inset: 0 0 auto; width: 100%; height: 59px; flex-direction: row; align-items: center; gap: 18px; padding: 0 16px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .brand { gap: 8px; padding: 0; }
  .brand-symbol { width: 31px; height: 31px; border-radius: 9px; }
  .brand-symbol svg { width: 21px; height: 21px; }
  .brand-copy strong { font-size: 10px; }
  .brand-copy small, .nav-caption, .sidebar-spacer, .sidebar-host, .sidebar-foot { display: none; }
  .sidebar-nav { margin-left: auto; }
  .nav-item { min-height: 35px; gap: 7px; padding: 0 9px; font-size: 10px; }
  .nav-item svg { width: 16px; height: 16px; }
  .nav-indicator { width: 4px; height: 4px; }
  .app-shell { display: block; }
  .main-content { width: 100%; margin: 0; }
  .topbar { position: static; min-height: 49px; padding: 0 17px; }
  .breadcrumb { font-size: 10px; }
  .topbar-actions { gap: 10px; }
  .topbar-clock { font-size: 9px; }
  .logout-button { gap: 4px; padding: 6px; font-size: 9px; }
  .logout-button svg { width: 14px; height: 14px; }
  .page-content { padding: 23px 16px 17px; }
  .page-heading { align-items: flex-start; margin-bottom: 17px; }
  .page-heading h1 { font-size: 21px; }
  .page-subtitle { font-size: 10px; }
  .live-status { gap: 6px; min-height: 26px; padding: 0 8px; font-size: 8px; }
  .host-strip { gap: 10px; min-height: 62px; padding: 10px; }
  .host-strip-icon { width: 33px; height: 33px; }
  .host-strip-icon svg { width: 18px; height: 18px; }
  .host-strip-copy span, .meta-label { font-size: 9px; }
  .host-strip-copy strong { max-width: 135px; font-size: 10px; }
  .host-strip-meta { gap: 4px; padding-left: 11px; }
  .host-strip-meta strong { font-size: 9px; }
  .host-strip-live { display: none; }
  .metric-grid { gap: 9px; }
  .metric-card { min-height: 154px; padding: 13px 13px 11px; }
  .metric-value { font-size: 24px; }
  .metric-state { font-size: 8px; }
  .network-rate-row { margin-top: 14px; }
  .network-device { margin-top: 17px; }
  .charts-section { margin-top: 23px; }
  .chart-grid { grid-template-columns: 1fr; gap: 9px; }
  .chart-card:first-child { grid-column: auto; }
  .chart-card:first-child .chart-plot, .chart-plot { height: 165px; }
  .page-footer { font-size: 8px; }
}

@media (max-width: 430px) {
  .brand-copy { display: none; }
  .sidebar { gap: 8px; }
  .nav-item { padding-right: 7px; padding-left: 7px; }
  .topbar-clock { display: none; }
  .topbar-divider { display: none; }
  .host-strip { gap: 8px; }
  .host-strip-copy strong { max-width: 105px; }
  .host-strip-meta { padding-left: 8px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 150px; padding: 12px 11px 10px; }
  .metric-label { font-size: 10px; }
  .metric-icon { width: 26px; height: 26px; }
  .metric-value { font-size: 21px; }
  .network-rate-row { grid-template-columns: 12px 1fr 12px 1fr; gap: 3px; }
  .network-rate-row > div strong { font-size: 11px; }
  .page-footer { align-items: flex-start; flex-direction: column; gap: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
