/* mtproto-proxy-pro — OLED dark, Telegram-blue accent. Vanilla CSS, no framework. */
:root {
  --bg: #0a0f1a;
  --surface: #111827;
  --surface-2: #161f33;
  --muted: #1b2436;
  --border: #283149;
  --fg: #f8fafc;
  --fg-dim: #a9b4c9;
  --brand: #229ed9;        /* Telegram blue */
  --brand-ink: #ffffff;
  --ok: #22c55e;           /* online / handshake */
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --maxw: 1080px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
/* The [hidden] attribute must win over class rules that set display (e.g. .banner). */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #142242 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--brand); color: #fff; padding: 10px 16px; z-index: 100; }
.skip-link:focus { left: 8px; top: 8px; }
/* Visible keyboard focus for every interactive element on the dark theme. */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(34, 158, 217, .3); }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: rgba(10,15,26,.78); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--fg); font-weight: 800; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand__mark { color: var(--brand); }
.topbar__nav { display: flex; align-items: center; gap: 22px; }
.topbar__nav a { color: var(--fg-dim); font-weight: 500; font-size: 14.5px; }
.topbar__nav a:hover { color: var(--fg); text-decoration: none; }
.ghbtn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--border); border-radius: 9px; color: var(--fg) !important; }
.ghbtn:hover { background: var(--surface-2); }

/* ---------- Hero ---------- */
.hero { padding: 60px 20px 30px; text-align: center; }
.pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-dim); background: var(--surface); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(34,197,94,.6); animation: pulse 2.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34,197,94,.5); } 70% { box-shadow: 0 0 0 8px rgba(34,197,94,0); } 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); } }
h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); line-height: 1.08; font-weight: 800; margin: 18px 0 14px; letter-spacing: -.02em; }
.hero__sub { max-width: 640px; margin: 0 auto 30px; color: var(--fg-dim); font-size: clamp(1rem, 2.5vw, 1.18rem); }
.hero__sub strong, .hero__sub em { color: var(--fg); font-style: normal; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 720px; margin: 0 auto 26px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 10px; }
.stat__num { display: block; font-size: clamp(1.3rem, 4vw, 1.9rem); font-weight: 800; font-variant-numeric: tabular-nums; color: var(--fg); }
.stat__label { font-size: 12.5px; color: var(--fg-dim); }
.cta { display: inline-block; background: var(--brand); color: var(--brand-ink) !important; font-weight: 700; padding: 13px 28px; border-radius: 11px; transition: transform .15s ease, filter .15s ease; }
.cta:hover { filter: brightness(1.08); text-decoration: none; transform: translateY(-1px); }

/* ---------- Section headers ---------- */
.section-h { font-size: clamp(1.4rem, 3.5vw, 1.9rem); font-weight: 700; margin: 48px 0 18px; letter-spacing: -.01em; }

