/* Aus index.html ausgelagert, damit die CSP "style-src 'self'" ohne
   'unsafe-inline' funktioniert. Keine style="..."-Attribute im Markup! */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a1a;
  color: #eee;
  margin: 0;
  padding: 2rem 1rem;
  min-height: 100vh;
}

/* ---------- Layout ---------- */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}
.token-card { grid-column: 1 / -1; }
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: #262626;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  min-width: 0;
}
h1 {
  font-size: 1.4rem;
  margin: 0 0 1.2rem 0;
  text-align: center;
}
h2 {
  font-size: 1.15rem;
  margin: 0 0 1.2rem 0;
}
h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: #ccc;
  margin: 1.6rem 0 0.6rem 0;
}
label {
  display: block;
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.4rem;
}
.token-hint {
  font-size: 0.75rem;
  color: #888;
  margin: 0.5rem 0 0 0;
}

/* ---------- Eingaben ---------- */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem;
  border-radius: 6px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #eee;
  font-size: 0.95rem;
}
input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #3cb371;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  cursor: pointer;
  user-select: none;
}
.checkbox-row input {
  width: auto;
  margin: 0;
  accent-color: #3cb371;
}
#urlRow { display: none; }
#urlRow.open { display: block; }
#urlList {
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.3rem;
}
.url-hint {
  font-size: 0.75rem;
  color: #888;
  margin: -0.2rem 0 0.8rem 0;
}
.url-input-row {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
input.url-input { flex: 1; }
.remove-url-btn {
  flex-shrink: 0;
  width: 2.2rem;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #888;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.remove-url-btn:hover:not(:disabled) {
  border-color: #f87171;
  color: #f87171;
}
.remove-url-btn:disabled {
  color: #444;
  cursor: not-allowed;
}
.remove-url-btn:disabled:hover { border-color: #444; }
#addUrlBtn {
  width: 100%;
  padding: 0.5rem;
  border: 1px dashed #555;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 1.2rem;
}
#addUrlBtn:hover:not(:disabled) {
  border-color: #3cb371;
  color: #3cb371;
}
#addUrlBtn:disabled { cursor: not-allowed; opacity: 0.5; }

/* Zeitraum-Auswahl 24h / 7d / 30d */
.range-select {
  border: none;
  padding: 0;
  margin: 0 0 1.2rem 0;
}
.range-select legend {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 0.4rem;
  padding: 0;
}
.range-options {
  display: inline-flex;
  border: 1px solid #444;
  border-radius: 6px;
  overflow: hidden;
}
.range-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.range-options label {
  margin: 0;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  color: #ccc;
  background: #1a1a1a;
  cursor: pointer;
  border-right: 1px solid #444;
}
.range-options label:last-of-type { border-right: none; }
.range-options input:checked + label {
  background: #3cb371;
  color: #fff;
}
.range-options input:focus-visible + label {
  outline: 2px solid #3cb371;
  outline-offset: -2px;
}

button.primary {
  width: 100%;
  padding: 0.8rem;
  border: none;
  border-radius: 6px;
  background: #3cb371;
  color: #ffffff;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
button.primary:hover:not(:disabled) { background: #45c47f; }
button.primary:disabled { background: #555; cursor: not-allowed; }

/* ---------- Meldungen ---------- */
.message {
  margin-top: 1rem;
  font-size: 0.9rem;
}
.message.simple { text-align: center; }
.success { color: #4ade80; }
.error { color: #f87171; }
.result-list {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  list-style: none;
  padding: 0;
}
.result-list li {
  padding: 0.3rem 0;
  border-bottom: 1px solid #333;
  word-break: break-all;
}
.result-list li:last-child { border-bottom: none; }

/* ---------- Statistik: Kennzahlen ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.kpi {
  background: #1f1f1f;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
}
.kpi-label {
  font-size: 0.75rem;
  color: #999;
}
.kpi-value {
  font-size: 1.35rem;
  font-weight: 600;
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  font-size: 0.72rem;
  color: #888;
  margin-top: 0.2rem;
}
.stats-meta {
  font-size: 0.75rem;
  color: #777;
  margin-top: 1.5rem;
}

/* ---------- Statistik: Charts ---------- */
.chart { min-height: 60px; }
.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.chart-empty {
  font-size: 0.85rem;
  color: #777;
  margin: 0.5rem 0;
}
.axis text {
  fill: #888;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.axis .grid {
  stroke: #333;
  stroke-width: 1;
}
path.line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
path.area { stroke: none; opacity: 0.18; }
rect.bar { stroke: none; }
/* Hover / Tooltip */
.chart { position: relative; }
.hover-catcher { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.crosshair { stroke: #888; stroke-width: 1; stroke-dasharray: 3 3; }
circle.dot { stroke: #262626; stroke-width: 2; }
.chart-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: #111;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}
.chart-tooltip-title {
  color: #aaa;
  margin-bottom: 0.3rem;
}
.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.5;
}
.chart-tooltip-label { color: #ccc; flex: 1; }
.chart-tooltip-value {
  font-weight: 600;
  margin-left: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.chart-tooltip-total {
  border-top: 1px solid #333;
  margin-top: 0.25rem;
  padding-top: 0.25rem;
}

/* Serienfarben */
.s-total     { stroke: #3cb371; fill: #3cb371; background: #3cb371; }
.s-origin    { stroke: #f59e0b; fill: #f59e0b; background: #f59e0b; }
.s-hitrate   { stroke: #60a5fa; fill: #60a5fa; background: #60a5fa; }
.s-requests  { stroke: #a78bfa; fill: #a78bfa; background: #a78bfa; }
.s-3xx       { stroke: #60a5fa; fill: #60a5fa; background: #60a5fa; }
.s-4xx       { stroke: #f59e0b; fill: #f59e0b; background: #f59e0b; }
.s-5xx       { stroke: #f87171; fill: #f87171; background: #f87171; }
.s-optimizer { stroke: #2dd4bf; fill: #2dd4bf; background: #2dd4bf; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.78rem;
  color: #aaa;
  margin-top: 0.4rem;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* Horizontale Balken (Regionen) */
.hbar-list {
  display: grid;
  gap: 0.45rem;
}
.hbar-row {
  display: grid;
  grid-template-columns: minmax(90px, 200px) 1fr 5.5rem;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.8rem;
}
.hbar-label {
  color: #ccc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hbar-track {
  height: 10px;
  background: #1f1f1f;
  border-radius: 3px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  background: #3cb371;
}
.hbar-value {
  color: #999;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
