:root {
  --bg: #070b16;
  --bg2: #0b1220;
  --card: #111a2e;
  --card2: #16213a;
  --border: #1e2a45;
  --text: #e9edf8;
  --muted: #93a0bb;
  --accent: #8b5cf6;
  --accent-2: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(59, 130, 246, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: #a78bfa; text-decoration: none; }
a:hover { color: #c4b5fd; }
h1, h2, h3, h4 { margin: 0 0 0.4em; line-height: 1.2; font-weight: 650; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.8em; }
small, .muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86em; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ===== Layout ===== */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, rgba(17, 26, 46, 0.95), rgba(9, 14, 26, 0.95));
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 18px;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}
.brand-name { font-weight: 700; letter-spacing: 0.3px; }
.brand-sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.nav-group { margin-top: 10px; }
.nav-label { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 2px 0; border-radius: 10px;
  color: #c7d2e8; font-weight: 500;
}
.nav-link:hover { background: rgba(139, 92, 246, 0.1); color: #fff; }
.nav-link.active { background: linear-gradient(90deg, rgba(139, 92, 246, 0.22), rgba(59, 130, 246, 0.1)); color: #fff; box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.25); }
.sidebar-foot { margin-top: 20px; padding: 12px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 26px; border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 22, 0.75); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 650; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; }
.content { padding: 24px 26px 60px; max-width: 1240px; width: 100%; }
.nav-toggle { display: none; }

/* ===== Components ===== */
.card { background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat { background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }
.stat-note { color: var(--muted); font-size: 0.8rem; margin-top: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: #16213a; color: var(--text);
  padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 0.88rem;
  cursor: pointer; transition: 0.15s ease; text-decoration: none;
}
.btn:hover { border-color: #33456b; color: #fff; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.btn-warn { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.label { display: block; font-size: 0.78rem; color: var(--muted); margin: 0 0 5px; font-weight: 600; letter-spacing: 0.03em; }
.input, select, textarea {
  width: 100%; background: #0c1526; border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 0.9rem; font-family: inherit;
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18); }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: #cbd5e1; }
.check input { width: auto; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid rgba(30, 42, 69, 0.7); vertical-align: top; }
th { background: rgba(11, 18, 32, 0.9); color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 650; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(139, 92, 246, 0.05); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 650; border: 1px solid transparent; }
.badge-ok { background: rgba(34, 197, 94, 0.12); color: #86efac; border-color: rgba(34, 197, 94, 0.35); }
.badge-warn { background: rgba(245, 158, 11, 0.12); color: #fcd34d; border-color: rgba(245, 158, 11, 0.35); }
.badge-err { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.35); }
.badge-info { background: rgba(59, 130, 246, 0.12); color: #93c5fd; border-color: rgba(59, 130, 246, 0.35); }
.badge-muted { background: rgba(148, 163, 184, 0.1); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.25); }

.progress { height: 8px; background: #0c1526; border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }

.alert { border-radius: 12px; padding: 11px 14px; margin: 0 0 14px; border: 1px solid; font-size: 0.88rem; }
.alert-ok { background: rgba(34, 197, 94, 0.08); border-color: rgba(34, 197, 94, 0.35); color: #bbf7d0; }
.alert-err { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.35); color: #fecaca; }
.alert-warn { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.35); color: #fde68a; }
.alert-info { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.35); color: #bfdbfe; }

.proxy-line { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: #0c1526; margin-bottom: 8px; }
.proxy-line code { flex: 1; word-break: break-all; font-size: 0.8rem; color: #d8e0f0; }

.pager { display: flex; gap: 8px; margin-top: 14px; align-items: center; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 0.88rem; }
.kv dt { color: var(--muted); }

/* ===== Public / landing ===== */
.public-shell { max-width: 1120px; margin: 0 auto; padding: 0 22px; }
.public-nav { display: flex; align-items: center; justify-content: space-between; padding: 22px 0; }
.public-nav .brand { padding: 0; }
.hero { padding: 56px 0 34px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -0.02em; }
.hero p.lead { color: var(--muted); max-width: 640px; margin: 10px auto 26px; font-size: 1.02rem; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: rgba(139, 92, 246, 0.08); color: #c4b5fd; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; }
.feature-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin: 26px 0; }
.feature { background: linear-gradient(180deg, var(--card), var(--card2)); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.feature .icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(139, 92, 246, 0.15); margin-bottom: 10px; font-size: 18px; }
.steps { counter-reset: step; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 20px 0; }
.step { background: rgba(17, 26, 46, 0.6); border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: relative; }
.step::before { counter-increment: step; content: counter(step); position: absolute; top: -12px; left: 14px; width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; }
.public-footer { border-top: 1px solid var(--border); margin-top: 40px; padding: 22px 0 40px; color: var(--muted); font-size: 0.82rem; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-card { max-width: 430px; margin: 6vh auto 40px; }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; margin-bottom: 18px; }

/* ===== Responsive ===== */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 270px; z-index: 50;
    transform: translateX(-102%); transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; }
  .nav-toggle { display: inline-flex; }
  .content { padding: 18px 16px 50px; }
  .topbar { padding: 12px 16px; }
  .kv { grid-template-columns: 110px 1fr; }
}

/* ===== Proxy Generator (gaya provider) ===== */
.gen-shell { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
.gen-form .field { margin-bottom: 12px; }
.gen-form .label { margin-bottom: 6px; }
.gen-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gen-hint { color: var(--muted); font-size: 0.72rem; margin-top: 4px; line-height: 1.45; }
.gen-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: #0e1727; color: var(--muted); font-size: 0.72rem; font-weight: 600; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg label {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #0e1727;
  font-size: 0.82rem; color: #cbd5e1; cursor: pointer; user-select: none;
}
.seg input { width: auto; margin: 0; accent-color: var(--accent); }
.seg label:has(input:checked) { border-color: rgba(139, 92, 246, 0.65); background: rgba(139, 92, 246, 0.12); color: #ddd6fe; }
select option:disabled { color: #586580; }
.gen-result {
  position: sticky; top: 16px; min-height: 540px; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0a101f, #0d1527); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.gen-result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 0.82rem; font-weight: 600; }
.gen-result-body { flex: 1; padding: 14px; overflow: auto; max-height: 58vh; }
.gen-empty { min-height: 380px; display: grid; place-items: center; text-align: center; padding: 30px 22px; color: #66738f; font-size: 0.86rem; line-height: 1.6; }
.gen-result-foot { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.gen-result-foot .btn { flex: 1; justify-content: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 1040px) {
  .gen-shell { grid-template-columns: 1fr; }
  .gen-result { position: static; min-height: 320px; }
  .gen-empty { min-height: 220px; }
  .gen-2col { grid-template-columns: 1fr; }
}
