/* ============================================================
   HSR Seismic Monitoring Demo — design system (Lead owned)
   LIGHT THEME (white / paper-blue instrument console).
   Section-specific styles live in section1.css / section2.css / section3.css.
   ============================================================ */
:root {
  --bg-0: #eef3f9;
  --bg-1: #ffffff;
  --bg-2: #f7fafd;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-solid: #ffffff;
  --line: rgba(16, 64, 110, 0.16);
  --line-strong: rgba(11, 110, 180, 0.45);
  --line-soft: rgba(16, 64, 110, 0.09);
  --cyan: #0b76c9;
  --cyan-dim: #4b93b5;
  --teal: #0f9d8a;
  --blue: #0b76c9;
  --violet: #6a5acd;
  --amber: #c47a10;
  --red: #cf2f4b;
  --text: #10263d;
  --text-bright: #06182b;
  --dim: #5f7d97;
  --dim-2: #8fa7bc;
  --font-mono: "DejaVu Sans Mono", "Liberation Mono", "Nimbus Mono PS", monospace;
  --font-ui: "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Droid Sans Fallback", sans-serif;
  --font-num: "DejaVu Sans", "Liberation Sans", "Nimbus Sans", sans-serif;
  --h-top: 62px;
  --h-foot: 26px;
  --r: 2px;
  --glow: 0 1px 2px rgba(16, 64, 110, 0.08);
  --shadow-panel: 0 1px 2px rgba(16, 64, 110, 0.06), 0 4px 14px rgba(16, 64, 110, 0.05);
  --shadow-float: 0 6px 24px rgba(16, 64, 110, 0.14);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(16, 64, 110, 0.04); }
::-webkit-scrollbar-thumb { background: rgba(16, 64, 110, 0.20); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(16, 64, 110, 0.34); }

/* ---------- background layers ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(11, 118, 201, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 118, 201, 0.045) 1px, transparent 1px),
    radial-gradient(ellipse 90% 65% at 50% -15%, rgba(150, 200, 240, 0.35), transparent 72%);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.9), rgba(0,0,0,0.55));
}
.bg-vignette {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 55%, rgba(170, 200, 225, 0.16) 100%);
}
.scanlines { display: none; }

/* ---------- layout ---------- */
#app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-rows: var(--h-top) 1fr var(--h-foot);
  height: 100vh;
}
.topbar {
  display: flex; align-items: center; gap: 26px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfdff);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8), 0 2px 12px rgba(16, 64, 110, 0.06);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 330px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--blue); font-size: 17px; background: #f2f8fe;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  clip-path: polygon(0 0, 100% 0, 100% 72%, 72% 100%, 0 100%);
}
.brand-title { font-size: 17px; font-weight: 700; letter-spacing: 2px; color: var(--text-bright); }
.brand-sub { font-family: var(--font-mono); font-size: 9px; letter-spacing: 2.4px; color: var(--dim); margin-top: 1px; }

.nav { display: flex; align-items: stretch; gap: 6px; height: 100%; flex: 1; justify-content: center; }
.nav-btn {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: transparent; border: 1px solid transparent; border-bottom: none;
  padding: 0 20px; cursor: pointer; color: var(--dim);
  transition: color .18s, background .18s, border-color .18s;
}
.nav-btn::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: transparent; }
.nav-btn:hover { color: var(--text); background: rgba(11, 118, 201, 0.05); }
.nav-btn.active { color: var(--blue); background: linear-gradient(180deg, rgba(11,118,201,0.02), rgba(11,118,201,0.08)); border-color: var(--line); }
.nav-btn.active::after { background: var(--blue); }
.nav-idx { font-family: var(--font-mono); font-size: 11px; color: var(--dim-2); border: 1px solid var(--line-soft); padding: 2px 5px; }
.nav-btn.active .nav-idx { color: var(--blue); border-color: var(--line-strong); background: #ffffff; }
.nav-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.nav-txt b { font-size: 14px; font-weight: 600; letter-spacing: 2.5px; }
.nav-txt i { font-style: normal; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 1.6px; color: var(--dim-2); }
.nav-btn.active .nav-txt i { color: var(--cyan-dim); }

.sysbar { display: flex; align-items: center; gap: 16px; font-family: var(--font-mono); font-size: 11px; color: var(--dim); }
.sys-item { display: flex; align-items: center; gap: 7px; }
.led { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--dim-2); }
.led-ok { background: var(--teal); box-shadow: 0 0 0 2px rgba(15, 157, 138, 0.16); animation: blink 2.2s infinite; }
.led-warn { background: var(--amber); box-shadow: 0 0 0 2px rgba(196, 122, 16, 0.16); }
.led-err { background: var(--red); box-shadow: 0 0 0 2px rgba(207, 47, 75, 0.16); }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
#clock-real { color: var(--text); font-size: 13px; letter-spacing: 1px; }

