:root {
  --bg: #17212b;
  --text: #ffffff;
  --hint: #708499;
  --accent: #5288c1;
  --secondary: #232e3c;
  --border: rgba(112, 132, 153, 0.25);
  --ok: #4fae4e;
  --warn: #e5a845;
  --bad: #e05252;
  --btn: #5288c1;
  --btn-text: #ffffff;
  --touch: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

#header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 10px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.demo-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--warn);
  color: #1a1a1a;
}

.live-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--ok);
  color: #0a1a0a;
  white-space: nowrap;
}

.live-badge.live-stale {
  background: var(--warn);
  color: #1a1a1a;
}

.error-banner {
  background: rgba(224, 82, 82, 0.15);
  border: 1px solid rgba(224, 82, 82, 0.45);
  color: var(--bad);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 14px;
}

.stale-data {
  opacity: 0.55;
}

.chart-placeholder {
  color: var(--hint);
  font-size: 0.85rem;
  padding: 24px 12px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

#main {
  flex: 1;
  padding: 12px 16px calc(var(--touch) + 16px + var(--safe-b));
}

#tabs {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--secondary);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}

.tab-btn {
  flex: 1;
  min-height: var(--touch);
  border: 0;
  background: transparent;
  color: var(--hint);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.verdict-band {
  border-radius: 12px;
  padding: 18px 16px;
  margin-bottom: 16px;
  text-align: center;
}

.verdict-ok {
  background: rgba(79, 174, 78, 0.15);
  border: 1px solid rgba(79, 174, 78, 0.35);
}

.verdict-main {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.verdict-sub {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--hint);
}

.chain-view {
  margin-bottom: 20px;
  padding: 16px 12px;
  background: var(--secondary);
  border-radius: 12px;
}

.chain-nodes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.chain-node {
  flex: 0 0 auto;
  min-width: 56px;
  text-align: center;
}

.node-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 8px 6px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.chain-seg {
  flex: 1 1 auto;
  min-width: 48px;
  text-align: center;
  position: relative;
  padding: 0 2px;
}

.chain-seg::before {
  content: '';
  display: block;
  height: 3px;
  background: var(--ok);
  border-radius: 2px;
  margin: 10px 0 6px;
}

.chain-seg-bad::before {
  background: transparent;
  border-top: 3px dashed var(--bad);
}

.seg-ms {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--ok);
}

.chain-seg-bad .seg-ms {
  color: var(--bad);
}

.seg-reason {
  display: block;
  font-size: 0.62rem;
  color: var(--bad);
  margin-top: 2px;
}

.chain-caption {
  margin: 12px 0 0;
  font-size: 0.72rem;
  color: var(--hint);
  word-break: break-word;
}

.chain-incident-note {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--warn);
}

  display: flex;
  flex-direction: column;
  gap: 12px;
}

.host-tile {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--secondary);
  color: inherit;
  padding: 12px 14px;
  cursor: pointer;
  font: inherit;
  min-height: var(--touch);
}

.tile-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.tile-name {
  font-weight: 600;
}

.tile-role {
  font-size: 0.75rem;
  color: var(--hint);
}

.metric-row {
  display: grid;
  grid-template-columns: 52px 1fr 80px;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 0.82rem;
}

.metric-label {
  color: var(--hint);
}

.metric-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.trend {
  font-size: 0.75rem;
  opacity: 0.8;
}

.metric-spark {
  display: block;
  height: 24px;
}

.tile-uptime {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--hint);
}

.host-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.host-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--secondary);
  color: inherit;
  padding: 14px 16px;
  cursor: pointer;
  font: inherit;
  min-height: var(--touch);
}

.host-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.host-card-name {
  font-weight: 600;
  font-size: 1rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-up {
  background: var(--ok);
}

.status-down {
  background: var(--bad);
}

.host-card-meta {
  font-size: 0.8rem;
  color: var(--hint);
  margin-top: 4px;
}

.host-detail-head {
  margin-bottom: 12px;
}

.host-detail-role,
.host-detail-ip,
.host-detail-xray {
  margin: 0 0 4px;
  font-size: 0.85rem;
  color: var(--hint);
}

.range-picker {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.range-btn {
  flex: 1;
  min-height: var(--touch);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--secondary);
  color: var(--hint);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.range-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(82, 136, 193, 0.12);
}

.chart-block {
  margin-bottom: 16px;
}

.chart-wrap {
  background: var(--secondary);
  border-radius: 10px;
  padding: 8px 8px 4px;
  border: 1px solid var(--border);
}

.chart-readout {
  font-size: 0.75rem;
  color: var(--hint);
  min-height: 1.2em;
  margin-bottom: 4px;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

.chart-svg-box {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.line-chart {
  width: 100%;
  min-width: 280px;
  height: 200px;
  display: block;
}

.chart-axis {
  fill: var(--hint);
  font-size: 9px;
}

.detail-section {
  margin-top: 20px;
}

.section-title {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 280px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--hint);
  font-weight: 500;
  background: rgba(0, 0, 0, 0.15);
}

.empty-note {
  color: var(--hint);
  font-size: 0.85rem;
}

.demo-banner {
  background: rgba(229, 168, 69, 0.15);
  border: 1px solid rgba(229, 168, 69, 0.4);
  color: var(--warn);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 14px;
}

.dpi-verdict-card {
  background: var(--secondary);
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.dpi-verdict-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ok);
}

.dpi-verdict-conf {
  font-size: 0.8rem;
  color: var(--hint);
  margin-top: 4px;
}

.evidence-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.evidence-row {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  align-items: center;
}

.ev-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  grid-row: span 2;
}

.ev-dot.pass {
  background: var(--ok);
}

.ev-dot.fail {
  background: var(--bad);
}

.ev-name {
  font-weight: 500;
}

.ev-val {
  color: var(--hint);
  font-size: 0.78rem;
}

.ev-age {
  grid-column: 3;
  grid-row: span 2;
  font-size: 0.72rem;
  color: var(--hint);
  text-align: right;
}

.canary-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0;
}

.canary-cell {
  flex: 0 0 10px;
  width: 10px;
  height: 28px;
  border-radius: 2px;
}

.canary-ok {
  background: var(--ok);
}

.canary-warn {
  background: var(--warn);
}

.canary-fail {
  background: var(--bad);
}

.strip-legend {
  margin: 8px 0 0;
  font-size: 0.72rem;
  color: var(--hint);
}

.strip-legend .leg {
  margin-right: 12px;
}

.strip-legend .leg::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}

.strip-legend .ok::before {
  background: var(--ok);
}

.strip-legend .warn::before {
  background: var(--warn);
}

.strip-legend .fail::before {
  background: var(--bad);
}

.action-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--hint);
  opacity: 0.65;
  cursor: not-allowed;
  font: inherit;
  min-height: var(--touch);
}

.action-title {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.action-blast {
  display: block;
  font-size: 0.75rem;
  margin-top: 4px;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.log-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.log-dot {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--hint);
}

.log-info .log-dot {
  background: var(--accent);
}

.log-warn .log-dot {
  background: var(--warn);
}

.log-critical .log-dot {
  background: var(--bad);
}

.log-meta {
  font-size: 0.72rem;
  color: var(--hint);
}

.log-msg {
  font-size: 0.88rem;
  margin-top: 2px;
}

.log-host {
  color: var(--accent);
}

.noscript-banner {
  background: var(--bad);
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
}
