:root {
  --bg: #0a0e1a;
  --bg-grad-1: #12172b;
  --bg-grad-2: #0a0e1a;
  --panel: rgba(255,255,255,.04);
  --panel-border: rgba(255,255,255,.08);
  --text: #eef2ff;
  --muted: #93a0c0;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --radius: 18px;
}

.light {
  --bg: #eef1f9;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #f8fafc;
  --panel: rgba(255,255,255,.75);
  --panel-border: rgba(15,23,42,.08);
  --text: #0f172a;
  --muted: #55618a;
}

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

body {
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  background:
    radial-gradient(1000px 600px at 90% -10%, rgba(124,92,255,.22), transparent 60%),
    radial-gradient(800px 500px at 0% 0%, rgba(34,211,238,.14), transparent 55%),
    linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }

/* ---- تاپ‌بار افقی ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(10,14,26,.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--panel-border);
}
.light .topbar { background: rgba(255,255,255,.6); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.logo .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; font-size: 1.1rem;
}
.topnav { display: flex; gap: 6px; }
.topnav a {
  padding: 9px 16px; border-radius: 12px; color: var(--muted); font-weight: 700; font-size: .9rem;
  transition: .15s;
}
.topnav a:hover { color: var(--text); background: var(--panel); }
.topnav a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.round-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--panel-border);
  background: var(--panel); color: var(--text); cursor: pointer; font-size: 1rem;
}
.round-btn:hover { border-color: var(--accent); }

/* ---- محتوا ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 28px; }
.page-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 24px; font-size: .9rem; }

.grid { display: grid; gap: 18px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }

/* ---- کارت شیشه‌ای ---- */
.glass {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 22px;
}

.metric { position: relative; overflow: hidden; }
.metric .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.metric .ico {
  width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 1.3rem;
}
.metric .lbl { color: var(--muted); font-size: .82rem; font-weight: 600; }
.metric .val { font-size: 1.7rem; font-weight: 800; margin-top: 2px; }
.metric .val small { font-size: .95rem; color: var(--muted); font-weight: 600; }
.ico.violet { background: rgba(124,92,255,.16); color: #a78bfa; }
.ico.cyan   { background: rgba(34,211,238,.16); color: var(--accent-2); }
.ico.green  { background: rgba(52,211,153,.16); color: var(--green); }
.ico.blue   { background: rgba(96,165,250,.16); color: var(--blue); }
.ico.amber  { background: rgba(251,191,36,.16); color: var(--amber); }
.ico.pink   { background: rgba(251,113,133,.16); color: var(--red); }

.bar { height: 7px; border-radius: 20px; background: var(--panel-border); overflow: hidden; margin-top: 12px; }
.bar > i { display: block; height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-head h2 { font-size: 1.1rem; font-weight: 800; display: flex; gap: 8px; align-items: center; }

/* فرم */
label { display: block; margin-bottom: 6px; font-size: .84rem; color: var(--muted); font-weight: 600; }
input, select {
  width: 100%; background: rgba(0,0,0,.2); border: 1px solid var(--panel-border);
  color: var(--text); padding: 12px 14px; border-radius: 12px; margin-bottom: 14px;
  font-family: inherit; font-size: .92rem; outline: none;
}
.light input, .light select { background: rgba(255,255,255,.7); }
input:focus, select:focus { border-color: var(--accent); }

button { cursor: pointer; border: none; border-radius: 12px; padding: 12px 18px; font-family: inherit; font-weight: 700; font-size: .9rem; transition: .15s; }
.btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.chip { padding: 7px 11px; border-radius: 10px; font-size: .8rem; }
.chip.g { background: rgba(124,92,255,.16); color: #a78bfa; }
.chip.s { background: var(--panel); border: 1px solid var(--panel-border); color: var(--text); }
.chip.r { background: rgba(251,113,133,.16); color: var(--red); }
.chip.w { background: rgba(251,191,36,.16); color: var(--amber); }

/* جدول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
th { color: var(--muted); font-weight: 700; font-size: .76rem; text-align: right; padding: 0 12px 4px; }
td { padding: 14px 12px; font-size: .87rem; background: var(--panel); border-top: 1px solid var(--panel-border); border-bottom: 1px solid var(--panel-border); }
td:first-child { border-right: 1px solid var(--panel-border); border-radius: 0 12px 12px 0; }
td:last-child { border-left: 1px solid var(--panel-border); border-radius: 12px 0 0 12px; }
tr:hover td { background: rgba(124,92,255,.06); }

.badge { padding: 5px 11px; border-radius: 20px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge.on { background: rgba(52,211,153,.16); color: var(--green); }
.badge.off { background: rgba(251,113,133,.16); color: var(--red); }
.badge.expired { background: rgba(251,191,36,.16); color: var(--amber); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-left: 7px; vertical-align: middle; }
.dot.online { background: var(--green); box-shadow: 0 0 10px var(--green); }

.actions { display: flex; gap: 6px; justify-content: center; }
.actions form { display: inline; }

.flash { padding: 13px 18px; border-radius: 14px; margin-bottom: 16px; font-weight: 600; font-size: .9rem; }
.flash.success { background: rgba(52,211,153,.14); color: var(--green); }
.flash.error { background: rgba(251,113,133,.14); color: var(--red); }

.muted { color: var(--muted); font-size: .85rem; }
.pill { background: var(--panel); border: 1px solid var(--panel-border); padding: 5px 12px; border-radius: 20px; font-size: .78rem; font-family: monospace; }
.mono { font-family: monospace; direction: ltr; }

.health-row { display: flex; gap: 26px; flex-wrap: wrap; }
.health-item { display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* مودال QR */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; place-items: center; z-index: 60; padding: 20px; }
.overlay.show { display: grid; }
.modal { background: var(--bg-grad-1); border: 1px solid var(--panel-border); border-radius: 20px; padding: 26px; max-width: 340px; width: 100%; text-align: center; }
.modal img { background: #fff; border-radius: 14px; padding: 12px; }

/* ورود */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { max-width: 400px; width: 100%; }
.login-card .mark-lg { width: 62px; height: 62px; border-radius: 18px; margin: 0 auto 14px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; font-size: 1.8rem; }
.login-card h1 { text-align: center; font-size: 1.4rem; }
.login-card .page-sub { text-align: center; }
.login-card input { text-align: left; }

/* لاگ */
.log-box { background: rgba(0,0,0,.35); border: 1px solid var(--panel-border); border-radius: 14px; padding: 16px; overflow-x: auto; }
.log-box pre { font-family: monospace; font-size: .8rem; white-space: pre-wrap; direction: ltr; }
.log-err { color: var(--red); }
.log-acc { color: var(--green); }

@media (max-width: 950px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .topnav a { padding: 8px 11px; font-size: .82rem; }
  .container { padding: 18px; }
  .logo span.txt { display: none; }
}
