/* ===================================================================
   myPrepaid-Server Speedtest — Design System
   Modernes, aufgeraeumtes UI · Dark/Light · responsive
   =================================================================== */

:root {
  --brand-1: #0099ff;
  --brand-2: #00d4ff;
  --brand-grad: linear-gradient(135deg, #0099ff 0%, #00d4ff 100%);

  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;

  --radius: 18px;
  --radius-sm: 12px;
  --gap: 20px;
  --maxw: 1080px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(0, 153, 255, .28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --trans: .25s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- Dark (default) ---------- */
:root,
:root[data-theme="dark"] {
  --bg-0: #070b14;
  --bg-1: #0c1424;
  --bg-glow: radial-gradient(1200px 600px at 80% -10%, rgba(0, 153, 255, .18), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(0, 212, 255, .12), transparent 55%);
  --surface: rgba(255, 255, 255, .045);
  --surface-2: rgba(255, 255, 255, .07);
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #eaf1fb;
  --muted: #8ea3bd;
  --track: rgba(255, 255, 255, .09);
}

/* ---------- Light ---------- */
:root[data-theme="light"] {
  --bg-0: #eef3fa;
  --bg-1: #f7fafe;
  --bg-glow: radial-gradient(1200px 600px at 80% -10%, rgba(0, 153, 255, .16), transparent 60%),
             radial-gradient(900px 500px at -10% 110%, rgba(0, 212, 255, .12), transparent 55%);
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --border: #e3eaf3;
  --border-strong: #cdd8e6;
  --text: #0f2135;
  --muted: #5a6b82;
  --track: #e3eaf3;
  --shadow: 0 20px 45px -24px rgba(20, 50, 90, .35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-1);
  background-image: var(--bg-glow);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg-0) 72%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .2px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--brand-grad);
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 8px 22px -8px rgba(0, 153, 255, .8);
}
.brand b { font-size: 1.05rem; }
.brand span { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); margin-top: -2px; }
.topbar .actions { display: flex; gap: 10px; }

