:root {
  --bg: #f1f2ed;
  --surface: #fbfcf8;
  --surface-strong: #ffffff;
  --ink: #18201c;
  --muted: #68716b;
  --faint: #98a099;
  --line: rgba(24, 32, 28, .10);
  --green: #17684d;
  --green-bright: #2b8b69;
  --green-soft: #dfeee6;
  --blue: #3f7198;
  --orange: #bd7a24;
  --red: #ae443b;
  --shadow: 0 20px 58px rgba(27, 38, 31, .07), 0 2px 7px rgba(27, 38, 31, .035);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-height: 100%; margin: 0; color: var(--ink); background: radial-gradient(circle at 78% -10%, rgba(83, 145, 116, .13), transparent 34%), var(--bg); }
button, input { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.is-hidden { display: none !important; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .15em; }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow: hidden; position: relative; }
.login-home-link { position: absolute; z-index: 2; top: max(20px, env(safe-area-inset-top)); left: max(20px, env(safe-area-inset-left)); padding: 8px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 650; }
.login-home-link:hover { color: var(--ink); background: rgba(255,255,255,.6); }
.login-view::before { content: ""; position: absolute; inset: 0; opacity: .25; background-image: radial-gradient(rgba(27,39,32,.23) .55px, transparent .55px); background-size: 7px 7px; mask-image: linear-gradient(#000, transparent 76%); }
.login-glow { position: absolute; width: 520px; height: 520px; border-radius: 50%; filter: blur(4px); }
.login-glow-one { right: -220px; top: -330px; background: radial-gradient(circle, rgba(42,132,97,.27), transparent 68%); }
.login-glow-two { left: -260px; bottom: -360px; background: radial-gradient(circle, rgba(189,122,36,.18), transparent 68%); }
.login-card { position: relative; width: min(430px, 100%); padding: 44px; border: 1px solid rgba(255,255,255,.86); border-radius: 26px; background: rgba(255,255,255,.76); backdrop-filter: blur(24px); box-shadow: var(--shadow); }
.login-card h1 { margin: 17px 0 9px; font: 500 34px/1.15 Georgia, "Songti SC", serif; letter-spacing: -.04em; }
.login-card > p:not(.eyebrow):not(.form-error) { margin: 0 0 30px; color: var(--muted); line-height: 1.65; font-size: 14px; }
.login-card label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.login-card input { width: 100%; height: 46px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: rgba(255,255,255,.8); }
.login-card input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,104,77,.10); }
.login-card button { width: 100%; height: 46px; margin-top: 10px; border: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; gap: 9px; color: white; background: var(--ink); font-weight: 700; }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--red); font-size: 12px; }

.pulse-mark { width: 34px; height: 34px; position: relative; display: inline-grid; place-items: center; border-radius: 11px; background: var(--ink); overflow: hidden; }
.pulse-mark i { position: absolute; width: 4px; border-radius: 4px; background: #f5f7f2; }
.pulse-mark i:nth-child(1) { height: 8px; transform: translateX(-7px); }
.pulse-mark i:nth-child(2) { height: 18px; }
.pulse-mark i:nth-child(3) { height: 12px; transform: translateX(7px); }
.pulse-mark.large { width: 44px; height: 44px; margin-bottom: 20px; border-radius: 14px; }
.pulse-mark.large i:nth-child(1) { height: 11px; transform: translateX(-9px); }
.pulse-mark.large i:nth-child(2) { height: 23px; }
.pulse-mark.large i:nth-child(3) { height: 15px; transform: translateX(9px); }

.dashboard { min-height: 100vh; }
.topbar { height: 70px; padding: 0 max(24px, calc((100vw - 1380px) / 2)); position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(241,242,237,.84); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; }
.brand > span:last-child { display: grid; }
.brand strong { font-size: 14px; letter-spacing: -.01em; }
.brand small { color: var(--faint); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.live-badge { height: 30px; padding: 0 11px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid rgba(23,104,77,.12); border-radius: 99px; background: rgba(255,255,255,.65); color: var(--green); font-size: 11px; font-weight: 700; }
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 0 4px rgba(43,139,105,.11); }
.live-badge.connecting { color: var(--orange); }
.live-badge.connecting i { background: var(--orange); box-shadow: 0 0 0 4px rgba(189,122,36,.10); }
.quiet-button, .small-button { border: 1px solid var(--line); background: rgba(255,255,255,.62); border-radius: 9px; font-size: 11px; font-weight: 680; }
.quiet-button { padding: 8px 12px; }
.small-button { padding: 7px 10px; }
.quiet-button:hover, .small-button:hover { background: white; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); }
.icon-button:hover { background: rgba(0,0,0,.05); }

