:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1d2939;
  --muted: #667085;
  --border: #d0d5dd;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning: #b45309;
  --success: #14804a;
  --info: #075985;
  --shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Tahoma, Vazirmatn, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: #0f172a;
  color: #fff;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}
.brand-icon { font-size: 24px; }
.nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-link {
  padding: 8px 12px;
  border-radius: 10px;
  color: #e5e7eb;
}
.nav-link:hover { background: rgba(255,255,255,0.12); }
.danger-link { color: #fecaca; }

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 18px 56px;
}
.footer {
  text-align: center;
  color: var(--muted);
  padding: 18px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0 0 6px; font-size: 28px; }
.page-head p { margin: 0; color: var(--muted); }
.head-actions, .quick-actions, .form-actions, .checkbox-row, .section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.section-head { justify-content: space-between; }

.panel, .auth-card, .subpanel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.subpanel {
  box-shadow: none;
  background: #fbfdff;
}
.auth-card {
  max-width: 460px;
  margin: 48px auto;
}
.panel h2, .subpanel h2 { margin-top: 0; }
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat-card span { display: block; color: var(--muted); }
.stat-card strong { display: block; font-size: 32px; margin-top: 8px; }
.big-title { font-size: 20px; font-weight: 700; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.3;
  transition: 0.15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(16,24,40,0.1); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.muted { background: #f2f4f7; }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 6px 9px; border-radius: 10px; font-size: 12px; }
.link { color: var(--primary); font-weight: 700; }
.inline-form { display: inline; }

.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 90px; }
.checkbox-card, .radio-card {
  flex-direction: row;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}
.tiny-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 400;
}
.delete-check { color: var(--danger); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 780px;
}
th, td {
  text-align: right;
  padding: 12px;
  border-bottom: 1px solid #eaecf0;
  vertical-align: top;
}
th { background: #f8fafc; color: #334155; font-weight: 700; }
tr:hover td { background: #fafafa; }
.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.wide-table table { min-width: 1200px; }

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.off { background: #fee2e2; color: #991b1b; }

.notice, .flash {
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.notice.info, .flash.info { background: #e0f2fe; color: var(--info); border-color: #bae6fd; }
.notice.warning, .flash.warning { background: #fef3c7; color: var(--warning); border-color: #fde68a; }
.notice.danger, .flash.danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.flash.success { background: #dcfce7; color: var(--success); border-color: #bbf7d0; }
.help, .empty { color: var(--muted); }
.empty { text-align: center; padding: 22px; }
.info-list {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px;
}
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 700; }
.search-form { display: flex; gap: 10px; flex-wrap: wrap; }
.search-form input { flex: 1; min-width: 260px; }

.question-blocks { display: flex; flex-direction: column; gap: 14px; }
.question-block {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}
.question-block.marked-delete {
  opacity: .55;
  background: #fff1f2;
}
.question-block-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.mini-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.hidden { display: none !important; }

@media (max-width: 900px) {
  .topbar, .page-head { flex-direction: column; align-items: stretch; }
  .cards-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
  .nav { width: 100%; }
  .nav-link { flex: 1; text-align: center; }
}