/* ---------- Controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.field { position: relative; display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 0 12px; height: 46px; }
.field--grow { flex: 1 1 260px; }
.field__icon { color: var(--fg-dim); flex: none; }
.field__lbl { color: var(--fg-dim); font-size: 13px; }
.field input, .field select { background: transparent; border: 0; color: var(--fg); font: inherit; font-size: 15px; outline: none; width: 100%; }
.field select { cursor: pointer; padding-right: 4px; }
.field select option { background: var(--surface); color: var(--fg); }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--fg-dim); font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; height: 46px; padding: 0 14px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--brand); width: 16px; height: 16px; }
.result-meta { color: var(--fg-dim); font-size: 13.5px; margin: 14px 2px; }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.ptable { width: 100%; border-collapse: collapse; }
.ptable thead th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-dim); padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.col-num { text-align: right; }
.col-actions { text-align: right; }
.ptable tbody tr { border-bottom: 1px solid var(--border); transition: background .12s ease; }
.ptable tbody tr:last-child { border-bottom: 0; }
.ptable tbody tr:hover { background: var(--surface-2); }
.ptable td { padding: 13px 16px; vertical-align: middle; font-size: 14.5px; }
.td-country { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.flag { font-size: 19px; line-height: 1; }
.cc { color: var(--fg-dim); font-size: 13px; font-weight: 600; }
.server { font-family: var(--mono); font-size: 13px; color: var(--fg); word-break: break-all; }
.server .port { color: var(--fg-dim); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); }
.badge--ee { color: #7dd3fc; border-color: #225; background: rgba(125,211,252,.08); }
.badge--dd { color: #c4b5fd; border-color: #225; background: rgba(196,181,253,.08); }
.badge--plain { color: var(--fg-dim); }
.lat { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; display: block; }
.lat--fast { color: var(--ok); }
.lat--mid { color: var(--warn); }
.lat--slow { color: var(--bad); }
.uptime { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--fg-dim); text-align: right; display: block; }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 13.5px; font-weight: 600; border-radius: 9px; padding: 8px 13px; cursor: pointer; border: 1px solid var(--border); background: var(--muted); color: var(--fg); transition: background .12s ease, filter .12s ease; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn--go { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--go:hover { filter: brightness(1.1); text-decoration: none; }
.btn--icon { padding: 8px 10px; min-width: 44px; justify-content: center; }
.status-tag { font-size: 11px; color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }
.status-tag--reach { color: var(--fg-dim); }

.empty { padding: 40px 16px; text-align: center; color: var(--fg-dim); }

/* ---------- Info / cards ---------- */
.info { margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0; color: var(--fg-dim); font-size: 14.5px; }
.card code, .note code { font-family: var(--mono); font-size: 12.5px; background: var(--muted); padding: 1px 6px; border-radius: 5px; color: var(--fg); }
.note { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: 10px; padding: 16px; color: var(--fg-dim); font-size: 14px; }
.note svg { color: var(--warn); flex: none; margin-top: 3px; }
.note strong { color: var(--fg); }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px 16px; margin-bottom: 10px; }
details summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; float: right; color: var(--fg-dim); font-weight: 400; }
details[open] summary::after { content: "–"; }
details p { margin: 0 0 14px; color: var(--fg-dim); font-size: 14.5px; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); margin-top: 50px; padding: 30px 0; }
.footer__inner p { margin: 4px 0; font-size: 14px; }
.muted { color: var(--fg-dim); font-size: 13px !important; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: var(--ok); color: #06210f; font-weight: 700; padding: 11px 20px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s ease, transform .2s ease; z-index: 60; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Blocked-country banner ---------- */
.banner { display: flex; align-items: center; gap: 12px; background: linear-gradient(90deg, rgba(34,158,217,.16), rgba(34,197,94,.10)); border: 1px solid var(--brand); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; color: var(--fg); font-size: 14.5px; }
.banner svg { color: var(--ok); flex: none; }

/* ---------- Resilience + reachability badges ---------- */
.toggle--shield { border-color: var(--ok); color: var(--fg); }
.badge.res { margin-left: 4px; }
.res--high { color: var(--ok); border-color: rgba(34,197,94,.4); background: rgba(34,197,94,.10); }
.res--mid  { color: var(--warn); border-color: rgba(245,158,11,.4); background: rgba(245,158,11,.10); }
.res--low  { color: var(--fg-dim); }
.reach-chip { display: inline-block; font-size: 11px; font-weight: 600; color: var(--ok); background: rgba(34,197,94,.10); border: 1px solid rgba(34,197,94,.35); border-radius: 999px; padding: 1px 7px; margin-top: 4px; }

/* ---------- Country guidance table ---------- */
.lead { color: var(--fg-dim); font-size: 15.5px; max-width: 760px; }
.lead strong, .lead em { color: var(--fg); font-style: normal; }
.lead .reach-chip { margin: 0; }
.ctable-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 8px; }
.ctable td { font-size: 14px; }
.ctable td:first-child { white-space: nowrap; font-weight: 600; }

/* ---------- Responsive: table -> cards ---------- */
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .topbar__nav a:not(.ghbtn) { display: none; }
  .ptable thead { position: absolute; left: -9999px; }
  .ptable, .ptable tbody, .ptable tr, .ptable td { display: block; width: 100%; }
  .ptable tr { padding: 12px 14px; }
  .ptable td { padding: 4px 2px; border: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .ptable td::before { content: attr(data-label); color: var(--fg-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
  .td-country { justify-content: flex-start; }
  .lat, .uptime { text-align: right; }
  .actions { justify-content: stretch; width: 100%; }
  .actions .btn--go { flex: 1; justify-content: center; }
  .col-actions { width: 100%; }
}

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