/* ============================================================
   面团发酵环境监测 · 样式表
   深色玻璃拟态风格，纯 CSS 绘制，图标全部为内联 SVG
   ============================================================ */

:root {
  --bg:        #070b13;
  --bg-2:      #0a1120;
  --panel:     rgba(255, 255, 255, 0.042);
  --panel-2:   rgba(255, 255, 255, 0.072);
  --line:      rgba(255, 255, 255, 0.088);
  --line-soft: rgba(255, 255, 255, 0.05);
  --tx:        #e9eef8;
  --tx-2:      #a8b5ca;
  --tx-3:      #71809a;
  --accent:    #38d9a9;
  --radius:    18px;
  --shadow:    0 18px 40px -24px rgba(0, 0, 0, 0.9);
}

* { box-sizing: border-box; }

button, .btn, .seg button, .icon-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 背景光晕，营造纵深 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 520px at 12% -8%,  rgba(56, 217, 169, 0.16), transparent 62%),
    radial-gradient(820px 500px at 92% -6%,  rgba(79, 140, 255, 0.16), transparent 60%),
    radial-gradient(760px 620px at 78% 108%, rgba(160, 107, 255, 0.13), transparent 62%),
    linear-gradient(180deg, #080d17 0%, #070b13 42%, #060a11 100%);
  pointer-events: none;
}

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 保证 hidden 属性始终生效（否则 .btn 等 display 会覆盖它） */
[hidden] { display: none !important; }

.ico {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.ico.sm { width: 15px; height: 15px; stroke-width: 1.8; }

.wrap {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 26px;
}

/* ==================== 顶栏 ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7, 11, 19, 0.74);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 13px;
  color: #04140f;
  background: linear-gradient(140deg, #4ef0bd 0%, #22b8f0 100%);
  box-shadow: 0 10px 26px -12px rgba(56, 217, 169, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.brand-mark .ico { width: 25px; height: 25px; stroke-width: 1.9; }
.brand-text h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand-text p {
  margin: 1px 0 0;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--tx-3);
}

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--tx-2);
  font-size: 12.5px;
  white-space: nowrap;
}
.pill .ico { color: var(--tx-3); }
.pill .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 217, 169, 0.16);
  animation: pulse 2.4s ease-in-out infinite;
}
.pill.offline .dot { background: #ff8a5c; box-shadow: 0 0 0 3px rgba(255, 138, 92, 0.16); animation: none; }
.pill.demo .dot { background: #ffd166; box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.16); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(0.82); }
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--tx-3);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 13px;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}
.seg button:hover { color: var(--tx); background: var(--panel-2); }
.seg button.on {
  color: #7df3c8;
  background: rgba(56, 217, 169, 0.14);
  box-shadow: inset 0 0 0 1px rgba(56, 217, 169, 0.28);
}

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--tx-2);
  cursor: pointer;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}
.icon-btn:hover { color: var(--tx); background: var(--panel-2); border-color: rgba(255, 255, 255, 0.16); }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; }
.icon-btn.sm .ico { width: 15px; height: 15px; }
.icon-btn.spin .ico { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 主区域 ==================== */
main.wrap { padding-top: 26px; }

/* ---------- KPI 卡片 ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.kpi {
  position: relative;
  overflow: hidden;
  padding: 17px 19px 14px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.kpi::after {
  content: "";
  position: absolute;
  right: -46px; top: -58px;
  width: 150px; height: 150px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--c-soft), transparent 68%);
  pointer-events: none;
}
.kpi-top { display: flex; align-items: center; gap: 10px; }
.kpi-ico {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  color: var(--c);
  background: var(--c-soft);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.045);
}
.kpi-ico .ico { width: 20px; height: 20px; }
.kpi-label { font-size: 13px; color: var(--tx-2); letter-spacing: 0.3px; }
.kpi-unit { margin-left: auto; font-size: 11.5px; color: var(--tx-3); }

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 12px 0 10px;
}
.kpi-value b {
  font-size: 31px;
  font-weight: 680;
  letter-spacing: -0.7px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.kpi-value span { font-size: 12px; color: var(--tx-3); }

.kpi-foot { display: flex; align-items: flex-end; gap: 10px; }
.spark { flex: 1 1 auto; height: 30px; min-width: 0; }
.spark svg { display: block; width: 100%; height: 30px; overflow: visible; }
.kpi-range { font-size: 11px; color: var(--tx-3); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- 图表区 ---------- */
.charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.card {
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.052), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.chart-card { padding: 16px 18px 8px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.card-head > div { min-width: 0; }
.card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.35;
  border-left: 3px solid var(--c, var(--accent));
  padding-left: 10px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-head h3 .t-tail { white-space: nowrap; }
.card-head p { margin: 3px 0 0 13px; font-size: 11.5px; color: var(--tx-3); letter-spacing: 0.4px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  color: var(--tx-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--accent)); }

.chart { position: relative; height: 258px; }
.chart svg, .modal-chart svg { display: block; width: 100%; height: 100%; }
.chart text, .modal-chart text { fill: var(--tx-3); font-size: 11px; font-family: inherit; }
.chart .grid-line, .modal-chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-line, .modal-chart .axis-line { stroke: rgba(255, 255, 255, 0.13); stroke-width: 1; }
.chart .crosshair, .modal-chart .crosshair { stroke: rgba(255, 255, 255, 0.28); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .empty-note, .modal-chart .empty-note { fill: var(--tx-3); font-size: 12px; }

.chart-tip {
  position: absolute;
  left: 0; top: 0;
  z-index: 4;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(10, 16, 27, 0.96);
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px -14px #000;
  font-size: 12px;
  color: var(--tx);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -128%);
  transition: opacity 0.12s;
}
.chart-tip.on { opacity: 1; }
.chart-tip .t-time { color: var(--tx-3); font-size: 11px; display: block; margin-bottom: 2px; }
.chart-tip .t-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-tip .t-val em { font-style: normal; color: var(--tx-3); font-weight: 400; margin-left: 3px; font-size: 11px; }

/* ---------- 表格 ---------- */
.table-card { padding: 16px 4px 6px; margin-bottom: 18px; }
.table-card .card-head { padding: 0 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  height: 32px;
  padding: 0 13px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--tx-2);
  text-decoration: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: color 0.18s, background 0.18s, border-color 0.18s;
}
.btn:hover { color: var(--tx); background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.18); }

