/* ── Vazirmatn Font ─────────────────────────────────────── */
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── Reset & Root ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base:        #060b18;
  --bg-surface:     #0d1628;
  --bg-elevated:    #111d35;
  --bg-card:        #131f38;
  --bg-card-hover:  #172341;
  --border:         rgba(99, 140, 255, 0.12);
  --border-strong:  rgba(99, 140, 255, 0.22);

  --accent:         #4f8eff;
  --accent-light:   #6fa3ff;
  --accent-glow:    rgba(79, 142, 255, 0.25);
  --accent-dim:     rgba(79, 142, 255, 0.08);

  --success:        #22d3a0;
  --success-glow:   rgba(34, 211, 160, 0.20);
  --success-dim:    rgba(34, 211, 160, 0.08);
  --danger:         #ff5c7a;
  --danger-glow:    rgba(255, 92, 122, 0.20);
  --danger-dim:     rgba(255, 92, 122, 0.08);
  --warn:           #ffb547;
  --warn-glow:      rgba(255, 181, 71, 0.20);
  --warn-dim:       rgba(255, 181, 71, 0.08);
  --purple:         #a78bfa;
  --cyan:           #22d3ee;
  --cyan-dim:       rgba(34, 211, 238, 0.12);

  --text-primary:   #e8eeff;
  --text-secondary: #8ba0cc;
  --text-muted:     #4e6490;

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;
  --shadow-card: 0 4px 32px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.04) inset;
}

/* ── Base ───────────────────────────────────────────────── */
html { font-size: 16px; }

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  font-weight: 400;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79,142,255,0.10) 0%, transparent 60%),
    linear-gradient(rgba(99,140,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,140,255,0.025) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Layout ─────────────────────────────────────────────── */
.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(13,22,40,0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 1rem;
  z-index: 100;
}

.topbar-brand { display: flex; align-items: center; gap: 0.9rem; }

.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 0 20px var(--accent-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.brand-text span { font-size: 0.72rem; color: var(--text-muted); display: block; }

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.user-badge {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.9rem 0.4rem 0.6rem;
  background: var(--accent-dim);
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  font-size: 0.8rem;
  color: var(--accent-light);
  font-weight: 600;
}

.user-badge::before {
  content: '';
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success);
  animation: pulse-dot 2s infinite;
}

.btn-logout {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1rem;
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255,92,122,0.25);
  border-radius: var(--radius-sm);
  font-size: 0.82rem; font-weight: 600;
  font-family: inherit;
  text-decoration: none; cursor: pointer;
  transition: all 0.2s ease;
}
.btn-logout:hover {
  background: rgba(255,92,122,0.15);
  border-color: var(--danger);
  box-shadow: 0 0 12px var(--danger-glow);
}

/* ── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  position: relative; overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.3); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px; border-radius: 99px;
}
.stat-card.accent::before  { background: linear-gradient(90deg, var(--accent), #7c3aed); }
.stat-card.success::before { background: linear-gradient(90deg, var(--success), var(--cyan)); }
.stat-card.warn::before    { background: linear-gradient(90deg, var(--warn), #f97316); }
.stat-card.danger::before  { background: linear-gradient(90deg, var(--danger), #f97316); }

.stat-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.55rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-sub   { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.35rem; }
.stat-icon  { position: absolute; top: 1.2rem; left: 1.2rem; font-size: 1.6rem; opacity: 0.12; }

/* ── Alert ──────────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.88rem;
  border: 1px solid;
  animation: slideDown 0.3s ease;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 0.05rem; }
.alert.success { background: var(--success-dim); border-color: rgba(34,211,160,0.25); color: var(--success); }
.alert.error   { background: var(--danger-dim);  border-color: rgba(255,92,122,0.25); color: var(--danger); }
.alert.warning { background: var(--warn-dim);    border-color: rgba(255,181,71,0.25); color: var(--warn); }
.alert.info    { background: var(--accent-dim);  border-color: var(--border-strong);  color: var(--accent-light); }

/* ── Section Header ─────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 0.8rem; font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.1em;
  display: flex; align-items: center; gap: 0.5rem;
}
.section-title::before {
  content: '';
  width: 3px; height: 14px;
  background: linear-gradient(180deg, var(--accent), var(--purple));
  border-radius: 99px;
}
.refresh-time { font-size: 0.73rem; color: var(--text-muted); }

/* ── Table ──────────────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.855rem; min-width: 820px; }

thead tr { background: rgba(6,11,24,0.6); border-bottom: 1px solid var(--border-strong); }

th {
  padding: 0.9rem 1rem;
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  white-space: nowrap;
}

tbody tr { border-bottom: 1px solid rgba(99,140,255,0.06); transition: background 0.15s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(79,142,255,0.04); }

td { padding: 0.95rem 1rem; text-align: right; vertical-align: middle; white-space: nowrap; }

/* ── Cell Types ─────────────────────────────────────────── */
.client-cell { display: flex; flex-direction: column; gap: 0.15rem; }
.client-email   { font-weight: 600; color: var(--text-primary); font-size: 0.875rem; }
.client-inbound { font-size: 0.72rem; color: var(--text-muted); }

