/* Smart Proxy Manager — dark panel theme (RTL) */
:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --card: #1b222c;
  --border: #2d3742;
  --text: #e6edf3;
  --muted: #8b949e;
  --primary: #3b82f6;
  --primary-soft: #1d4ed84d;
  --ok: #22c55e;
  --warn: #eab308;
  --bad: #ef4444;
  --purple: #a78bfa;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--bg-soft); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.brand-icon { font-size: 26px; }
.brand-title { font-weight: 700; font-size: 15px; }
.brand-sub { color: var(--muted); font-size: 11px; }
.sidebar nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  color: var(--text); text-decoration: none; padding: 10px 12px; border-radius: 8px;
  display: flex; gap: 10px; align-items: center; font-size: 14px;
}
.sidebar nav a:hover { background: var(--card); }
.sidebar nav a.active { background: var(--primary-soft); color: #93c5fd; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.content { flex: 1; padding: 26px 30px; max-width: 1400px; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0 0 12px; }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; margin-bottom: 18px;
}
.table-card { padding: 6px 12px 12px; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: right; color: var(--muted); font-weight: 600; padding: 10px 8px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 9px 8px; border-bottom: 1px solid #21283230; vertical-align: middle; }
.table tr:hover td { background: #ffffff06; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12px; }
.stat.ok .num { color: var(--ok); }
.stat.bad .num { color: var(--bad); }
.stat.warn .num { color: var(--warn); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge.HEALTHY, .badge.RECOVERED, .badge.active, .badge.ok { background: #22c55e26; color: var(--ok); }
.badge.NEW { background: #3b82f626; color: #60a5fa; }
.badge.UNSTABLE, .badge.pending, .badge.pending_login { background: #eab30826; color: var(--warn); }
.badge.DOWN, .badge.error, .badge.critical { background: #ef444426; color: var(--bad); }
.badge.BLACKLISTED, .badge.DISABLED, .badge.disabled, .badge.needs_relogin { background: #6b728026; color: #9ca3af; }
.badge.warning { background: #eab30826; color: var(--warn); }
.badge.info { background: #3b82f626; color: #60a5fa; }

.btn {
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: filter .15s;
}
.btn:hover { filter: brightness(1.25); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: #7f1d1d; border-color: #b91c1c; }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-family: inherit; font-size: 13px; width: 100%;
}
input:focus, select:focus { outline: 1px solid var(--primary); }
label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 6px; margin: 0; }
.check input { width: auto; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-grid .full, .form-grid .wide { grid-column: 1 / -1; }
.form-error { color: var(--bad); font-size: 12px; margin-top: 10px; min-height: 16px; }
.ok-text { color: var(--ok); }
.muted { color: var(--muted); font-size: 12px; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; direction: ltr; display: inline-block; }

.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { width: auto; min-width: 140px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

.pager { display: flex; align-items: center; gap: 12px; padding: 10px 4px; }

.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(ellipse at top, #10233f, var(--bg)); }
.auth-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 380px; display: flex; flex-direction: column; gap: 4px;
}
.auth-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.auth-card .btn { margin-top: 8px; }

.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal.hidden, .hidden { display: none; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 360px; display: flex; flex-direction: column; gap: 10px; }
.modal-box input { margin-bottom: 6px; }

#toast-wrap { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-right: 4px solid var(--primary);
  padding: 12px 16px; border-radius: 10px; min-width: 260px; animation: slidein .25s;
}
.toast.ok { border-right-color: var(--ok); }
.toast.bad { border-right-color: var(--bad); }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } }

.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-inline-start: 6px; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

.log-view pre {
  direction: ltr; text-align: left; font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px; max-height: 70vh; overflow: auto; white-space: pre-wrap; color: #c9d1d9;
}

.url-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; display: inline-block; }
.copy-btn { cursor: pointer; }

/* gateway page (v1.0.3, multi-profile) */
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row input { flex: 1; direction: ltr; text-align: left; font-size: 12px; }
.inline-btns { display: flex; gap: 6px; align-items: center; }
.inline-btns input { flex: 1; min-width: 0; direction: ltr; text-align: left; font-size: 11px; }
.gw-node-box {
  background: var(--bg); border: 1px dashed var(--border); border-radius: 10px;
  padding: 12px 14px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
}
.gw-node-box .item { display: flex; flex-direction: column; gap: 2px; }
.gw-node-box .item .k { color: var(--muted); font-size: 11px; }
.gw-node-box .item .v { font-weight: 600; font-size: 13px; }
.gw-item {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  margin-bottom: 12px; background: var(--bg);
}
.gw-item.off { opacity: 0.6; }
.gw-item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.gw-item-head .title { font-weight: 700; font-size: 14px; }
.gw-item-head .btn { margin-inline-start: auto; }
.gw-item-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.gw-item-meta .m { display: flex; flex-direction: column; gap: 2px; }
.gw-item-meta .m .k { color: var(--muted); font-size: 11px; }
.gw-item-meta .m .v { font-weight: 600; font-size: 12.5px; }
.gw-test-result { margin-top: 8px; font-size: 12.5px; }
.gw-test-result.ok { color: var(--ok); }
.gw-test-result.bad { color: var(--bad); }
/* v1.0.8: quota / online stats blocks inside each gateway card */
.gw-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
}
.gw-quota {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--bg); display: flex; flex-direction: column; gap: 6px;
}
.gw-quota-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gw-quota-row .k { color: var(--muted); font-size: 11px; min-width: 110px; }
.gw-quota-row .v { font-weight: 600; font-size: 12.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gw-quota-row .v.inline-btns { flex: 1; }
.gw-usage-bar {
  height: 8px; border-radius: 6px; background: var(--border); overflow: hidden; direction: ltr;
}
.gw-usage-fill { height: 100%; background: var(--ok); border-radius: 6px; transition: width .4s; }
.gw-usage-fill.high { background: var(--warn); }
.gw-usage-fill.full { background: var(--bad); }
.gw-ip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.gw-ip {
  font-size: 11px; border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 8px; background: #22c55e14; color: var(--ok); direction: ltr;
}
.badge.bad { background: #ef444426; color: var(--bad); }
.code-block {
  direction: ltr; text-align: left; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 11.5px; white-space: pre; overflow-x: auto; color: #c9d1d9; margin: 0 0 10px;
}

.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-inline-end: 4px; }
footer.version { color: var(--muted); font-size: 11px; margin-top: 30px; }
