/* VPN Gate Config Hub — dark navy dashboard theme. Logical properties are used throughout so RTL (Arabic) works from dir="rtl". */
:root {
  --bg: #0a1128;
  --bg-2: #0d1733;
  --surface: #111b3a;
  --surface-2: #16224a;
  --border: #25356a;
  --text: #e8eefc;
  --muted: #a3b3d9;
  --accent: #38bdf8;
  --accent-2: #3b82f6;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --on-accent: #04112b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(2, 8, 30, .45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Noto Naskh Arabic", "Segoe UI Arabic", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.65; color: var(--text);
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(56, 189, 248, .14), transparent 60%),
    radial-gradient(900px 500px at 5% 0%, rgba(59, 130, 246, .16), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
a:hover { color: #7dd3fc; }
img, svg { max-width: 100%; }
code, .mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.container { width: min(1160px, 100% - 32px); margin-inline: auto; }
.section { padding-block: 56px 8px; }
.section-tight { padding-block: 8px; }
.section-head { margin-bottom: 20px; }
.section-head p { color: var(--muted); max-width: 70ch; }
.center { text-align: center; margin-block: 20px; }
.muted { color: var(--muted); }
.sr-only { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 8px; z-index: 100; font-weight: 600; }
.skip-link:focus { top: 10px; }
[hidden] { display: none !important; }

/* Header / nav */
.site-header { position: sticky; top: 0; z-index: 50; background: rgba(10, 17, 40, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; }
.brand-name { font-size: 1.05rem; }
.site-nav { display: flex; align-items: center; gap: 18px; }
.site-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-nav li a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.site-nav li a:hover { color: var(--text); background: var(--surface); }
.lang-picker { display: inline-flex; align-items: center; gap: 6px; padding-inline: 10px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); }
.lang-picker select { background: transparent; color: var(--text); border: 0; padding: 8px 10px; font: inherit; cursor: pointer; }
.lang-picker select option { background: var(--surface); color: var(--text); }
.nav-toggle { display: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; width: 44px; height: 44px; padding: 0; cursor: pointer; flex-direction: column; align-items: center; justify-content: center; gap: 5px; }
.nav-toggle .bar { width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.nav-toggle[aria-expanded="true"] .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; transition: transform .15s, box-shadow .15s, background .15s; }
.btn-primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--on-accent); box-shadow: 0 6px 20px rgba(56, 189, 248, .25); }
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 26px rgba(56, 189, 248, .38); color: var(--on-accent); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 12px; min-height: 36px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; color: var(--muted); width: 40px; height: 40px; border-radius: 10px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