.table-wrap { overflow-x: auto; padding: 0 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.6px;
  color: var(--tx-3);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th .u { color: var(--tx-3); opacity: 0.72; font-size: 10.5px; font-weight: 400; }
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--tx-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--panel-2); }
tbody td:first-child { color: var(--tx); }
th.num, td.num { text-align: right; }
td.empty { text-align: center; color: var(--tx-3); padding: 26px 0; }
.dot-mini { display: inline-block; margin-right: 7px; vertical-align: 1px; }

/* ---------- 系统信息条 ---------- */
.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 30px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
}
.meta-item { display: inline-flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--tx-3); }
.meta-item .ico { color: var(--tx-3); opacity: 0.9; }
.meta-item b { color: var(--tx-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 页脚 ---------- */
.foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 26px;
  padding-bottom: 40px;
  font-size: 12px;
  color: var(--tx-3);
}
.foot .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--tx-3); opacity: 0.6; }

/* ==================== 图表放大弹层 ==================== */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 100; display: none; }
.modal.on { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fade 0.16s ease;
}
.modal-panel {
  position: relative;
  margin: 5vh auto;
  width: min(1080px, 92vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #0d1626, #0a1220);
  box-shadow: 0 40px 90px -40px #000;
  animation: pop 0.18s ease;
}
.modal-head { margin-bottom: 4px; }
.modal-chart { position: relative; height: min(56vh, 440px); margin-top: 8px; }
.modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line-soft);
  font-size: 12.5px;
  color: var(--tx-3);
}
.modal-stats b { color: var(--tx); font-weight: 600; font-variant-numeric: tabular-nums; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* ==================== 响应式 ==================== */

/* 中屏：图表转单列 */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts { grid-template-columns: minmax(0, 1fr); }
}