.page { width: min(1380px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 68px; }
.hero { margin-bottom: 30px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.hero h1 { margin: 10px 0 7px; font: 500 clamp(32px, 4vw, 52px)/1.06 Georgia, "Songti SC", serif; letter-spacing: -.045em; }
.hero-meta { margin: 0; color: var(--muted); font-size: 13px; }
.health-badge { min-width: 180px; padding: 13px 16px; display: flex; align-items: center; gap: 11px; border: 1px solid rgba(23,104,77,.13); border-radius: 14px; background: rgba(255,255,255,.68); }
.health-badge small, .health-badge strong { display: block; }
.health-badge small { color: var(--faint); font-size: 9px; text-transform: uppercase; letter-spacing: .09em; }
.health-badge strong { margin-top: 2px; font-size: 13px; }
.health-orb { width: 12px; height: 12px; flex: 0 0 auto; border: 3px solid white; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 0 4px rgba(43,139,105,.12); }
.health-badge.warning .health-orb { background: var(--orange); box-shadow: 0 0 0 4px rgba(189,122,36,.12); }
.health-badge.critical .health-orb { background: var(--red); box-shadow: 0 0 0 4px rgba(174,68,59,.12); }
.health-badge.unknown .health-orb { background: var(--faint); box-shadow: 0 0 0 4px rgba(152,160,153,.12); }

.alert-stack { margin-bottom: 18px; display: grid; gap: 8px; }
.alert-item { min-height: 44px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(189,122,36,.18); border-radius: 11px; background: #fff8eb; color: #78501c; font-size: 12px; }
.alert-item::before { content: "!"; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--orange); font-size: 11px; font-weight: 800; }
.alert-item.critical { border-color: rgba(174,68,59,.18); background: #fff1ef; color: #7d302a; }
.alert-item.critical::before { background: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card, .chart-card, .detail-card { border: 1px solid rgba(255,255,255,.84); background: rgba(251,252,248,.88); box-shadow: var(--shadow); }
.metric-card { min-height: 340px; padding: 22px; border-radius: 20px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; width: 150px; height: 150px; right: -80px; top: -90px; border-radius: 50%; background: rgba(23,104,77,.055); }
.metric-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.metric-heading h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.025em; }
.metric-kicker { color: var(--faint); font-size: 8.5px; font-weight: 800; letter-spacing: .14em; }
.metric-tag, .soft-badge { padding: 5px 8px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-size: 9.5px; font-weight: 700; white-space: nowrap; }
.ring-wrap { width: 158px; height: 158px; margin: 20px auto 18px; position: relative; display: grid; place-items: center; }
.metric-ring { width: 100%; height: 100%; overflow: visible; transform: rotate(-90deg); }
.metric-ring circle { fill: none; stroke-width: 8; }
.ring-track { stroke: rgba(24,32,28,.075); }
.ring-value { stroke: var(--green-bright); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .65s ease, stroke .25s; }
.metric-card.warning .ring-value { stroke: var(--orange); }
.metric-card.critical .ring-value { stroke: var(--red); }
.ring-label { position: absolute; display: flex; align-items: baseline; }
.ring-label strong { font: 500 36px/1 Georgia, serif; letter-spacing: -.04em; }
.ring-label span { margin-left: 2px; color: var(--faint); font-size: 12px; }
.metric-foot { padding-top: 15px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.metric-foot span, .network-row span { min-width: 0; }
.metric-foot small, .metric-foot strong, .network-row small, .network-row strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.metric-foot small, .network-row small { color: var(--faint); font-size: 9px; }
.metric-foot strong, .network-row strong { margin-top: 4px; font-size: 11.5px; }
.load-row { margin: 30px 0 26px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.load-row div { padding: 12px 8px; border-radius: 12px; background: rgba(24,32,28,.035); text-align: center; }
.load-row strong, .load-row small { display: block; }
.load-row strong { font: 500 23px Georgia, serif; }
.load-row small { margin-top: 5px; color: var(--faint); font-size: 8.5px; }
.bar-block + .bar-block { margin-top: 14px; }
.bar-label { margin-bottom: 6px; display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
progress { width: 100%; height: 6px; display: block; border: 0; overflow: hidden; border-radius: 9px; background: rgba(24,32,28,.08); }
progress::-webkit-progress-bar { background: rgba(24,32,28,.08); border-radius: 9px; }
progress::-webkit-progress-value { background: var(--green-bright); border-radius: 9px; transition: width .4s; }
progress::-moz-progress-bar { background: var(--green-bright); border-radius: 9px; }
.network-row { margin-top: 25px; padding-top: 15px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }

.history-section { margin-top: 54px; }
.section-heading { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; }
.section-heading h2, .detail-head h2 { margin: 5px 0 0; font-size: 22px; letter-spacing: -.035em; }
.range-switch { padding: 3px; display: flex; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.55); }
.range-switch button { min-width: 58px; height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 10.5px; }
.range-switch button.active { color: white; background: var(--ink); box-shadow: 0 3px 10px rgba(24,32,28,.15); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-card { min-width: 0; padding: 20px 20px 13px; border-radius: 18px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-title { display: flex; align-items: center; justify-content: space-between; }
.chart-title > div { display: flex; align-items: center; gap: 8px; }
.chart-title h3 { margin: 0; font-size: 12px; }
.chart-title > strong { font: 500 18px Georgia, serif; }
.chart-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 0 4px rgba(43,139,105,.10); }
.chart-dot.memory { background: var(--blue); box-shadow: 0 0 0 4px rgba(63,113,152,.10); }
.chart-dot.network { background: var(--orange); box-shadow: 0 0 0 4px rgba(189,122,36,.10); }
canvas { width: 100%; height: 220px; display: block; margin-top: 8px; }
.chart-legend { padding: 0 10px 6px; display: flex; justify-content: center; gap: 20px; color: var(--muted); font-size: 9px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { width: 16px; height: 2px; background: var(--orange); }
.chart-legend i.tx { background: var(--blue); }

.detail-grid { margin-top: 54px; display: grid; grid-template-columns: .9fr 1.4fr; gap: 14px; align-items: start; }
.detail-card { min-width: 0; padding: 22px; border-radius: 18px; }
.maintenance-card { grid-column: 1; grid-row: 1; }
.process-card { grid-column: 2; grid-row: 1 / span 2; }
.port-card { grid-column: 1; grid-row: 2; }
.detail-head { margin-bottom: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-head h2 { font-size: 18px; }
.service-list { display: grid; gap: 8px; }
.service-row { min-height: 58px; padding: 9px 10px; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.5); }
.service-icon { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--green); font-size: 11px; font-weight: 800; }
.service-icon.codex { background: #292e2b; }
.service-icon.system { background: var(--blue); }
.service-row > div { min-width: 0; flex: 1; }
.service-row strong, .service-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.service-row strong { font-size: 11.5px; }
.service-row small { margin-top: 3px; color: var(--faint); font-size: 9px; }
.state-pill { padding: 4px 7px; border-radius: 99px; color: var(--orange); background: rgba(189,122,36,.11); font-size: 9px; font-weight: 750; }
.state-pill.good { color: var(--green); background: var(--green-soft); }
.state-pill.bad { color: var(--red); background: rgba(174,68,59,.10); }
.system-facts { margin-top: 18px; padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px 12px; border-radius: 13px; background: rgba(24,32,28,.035); }
.system-facts span:last-child { grid-column: 1 / -1; }
.system-facts small, .system-facts strong { display: block; }
.system-facts small { color: var(--faint); font-size: 9px; }
.system-facts strong { margin-top: 4px; font-size: 11px; }
.table-wrap { overflow-x: auto; }
.port-card .table-wrap { max-height: 300px; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 0 10px 9px; color: var(--faint); text-align: right; font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; }
th:first-child, td:first-child { text-align: left; }
td { height: 38px; padding: 0 10px; border-top: 1px solid var(--line); text-align: right; color: var(--muted); font: 10.5px ui-monospace, SFMono-Regular, Menlo, monospace; }
td:first-child { color: var(--ink); font-family: inherit; font-weight: 650; }
.empty-cell { height: 80px; text-align: center !important; color: var(--faint); font-family: inherit; font-weight: 400 !important; }
footer { min-height: 64px; padding: 0 max(24px, calc((100vw - 1380px) / 2)); display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); color: var(--faint); font-size: 9px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; max-width: min(360px, calc(100vw - 40px)); padding: 12px 15px; border-radius: 11px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 330px; }
}

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 14px; }
  .brand small, .quiet-button { display: none; }
  .live-badge { padding: 0 9px; }
  .page { width: min(100% - 24px, 620px); padding: 32px 0 48px; }
  .hero { align-items: flex-start; }
  .hero h1 { font-size: 34px; }
  .health-badge { min-width: 0; padding: 10px 12px; }
  .health-badge small { display: none; }
  .metric-grid, .chart-grid, .detail-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: auto; }
  .maintenance-card, .process-card, .port-card { grid-column: auto; grid-row: auto; }
  .metric-card { min-height: 320px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .range-switch { width: 100%; overflow-x: auto; }
  .range-switch button { min-width: 20%; flex: 1; padding: 0 6px; }
  .history-section, .detail-grid { margin-top: 40px; }
  footer { padding: 0 14px; }
}

@media (max-width: 430px) {
  .login-card { padding: 34px 24px; }
  .hero { display: block; }
  .health-badge { width: fit-content; margin-top: 18px; }
  .metric-grid { gap: 10px; }
  .metric-card { padding: 19px; }
  .ring-wrap { width: 150px; height: 150px; }
  .detail-card, .chart-card { padding: 18px 14px; }
  .port-card .table-wrap { max-height: none; }
  td, th { padding-left: 7px; padding-right: 7px; }
  .port-card table th:last-child, .port-card table td:last-child { display: none; }
}

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