:root {
  --bg: #0b1220;
  --surface: #111827;
  --surface-soft: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --border: #334155;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

.container {
  width: min(1100px, 92%);
  margin-inline: auto;
}

.topbar {
  background: rgba(17, 24, 39, 0.9);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}

.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #f8fafc;
  text-decoration: none;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.brand-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(140deg, #0ea5e9, #6366f1);
  box-shadow: 0 0 18px rgba(14, 165, 233, 0.45);
}

.nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
}
.nav a:hover { background: rgba(148, 163, 184, 0.12); }
.nav a.nav-tickets { position: relative; }
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-right: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  border-radius: 10px;
  vertical-align: middle;
}

.main-content { padding: 28px 0 48px; }

.card, .auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 10px 28px rgba(2, 6, 23, 0.45);
}

.auth-card {
  max-width: 560px;
  margin: 32px auto;
}

.wide { width: 100%; }

.cards-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
}
th { background: var(--surface-soft); font-size: 14px; }

.form-grid {
  display: grid;
  gap: 10px;
}

input, select, textarea {
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}

.btn {
  border: 0;
  cursor: pointer;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.btn:hover { background: var(--primary-dark); }
.btn.small { padding: 7px 10px; font-size: 13px; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.danger { background: var(--danger); }
.btn.full { width: 100%; }

.badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-open { background: #dbeafe; color: #1d4ed8; }
.status-in_review { background: #fef3c7; color: #92400e; }
.status-answered { background: #dcfce7; color: #166534; }
.status-follow_up { background: #ede9fe; color: #5b21b6; }
.ok { background: #dcfce7; color: #166534; }
.warn { background: #fef3c7; color: #92400e; }

.tag {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  margin: 2px;
  font-size: 12px;
}

.filters {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 14px;
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid;
}
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.muted, .meta { color: var(--muted); font-size: 14px; }

.timeline { margin: 16px 0; display: grid; gap: 10px; }
.timeline-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.timeline-item.user {
  border-right: 4px solid #3b82f6;
  background: rgba(15, 23, 42, 0.6);
}
.timeline-item.admin {
  border-right: 4px solid #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(6, 95, 70, 0.08));
  border-color: rgba(16, 185, 129, 0.4);
}

.inline-form { display: inline-block; }
.bulk-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.bulk-row label { margin: 0; }
.bulk-row select { width: auto; min-width: 140px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.lang-switch {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1;
}

.pagination {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}
.pagination a {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  text-decoration: none;
}
.pagination a.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #fff;
  padding: 18px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
}
.sidebar-nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }

.admin-main {
  padding: 20px;
  background: var(--bg);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.stat-card p {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 700;
}

.channel-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(99, 102, 241, 0.18));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: 0 8px 32px rgba(56, 189, 248, 0.12);
}

.channel-hero h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  color: #f8fafc;
}
.channel-hero .muted {
  margin: 0;
  font-size: 14px;
}

.channel-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0ea5e9, #6366f1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  font-size: 28px;
  flex-shrink: 0;
}

.channel-feed {
  display: grid;
  gap: 16px;
  max-width: 800px;
  margin-inline: auto;
}

.channel-post {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.channel-post-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.channel-post-head h3,
.channel-post-head h1 {
  margin: 0;
  color: var(--success);
  font-weight: 700;
}
.channel-post-head h3 a.channel-post-title,
.channel-post-head h1 a.channel-post-title {
  color: var(--success);
  text-decoration: none;
}
.channel-post-head h3 a.channel-post-title:hover,
.channel-post-head h1 a.channel-post-title:hover {
  text-decoration: underline;
}
.channel-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
  opacity: 0.7;
}
.channel-post-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.95em;
}
.channel-single-head {
  flex-direction: column;
  text-align: center;
}
.channel-single-head time {
  margin-top: 4px;
}

.channel-post-head time {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.channel-post-text {
  margin: 0 0 12px;
  white-space: pre-wrap;
  line-height: 1.65;
}

.channel-post-text br {
  display: block;
  content: "";
  margin-top: 0.35em;
}

.prose.channel-post-text {
  margin-top: 8px;
}

.announcement-link {
  color: #38bdf8;
  text-decoration: underline;
}
.announcement-link:hover {
  color: #7dd3fc;
}

.channel-single {
  max-width: 760px;
  margin-inline: auto;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.modal-open {
  opacity: 1;
  visibility: visible;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}
.modal-box h3 { margin: 0 0 8px; }
.modal-status-options {
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.modal-option input { width: auto; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 920px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .topbar-inner {
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 0;
  }
  .nav {
    width: 100%;
    gap: 6px;
  }
  .nav a, .nav .btn, .nav button {
    font-size: 12px;
    padding: 6px 8px;
  }
  .btn {
    font-size: 13px;
    padding: 8px 10px;
  }
  th, td {
    padding: 8px 6px;
    font-size: 12px;
  }
  .page-head {
    flex-direction: column;
    align-items: stretch;
  }
  .filters {
    grid-template-columns: 1fr;
  }
  .channel-post-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
