/* ═══════════════════ ProtonProxyPanel — Pro dark dashboard, RTL ═══════════════════ */
:root {
  --bg: #070a14;
  --bg2: #0d1226;
  --card: rgba(148,163,205,.055);
  --card2: rgba(148,163,205,.085);
  --border: rgba(148,163,205,.14);
  --border-soft: rgba(148,163,205,.09);
  --text: #edf0fa;
  --muted: #8e97b8;
  --accent1: #8b5cf6;
  --accent2: #22d3ee;
  --grad: linear-gradient(120deg, #7c3aed 0%, #4f46e5 45%, #06b6d4 100%);
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
  --shadow: 0 10px 40px rgba(2,6,23,.45);
  --glow: 0 0 0 1px rgba(139,92,246,.25), 0 8px 40px rgba(79,70,229,.18);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1100px 640px at 88% -12%, rgba(124,58,237,.20), transparent 58%),
    radial-gradient(900px 560px at -8% 108%, rgba(6,182,212,.14), transparent 55%),
    radial-gradient(700px 400px at 50% 50%, rgba(79,70,229,.07), transparent 70%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
::selection { background: rgba(124,58,237,.45); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .78rem; }
.center { text-align: center; }
.ok-text { color: var(--ok); font-size: .85rem; }
.flex-spacer { flex: 1; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,205,.22); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,205,.38); background-clip: content-box; }

main { max-width: 1150px; margin: 0 auto; padding: 22px 20px 70px; display: flex; flex-direction: column; gap: 18px; }

