/* EH VPN manager - control plane */
:root {
  color-scheme: dark;
  --bg: #0a0f1e;
  --bg2: #0e1428;
  --card: #141b2f;
  --card2: #1a2340;
  --line: #26314f;
  --text: #eef2fb;
  --muted: #a3aec7;
  --dim: #6f7c99;
  --accent: #6d8cff;
  --accent2: #8b6dff;
  --ok: #37d67a;
  --warn: #ffc857;
  --danger: #ff6b7a;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 480px at 90% -10%, #1b2a5a 0%, transparent 60%),
    radial-gradient(700px 520px at 0% 0%, #2a1b4a 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Kufi Arabic", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; direction: ltr; unicode-bidi: embed; }
.small { font-size: 13px; }
.tiny { font-size: 11px; color: var(--dim); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 15, 30, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 22px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 19px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.logo {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: transparent;
  flex: 0 0 auto;
}
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.logo svg { width: 20px; height: 20px; }
.nav { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }
.nav a, .link-btn {
  padding: 7px 13px; border-radius: 10px; color: var(--muted);
  font-size: 14px; font-weight: 600; border: 1px solid transparent;
  background: transparent; cursor: pointer; font-family: inherit;
}
.nav a:hover, .link-btn:hover { color: var(--text); background: var(--card); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--card); border-color: var(--line); }
.lang-switch {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 10px; color: var(--text);
  font-size: 13px; font-weight: 700; border: 1px solid var(--line);
  background: var(--card2); white-space: nowrap;
}
.lang-switch:hover {
  color: var(--text); border-color: var(--accent);
  background: var(--card); text-decoration: none;
}
.inline-form { display: inline; margin: 0; }

.wrap { max-width: 1180px; width: 100%; margin: 0 auto; padding: 26px 20px 70px; flex: 1 0 auto; }
.footer {
  text-align: center; color: var(--dim); font-size: 12px;
  padding: 24px 0 34px; flex-shrink: 0;
}
.footer-line { opacity: .9; }
.footer-friends {
  margin-top: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700; font-style: italic;
  font-size: 14px; color: #add8e6; letter-spacing: .2px;
}

/* headings */
.hero, .page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.hero h1, .page-head h1 { margin: 0; font-size: 26px; letter-spacing: .2px; }
.hero p, .page-head p { margin: 4px 0 0; }
.hero-side {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; justify-content: flex-end;
}
.hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hero-actions form { margin: 0; }
@media (max-width: 640px) {
  .hero-side { width: 100%; justify-content: space-between; }
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 16px; font-size: 13px; color: var(--muted);
}
.back { font-size: 13px; color: var(--dim); }

/* alerts */
.alert {
  border-radius: 12px; padding: 12px 16px; margin-bottom: 16px;
  border: 1px solid var(--line); background: var(--card); font-size: 14px;
}
.alert.error { border-color: rgba(255, 107, 122, .4); background: rgba(255, 107, 122, .08); color: #ffd3d8; }
.alert.ok { border-color: rgba(55, 214, 122, .35); background: rgba(55, 214, 122, .08); color: #c9ffe0; }

/* cards */
.cards {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 18px;
}
@media (max-width: 900px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .cards { grid-template-columns: 1fr; } }

.stat {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 2px;
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat strong { font-size: 26px; font-weight: 800; letter-spacing: .2px; }
.stat .unit { font-size: 13px; color: var(--muted); margin-inline-start: 5px; font-weight: 600; }
.stat small { color: var(--dim); font-size: 12px; }
.small-strong { font-size: 18px !important; }

/* panels */
.panel {
  background: linear-gradient(180deg, rgba(20, 27, 47, .92), rgba(14, 20, 40, .92));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head .hint { color: var(--dim); font-size: 12.5px; }
.meta-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
@media (max-width: 820px) { .meta-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .meta-grid { grid-template-columns: 1fr; } }
.meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta > span { color: var(--dim); font-size: 12px; }
.meta strong { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.meta small { color: var(--muted); font-size: 12px; }
.services { display: flex; gap: 6px; flex-wrap: wrap; }

/* pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
  border: 1px solid var(--line); background: var(--card2); color: var(--muted);
  white-space: nowrap;
}
.pill.on { color: #bfffd8; border-color: rgba(55, 214, 122, .3); background: rgba(55, 214, 122, .09); }
.pill.off { color: var(--muted); }
.pill.warn { color: #ffe2a3; border-color: rgba(255, 200, 87, .38); background: rgba(255, 200, 87, .1); }
.pill.bad { color: #ffc3ca; border-color: rgba(255, 107, 122, .35); background: rgba(255, 107, 122, .1); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--dim); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(55, 214, 122, .15); }
.dot.off { background: var(--dim); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 200, 87, .15); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 122, .15); }

/* forms */
.add-form {
  display: grid; grid-template-columns: 1fr 1fr 170px auto; gap: 12px; align-items: end;
}
@media (max-width: 900px) { .add-form { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .add-form { grid-template-columns: 1fr; } }

.hs-options {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(90, 160, 255, 0.04);
}
.hs-options-title {
  grid-column: 1 / -1;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.hs-options-note { grid-column: 1 / -1; margin: 0; }
.hs-options[hidden] { display: none; }
@media (max-width: 620px) { .hs-options { grid-template-columns: 1fr; } }
.regen-form { flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.regen-form label.tiny { display: flex; flex-direction: column; gap: 4px; }
.regen-form select { min-width: 130px; }
.manual-install { margin-top: 14px; }
.manual-install summary {
  cursor: pointer; font-size: 13px; color: var(--muted); user-select: none;
}
.manual-install summary:hover { color: var(--text); }
.manual-install[open] summary { margin-bottom: 8px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: #0a0f1e; border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 10px 12px; font-size: 14px; font-family: inherit;
  width: 100%; min-width: 0;
}
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
select { appearance: none; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(109, 140, 255, .45); outline-offset: 1px; border-color: var(--accent);
}
.field-help { color: var(--dim); font-size: 11.5px; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; color: var(--text); }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
label.check > span { display: flex; flex-direction: column; gap: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 9px 18px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-weight: 700; font-size: 14px; font-family: inherit;
  box-shadow: 0 8px 22px rgba(109, 140, 255, .25);
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 12.5px; border-radius: 9px; box-shadow: none; }
.btn.ghost {
  background: var(--card2); border-color: var(--line); color: var(--text);
  box-shadow: none; font-weight: 600;
}
.btn.danger { background: linear-gradient(135deg, #ff5d6e, #d93a53); box-shadow: 0 8px 22px rgba(255, 93, 110, .22); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
table.data th, table.data td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data thead th { background: var(--card2); color: var(--muted); font-size: 12px; font-weight: 700; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: rgba(109, 140, 255, .04); }
table.data td.wrap-cell { white-space: normal; min-width: 220px; }
.user-link { font-weight: 700; color: var(--text); }
.user-link:hover { color: var(--accent); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mini {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 9px; border-radius: 8px; font-size: 12px;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.mini:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }
.mini.danger { color: #ffc3ca; border-color: rgba(255, 107, 122, .3); }
.mini.danger:hover { background: rgba(255, 107, 122, .12); }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }

/* layout helpers */
.two-col { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }

.link-list { display: flex; flex-direction: column; gap: 12px; }
.link-list input { direction: ltr; font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; }
.note {
  margin-top: 14px; padding: 11px 14px; border-radius: 11px; font-size: 12.5px;
  background: rgba(255, 200, 87, .07); border: 1px solid rgba(255, 200, 87, .22); color: #f4d799;
}
.code {
  background: #070b16; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 14px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; line-height: 1.6; color: #c6d2ec;
  direction: ltr; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere;
  margin: 0;
}
.qr-grid { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.qr { margin: 0; text-align: center; }
.qr img, .qr canvas {
  width: 170px; height: 170px; background: #fff; padding: 8px; border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .35);
}
.qr figcaption { color: var(--muted); font-size: 12px; margin-top: 8px; }
.danger-zone { border-color: rgba(255, 107, 122, .28); }
.danger-zone .panel-head h2 { color: #ffb6bf; }

/* logs */
.logs {
  margin: 0; padding: 16px; background: #070b16; border: 1px solid var(--line);
  border-radius: 12px; overflow: auto; max-height: 68vh;
  direction: ltr; text-align: left; font-size: 12px; line-height: 1.6;
  font-family: ui-monospace, Consolas, monospace; color: #c6d2ec;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.logs.short { max-height: 320px; }

/* maintenance */
.warn-text { color: var(--warn) !important; }
.maintenance .meta-grid { margin-bottom: 4px; }
.maintenance .maint-log {
  margin-top: 14px; background: var(--card2); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden;
}
.maintenance .maint-log summary {
  padding: 10px 14px; cursor: pointer; font-size: 12.5px; color: var(--muted);
  list-style: none;
}
.maintenance .maint-log summary::-webkit-details-marker { display: none; }
.maintenance .maint-log summary:after { content: "+"; float: inline-end; }
.maintenance .maint-log[open] summary:after { content: "–"; }
.maintenance .maint-log pre {
  margin: 0; padding: 0 14px 14px; max-height: 260px; overflow: auto;
  font-size: 11.5px; line-height: 1.55; color: var(--muted);
  white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; text-align: left;
}

/* error */
.error-panel { text-align: center; padding: 46px 22px; }
.error-panel h1 { margin: 0; font-size: 62px; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 420px; padding: 22px; }
.login-card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: 20px; padding: 30px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
}
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-brand p { margin: 0; color: var(--dim); font-size: 12.5px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card .btn { margin-top: 4px; }
.login-note { margin: 18px 0 0; color: var(--dim); font-size: 12px; text-align: center; }
.login-lang { display: flex; justify-content: flex-end; margin-bottom: 14px; }

/* protocol cards on the client page */
.proto-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
@media (max-width: 860px) { .proto-grid { grid-template-columns: 1fr; } }
.proto {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.proto-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.proto-title { display: flex; flex-direction: column; gap: 2px; }
.proto-title strong { font-size: 17px; }
.proto-title span { color: var(--dim); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 4px 10px; font-size: 11.5px; font-weight: 700; border: 1px solid var(--line);
  background: var(--card2); color: var(--muted); white-space: nowrap;
}
.badge.on { color: #bfffd8; border-color: rgba(55, 214, 122, .3); background: rgba(55, 214, 122, .09); }
.badge.bad { color: #ffc3ca; border-color: rgba(255, 107, 122, .35); background: rgba(255, 107, 122, .1); }
.badge.warn { color: #ffe2a3; border-color: rgba(255, 200, 87, .38); background: rgba(255, 200, 87, .1); }

/* install progress */
.install-log { margin-top: 12px; }
.progress {
  height: 6px; border-radius: 999px; background: var(--card2); overflow: hidden;
  border: 1px solid var(--line);
}
.progress > span {
  display: block; height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { margin-inline-start: -30%; }
  100% { margin-inline-start: 100%; }
}

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

/* confirm modal */
body.modal-open { overflow: hidden; }
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 20px;
  background: rgba(4, 7, 16, .68);
  backdrop-filter: blur(4px);
  animation: modal-fade .14s ease-out;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 430px; margin: 0;
  padding: 24px 24px 18px; text-align: center;
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .6);
  animation: modal-in .18s cubic-bezier(.2, .9, .3, 1.1);
}
.modal-icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  display: grid; place-items: center; border-radius: 16px;
  color: var(--warn); background: rgba(255, 200, 87, .1);
  border: 1px solid rgba(255, 200, 87, .28);
}
.modal-icon svg { width: 26px; height: 26px; }
.modal h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.modal p { margin: 0 0 20px; color: var(--muted); font-size: 13.5px; line-height: 1.65; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions .btn { min-height: 42px; font-size: 14px; }
@media (max-width: 420px) {
  .modal { padding: 20px 18px 16px; }
  .modal-actions { grid-template-columns: 1fr; }
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: none; }
}
