:root {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-card: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #0ea5e9;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-persian, 'Vazirmatn', Tahoma, sans-serif);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: rgba(99, 102, 241, 0.12); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.18), transparent 45%), var(--bg);
}
.auth-box { width: 100%; max-width: 440px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-muted); }

.studio-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-weight: 800;
  font-size: 16px;
}
.brand-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}
.nav-group-title {
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
  text-transform: uppercase;
}
.nav-item {
  width: 100%;
  text-align: right;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-item:hover, .nav-item.active {
  background: rgba(99, 102, 241, 0.16);
  color: #fff;
}
[data-theme="light"] .nav-item:hover,
[data-theme="light"] .nav-item.active { color: var(--primary); }

.main-area { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.content-wrap { padding: 24px; flex: 1; overflow-x: auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.kpi-label { font-size: 13px; color: var(--text-muted); }

.table-wrap { overflow-x: auto; }
table.studio-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.studio-table th, table.studio-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
table.studio-table th { color: var(--text-muted); font-weight: 600; }

.toast-container {
  position: fixed;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 260px;
  font-size: 14px;
}
.toast.success { border-right: 4px solid var(--success); }
.toast.error { border-right: 4px solid var(--danger); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  display: none;
  place-items: center;
  z-index: 9000;
  padding: 16px;
}
.modal-backdrop.open { display: grid; }
.modal-dialog { width: 100%; max-width: 520px; }

.mobile-menu-btn { display: none; }

@media (max-width: 900px) {
  .studio-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    right: -280px;
    bottom: 0;
    width: 270px;
    z-index: 8000;
    transition: right 0.2s ease;
  }
  .sidebar.open { right: 0; }
  .mobile-menu-btn { display: inline-flex; }
}