.icon-btn {
  height: 40px; min-width: 40px; padding: 0 12px;
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 11px; cursor: pointer;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  font-size: .9rem; font-weight: 600;
  transition: var(--trans);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Layout ---------- */
main { padding: 34px 0 60px; }
.grid { display: grid; gap: var(--gap); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

/* ---------- Hero / Gauge ---------- */
.hero { padding: 26px; text-align: center; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -2px -2px auto -2px; height: 3px;
  background: var(--brand-grad); opacity: .9;
}

.server-picker {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.server-picker label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.select {
  appearance: none; -webkit-appearance: none;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 11px;
  padding: 10px 38px 10px 14px; font-size: .92rem; font-weight: 600; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%238ea3bd' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 14px center;
  max-width: 320px;
  transition: var(--trans);
}
.select:focus-visible { outline: none; box-shadow: var(--ring); }
.pill {
  font-size: .78rem; font-weight: 700; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border);
}
.pill b { color: var(--brand-2); }

.gauge-wrap { position: relative; width: 100%; max-width: 420px; margin: 6px auto 8px; }
.gauge-wrap canvas { width: 100%; height: 260px; display: block; }
.gauge-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
  transform: translateY(14px);
}
.gauge-phase {
  font-size: .78rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 7px;
}
.gauge-phase .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand-1); }
.gauge-value { font-size: 3.4rem; font-weight: 800; line-height: 1; margin: 6px 0 0;
  font-variant-numeric: tabular-nums;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.gauge-unit { font-size: .85rem; color: var(--muted); font-weight: 700; }

/* ---------- Mode segmented control ---------- */
.segmented {
  display: inline-flex; gap: 4px; padding: 5px; margin: 10px auto 2px;
  border-radius: 13px; background: var(--surface-2); border: 1px solid var(--border);
  flex-wrap: wrap; justify-content: center;
}
.seg-btn {
  border: none; background: transparent; color: var(--muted);
  font-weight: 700; font-size: .86rem; padding: 9px 16px; border-radius: 9px;
  cursor: pointer; transition: var(--trans); font-family: inherit;
}
.seg-btn:hover { color: var(--text); }
.seg-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.seg-btn.active {
  background: var(--brand-grad); color: #012039;
  box-shadow: 0 6px 16px -8px rgba(0, 153, 255, .8);
}
.seg-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Nicht getestete Kachel dezent ausgrauen */
.stat.disabled { opacity: .38; filter: grayscale(.4); }

/* Dauer-Wähler */
.duration-picker {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 12px auto 2px;
}
.duration-picker label { font-size: .82rem; color: var(--muted); font-weight: 700; }
.duration-picker .select { padding-top: 8px; padding-bottom: 8px; }

.admin-sep { border: none; border-top: 1px solid var(--border); margin: 20px 0 4px; }

/* Vor-Checks */
.skip-precheck {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 12px;
  font-size: .82rem; color: var(--muted); font-weight: 600; cursor: pointer;
}
.precheck { margin-top: var(--gap); padding: 22px; }
#precheckContent { display: grid; gap: 12px; }
.pc-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); padding: 14px 16px;
}
.pc-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.pc-head .pc-ico { font-size: 1.1rem; }
.pc-head .pc-state { margin-left: auto; font-size: .8rem; font-weight: 700; }
.pc-state.run { color: var(--warn); }
.pc-state.ok { color: var(--ok); }
.pc-state.err { color: var(--bad); }
.pc-body { margin-top: 10px; font-size: .88rem; color: var(--muted); }
.pc-body b { color: var(--text); }
.pc-metrics { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 6px; }
.pc-metrics span b { color: var(--brand-2); }
.pc-hops {
  margin-top: 8px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .8rem; line-height: 1.6; color: var(--text);
  background: var(--bg-0); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; max-height: 240px; overflow: auto; white-space: pre-wrap;
}

/* Checkboxen (Admin) */
.check {
  display: flex; align-items: flex-start; gap: 10px; margin: 8px 0;
  font-size: .88rem; cursor: pointer;
}
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--brand-1); flex-shrink: 0; }
.check code { font-size: .82em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Admin: Log & IP-Regeln */
.log-byip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.log-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); cursor: pointer;
}
.log-chip:hover { border-color: var(--brand-1); }
.log-chip b { color: var(--brand-2); }
.log-list { display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.log-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px 12px; align-items: center;
  padding: 8px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); font-size: .82rem;
}
.log-row .lip { font-weight: 700; }
.log-row .lt { color: var(--muted); font-size: .78rem; }
.log-row .lm { font-variant-numeric: tabular-nums; color: var(--muted); }
.log-row .lm b { color: var(--text); }

.ip-rule-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); margin-bottom: 6px; font-size: .85rem;
}
.ip-rule-item .tag {
  font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
}
.ip-rule-item .tag.block { background: rgba(239,68,68,.15); color: #fca5a5; }
.ip-rule-item .tag.limit { background: rgba(245,158,11,.15); color: #fcd34d; }

.limit-banner {
  margin-top: var(--gap); padding: 12px 16px; border-radius: var(--radius-sm);
  background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.35);
  color: var(--warn); font-size: .88rem; font-weight: 600;
}

/* ---------- Start button ---------- */
.start-btn {
  margin-top: 14px;
  border: none; cursor: pointer;
  padding: 15px 44px; border-radius: 14px;
  font-size: 1.05rem; font-weight: 800; letter-spacing: .3px;
  color: #012039; background: var(--brand-grad);
  box-shadow: 0 14px 34px -12px rgba(0, 153, 255, .85);
  transition: var(--trans);
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 20px 42px -14px rgba(0, 153, 255, .95); }
.start-btn:active { transform: translateY(0); }
.start-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.start-btn.running {
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); box-shadow: none;
}

