/* =========================
   Base
   ========================= */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  overflow-x: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Page container */
.page {
  width: 100%;
  max-width: 1100px;
  margin-inline: auto;
  padding-inline: clamp(8px, 2vw, 20px);
  padding-block: 12px;
}

.page-title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: clamp(1.25rem, 1.2vw + 1rem, 2rem);
}

.section-title { margin: 14px 0; font-size: clamp(1rem, 1vw + 0.9rem, 1.4rem); }

/* =========================
   Controls
   ========================= */
.control-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  flex-wrap: wrap;            /* allow wrapping of children */
}

.label { font-size: clamp(0.85rem, 0.5vw + 0.7rem, 1rem); }

.num-input {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  min-width: 90px;
}

/* --- Preset buttons strip --- */
#window-preset-boxes {
  display: flex;              /* keep in a row */
  flex-wrap: wrap;            /* wrap onto new lines on small widths */
  gap: 8px;                   /* use gap instead of per-box margins */
  max-width: 100%;
  min-width: 0;               /* prevents flex overflow in iOS Safari */
}

.window-preset-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  background: #f7f7fa;
  font-weight: 600;
  font-size: 1rem;
  color: #222;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.window-preset-box:hover { background: #e9f1fb; border-color: #bcdffb; }

.window-preset-box.selected {
  background: #e0e0e0;
  color: #222;
  border-color: #bdbdbd;
  box-shadow: 0 2px 8px rgba(160,160,160,0.08);
}

.window-preset-box:active { background: #1765c1; color: #fff; border-color: #1765c1; }

/* Make the preset strip take a full row on phones so it can wrap cleanly */
@media (max-width: 600px) {
  #summary-controls {
    flex-direction: column;         /* stack "Data as of" above the buttons */
    align-items: stretch;           /* let children fill width */
    gap: 10px;
  }

  #window-preset-boxes {
    width: 100%;
    justify-content: flex-start;    /* start at left, then wrap */
    gap: 8px;
  }

  .window-preset-box {
    padding: 6px 12px;
    font-size: 0.95rem;
    white-space: nowrap;            /* keep labels on one line */
  }

  #window-custom {
    max-width: 160px;
  }
}

/* =========================
   Tabs
   ========================= */
.tabs { margin-top: 6px; overflow-x: auto; }
.tab-item {
  display: inline-block;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  font-size: clamp(0.85rem, 0.6vw + 0.7rem, 1rem);
}
.tab-item--selected { border-bottom-color: #1a73e8; font-weight: 600; }

/* =========================
   Cards
   ========================= */
.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-card {
  flex: 1 1 240px;  /* minimum width ~240px, then grow */
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.stat-title { margin: 0 0 6px; font-size: clamp(0.8rem, 0.6vw + 0.65rem, 1rem); color: #333; }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stat-value { font-weight: 700; letter-spacing: 0.2px; font-size: clamp(1.1rem, 1.2vw + 0.9rem, 2rem); }
.stat-change { margin-left: 8px; font-weight: 600; font-size: clamp(0.8rem, 0.7vw + 0.6rem, 1rem); }
.stat-change.up { color: #137333; }
.stat-change.down { color: #c5221f; }

/* Mobile tweaks for cards */
@media (max-width: 768px) {
  .stat-card { flex: 1 1 160px; padding: 10px; border-radius: 10px; }
}

@media (max-width: 480px) {
  .stat-card { flex: 1 1 140px; }
  .tab-item { padding: 8px 10px; }
}

/* =========================
   Graphs
   ========================= */
.graph { height: 60vh; min-height: 320px; width: 100%; }
@media (max-width: 768px) {
  .graph { height: 52vh; min-height: 300px; }
}


/* Hide Plotly modebar on all graphs.. this made mobile look pretty bad and i never use these buttons anyways. */
.js-plotly-plot .modebar, .modebar {
  display: none !important;
}