/* 手机与窄屏 */
@media (max-width: 720px) {
  .wrap { padding: 0 16px; }

  /* 顶栏：第一行 品牌 + 状态 + 刷新，第二行时间范围整行等分 */
  .topbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "brand pill refresh"
      "seg   seg  seg";
    align-items: center;
    gap: 9px 8px;
    min-height: 0;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .topbar-right { display: contents; }
  .brand { grid-area: brand; gap: 10px; min-width: 0; }
  .brand-mark { width: 38px; height: 38px; border-radius: 11px; }
  .brand-mark .ico { width: 21px; height: 21px; }
  .brand-text { min-width: 0; }
  .brand-text h1 { font-size: 16.5px; overflow: hidden; text-overflow: ellipsis; }
  .brand-text p { font-size: 9.5px; letter-spacing: 1.2px; }
  .pill {
    grid-area: pill;
    justify-self: end;
    height: 34px;
    padding: 0 11px;
    font-size: 11.5px;
    white-space: nowrap;
  }
  .pill .ico { display: none; }
  .pill span { white-space: nowrap; }
  #refreshBtn { grid-area: refresh; width: 34px; height: 34px; }
  /* 只影响顶栏里的分段控件，别误伤播放器等处的 .seg */
  .topbar .seg {
    grid-area: seg;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    width: 100%;
  }
  .topbar .seg button { padding: 7px 4px; font-size: 12px; min-height: 32px; text-align: center; }

  main.wrap { padding-top: 16px; }

  /* KPI：手机上双列，信息密度更高 */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px 11px; border-radius: 15px; }
  .kpi-top { gap: 8px; }
  .kpi-ico { width: 30px; height: 30px; border-radius: 9px; }
  .kpi-ico .ico { width: 17px; height: 17px; }
  .kpi-label { font-size: 12.5px; }
  .kpi-value { margin: 9px 0 8px; gap: 4px; }
  .kpi-value b { font-size: 24px; letter-spacing: -0.5px; }
  .kpi-value span { font-size: 11px; }
  .spark { height: 24px; }
  .spark svg { height: 24px; }

  /* 图表：矮一点，横向刻度自动减到 3~4 个 */
  .charts { gap: 12px; }
  .chart-card { padding: 14px 12px 6px; }
  .card-head h3 { font-size: 13.5px; }
  .card-head p { font-size: 11px; margin-left: 13px; }
  .chart { height: 208px; }
  .chart text { font-size: 10.5px; }
  .badge { height: 24px; padding: 0 9px; font-size: 11px; }
  .card-tools { gap: 6px; }
  .icon-btn.sm { width: 28px; height: 28px; border-radius: 8px; }

  /* 表格：手机上改成卡片流，不再横向滚动 */
  .table-card { padding: 14px 12px 8px; }
  .table-card .card-head { padding: 0 4px; }
  .table-wrap { padding: 0; overflow: visible; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    padding: 11px 13px 12px;
    margin-top: 8px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.038);
    border: 1px solid var(--line-soft);
  }
  tbody tr:hover { background: rgba(255, 255, 255, 0.06); }
  tbody td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
    border: 0;
    font-size: 13.5px;
  }
  tbody td::before {
    content: attr(data-label);
    color: var(--tx-3);
    font-size: 11.5px;
    letter-spacing: 0.2px;
  }
  tbody tr td:first-child {
    grid-column: 1 / -1;
    padding: 0 0 7px;
    margin-bottom: 4px;
    border-bottom: 1px dashed var(--line);
    font-size: 12px;
    color: var(--tx-2);
    font-variant-numeric: tabular-nums;
  }
  tbody tr td:first-child::before { content: none; }
  th.num, td.num { text-align: left; }
  td.empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 24px 0;
    display: block;
  }
  td.empty::before { content: none; }

  /* 系统信息：两列 */
  .meta-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
    padding: 13px 14px;
  }
  .meta-item { font-size: 11.5px; gap: 7px; }
  .meta-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .foot {
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 20px;
    padding-bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  }

  /* 弹层全屏化：图表弹性撑满剩余高度，手指看曲线更清楚 */
  .modal-panel {
    margin: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: 0;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .modal-chart { height: auto; flex: 1 1 auto; min-height: 0; margin-bottom: 6px; }
  .modal-stats { gap: 8px 18px; font-size: 12px; }
}

/* 小屏：优先保留中文主标题，去掉装饰用的英文副标题 */
@media (max-width: 470px) {
  .brand-text p { display: none; }
  /* 图表标题允许在"主题"与"消息监控"之间折行，避免被截断 */
  .card-head h3 { white-space: normal; }
}

/* 超小屏（≤360） */
@media (max-width: 380px) {
  .kpi-range { display: none; }
  .kpi-value b { font-size: 21px; }
  .topbar .seg button { padding: 7px 8px; }
  .chart { height: 190px; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark .ico { width: 18px; height: 18px; }
  .brand-text h1 { font-size: 15px; }
  .pill { font-size: 11px; padding: 0 9px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ==================== 桌面端页面导航 ==================== */
.pagenav {
  display: flex;
  gap: 3px;
  margin-left: 10px;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.pagenav a {
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 13px;
  color: var(--tx-3);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}
.pagenav a:hover { color: var(--tx); background: var(--panel-2); }
.pagenav a.on {
  color: #7df3c8;
  background: rgba(56, 217, 169, 0.14);
  box-shadow: inset 0 0 0 1px rgba(56, 217, 169, 0.28);
}

/* ==================== 手机端底部标签栏 ==================== */
.tabbar { display: none; }

@media (max-width: 720px) {
  .pagenav { display: none; }
  body { padding-bottom: 60px; }
  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 70;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(8, 13, 22, 0.93);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tabbar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 9px 0 8px;
    font-size: 11px;
    color: var(--tx-3);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar a .ico { width: 20px; height: 20px; }
  .tabbar a.on { color: #7df3c8; }
}