input[type="search"], input[type="number"], select {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: inherit; min-height: 44px;
}
input::placeholder { color: #7f90ba; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

/* Hero */
.hero { padding-block: 64px 28px; }
.hero-inner { text-align: start; }
.eyebrow { display: inline-block; color: var(--accent); background: rgba(56, 189, 248, .1); border: 1px solid rgba(56, 189, 248, .3); padding: 4px 12px; border-radius: 999px; font-size: .85rem; font-weight: 600; margin-bottom: 16px; }
.hero h1 { background: linear-gradient(120deg, #fff 20%, var(--accent) 80%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 62ch; }
.hero-search { display: flex; gap: 10px; max-width: 640px; margin-block: 24px 18px; }
.hero-search input { flex: 1; }
.status-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 10px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .92rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 0 rgba(251, 191, 36, .6); }
.status-pill[data-state="live"] .dot { background: var(--good); box-shadow: 0 0 10px 2px rgba(52, 211, 153, .65); animation: pulse 2.4s infinite; }
.status-pill[data-state="cached"] .dot { background: var(--warn); box-shadow: 0 0 8px 1px rgba(251, 191, 36, .5); }
.status-pill[data-state="error"] .dot, .status-pill[data-state="offline"] .dot { background: var(--bad); box-shadow: 0 0 8px 1px rgba(248, 113, 113, .55); }
.status-pill[data-state="loading"] .dot { background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.updated { color: var(--muted); font-size: .92rem; }
.hint { color: var(--muted); font-size: .92rem; margin-block: 4px; }
.notice { color: var(--muted); font-size: .95rem; padding: 10px 14px; border-inline-start: 3px solid var(--border); background: rgba(17, 27, 58, .6); border-radius: 6px; max-width: 80ch; }
.notice-accent { border-inline-start-color: var(--accent); }

/* Panels */
.panel { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 22px; margin-block: 18px; }
.panel-error { border-color: rgba(248, 113, 113, .6); background: rgba(80, 20, 30, .35); }
.panel-title { color: #fecaca; font-size: 1.15rem; }
.panel-empty { text-align: center; color: var(--muted); }
.empty { color: var(--muted); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: .78rem; }
.skeleton { position: relative; color: transparent !important; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), #1f2f66, var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; min-height: 2.4rem; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Top 5 cards */
.method { margin-block: 10px 18px; color: var(--muted); }
.method summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.method p { margin-top: 8px; max-width: 80ch; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.server-card { position: relative; background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); transition: transform .2s, border-color .2s; }
.server-card:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rank { font-weight: 800; color: var(--on-accent); background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-radius: 999px; padding: 2px 12px; font-size: .85rem; white-space: nowrap; }
.country { display: flex; align-items: center; gap: 10px; min-width: 0; }
.flag { font-size: 1.7rem; line-height: 1; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.country-name { font-weight: 700; overflow-wrap: anywhere; }
.cc { font-family: var(--mono); font-size: .8rem; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; direction: ltr; unicode-bidi: isolate; }
.hostline { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; text-align: start; color: #bfe6ff; overflow-wrap: anywhere; font-size: .95rem; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; margin: 0; }
.metrics div { background: rgba(10, 17, 40, .55); border-radius: 10px; padding: 8px 12px; }
.metrics dt { color: var(--muted); font-size: .78rem; }
.metrics dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.score-bar { height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.score-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 999px; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: .9rem; color: var(--muted); }
.score-row strong { color: var(--text); font-size: 1.1rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.chip-yes::before { background: var(--good); }
.chip-yes { color: #a7f3d0; border-color: rgba(52, 211, 153, .4); }
.chip-no { color: #fecaca; border-color: rgba(248, 113, 113, .4); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.card-actions .btn { flex: 1 1 auto; }
.card-skel { height: 300px; border-radius: var(--radius); }

/* Filters */
.filters { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.field { grid-column: span 3; display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: span 6; }
.field-check { grid-column: span 12; flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.field label { font-size: .88rem; color: var(--muted); }
.field .check { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; }
.result-count { color: var(--muted); margin-block: 14px 8px; font-size: .92rem; }

/* Table */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.server-table { width: 100%; border-collapse: collapse; }
.server-table th, .server-table td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
.server-table th { background: var(--surface-2); color: var(--muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.server-table tbody tr:last-child td { border-bottom: 0; }
.server-table tbody tr:hover { background: rgba(56, 189, 248, .06); }
.server-table .num { text-align: end; font-variant-numeric: tabular-nums; }
.server-table td.ip { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.server-table td.host { overflow-wrap: anywhere; font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.cell-country { display: flex; align-items: center; gap: 8px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Steps */
.steps { list-style: none; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; counter-reset: s; }
.steps li { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.steps h3 { margin-bottom: .2em; }
.steps p { margin: 0; color: var(--muted); font-size: .95rem; }
.step-num { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--on-accent); background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.help { margin-top: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.help ul, .plain { padding-inline-start: 22px; }
.help li, .plain li { margin-bottom: .6em; }

/* Pilot banner */
.pilot-banner { background: linear-gradient(90deg, #0b1a45, #0d2a63 55%, #0b1a45); border-bottom: 1px solid var(--border); }
.pilot-inner { display: flex; align-items: center; justify-content: center; gap: 10px; padding-block: 6px; }
.pilot-inner p { margin: 0; font-size: .9rem; color: var(--text); text-align: center; }
.pilot-inner strong { color: var(--accent); }
.pilot-logo { border-radius: 6px; flex: none; }

/* Footer */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: var(--bg-2); padding-block: 32px; }
.footer-brand { display: flex; align-items: center; gap: 18px; margin-bottom: 16px; }
.footer-brand img { border-radius: 14px; border: 1px solid var(--border); flex: none; }
.footer-pilot { margin: 0 0 6px; font-weight: 600; }
.footer-pilot strong { color: var(--accent); }
.footer-credit, .footer-copy { color: var(--muted); margin: 6px 0 0; }
.footer-copy strong { color: var(--text); }
.footer-independent { color: var(--muted); max-width: 80ch; margin: 0; }
@media (max-width: 520px) { .footer-brand { flex-direction: column; align-items: flex-start; } .pilot-inner p { font-size: .82rem; } }
.footer-links { list-style: none; display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 0; margin: 0 0 14px; }
.footer-contact { color: var(--muted); margin: 0; }

/* Dialog */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: min(560px, calc(100% - 24px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(3, 8, 24, .72); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dialog-head h2 { margin: 0; font-size: 1.3rem; }
.detail-list { display: grid; grid-template-columns: minmax(120px, 36%) 1fr; gap: 8px 14px; margin: 14px 0; }
.detail-list dt { color: var(--muted); font-size: .9rem; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.detail-list dd.mono { color: #bfe6ff; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }

/* Toasts */
.toasts { position: fixed; inset-inline-end: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 10px; z-index: 200; max-width: min(420px, calc(100% - 32px)); }
.toast { background: var(--surface-2); border: 1px solid var(--border); border-inline-start: 4px solid var(--accent); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow); animation: slide .25s ease-out; }
.toast-error { border-inline-start-color: var(--bad); }
.toast-warn { border-inline-start-color: var(--warn); }
@keyframes slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Responsive */
@media (max-width: 960px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .field { grid-column: span 6; }
  .field-wide { grid-column: span 12; }
}
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .site-nav { position: absolute; inset-inline: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 10px; padding: 14px 16px 18px; background: var(--bg); border-bottom: 1px solid var(--border); display: none; }
  .site-nav.open { display: flex; }
  .site-nav ul { flex-direction: column; }
  .lang-picker { align-self: flex-start; }
  .header-inner { position: relative; }
}
@media (max-width: 720px) {
  .hero { padding-block: 40px 20px; }
  .hero-search { flex-direction: column; }
  .stat-value { font-size: 1.6rem; }
  .server-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .server-table, .server-table tbody, .server-table tr, .server-table td { display: block; width: 100%; }
  .server-table tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .server-table td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: end; }
  .server-table td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; text-align: start; flex: none; }
  .server-table td.country-cell::before { display: none; }
  .server-table td.country-cell { justify-content: flex-start; }
  .server-table .num { text-align: end; }
  .row-actions { justify-content: flex-start; }
  .server-table td.actions-cell::before { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .field { grid-column: span 12; }
  .detail-list { grid-template-columns: 1fr; gap: 2px; }
  .detail-list dd { margin-bottom: 8px; }
}
@media (max-width: 420px) { .stats-grid { grid-template-columns: 1fr; } }

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