:root {
  --bg: #f5f5f7;
  --text: #1d1d1f;
  --secondary: #86868b;
  --accent: #0071e3;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 2px 24px rgba(0, 0, 0, 0.06);
  --border: #d2d2d7;
  --radius: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; touch-action: manipulation; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px;
  -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: 640px; }
.header { position: relative; text-align: center; margin-bottom: 32px; padding-top: 32px; }
.header-actions { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; }
.header-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--secondary); padding: 8px 12px; border: 1px solid rgba(0, 0, 0, 0.06); background: rgba(255, 255, 255, 0.7); border-radius: 999px; }
.header-link svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lang-switch { position: absolute; top: 0; right: 0; display: flex; gap: 4px; }
.lang-btn { border: none; background: transparent; color: var(--secondary); font: inherit; font-size: 12px; font-weight: 500; padding: 4px 8px; border-radius: 6px; cursor: pointer; transition: all 0.15s; }
.lang-btn:hover { color: var(--text); background: rgba(0, 0, 0, 0.04); }
.lang-btn.active { color: var(--accent); background: rgba(0, 113, 227, 0.08); }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.logo {
  display: inline-block;
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #0071e3, #5e9eff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
}

h1 { font-size: 22px; font-weight: 600; margin-top: 12px; letter-spacing: -0.3px; }
.subtitle { color: var(--secondary); font-size: 15px; margin-top: 6px; letter-spacing: 0.2px; line-height: 1.6; }
.update-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px 16px; }
.update-controls { display: flex; align-items: center; gap: 16px; }
.refresh-control { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--secondary); white-space: nowrap; }
.connection { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.connection-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; background: #ff9500; }
.connection[data-state="checking"] .connection-dot { background: var(--secondary); }
.connection[data-state="live"] .connection-dot { background: #34c759; }
.connection[data-state="error"] .connection-dot { background: #ff3b30; }
.updated { color: var(--secondary); font-size: 12px; text-align: right; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--card-shadow);
  min-width: 0;
}

.card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: rgba(0, 113, 227, 0.07); color: var(--accent); flex-shrink: 0; }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
h2 { font-size: 16px; font-weight: 600; }
.card-label { margin-left: auto; font-size: 11px; color: var(--secondary); }
.metric-value { font-size: 40px; font-weight: 600; line-height: 1.1; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.meter { height: 6px; background: rgba(0, 0, 0, 0.05); border-radius: 3px; overflow: hidden; margin: 20px 0 12px; }
.meter span { display: block; height: 100%; width: 0%; background: var(--accent); border-radius: inherit; transition: width 0.4s ease; }
.meter[data-high="true"] span { background: #ff9500; }
.metric-detail { font-size: 12px; color: var(--secondary); line-height: 1.65; min-height: 20px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.network-speeds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.direction { color: var(--secondary); font-size: 12px; margin-bottom: 6px; }
.network-value { font-size: 23px; font-weight: 600; letter-spacing: -0.5px; line-height: 1.4; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.network-total { margin-top: 23px; }
.page-footer { text-align: center; margin-top: 20px; font-size: 13px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; border-radius: 4px; }
.noscript { text-align: center; margin-top: 20px; color: #b47800; font-size: 14px; }
.history { margin-top: 36px; }
.history-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 0 4px 12px; }
.history-controls { display: flex; gap: 12px; }
.history-controls label { display: flex; align-items: center; gap: 7px; color: var(--secondary); font-size: 12px; }
.history-controls select, .refresh-control select { max-width: 170px; border: 1px solid var(--border); border-radius: 8px; padding: 8px; background: white; color: var(--text); font: inherit; }
.history-controls select:focus-visible, .refresh-control select:focus-visible, .history-inspector input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.history-state { font-size: 12px; color: var(--secondary); min-height: 20px; margin: 0 4px 12px; line-height: 1.65; }
.history-state[data-state="error"] { color: #b47800; }
.chart-card { margin-top: 16px; padding: 22px 18px 18px; }
.chart-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 6px 12px; }
.chart-heading h3 { font-size: 14px; font-weight: 600; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--secondary); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend span::before { content: ''; height: 3px; width: 11px; border-radius: 2px; background: var(--accent); }
.chart-legend .memory::before { background: #8b5cf6; }
.chart-legend .disk::before { background: #16a085; }
.chart-legend .send::before { background: #e28723; }
.chart { min-height: 140px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: #eeeeF2; stroke-width: 1; }
.chart-axis { fill: #86868b; font-size: 11px; font-family: var(--font); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-cursor { stroke: #b9bdc5; stroke-width: 1; stroke-dasharray: 4 4; }
.chart-empty { display: flex; min-height: 168px; align-items: center; justify-content: center; color: var(--secondary); font-size: 13px; text-align: center; padding: 16px; }
.chart-tooltip { color: var(--secondary); min-height: 36px; font-size: 11px; font-variant-numeric: tabular-nums; line-height: 1.7; margin: 4px 6px 0; overflow-wrap: anywhere; }
.history-inspector { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--secondary); margin: 18px 6px 0; }
.history-inspector[hidden] { display: none; }
.history-inspector input { min-width: 0; flex: 1; accent-color: var(--accent); }

@media (max-width: 540px) {
  body { padding: 20px 16px; }
  .header { margin-bottom: 26px; }
  .metrics { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .card { padding: 22px; }
  .update-bar { align-items: flex-start; flex-wrap: wrap; }
  .update-controls { flex-direction: column; align-items: flex-end; gap: 6px; margin-left: auto; }
  .updated { line-height: 1.5; }
  .history-heading { align-items: flex-start; }
  .history-controls { width: 100%; gap: 10px; }
  .history-controls label { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; }
  .history-controls select { width: 100%; max-width: none; }
  .chart-card { padding: 18px 10px 14px; }
  .chart { min-height: 115px; }
}

@media (prefers-reduced-motion: reduce) {
  .meter span { transition: none; }
}
