:root {
  color-scheme: light;
  --ink: #173149;
  --ink-soft: #38566a;
  --muted: #526a77;
  --paper: #f2f7f7;
  --surface: #ffffff;
  --line: #d7e4e5;
  --aqua: #116d7b;
  --aqua-deep: #126172;
  --aqua-pale: #e4f4f4;
  --green: #237758;
  --green-pale: #e8f5ed;
  --amber: #9a6117;
  --amber-pale: #fff3dc;
  --red: #ad3e42;
  --red-pale: #fff0ed;
  --shadow: 0 14px 40px rgba(31, 71, 84, .07);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
.skip-link { position: absolute; z-index: 10; top: 8px; left: 8px; padding: 10px 13px; border-radius: 5px; color: white; background: #142f45; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.masthead {
  min-height: 76px; padding: 0 clamp(18px, 5vw, 68px); display: flex; align-items: center;
  justify-content: space-between; color: #f5fbfc; background: #142f45; border-bottom: 3px solid #38a0a8;
}
.brand { display: flex; align-items: center; gap: 13px; color: inherit; text-decoration: none; }
.brand-mark { width: 33px; height: 33px; display: flex; align-items: end; justify-content: center; gap: 3px; padding: 6px 7px; border: 1px solid rgba(182, 235, 235, .5); border-radius: 11px 11px 11px 3px; transform: rotate(-3deg); }
.brand-mark i { width: 4px; border-radius: 4px; background: #67c9c7; transform: rotate(3deg); }
.brand-mark i:nth-child(1) { height: 9px; opacity: .68; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; opacity: .82; }
.brand strong { display: block; font-size: 17px; font-weight: 650; letter-spacing: .06em; }
.brand small { display: block; margin-top: 2px; color: #a9c4cd; font-size: 11px; letter-spacing: .08em; }
.masthead-right { display: flex; align-items: center; gap: 16px; }
.local-badge { display: inline-flex; align-items: center; gap: 8px; color: #d6e9ec; font-size: 12px; }
.local-dot { width: 7px; height: 7px; border-radius: 50%; background: #77d0ab; box-shadow: 0 0 0 4px rgba(119, 208, 171, .14); }
.quiet-button { border: 1px solid #557080; border-radius: 7px; padding: 8px 14px; color: #e5f1f2; background: transparent; }
.quiet-button:hover { background: rgba(255,255,255,.08); }

.page-shell { width: min(1160px, calc(100% - 40px)); margin: 30px auto 0; }
.demo-notice { display: flex; align-items: center; gap: 12px; min-height: 62px; padding: 11px 17px; border: 1px solid #e8d9b9; border-radius: 8px; background: #fffaf0; color: #684f2f; }
.notice-mark { flex: 0 0 auto; width: 31px; height: 31px; display: grid; place-items: center; border-radius: 5px; background: #f4e6c9; color: #75531e; font-size: 12px; font-weight: 700; }
.demo-notice strong { display: block; font-size: 13px; }
.notice-copy { display: block; margin-top: 2px; color: #796c55; font-size: 12px; line-height: 1.45; }

.login-panel { display: grid; grid-template-columns: 1fr minmax(280px, 390px); gap: clamp(25px, 6vw, 84px); align-items: center; margin: 24px 0 40px; padding: clamp(25px, 5vw, 56px); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.login-copy h1, .dashboard-heading h1 { margin: 5px 0 10px; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; letter-spacing: -.045em; }
.login-copy > p:last-child { max-width: 410px; margin: 0; color: var(--muted); line-height: 1.7; }
.eyebrow { margin: 0; color: var(--aqua); font-size: 10px; font-weight: 700; letter-spacing: .15em; }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.login-form input, .login-form select { width: 100%; min-height: 46px; padding: 0 13px; border: 1px solid #c9d9dc; border-radius: 7px; outline: none; color: var(--ink); background: #fcfefe; }
.login-form input:focus, .login-form select:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(20,127,145,.14); }
.source-help { margin: -2px 0 3px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.primary-button, .outline-button { min-height: 44px; border-radius: 7px; font-size: 13px; font-weight: 650; transition: background-color .18s ease, transform .18s ease; }
.primary-button { display: flex; justify-content: space-between; align-items: center; margin-top: 9px; padding: 0 15px; border: 0; color: white; background: var(--aqua-deep); }
.primary-button:hover { background: #0c5362; }
.primary-button:active, .outline-button:active { transform: translateY(1px); }
.primary-button:disabled { cursor: wait; opacity: .7; }
.form-message { min-height: 17px; margin: 0; color: var(--red); font-size: 12px; }

.dashboard { padding-bottom: 12px; }
.dashboard-heading, .section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.dashboard-heading { margin: 36px 0 25px; }
.dashboard-heading h1 { margin-bottom: 5px; font-size: clamp(27px, 4vw, 36px); }
.muted { margin: 0; color: var(--muted); font-size: 13px; }
.outline-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid #bfd4d8; color: var(--aqua-deep); background: var(--surface); }
.outline-button:hover { background: var(--aqua-pale); }
.outline-button span { font-size: 18px; line-height: 1; }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.summary-card { min-height: 100px; padding: 16px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.summary-card span { display: block; color: var(--muted); font-size: 11px; }
.summary-card strong { display: block; margin-top: 10px; color: var(--ink); font-family: "Cascadia Code", Consolas, monospace; font-size: 27px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.summary-card.alert strong { color: var(--red); }

.farm-section, .pool-section, .alarm-section { margin-top: 34px; }
.section-heading { margin-bottom: 14px; }
.section-heading h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: -.025em; }
.section-meta, .freshness-legend { color: var(--muted); font-size: 11px; }
.farm-list { display: flex; gap: 9px; flex-wrap: wrap; }
.farm-option { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; padding: 0 14px; border: 1px solid #d5e1e2; border-radius: 7px; color: var(--ink-soft); background: rgba(255,255,255,.68); text-align: left; }
.farm-option:hover { border-color: #8abec2; background: var(--surface); }
.farm-option[aria-pressed="true"] { border-color: var(--aqua); color: #105b67; background: #e4f4f3; box-shadow: inset 0 -2px 0 var(--aqua); }
.gateway-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 8px; margin-top: 10px; }
.gateway-card { padding: 11px 13px; border: 1px solid #d6e4e5; border-radius: 7px; background: rgba(255,255,255,.62); }
.gateway-headline, .gateway-detail { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gateway-headline strong { overflow: hidden; color: var(--ink-soft); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.gateway-state { flex: 0 0 auto; padding: 3px 7px; border-radius: 4px; color: var(--green); background: var(--green-pale); font-size: 10px; font-weight: 650; }
.gateway--stale .gateway-state { color: var(--amber); background: var(--amber-pale); }
.gateway--unknown .gateway-state, .gateway--future .gateway-state { color: var(--red); background: var(--red-pale); }
.gateway-detail { justify-content: flex-start; flex-wrap: wrap; margin-top: 5px; color: var(--muted); font-size: 10px; }
.gateway-empty { padding: 8px 0; color: var(--muted); font-size: 11px; }
.farm-option small { color: var(--muted); font-size: 10px; }
.pool-heading { margin-bottom: 7px; }
.freshness-legend { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-dot { width: 7px; height: 7px; margin-left: 8px; border-radius: 50%; background: #65a984; }
.legend-dot.stale { background: #d3943b; }
.legend-dot.unknown { background: #99aab1; }
.selected-farm-note { min-height: 21px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.pool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pool-card { position: relative; overflow: hidden; min-width: 0; padding: 16px 17px 15px 20px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 4px 14px rgba(39, 83, 93, .035); }
.pool-card::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; background: #70ae8e; }
.pool-card[data-freshness="stale"]::before { background: #d79d51; }
.pool-card[data-freshness="unknown"]::before { background: #9baeb3; }
.pool-card[data-freshness="future"]::before { background: #bd6a6a; }
.pool-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.pool-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pool-name h3 { overflow: hidden; margin: 0; font-size: 17px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.pool-name span { color: var(--muted); font-family: "Cascadia Code", Consolas, monospace; font-size: 10px; }
.status-chip { flex: 0 0 auto; max-width: 60%; overflow: hidden; padding: 5px 9px; border-radius: 4px; color: var(--green); background: var(--green-pale); font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.status-chip.tone--warning { color: var(--amber); background: var(--amber-pale); }
.status-chip.tone--critical { color: var(--red); background: var(--red-pale); }
.status-chip.tone--neutral { color: #576e79; background: #edf2f2; }
.status-chip.tone--working { color: var(--aqua-deep); background: var(--aqua-pale); }
.telemetry-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 17px; padding: 13px 0 11px; border-top: 1px solid #e5eded; border-bottom: 1px solid #e5eded; }
.telemetry-item span { display: block; color: var(--muted); font-size: 10px; }
.telemetry-item strong { display: block; overflow: hidden; margin-top: 4px; color: #27465b; font-family: "Cascadia Code", Consolas, monospace; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.telemetry-item strong.text-value { font-family: inherit; font-size: 12px; }
.pool-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 11px; color: var(--muted); font-size: 10px; }
.pool-foot .alarm-count { color: var(--red); font-weight: 650; }
.empty-state { padding: 26px; border: 1px dashed #c7d7d9; border-radius: 8px; color: var(--muted); text-align: center; }
.alarm-list { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.alarm-row { display: grid; grid-template-columns: 68px 1fr auto; align-items: center; gap: 12px; min-height: 58px; padding: 9px 15px; border-bottom: 1px solid #e6eeee; }
.alarm-row:last-child { border-bottom: 0; }
.alarm-marker { width: max-content; padding: 4px 7px; border-radius: 4px; color: #526a77; background: #edf2f2; font-size: 10px; font-weight: 650; }
.alarm-marker.alarm-active { color: var(--red); background: var(--red-pale); }
.alarm-message { min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.alarm-message strong { color: var(--ink-soft); font-size: 12px; font-weight: 650; }
.alarm-message span, .alarm-time { color: var(--muted); font-size: 10px; }
.alarm-time { white-space: nowrap; }
.updated-at { margin: 21px 0 0; color: var(--muted); font-size: 11px; text-align: right; }
.global-message { position: sticky; bottom: 14px; width: fit-content; max-width: 100%; margin: 12px auto; padding: 11px 16px; border: 1px solid #e9c2bc; border-radius: 7px; color: #87383c; background: #fff7f5; box-shadow: var(--shadow); font-size: 13px; }
.page-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 42px; padding: 17px 0 25px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; letter-spacing: .04em; }

button:focus-visible, a:focus-visible, main:focus-visible { outline: 3px solid #eab54e; outline-offset: 3px; }
.login-form input:focus-visible, .login-form select:focus-visible { outline: 3px solid rgba(20,127,145,.23); outline-offset: 1px; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .masthead { min-height: 66px; padding: 0 17px; }
  .brand strong { font-size: 15px; }
  .local-badge { font-size: 10px; }
  .page-shell { width: min(100% - 28px, 520px); margin-top: 17px; }
  .demo-notice { align-items: flex-start; padding: 12px; }
  .notice-copy { line-height: 1.55; }
  .login-panel { grid-template-columns: 1fr; gap: 22px; margin: 16px 0 28px; padding: 23px 19px 17px; }
  .login-copy h1 { font-size: 29px; }
  .dashboard-heading { align-items: center; margin: 27px 0 18px; }
  .dashboard-heading h1 { font-size: 28px; }
  .outline-button { min-height: 44px; padding: 0 11px; font-size: 11px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .summary-card { min-height: 82px; padding: 12px; }
  .summary-card strong { margin-top: 7px; font-size: 23px; }
  .farm-section, .pool-section, .alarm-section { margin-top: 27px; }
  .pool-grid { grid-template-columns: 1fr; gap: 9px; }
  .pool-card { padding: 14px 13px 13px 17px; }
  .telemetry-grid { gap: 4px; }
  .telemetry-item strong { font-size: 15px; }
  .freshness-legend { gap: 3px; font-size: 9px; }
  .alarm-row { grid-template-columns: 58px 1fr; gap: 8px; padding: 10px; }
  .alarm-time { grid-column: 2; }
  .legend-dot { width: 6px; height: 6px; margin-left: 5px; }
  .page-footer { margin-top: 30px; }
}
@media (max-width: 370px) {
  .masthead-right { gap: 7px; }
  .local-badge { gap: 5px; }
  .summary-card { padding: 10px; }
  .telemetry-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
