:root {
  color-scheme: dark;
  --bg: #0b0e12;
  --surface: #11151a;
  --surface-2: #171c22;
  --surface-3: #1d232b;
  --line: #29313b;
  --line-strong: #384351;
  --text: #f3f6fa;
  --muted: #929daa;
  --subtle: #687483;
  --blue: #6ea8fe;
  --teal: #53c8b7;
  --amber: #e5ad4f;
  --red: #ec6a6a;
  --green: #46bd82;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); background: var(--bg); font: 14px/1.5 var(--font); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); padding: 32px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.login-mark { width: 32px; height: 3px; margin-bottom: 18px; background: var(--blue); border-radius: 2px; }
.login-card h1 { margin: 2px 0 2px; font-size: 26px; letter-spacing: -.03em; }
.login-host { margin: 0 0 28px; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.login-card label { display: block; margin: 16px 0 6px; color: #c9d1da; font-size: 13px; }
.login-card input { width: 100%; height: 44px; padding: 0 12px; color: var(--text); background: #0d1116; border: 1px solid var(--line-strong); border-radius: 7px; outline: none; }
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(110,168,254,.14); }
.form-error { min-height: 21px; margin: 10px 0 4px; color: #ff8b8b; font-size: 13px; }

.button { min-height: 36px; padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface-2); cursor: pointer; }
.button:hover { background: var(--surface-3); border-color: #4a5868; }
.button:focus-visible, .range-switch button:focus-visible, .mini-tabs button:focus-visible, .text-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.button.primary { width: 100%; margin-top: 10px; color: #08111f; background: #8db9ff; border-color: #8db9ff; font-weight: 700; }
.button.primary:hover { background: #a6c9ff; }
.button.ghost { background: transparent; }

.app-shell { width: min(1500px, calc(100% - 40px)); margin: 0 auto 72px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 76px; padding: 12px 0; background: rgba(11,14,18,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.host-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.host-row { display: flex; align-items: baseline; gap: 10px; }
.host-block h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.host-block p { margin: 2px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(229,173,79,.12); }
.status-dot.live { background: var(--green); box-shadow: 0 0 0 4px rgba(70,189,130,.12); }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 4px rgba(236,106,106,.12); }
.status-label { color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.range-switch { display: flex; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.range-switch button { padding: 6px 9px; color: var(--muted); background: transparent; border: 0; border-radius: 5px; cursor: pointer; font-size: 12px; }
.range-switch button.active { color: var(--text); background: var(--surface-3); }

main { padding-top: 20px; }
.alert-strip { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 54px; margin-bottom: 14px; padding: 11px 14px; background: rgba(70,189,130,.07); border: 1px solid rgba(70,189,130,.28); border-radius: var(--radius); }
.alert-strip.warning { background: rgba(229,173,79,.07); border-color: rgba(229,173,79,.35); }
.alert-strip.critical { background: rgba(236,106,106,.08); border-color: rgba(236,106,106,.4); }
.alert-strip strong { margin-right: 9px; }
.alert-strip span { color: var(--muted); font-size: 12px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.metric-card { min-width: 0; padding: 18px; }
.metric-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.kicker { margin: 0 0 4px; color: var(--muted); font: 700 11px/1.2 var(--mono); letter-spacing: .08em; }
.metric-card h2 { margin: 0; font-size: 27px; line-height: 1.15; letter-spacing: -.035em; }
.metric-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.metric-stats span { padding: 4px 7px; color: var(--muted); background: var(--surface-2); border-radius: 5px; font-size: 11px; }
.metric-caption { min-height: 21px; margin: 7px 0 2px; color: var(--muted); font-size: 12px; }
.chart { width: 100%; height: 250px; }
.core-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; margin-top: 4px; }
.core { min-width: 0; }
.core-label { display: flex; justify-content: space-between; color: var(--subtle); font: 10px var(--mono); }
.core-bar, .progress { height: 4px; overflow: hidden; margin-top: 4px; background: #252c34; border-radius: 999px; }
.core-bar span, .progress span { display: block; height: 100%; background: var(--blue); border-radius: inherit; }
.detail-line { margin-top: 4px; color: var(--muted); font-size: 12px; }

.section-block { margin-top: 28px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 10px; padding: 0 2px; }
.section-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.section-heading > p { margin: 0; color: var(--muted); font-size: 12px; text-align: right; }
.health-grid, .storage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compact-panel { min-width: 0; padding: 16px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; margin-bottom: 10px; }
.panel-heading h3 { margin: 0; font-size: 14px; }
.panel-heading > span { color: var(--muted); font-size: 11px; }
.unit-panel { margin-top: 14px; }
.unit-tools { display: flex; align-items: center; gap: 9px; }
.unit-tools input { width: 150px; height: 32px; padding: 0 9px; color: var(--text); background: #0c1015; border: 1px solid var(--line); border-radius: 6px; outline: none; }
.unit-tools input:focus { border-color: var(--blue); }
.mini-tabs { display: flex; gap: 4px; }
.mini-tabs button, .text-button { padding: 4px 8px; color: var(--muted); background: transparent; border: 0; border-radius: 5px; cursor: pointer; font-size: 12px; }
.mini-tabs button.active { color: var(--text); background: var(--surface-3); }
.text-button.active { color: var(--blue); }

.issue-list { display: grid; gap: 7px; max-height: 286px; overflow: auto; }
.issue { padding: 9px 10px; background: var(--surface-2); border-left: 3px solid var(--amber); border-radius: 5px; }
.issue.critical { border-left-color: var(--red); }
.issue strong { display: block; font-size: 12px; }
.issue span { color: var(--muted); font-size: 11px; }
.empty-state { padding: 24px 10px; color: var(--muted); text-align: center; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 9px 8px; border-bottom: 1px solid #232a32; text-align: left; vertical-align: middle; }
th { color: var(--subtle); font-size: 10px; font-weight: 600; letter-spacing: .04em; }
td { color: #d7dde4; font-size: 12px; }
td.name-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 11px; }
tr.problem td:first-child { color: #ff9999; }
.status-chip { display: inline-block; padding: 2px 6px; color: var(--muted); background: var(--surface-3); border-radius: 4px; font-size: 10px; }
.status-chip.ok { color: #8ee1b5; background: rgba(70,189,130,.11); }
.status-chip.bad { color: #ff9999; background: rgba(236,106,106,.11); }

.bar-list { display: grid; gap: 10px; }
.bar-row { min-width: 0; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 5px; }
.bar-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 11px var(--mono); }
.bar-head span { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.progress { height: 6px; margin: 0; }
.progress.warn span { background: var(--amber); }
.progress.danger span { background: var(--red); }
.load-more { display: block; margin: 12px auto 0; }
.event-list { display: grid; }
.event { display: grid; grid-template-columns: 110px 1fr auto; gap: 14px; padding: 10px 2px; border-bottom: 1px solid #232a32; }
.event:last-child { border-bottom: 0; }
.event time, .event small { color: var(--muted); font-size: 11px; }
.event strong { font-size: 12px; }
.event.resolved strong { color: var(--muted); }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 360px; padding: 10px 13px; color: var(--text); background: #202731; border: 1px solid var(--line-strong); border-radius: 7px; box-shadow: 0 12px 40px rgba(0,0,0,.35); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .topbar { position: static; align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .range-switch { order: 3; }
  .core-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 20px, 1500px); margin-bottom: 40px; }
  .topbar { display: block; padding: 14px 0; }
  .top-actions { justify-content: flex-start; margin-top: 12px; }
  .range-switch { width: 100%; overflow-x: auto; order: 0; }
  .range-switch button { flex: 1 0 auto; }
  .metric-grid, .health-grid, .storage-grid { grid-template-columns: 1fr; }
  .metric-card, .compact-panel { padding: 13px; }
  .chart { height: 220px; }
  .metric-card h2 { font-size: 24px; }
  .section-heading { align-items: flex-start; }
  .unit-panel .panel-heading { display: block; }
  .unit-tools { margin-top: 10px; flex-wrap: wrap; }
  .unit-tools input { width: 100%; }
  .event { grid-template-columns: 88px 1fr; }
  .event small { grid-column: 2; }
  th, td { padding: 8px 6px; }
  .login-card { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