/* ---------- Stat tiles ---------- */
.stats-grid { grid-template-columns: repeat(4, 1fr); margin-top: var(--gap); }
.stat {
  padding: 18px; text-align: left; position: relative; overflow: hidden;
  transition: var(--trans);
}
.stat:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.stat .lbl { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); font-weight: 700; }
.stat .ico { font-size: 1rem; }
.stat .val { font-size: 2rem; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1; }
.stat .u { font-size: .8rem; color: var(--muted); font-weight: 700; margin-left: 4px; }
.stat[data-k="dl"] .val { color: var(--brand-1); }
.stat[data-k="ul"] .val { color: var(--brand-2); }
.stat.active { box-shadow: var(--ring); border-color: transparent; }

/* ---------- Result panel ---------- */
.result-panel { margin-top: var(--gap); padding: 22px; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.rating {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 1.1rem;
  padding: 10px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.rating .emoji { font-size: 1.4rem; }
.result-meta { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 16px; color: var(--muted); font-size: .9rem; }
.result-meta b { color: var(--text); font-weight: 700; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- History ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 1.05rem; margin: 0; }
.history { margin-top: var(--gap); padding: 22px; }
.chart-box { height: 260px; position: relative; }
.history-list { margin-top: 16px; display: grid; gap: 8px; }
.hrow {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border); font-size: .88rem;
}
.hrow .when { color: var(--muted); }
.hrow .m { font-weight: 700; font-variant-numeric: tabular-nums; }
.hrow .m.dl { color: var(--brand-1); }
.hrow .m.ul { color: var(--brand-2); }

/* ---------- Buttons (generic) ---------- */
.btn {
  cursor: pointer; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  padding: 10px 16px; border-radius: 11px; font-weight: 700; font-size: .88rem;
  display: inline-flex; align-items: center; gap: 8px; transition: var(--trans);
}
.btn:hover { border-color: var(--brand-1); transform: translateY(-1px); }
.btn.primary { background: var(--brand-grad); color: #012039; border: none; }
.btn.ghost { background: transparent; }
.btn.danger { color: #fff; background: var(--bad); border-color: transparent; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 8, 16, .66); backdrop-filter: blur(6px); }
.modal-card { width: 100%; max-width: 520px; background: var(--bg-1); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; animation: pop .2s ease; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 22px; }
.modal-body p.hint { color: var(--muted); font-size: .86rem; margin: 0 0 16px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  font-size: .95rem; font-family: inherit; transition: var(--trans);
}
.input:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--brand-1); }
.row { display: flex; gap: 10px; }
.row .input { flex: 1; }

.server-admin-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--border); margin-bottom: 8px; font-size: .88rem;
}
.server-admin-item small { color: var(--muted); display: block; }

.note { font-size: .82rem; padding: 10px 12px; border-radius: 10px; margin-top: 10px; }
.note.ok { background: rgba(34, 197, 94, .12); border: 1px solid rgba(34, 197, 94, .3); color: var(--ok); }
.note.err { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(30px);
  background: var(--bg-0); color: var(--text); border: 1px solid var(--border-strong);
  padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 600; font-size: .9rem; opacity: 0; pointer-events: none; transition: var(--trans); z-index: 80;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Footer ---------- */
footer { border-top: 1px solid var(--border); padding: 26px 0; color: var(--muted); font-size: .85rem; }
footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Loading ---------- */
.loading { text-align: center; padding: 60px 0; color: var(--muted); }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 16px; border-radius: 50%;
  border: 4px solid var(--track); border-top-color: var(--brand-1); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .gauge-value { font-size: 2.9rem; }
  .brand span { display: none; }
}
@media (max-width: 460px) {
  .hrow { grid-template-columns: 1fr auto; }
  .hrow .when { grid-column: 1 / -1; }
  .icon-btn .txt { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