.glass {
  background: linear-gradient(180deg, var(--card2), var(--card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

/* ───────────────── buttons / fields */
.btn {
  font-family: inherit; font-size: .88rem; color: var(--text);
  background: rgba(148,163,205,.09); border: 1px solid var(--border);
  border-radius: 11px; padding: 9px 15px; cursor: pointer;
  transition: all .16s ease; white-space: nowrap;
}
.btn:hover { background: rgba(148,163,205,.16); transform: translateY(-1px); border-color: rgba(148,163,205,.28); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid rgba(139,92,246,.7); outline-offset: 2px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.primary {
  background: var(--grad); border: none; font-weight: 700;
  box-shadow: 0 8px 26px rgba(79,70,229,.4), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn.primary:hover { filter: brightness(1.13); box-shadow: 0 10px 32px rgba(79,70,229,.5); }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(248,113,113,.14); border-color: rgba(248,113,113,.4); }
.btn.sm { padding: 6px 11px; font-size: .78rem; border-radius: 9px; }
.icon { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; }
.danger-hover:hover { background: rgba(248,113,113,.15) !important; border-color: rgba(248,113,113,.35) !important; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: .8rem; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font-family: inherit; font-size: .9rem; color: var(--text);
  background: rgba(2,6,23,.55); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 13px; outline: none; transition: border .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: rgba(142,151,184,.55); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(139,92,246,.75);
  box-shadow: 0 0 0 3px rgba(139,92,246,.16);
}
select option { background: var(--bg2); }

/* ───────────────── topbar */
.topbar {
  position: sticky; top: 12px; z-index: 40; margin: 12px auto 0; max-width: 1150px;
  width: calc(100% - 40px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 18px;
}
.topbar::after {
  content: ''; position: absolute; inset-inline: 10%; bottom: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,92,246,.65), rgba(34,211,238,.55), transparent);
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo { font-size: 1.4rem; filter: drop-shadow(0 0 12px rgba(139,92,246,.85)); }
.title { font-weight: 800; font-size: 1.04rem; letter-spacing: -.01em; }
.top-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.domain-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.25);
  border-radius: 999px; padding: 6px 13px; font-size: .76rem; color: #a5f3fc;
}
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(2,6,23,.45); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 13px; font-size: .78rem;
}
.pill b { font-weight: 600; }
.pill small { color: var(--muted); direction: ltr; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.pill.on .dot { background: var(--ok); box-shadow: 0 0 10px var(--ok); animation: pulse 2s infinite; }
.pill.off .dot { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
@keyframes pulse { 50% { opacity: .5; } }

/* ───────────────── banners */
.banner {
  padding: 12px 17px; border-radius: 13px; font-size: .87rem;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.banner.error { background: rgba(248,113,113,.12); border: 1px solid rgba(248,113,113,.42); color: #fecaca; }
.banner.warn  { background: rgba(251,191,36,.10); border: 1px solid rgba(251,191,36,.4); color: #fde68a; }
.banner a { color: inherit; font-weight: 700; }

/* ───────────────── stats */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 13px; }
.stat-card {
  position: relative; overflow: hidden;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 3px;
  transition: transform .16s ease, border-color .16s ease;
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(148,163,205,.26); }
.stat-card::before {
  content: attr(data-icon); position: absolute; inset-inline-end: 12px; top: 10px;
  font-size: 1.35rem; opacity: .5; filter: saturate(.8);
}
.stat-card::after {
  content: ''; position: absolute; inset-inline: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(148,163,205,.35), transparent);
}
.stat-card.ok::after { background: linear-gradient(90deg, transparent, rgba(52,211,153,.75), transparent); }
.stat-card.bad::after { background: linear-gradient(90deg, transparent, rgba(251,191,36,.7), transparent); }
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card.ok .stat-num { color: var(--ok); text-shadow: 0 0 24px rgba(52,211,153,.4); }
.stat-card.bad .stat-num { color: var(--warn); }
.stat-lbl { font-size: .75rem; color: var(--muted); }

/* ───────────────── cards & add bar */
.card { padding: 20px; }
.card-title { font-size: .98rem; font-weight: 800; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ''; width: 4px; height: 16px; border-radius: 4px; background: var(--grad); display: inline-block; }
.add-grid { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-grid .field:nth-child(1) { min-width: 220px; flex: 1; }
.w-small { width: 122px; }
.add-grid .btn.big { padding: 11px 28px; font-size: .95rem; }
.bulk-row { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }

/* ───────────────── table */
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.search { max-width: 270px; font-size: .82rem; }
.table-wrap { overflow-x: auto; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
thead th {
  text-align: right; color: var(--muted); font-weight: 600; font-size: .73rem;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
  cursor: default; user-select: none; background: rgba(2,6,23,.35);
  position: sticky; top: 0;
}
thead th[data-sort] { cursor: pointer; }
thead th[data-sort]:hover { color: var(--text); }
tbody td { padding: 11px 12px; border-bottom: 1px solid rgba(148,163,205,.06); vertical-align: middle; white-space: nowrap; }
tbody tr { transition: background .12s, box-shadow .12s; }
tbody tr:hover { background: rgba(139,92,246,.05); box-shadow: inset 3px 0 0 var(--accent1); }
tbody tr.disabled-row { opacity: .42; }

.loc { display: flex; align-items: center; gap: 10px; }
.flag { font-size: 1.3rem; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.loc-name { font-weight: 700; font-size: .88rem; }
.loc-city { font-size: .72rem; color: var(--muted); }

.state-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .72rem; padding: 4px 11px; border-radius: 999px; font-weight: 700;
}
.state-chip i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.st-online { background: rgba(52,211,153,.13); color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(52,211,153,.3); } .st-online i { background: var(--ok); box-shadow: 0 0 7px var(--ok); }
.st-starting, .st-stopped { background: rgba(148,163,205,.12); color: #b6bedd; } .st-starting i, .st-stopped i { background: var(--muted); }
.st-offline, .st-error { background: rgba(248,113,113,.12); color: #fca5a5; box-shadow: inset 0 0 0 1px rgba(248,113,113,.28); } .st-offline i, .st-error i { background: var(--bad); }

.latency-badge { font-variant-numeric: tabular-nums; direction: ltr; font-weight: 700; font-size: .84rem; }
.lat-good { color: var(--ok); } .lat-mid { color: var(--warn); } .lat-bad { color: var(--bad); }

.port-cell { display: inline-flex; align-items: center; gap: 6px; direction: ltr; }
.port-val { font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; padding: 3px 9px; border-radius: 8px; }
.port-val:hover { background: rgba(139,92,246,.16); outline: 1px dashed rgba(139,92,246,.55); }
.port-input { width: 80px; padding: 4px 8px; }
.proto-tags small { background: rgba(34,211,238,.1); color: #67e8f9; padding: 2px 8px; border-radius: 6px; margin-inline: 2px; font-size: .64rem; font-weight: 600; }

.exit-ip { direction: ltr; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.err-line { color: #fca5a5; font-size: .72rem; max-width: 240px; overflow: hidden; text-overflow: ellipsis; display: block; white-space: normal; }

.actions { display: flex; gap: 4px; }
.act-btn {
  background: rgba(148,163,205,.06); border: 1px solid transparent; border-radius: 9px;
  width: 31px; height: 31px; cursor: pointer; font-size: .92rem; color: var(--muted);
  transition: all .13s; display: inline-flex; align-items: center; justify-content: center;
}
.act-btn:hover { background: rgba(139,92,246,.15); color: var(--text); transform: translateY(-1px); }
.act-btn.del:hover { background: rgba(248,113,113,.16); color: #fca5a5; }

/* ───────────────── empty state */
.empty { text-align: center; padding: 52px 12px; }
.empty-icon { font-size: 3.2rem; margin-bottom: 14px; filter: grayscale(.2) drop-shadow(0 6px 20px rgba(139,92,246,.35)); }

/* ───────────────── modal / drawer / menu */
dialog {
  position: fixed; inset: 0; margin: auto; z-index: 90;
  color: var(--text); padding: 22px 24px; width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--border); background: #0c1122f2; backdrop-filter: blur(24px);
  border-radius: 20px; box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
dialog.narrow { width: min(410px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(3,5,12,.65); backdrop-filter: blur(4px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h2 { font-size: 1.02rem; }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.close-x { font-size: 1rem; }

.tabs { display: flex; gap: 4px; margin: 12px 0 18px; background: rgba(2,6,23,.5); border: 1px solid var(--border); padding: 4px; border-radius: 12px; }
.tab {
  flex: 1; background: none; border: none; color: var(--muted); font-family: inherit;
  font-size: .83rem; font-weight: 600; padding: 8px 13px; cursor: pointer; border-radius: 9px;
  transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; background: var(--grad); box-shadow: 0 4px 18px rgba(79,70,229,.35); }
.tab-page { display: none; }
.tab-page.active { display: block; animation: fadeUp .18s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(4px); } }

.form-grid { display: flex; flex-direction: column; gap: 13px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cred-row { display: grid; grid-template-columns: 1fr 1.25fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.check { display: flex; gap: 9px; align-items: center; font-size: .86rem; }
.check input { width: 17px; height: 17px; accent-color: var(--accent1); }
.sep { border: none; border-top: 1px dashed var(--border); margin: 6px 0; }
.hint { font-size: .8rem; color: var(--muted); line-height: 1.9; margin-bottom: 12px; }
.hint-inline { font-size: .78rem; }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: .8rem; line-height: 1.5; }
.row-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.form-err { color: #fca5a5; font-size: .82rem; margin-top: 8px; }

#login-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(900px 500px at 70% -10%, rgba(124,58,237,.25), transparent 60%), var(--bg);
}
.login-card {
  width: min(380px, calc(100vw - 40px)); padding: 38px 32px; text-align: center;
  display: flex; flex-direction: column; gap: 14px; position: relative;
}
.login-card::before {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: linear-gradient(140deg, rgba(139,92,246,.8), rgba(34,211,238,.4), transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.logo-big { font-size: 3.1rem; filter: drop-shadow(0 0 26px rgba(139,92,246,.9)); animation: floaty 3.4s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-5px); } }
.login-card h1 { font-size: 1.28rem; font-weight: 800; }
.login-card form { display: flex; flex-direction: column; gap: 11px; }
.login-card input { text-align: center; padding: 13px; font-size: 1rem; }

.drawer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  background: #0a0f20f5; border-top: 1px solid var(--border);
  backdrop-filter: blur(20px); height: 46vh; display: flex; flex-direction: column;
  border-radius: 20px 20px 0 0; box-shadow: 0 -20px 70px rgba(0,0,0,.5);
}
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 13px 18px; border-bottom: 1px solid var(--border); }
#logs-view {
  flex: 1; overflow: auto; padding: 13px 18px; direction: ltr; text-align: left;
  font-family: ui-monospace, Consolas, monospace; font-size: .74rem; line-height: 1.6;
  color: #86efac; white-space: pre-wrap; word-break: break-all;
}

.menu {
  position: fixed; z-index: 95; display: flex; flex-direction: column; min-width: 195px;
  background: #121831; border: 1px solid var(--border); border-radius: 13px; padding: 6px;
  box-shadow: 0 16px 50px rgba(0,0,0,.55);
}
.menu a { color: var(--text); text-decoration: none; font-size: .84rem; padding: 9px 13px; border-radius: 9px; }
.menu a:hover { background: rgba(139,92,246,.2); }

/* ───────────────── toasts */
#toasts { position: fixed; top: 16px; left: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #121831f2; border: 1px solid var(--border); border-right: 3px solid var(--accent1);
  padding: 12px 16px; border-radius: 12px; font-size: .84rem; max-width: 350px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45); animation: slideIn .25s ease;
}
.toast.ok { border-right-color: var(--ok); }
.toast.bad { border-right-color: var(--bad); }
@keyframes slideIn { from { transform: translateX(-14px); opacity: 0; } }

.dropzone {
  border: 2px dashed rgba(139,92,246,.5); border-radius: 15px;
  padding: 24px; text-align: center; cursor: pointer; display: flex;
  flex-direction: column; gap: 6px; align-items: center; transition: all .15s;
  background: rgba(139,92,246,.06);
}
.dropzone:hover, .dropzone.drag { background: rgba(139,92,246,.13); border-color: var(--accent1); box-shadow: var(--glow); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; max-height: 150px; overflow-y: auto; padding: 2px; }
.mono-list {
  display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto;
  background: rgba(2,6,23,.45); border: 1px solid var(--border); border-radius: 12px; padding: 8px;
}
.mono-line {
  font-family: ui-monospace, Consolas, monospace; font-size: .84rem; direction: ltr; text-align: left;
  padding: 7px 11px; border-radius: 8px; cursor: pointer; transition: background .12s;
  border-bottom: 1px dashed rgba(148,163,205,.12); white-space: pre;
}
.mono-line:hover { background: rgba(139,92,246,.14); }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(148,163,205,.08); border: 1px solid var(--border);
  padding: 5px 11px; border-radius: 999px; font-size: .76rem; direction: ltr;
}
.chip b { font-weight: 600; }
.chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .8rem; }
.chip button:hover { color: #fca5a5; }
.pill.on { background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.3); }

/* ───────────────── footer */
footer.center { padding: 8px 0 0; letter-spacing: .01em; }

/* ───────────────── responsive */
@media (max-width: 760px) {
  .topbar { top: 6px; flex-wrap: wrap; }
  .btn-txt { display: none; }
  thead th:nth-child(2), tbody td:nth-child(2) { display: none; }
  .search { max-width: 170px; }
  .domain-chip { display: none; }
  .stat-num { font-size: 1.6rem; }
  dialog { padding: 18px 16px; }
  .cred-row { grid-template-columns: 1fr 1fr; row-gap: 6px; }
}