main { position: relative; min-height: 0; }
.section { position: absolute; inset: 0; display: none; }
.section.active { display: block; }
.section-root { position: absolute; inset: 0; padding: 12px 14px; overflow: hidden; }

.bottombar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-top: 1px solid var(--line);
  background: #ffffff;
  font-size: 10.5px; color: var(--dim);
}
.foot-left, .foot-right { display: flex; align-items: center; gap: 14px; }
.foot-item b { color: var(--blue); font-weight: 600; margin-right: 4px; }
.foot-sep { color: var(--dim-2); }

/* ---------- panels ---------- */
.panel {
  position: relative; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-panel);
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: rgba(11, 118, 201, 0.38); border-style: solid;
}
.panel::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.panel::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.panel-head {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px 6px;
  border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #f7fbfe, #fdfeff);
  flex: 0 0 auto;
}
.panel-title {
  font-size: 12px; letter-spacing: 2px; color: var(--text-bright); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.panel-title::before { content: ""; width: 3px; height: 12px; background: var(--blue); }
.panel-title em { font-style: normal; font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 1.6px; color: var(--dim-2); }
.panel-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-body { position: relative; flex: 1 1 auto; min-height: 0; padding: 8px 10px 10px; overflow: hidden; }
.panel-body.scroll { overflow-y: auto; }
.panel-note { font-size: 10px; color: var(--dim); }
.panel-canvas-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
.panel-canvas-wrap canvas, canvas.fill { display: block; width: 100%; height: 100%; }

/* ---------- text / metrics ---------- */
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.dim2 { color: var(--dim-2); }
.cyan { color: var(--blue); }
.teal { color: var(--teal); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.bright { color: var(--text-bright); }
.tiny { font-size: 10px; }
.small { font-size: 11px; }
.nowrap { white-space: nowrap; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.kpi {
  position: relative; padding: 8px 12px 9px;
  background: #ffffff;
  border: 1px solid var(--line-soft); border-left: 2px solid var(--blue);
  box-shadow: 0 1px 2px rgba(16,64,110,0.05);
}
.kpi-label { font-size: 10px; color: var(--dim); letter-spacing: 1px; text-transform: uppercase; }
.kpi-val { font-family: var(--font-num); font-size: 24px; font-weight: 600; color: var(--text-bright); line-height: 1.15; margin-top: 3px; }
.kpi-val u { text-decoration: none; font-size: 11px; color: var(--dim); margin-left: 4px; font-family: var(--font-mono); }
.kpi-sub { font-size: 10px; color: var(--dim-2); margin-top: 2px; font-family: var(--font-mono); }
.kpi.amber { border-left-color: var(--amber); } .kpi.amber .kpi-val { color: var(--amber); }
.kpi.red { border-left-color: var(--red); } .kpi.red .kpi-val { color: var(--red); }
.kpi.teal { border-left-color: var(--teal); }

/* ---------- badges / buttons / controls ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  padding: 2px 6px; border: 1px solid var(--line-soft); color: var(--dim); text-transform: uppercase;
  background: #f8fbfe;
}
.badge-ok { color: #0b7a6b; border-color: rgba(15,157,138,0.38); background: rgba(15,157,138,0.08); }
.badge-live { color: var(--blue); border-color: var(--line-strong); background: rgba(11,118,201,0.07); }
.badge-sim { color: var(--amber); border-color: rgba(196,122,16,0.42); background: rgba(196,122,16,0.08); }
.badge-warn { color: var(--amber); border-color: rgba(196,122,16,0.38); }
.badge-err { color: var(--red); border-color: rgba(207,47,75,0.4); background: rgba(207,47,75,0.07); }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 6px 14px; cursor: pointer;
  background: #f4faff; color: var(--blue);
  border: 1px solid #b9d4ea;
  font-size: 11px; letter-spacing: 1.5px;
  transition: all .16s;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%);
}
.btn:hover { background: #e6f3fd; border-color: var(--blue); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--blue); color: #ffffff; font-weight: 700; border-color: var(--blue); }
.btn.primary:hover { background: #0965ac; }
.btn.ghost { background: #ffffff; border-color: #d5e2ef; color: var(--dim); }
.btn.ghost:hover { color: var(--text); border-color: #b9d4ea; }
.btn.sm { padding: 3px 9px; font-size: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.seg { display: inline-flex; border: 1px solid #d5e2ef; background: #ffffff; }
.seg button {
  background: transparent; border: none; color: var(--dim); cursor: pointer;
  padding: 3px 9px; font-family: var(--font-mono); font-size: 10px; letter-spacing: .5px;
}
.seg button + button { border-left: 1px solid #e3edf6; }
.seg button.active { color: #ffffff; background: var(--blue); font-weight: 700; }
.seg button:not(.active):hover { color: var(--text); background: rgba(11,118,201,0.06); }

input[type="range"].range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: linear-gradient(90deg, #9fc9e8, #dbe9f5);
  outline: none; border-radius: 2px;
}
input[type="range"].range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px;
  background: #ffffff; border: 2px solid var(--blue); border-radius: 50%;
  box-shadow: 0 1px 3px rgba(16,64,110,0.25); cursor: pointer;
}
input[type="range"].range::-moz-range-thumb {
  width: 10px; height: 10px; background: #ffffff; border: 2px solid var(--blue);
  border-radius: 50%; box-shadow: 0 1px 3px rgba(16,64,110,0.25); cursor: pointer;
}

/* ---------- tables / logs ---------- */
.dtable { width: 100%; border-collapse: collapse; font-size: 10.5px; font-family: var(--font-mono); }
.dtable th { text-align: left; color: var(--dim); font-weight: 400; letter-spacing: 1px; padding: 3px 6px; border-bottom: 1px solid var(--line); font-size: 9.5px; }
.dtable td { padding: 3px 6px; border-bottom: 1px solid rgba(16,64,110,0.07); color: var(--text); }
.dtable tr:hover td { background: rgba(11,118,201,0.05); }
.log-list { font-family: var(--font-mono); font-size: 10px; display: flex; flex-direction: column; gap: 3px; }
.log-line { display: flex; gap: 6px; color: var(--dim); white-space: nowrap; }
.log-line .t { color: var(--dim-2); }
.log-line .tag { color: var(--blue); }
.log-line.ok .tag { color: var(--teal); }
.log-line.warn .tag { color: var(--amber); }

/* ---------- misc ---------- */
.divider { height: 1px; background: var(--line-soft); margin: 8px 0; flex: 0 0 auto; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.spacer { flex: 1 1 auto; }
.hidden { display: none !important; }
.center { display: grid; place-items: center; height: 100%; }
.module-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px; height: 100%;
  color: var(--dim); font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px;
}
.spin { width: 12px; height: 12px; border: 2px solid #cfe0ef; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%) translateY(20px);
  background: #ffffff; border: 1px solid var(--line-strong);
  color: var(--text); padding: 8px 16px; font-size: 11px; letter-spacing: 1px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 60;
  box-shadow: var(--shadow-float);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.err-banner {
  margin: 10px; padding: 10px 14px; border: 1px solid rgba(207,47,75,0.4);
  background: rgba(207,47,75,0.06); color: var(--red); font-family: var(--font-mono); font-size: 11px;
}
.scan-btn { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px; color: var(--dim); border: 1px solid #d5e2ef; background: #ffffff; padding: 2px 5px; cursor: pointer; }
.scan-btn:hover { color: var(--blue); border-color: var(--blue); }
.scan-btn.active { color: var(--blue); border-color: var(--blue); background: rgba(11,118,201,0.07); }

@media (max-width: 1500px) {
  .brand { min-width: 250px; }
  .brand-sub { display: none; }
  .nav-btn { padding: 0 12px; }
}
@media (max-width: 1200px) {
  .nav-txt i { display: none; }
  .sys-item.dim { display: none; }
}

/* ============================================================
   MOBILE LAYOUT (≤900px): one-column, vertical scroll
   Section-specific stacking lives in section1–4.css.
   ============================================================ */
@media (max-width: 900px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-text-size-adjust: 100%;
  }
  #app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* ---- top bar: brand + status row, tabs scroll horizontally ---- */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 8px 10px 6px;
  }
  .brand { min-width: 0; flex: 1 1 auto; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; font-size: 14px; }
  .brand-title { font-size: 14px; letter-spacing: 1px; }
  .brand-sub { display: none; }
  .sysbar {
    order: 2;
    margin-left: auto;
    gap: 8px;
    font-size: 9px;
    flex: 0 0 auto;
  }
  .sysbar .sys-item:nth-child(3) { display: none; }   /* 2406 · P320 · 100 Hz */
  #clock-real { font-size: 10px; letter-spacing: .5px; }
  .nav {
    order: 3;
    flex: 1 1 100%;
    height: auto;
    min-height: 0;
    justify-content: flex-start;
    gap: 4px;
    padding: 2px 0 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn {
    flex: 0 0 auto;
    padding: 6px 10px;
    gap: 6px;
    border: 1px solid transparent;
  }
  .nav-btn.active { border-color: var(--line); }
  .nav-idx { font-size: 9px; padding: 1px 4px; }
  .nav-txt b { font-size: 12px; letter-spacing: .5px; }
  .nav-txt i { display: none; }

  /* ---- main: natural document flow ---- */
  main { position: relative; min-height: 0; flex: 1 1 auto; }
  .section { position: static; display: none; }
  .section.active { display: block; }
  .section-root {
    position: static;
    inset: auto;
    height: auto;
    overflow: visible;
    padding: 8px 10px 16px;
  }

  /* ---- footer: compact, wrap ---- */
  .bottombar {
    position: static;
    height: auto;
    min-height: 0;
    flex-wrap: wrap;
    gap: 2px 10px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    font-size: 9px;
  }
  .foot-right { flex-wrap: wrap; gap: 6px; }
  .foot-hint, #foot-hint { display: none; }
  .foot-item.dim { display: none; }

  /* ---- shared components ---- */
  .panel-head { flex-wrap: wrap; gap: 4px 8px; padding: 6px 10px 5px; }
  .panel-title { font-size: 11px; letter-spacing: 1px; }
  .panel-title em { display: none; }
  .panel-tools { gap: 6px; flex-wrap: wrap; }
  .panel-body { padding: 6px 8px 8px; }
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .kpi { padding: 6px 8px 7px; }
  .kpi-val { font-size: 19px; }
  .kpi-sub { font-size: 9px; }
  .badge { font-size: 8px; padding: 1px 4px; letter-spacing: .5px; }
  .btn { min-height: 34px; padding: 6px 12px; font-size: 11px; }
  .btn.sm { min-height: 28px; padding: 4px 9px; }
  .seg button { min-height: 30px; padding: 4px 10px; font-size: 10px; }
  input[type="range"].range { height: 6px; }
  input[type="range"].range::-webkit-slider-thumb { width: 18px; height: 18px; }
  input[type="range"].range::-moz-range-thumb { width: 16px; height: 16px; }
  .toast {
    left: 10px; right: 10px; bottom: 14px;
    transform: translateY(20px);
    width: auto;
    text-align: center;
    font-size: 11px;
  }
  .toast.show { transform: translateY(0); }
  .err-banner { margin: 6px; font-size: 10px; }
  .dtable { font-size: 10px; }
  .log-list { font-size: 10px; }
}

@media (max-width: 420px) {
  .brand-title { font-size: 13px; letter-spacing: .5px; }
  .section-root { padding: 6px 8px 14px; }
  .kpi-val { font-size: 17px; }
}

/* integration: 02 的事件池过渡遮罩只做视觉提示，不要挡住顶部导航/点按 */
.s2-pooloverlay { pointer-events: none !important; }
