:root {
  --bg: #0b0f14;
  --panel: #111822;
  --text: #e6edf3;
  --muted: #a9b4c0;
  --primary: #f0b90b;
  --accent: #50c878; /* emerald */
  --danger: #e5534b;
  --border: #1d2633;
}

* { box-sizing: border-box; }
html, body { min-height: 100dvh; height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft Yahei", Arial, sans-serif;
  background: linear-gradient(180deg, #0b0f14 0%, #0c1117 100%);
  color: var(--text);
  /* Respect iOS notch/status bar safe area */
  padding-top: calc(12px + constant(safe-area-inset-top));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}

.container { max-width: 1080px; margin: 0 auto; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
header h1 { margin: 4px 0 0; font-size: 22px; font-weight: 600; }
.app-header .brand { display: flex; align-items: center; gap: 10px; }
.app-logo { width: 28px; height: 28px; border-radius: 6px; flex: 0 0 28px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}


.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.row.actions { margin-top: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select {
  background: #0e141b;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  border-radius: 8px;
  min-width: 140px;
}

button {
  background: var(--primary);
  color: #141414;
  border: none;
  padding: 10px 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}
button:hover { filter: brightness(0.95); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: #0e141b; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { margin-top: 6px; font-size: 18px; font-weight: 600; }
.stat .value.primary { color: var(--accent); font-size: 22px; }
.stat .value.primary.big { font-size: 28px; }

.chart { width: 100%; height: clamp(280px, 42vh, 460px); }

.range-tabs { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--border); padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
.range-tabs {
  display: flex;
  justify-content: space-around;
  gap: 8px;
  margin-top: 8px;
}
.range-tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 10px 10px;
  font-weight: 600;
  cursor: pointer;
  min-width: 64px;
  line-height: 40px;
  font-size: 15px;
}
.range-tabs button.active {
  color: var(--text);
  border-bottom: 2px solid var(--text);
}

.footer { color: var(--muted); font-size: 12px; text-align: center; padding-bottom: 20px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .chart { height: clamp(260px, 40vh, 340px); }
  .field input, .field select { min-width: 0; width: 100%; }
  button { width: 100%; margin-top: 6px; }
  .range-tabs button { width: auto !important; margin-top: 0; }
}

@media (max-width: 420px) {
  .chart { height: 300px; }
}
/* muted text */
.muted { color: var(--muted); }
/* mobile tap highlight disable */
* { -webkit-tap-highlight-color: rgba(0,0,0,0); }