.status-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.65rem; border-radius: 99px;
  font-size: 0.73rem; font-weight: 600;
}
.status-badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.status-on  { background: var(--success-dim); border: 1px solid rgba(34,211,160,0.25); color: var(--success); }
.status-on::before  { background: var(--success); box-shadow: 0 0 4px var(--success); animation: pulse-dot 2s infinite; }
.status-off { background: var(--danger-dim);  border: 1px solid rgba(255,92,122,0.2);  color: var(--danger); }
.status-off::before { background: var(--danger); }

.traffic-up   { color: var(--purple); font-weight: 600; }
.traffic-down { color: var(--cyan);   font-weight: 600; }
.traffic-used { color: var(--text-primary); font-weight: 700; }

.quota-wrap     { display: flex; flex-direction: column; gap: 0.15rem; }
.quota-total    { font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; }
.quota-remain   { font-size: 0.72rem; color: var(--text-muted); }
.quota-unlimited{ font-size: 0.82rem; color: var(--text-muted); font-style: italic; }

/* ── Progress ───────────────────────────────────────────── */
.progress-cell { min-width: 130px; }
.progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.35rem; }
.progress-pct { font-size: 0.75rem; font-weight: 700; }
.progress-track { height: 5px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1);
  position: relative;
}
.progress-fill::after {
  content: ''; position: absolute; top: 0; right: 0; bottom: 0;
  width: 40%; background: rgba(255,255,255,0.25); border-radius: 99px;
}
.pct-ok    .progress-pct { color: var(--accent-light); }
.pct-ok    .progress-fill { background: linear-gradient(90deg, var(--accent), #7c3aed); }
.pct-warn  .progress-pct { color: var(--warn); }
.pct-warn  .progress-fill { background: linear-gradient(90deg, var(--warn), #f97316); }
.pct-danger .progress-pct { color: var(--danger); }
.pct-danger .progress-fill { background: linear-gradient(90deg, var(--danger), #f97316); }

.expiry-date  { font-size: 0.8rem; color: var(--text-secondary); }
.expiry-never { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

/* ── GB Control ─────────────────────────────────────────── */
.gb-control { display: flex; align-items: center; gap: 0.3rem; direction: ltr; }
.gb-input {
  width: 58px; padding: 0.35rem 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.82rem;
  text-align: center; outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  -moz-appearance: textfield;
}
.gb-input::-webkit-inner-spin-button,
.gb-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.gb-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.gb-label { font-size: 0.72rem; color: var(--text-muted); }

/* ── Action Buttons ─────────────────────────────────────── */
.action-group { display: flex; gap: 0.35rem; justify-content: flex-end; flex-wrap: nowrap; }

.btn-action {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.38rem 0.75rem;
  border: 1px solid; border-radius: var(--radius-sm);
  font-size: 0.78rem; font-weight: 700;
  font-family: inherit;
  cursor: pointer; white-space: nowrap;
  background: transparent;
  transition: all 0.18s ease;
}
.btn-action:hover  { transform: translateY(-1px); }
.btn-action:active { transform: scale(0.97); }

.btn-plus  { color: var(--success); border-color: rgba(34,211,160,0.3);  background: var(--success-dim); }
.btn-plus:hover  { background: rgba(34,211,160,0.14); border-color: var(--success); box-shadow: 0 4px 14px var(--success-glow); }
.btn-minus { color: var(--warn);    border-color: rgba(255,181,71,0.3);   background: var(--warn-dim); }
.btn-minus:hover { background: rgba(255,181,71,0.14); border-color: var(--warn); box-shadow: 0 4px 14px var(--warn-glow); }
.btn-reset { color: var(--danger);  border-color: rgba(255,92,122,0.3);   background: var(--danger-dim); }
.btn-reset:hover { background: rgba(255,92,122,0.14); border-color: var(--danger); box-shadow: 0 4px 14px var(--danger-glow); }

/* ── Empty State ────────────────────────────────────────── */
.empty-state { padding: 4rem 2rem; text-align: center; }
.empty-icon  { font-size: 3.5rem; margin-bottom: 1rem; display: block; opacity: 0.4; }
.empty-title { font-size: 1rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.empty-hint  { font-size: 0.8rem; color: var(--text-muted); }
.empty-hint code {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  font-size: 0.78rem; color: var(--accent-light);
}

/* ── Footer ─────────────────────────────────────────────── */
.footer { text-align: center; margin-top: 2rem; font-size: 0.73rem; color: var(--text-muted); }
.footer span { color: var(--accent-light); }

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%; max-width: 400px;
  background: rgba(13,22,40,0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03) inset;
  animation: fadeUp 0.4s ease;
}

.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1.5rem;
  box-shadow: 0 0 40px var(--accent-glow);
}

.login-title    { text-align: center; font-size: 1.3rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.35rem; }
.login-subtitle { text-align: center; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2rem; }

.form-group  { margin-bottom: 1.25rem; }
.form-label  { display: block; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.5rem; font-weight: 600; }
.form-input  {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 0.95rem;
  font-family: inherit; outline: none;
  transition: all 0.2s ease;
}
.form-input:focus { border-color: var(--accent); background: var(--bg-elevated); box-shadow: 0 0 0 3px var(--accent-glow); }

.btn-login {
  width: 100%; padding: 0.8rem;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px var(--accent-glow);
  margin-top: 0.5rem;
  position: relative; overflow: hidden;
}
.btn-login::before {
  content: ''; position: absolute; top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.12), transparent);
  transition: left 0.45s ease;
}
.btn-login:hover::before { left: 100%; }
.btn-login:hover { box-shadow: 0 6px 28px rgba(79,142,255,0.45); transform: translateY(-1px); }
.btn-login:active { transform: scale(0.99); }

/* ── Dialog ─────────────────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  justify-content: center; align-items: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.active { display: flex; animation: fadeIn 0.2s ease; }

.dialog-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 2rem;
  max-width: 400px; width: 90%;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  animation: dialogPop 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.dialog-icon {
  width: 56px; height: 56px;
  background: var(--warn-dim);
  border: 1px solid rgba(255,181,71,0.3);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.7rem;
  margin: 0 auto 1.25rem;
}
.dialog-title { text-align: center; font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.5rem; }
.dialog-msg   { text-align: center; font-size: 0.87rem; color: var(--text-secondary); line-height: 1.65; margin-bottom: 1.75rem; word-break: break-all; }
.dialog-actions { display: flex; gap: 0.75rem; }

.btn-dialog {
  flex: 1; padding: 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 700; font-family: inherit;
  cursor: pointer; border: 1px solid;
  transition: all 0.18s ease;
}
.btn-confirm { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: 0 4px 16px var(--danger-glow); }
.btn-confirm:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-cancel { background: transparent; color: var(--text-secondary); border-color: var(--border-strong); }
.btn-cancel:hover { background: var(--bg-card); color: var(--text-primary); }

/* ── Animations ─────────────────────────────────────────── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(0.85); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dialogPop {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { position: static; padding: 0.85rem 1rem; }
  .brand-text span { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .stat-value { font-size: 1.25rem; }
  th, td { padding: 0.7rem 0.6rem; }
  .page-wrapper { padding: 1rem 0.75rem 2rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .user-badge { display: none; }
}
