/* ==========================================================
   فرم‌ساز — نسخه‌ی نهایی
   فونت: Pinar (محلی از /fonts/)
   اسکرول داخلی main-content
   ========================================================== */

/* ═══════════════════════════════════════════════════════════
   فونت‌های Pinar — محلی، بدون CDN
   ═══════════════════════════════════════════════════════════ */
@font-face {
  font-family: 'Pinar';
  src: url('/fonts/PINAR-LIGHT.TTF') format('truetype');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pinar';
  src: url('/fonts/PINAR-REGULAR.TTF') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pinar';
  src: url('/fonts/PINAR-MEDIUM.TTF') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pinar';
  src: url('/fonts/PINAR-SEMIBOLD.TTF') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Pinar';
  src: url('/fonts/PINAR-BOLD.TTF') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ═══════════════════════════════════════════════════════════
   Variables
   ═══════════════════════════════════════════════════════════ */
:root {
  --brand: #00BFA6;
  --brand-dark: #00967F;
  --brand-darker: #007A68;
  --brand-soft: #EFFCF9;
  --brand-light: #D9F5F0;

  --bg-1: #F7F9FB;
  --bg-2: #F2F5F7;
  --white: #fff;

  --text-1: #0F1922;
  --text-2: #5A6B78;
  --text-3: #8A98A3;

  --border-1: rgba(15,25,34,.08);
  --border-2: rgba(15,25,34,.14);
  --border-3: rgba(0,191,166,.30);

  --danger: #EF4444;
  --success: #10B981;
  --warning: #F59E0B;

  --shadow-sm: 0 1px 3px rgba(15,25,34,.05);
  --shadow-md: 0 4px 14px rgba(15,25,34,.08);
  --shadow-lg: 0 12px 32px rgba(15,25,34,.10);

  --radius: 14px;
  --field-h: 44px;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg-1: #0A1418;
  --bg-2: #0D1A1F;
  --white: #112128;
  --text-1: #E8EFF4;
  --text-2: #92A8B4;
  --text-3: #6B7885;
  --border-1: rgba(232,239,244,.08);
  --border-2: rgba(232,239,244,.14);
  --brand-soft: #0A2A25;
  --brand-light: #0F3D36;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,.30);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.40);
}

/* ═══════════════════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Pinar', Tahoma, 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text-1);
  background: var(--bg-1);
  direction: rtl;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

a { color: var(--brand-dark); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--brand); }

input, select, textarea, button {
  font-family: 'Pinar', Tahoma, sans-serif;
}

table, th, td {
  font-family: 'Pinar', Tahoma, sans-serif;
}

/* ═══════════════════════════════════════════════════════════
   Login
   ═══════════════════════════════════════════════════════════ */
body.login-body {
  background: linear-gradient(135deg, #003D34 0%, #00BFA6 100%);
  display: grid; place-items: center;
  padding: 20px;
  height: auto; min-height: 100vh;
  overflow-y: auto;
}
.login-card {
  background: #fff; border-radius: 22px;
  padding: 42px 36px 32px;
  width: 100%; max-width: 420px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
  animation: loginSlide .4s ease;
}
@keyframes loginSlide {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: none; }
}
.login-brand { margin-bottom: 22px; }
.login-logo {
  width: 84px; height: 84px; margin: 0 auto 14px;
  display: block; border-radius: 20px;
  box-shadow: 0 12px 30px rgba(0,191,166,.35);
}
.login-brand h1 { font-size: 22px; font-weight: 700; color: #003D34; }
.login-brand p  { margin-top: 4px; font-size: 12.5px; color: #5A6B78; }

/* ═══════════════════════════════════════════════════════════
   Layout
   ═══════════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════════════════════ */
.sidebar {
  width: 84px;
  height: 100%;
  background: linear-gradient(180deg, #00BFA6 0%, #00967F 100%);
  padding: 18px 12px;
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .3s cubic-bezier(.4,0,.2,1);
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
  position: relative;
  box-shadow: 1px 0 0 rgba(0,0,0,.05);
  z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 0; height: 0; }
.sidebar.open { width: 240px; }

.sidebar-brand {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,.20);
  margin-bottom: 14px;
  flex-shrink: 0;
}
.brand-logo-wrap {
  width: 52px; height: 52px; border-radius: 13px;
  overflow: hidden; flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,.30), 0 0 0 1px rgba(255,255,255,.15) inset;
  transition: all .25s;
}
.brand-logo-wrap img { width: 100%; height: 100%; display: block; object-fit: contain; }
.brand-logo-wrap:hover { transform: translateY(-2px) scale(1.03); }
.sidebar.open .brand-logo-wrap { width: 68px; height: 68px; border-radius: 17px; }

.brand-text {
  color: #fff; text-align: center;
  opacity: 0; max-height: 0; overflow: hidden;
  transition: opacity .2s, max-height .3s;
}
.sidebar.open .brand-text { opacity: 1; max-height: 60px; }
.brand-text strong { display: block; font-weight: 700; font-size: 14px; }
.brand-text small  { font-size: 11px; opacity: .8; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-link {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  height: 46px; border-radius: 12px;
  color: rgba(255,255,255,.85);
  font-weight: 500; font-size: 13.5px;
  transition: all var(--transition);
  cursor: pointer; border: 0; background: transparent;
  padding: 0 12px; text-decoration: none;
  flex-shrink: 0;
}
.sidebar.open .nav-link { justify-content: flex-start; }
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-link.active { background: #fff; color: var(--brand-darker); font-weight: 600; }

.nav-icon { width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center; }
.nav-icon svg { width: 20px; height: 20px; }

.nav-label { display: none; white-space: nowrap; }
.sidebar.open .nav-label { display: inline; }

.nav-divider { height: 1px; background: rgba(255,255,255,.15); margin: 12px 6px; flex-shrink: 0; }

.nav-logout { color: rgba(255,220,220,.95); }
.nav-logout:hover { background: rgba(239,68,68,.25); color: #fff; }

.sidebar-toggle {
  margin-top: auto; width: 100%; height: 40px; border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.10); color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.20); }
.sidebar-toggle svg { transition: transform .3s; }
.sidebar.open .sidebar-toggle svg { transform: rotate(180deg); }

/* ═══════════════════════════════════════════════════════════
   Main content — اسکرول داخلی
   ═══════════════════════════════════════════════════════════ */
.main-content {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 24px;
  min-width: 0;
  direction: rtl;
}
.main-content::-webkit-scrollbar { width: 8px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb {
  background: rgba(0,191,166,.30);
  border-radius: 8px;
}
.main-content::-webkit-scrollbar-thumb:hover { background: rgba(0,191,166,.50); }

/* ═══════════════════════════════════════════════════════════
   Topbar
   ═══════════════════════════════════════════════════════════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(135deg, #00BFA6 0%, #00967F 100%);
  color: #fff; border-radius: 18px; padding: 12px 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0,191,166,.20);
  flex-wrap: wrap; gap: 12px;
  position: relative; z-index: 500;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.topbar-title-wrap { min-width: 0; }
.topbar-title-wrap h2 { font-size: 16px; font-weight: 700; margin: 0; line-height: 1.3; }
.topbar-subtitle { font-size: 11.5px; opacity: .85; display: block; margin-top: 2px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; position: relative; z-index: 2; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.20);
  color: #fff; cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--transition);
}
.icon-btn:hover { background: rgba(255,255,255,.28); transform: translateY(-1px); }

.menu-toggle {
  display: none; width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.20);
  color: #fff; cursor: pointer;
  align-items: center; justify-content: center;
}

/* ═══════════════════════════════════════════════════════════
   User chip
   ═══════════════════════════════════════════════════════════ */
.user-chip { position: relative; z-index: 600; }

.user-chip-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 12px 5px 6px; height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.20);
  color: #fff; cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}
.user-chip-btn:hover { background: rgba(255,255,255,.28); }
.user-chip-btn .user-info { text-align: right; line-height: 1.35; }
.user-chip-btn .user-info strong { font-size: 12.5px; display: block; color: #fff; font-weight: 600; }
.user-chip-btn .user-info small  { font-size: 10.5px; color: rgba(255,255,255,.80); }
.user-chip-btn .avatar {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255,255,255,.95); color: var(--brand-darker);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
  text-transform: uppercase;
}
.user-chip-btn .chevron {
  color: rgba(255,255,255,.85);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.user-chip.open .user-chip-btn .chevron { transform: rotate(180deg); }

.user-dropdown {
  position: absolute; top: calc(100% + 10px); left: 0;
  min-width: 200px;
  background: var(--white);
  border-radius: 14px;
  border: 1px solid var(--border-2);
  border-top: 3px solid var(--brand);
  box-shadow: 0 24px 60px rgba(15,25,34,.18);
  padding: 8px;
  opacity: 0; visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition);
  z-index: 9999;
  pointer-events: none;
}
.user-chip.open .user-dropdown {
  opacity: 1; visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-1); font-size: 13px; font-weight: 500;
  transition: all var(--transition);
}
.dropdown-item:hover { background: var(--brand-soft); color: var(--brand-darker); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: #FEF2F2; color: #991B1B; }

/* ═══════════════════════════════════════════════════════════
   Page content
   ═══════════════════════════════════════════════════════════ */
.page-content { display: flex; flex-direction: column; gap: 14px; }

/* ═══════════════════════════════════════════════════════════
   Glass
   ═══════════════════════════════════════════════════════════ */
.glass {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-1);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.glass:hover { box-shadow: var(--shadow-md); }

/* ═══════════════════════════════════════════════════════════
   Alerts
   ═══════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  margin-bottom: 10px;
  border: 1px solid transparent;
  animation: slideIn .25s ease both;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.alert-danger  { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.alert-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
[data-theme="dark"] .alert-danger  { background: rgba(239,68,68,.12); color: #FCA5A5; border-color: rgba(239,68,68,.25); }
[data-theme="dark"] .alert-success { background: rgba(16,185,129,.12); color: #6EE7B7; border-color: rgba(16,185,129,.25); }

/* ═══════════════════════════════════════════════════════════
   Forms
   ═══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 14px; text-align: right; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.form-control {
  width: 100%; height: var(--field-h); padding: 0 14px;
  border: 1.5px solid var(--border-2); border-radius: 10px;
  font-size: 14px; background: var(--white); color: var(--text-1);
  transition: all var(--transition); outline: none;
}
.form-control::placeholder { color: var(--text-3); }
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(0,191,166,.10);
}
textarea.form-control {
  height: auto; min-height: 80px;
  padding: 10px 14px; resize: vertical;
}
select.form-control { cursor: pointer; padding-left: 8px; }

/* ═══════════════════════════════════════════════════════════
   Buttons
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--field-h); padding: 0 20px;
  border-radius: 10px; border: none;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
  font-family: inherit;
}
.btn-primary {
  background: var(--brand); color: #fff;
  box-shadow: 0 4px 14px rgba(0,191,166,.25);
}
.btn-primary:hover { background: var(--brand-dark); color: #fff; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-outline {
  background: var(--white);
  border: 1.5px solid var(--border-2);
  color: var(--text-1);
}
.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; color: #fff; }

.btn-block { width: 100%; height: 50px; font-size: 14.5px; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 12.5px; }

.btn-mini {
  height: 32px; padding: 0 12px;
  font-size: 11.5px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-darker);
  border: 1px solid var(--border-3);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; transition: all var(--transition);
  font-family: inherit;
}
.btn-mini:hover {
  background: var(--brand); color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}
.btn-mini.danger {
  background: rgba(239,68,68,.10);
  color: var(--danger);
  border-color: rgba(239,68,68,.20);
}
.btn-mini.danger:hover { background: var(--danger); color: #fff; }

/* دکمه‌ی QR کنار کپی لینک */
.qr-mini-btn {
  height: 32px;
  width: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.qr-mini-btn svg {
  width: 14px;
  height: 14px;
  display: block;
}

/* ═══════════════════════════════════════════════════════════
   Dashboard
   ═══════════════════════════════════════════════════════════ */
.dash-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
}

.forms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.form-card {
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.form-card-head {
  display: flex; justify-content: space-between;
  align-items: flex-start; gap: 10px;
}
.form-code-box {
  background: var(--brand-soft);
  border: 1px dashed var(--border-3);
  border-radius: 10px; padding: 8px 12px;
}
.form-card-meta {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  background: var(--bg-2);
  border-radius: 10px; padding: 10px;
}
.form-card-meta div { text-align: center; }
.form-card-meta strong {
  display: block; font-size: 15px; font-weight: 700;
  color: var(--brand-darker);
  font-variant-numeric: tabular-nums;
}
.form-card-meta span {
  display: block; font-size: 10.5px; color: var(--text-2);
}

/* کارت فرم: آیکن‌دکمه‌ها در یک سطر */
.form-card-actions {
  display: flex;
  gap: 6px;
  justify-content: space-between;
  flex-wrap: nowrap;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-1);
}
.form-card-actions > .card-icon-form {
  display: contents;
  margin: 0;
}
.card-icon-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 38px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-darker);
  border: 1px solid var(--border-3);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 0;
  font-family: inherit;
  transition: all var(--transition);
}
.card-icon-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,191,166,.25);
}
.card-icon-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.card-icon-btn.danger {
  background: rgba(239,68,68,.10);
  color: var(--danger);
  border-color: rgba(239,68,68,.20);
}
.card-icon-btn.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(239,68,68,.25);
}

.chip {
  display: inline-block; padding: 3px 10px;
  border-radius: 8px; font-size: 11px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-darker);
  border: 1px solid var(--border-3);
}
.chip-ok   { background: rgba(16,185,129,.12); color: #047857; border-color: rgba(16,185,129,.25); }
.chip-warn { background: rgba(245,158,11,.12); color: #B45309; border-color: rgba(245,158,11,.25); }

.empty-state {
  padding: 50px 20px; text-align: center; color: var(--text-2);
}
.empty-state svg { color: var(--brand); margin-bottom: 10px; }
.empty-state h3 { color: var(--text-1); margin-bottom: 4px; font-size: 15px; }
.empty-state p  { font-size: 13px; }

/* ═══════════════════════════════════════════════════════════
   Tables
   ═══════════════════════════════════════════════════════════ */
.table-wrap { display: flex; flex-direction: column; overflow: hidden; }
.table-scroll { overflow: auto; max-height: 70vh; }

.table-modern {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.table-modern th,
.table-modern td {
  padding: 10px 12px; text-align: right;
  border-bottom: 1px solid var(--border-1);
  white-space: nowrap;
}
.table-modern thead th {
  background: var(--bg-2);
  font-weight: 700; font-size: 11.5px;
  position: sticky; top: 0; z-index: 2;
  border-bottom: 2px solid var(--border-2);
}
.table-modern tbody tr:nth-child(even) { background: rgba(0,191,166,.02); }
.table-modern tbody tr:hover { background: rgba(0,191,166,.06); }
.table-modern .empty {
  text-align: center; padding: 40px;
  color: var(--text-3);
}
.mono { font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.sub-row td {
  background: var(--brand-soft);
  padding: 10px 14px !important;
  white-space: normal !important;
}
[data-theme="dark"] .sub-row td { background: rgba(0,191,166,.06); }

.inline-form {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  width: 100%;
}
.check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; height: var(--field-h);
  cursor: pointer; user-select: none;
}
.check input[type="checkbox"] {
  accent-color: var(--brand);
  width: 16px; height: 16px;
  cursor: pointer;
}

.badge-ok, .badge-off {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 700;
}
.badge-ok  { background: #ECFDF5; color: #065F46; border: 1px solid #A7F3D0; }
.badge-off { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }
[data-theme="dark"] .badge-ok  { background: rgba(16,185,129,.15); color: #6EE7B7; border-color: rgba(16,185,129,.30); }
[data-theme="dark"] .badge-off { background: rgba(239,68,68,.15); color: #FCA5A5; border-color: rgba(239,68,68,.30); }

/* دکمه‌ی آیکن داخل جدول (حذف سطر پاسخ) */
.table-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-3);
  background: var(--brand-soft);
  color: var(--brand-darker);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  padding: 0;
  font-family: inherit;
}
.table-icon-btn:hover {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,191,166,.25);
}
.table-icon-btn:active { transform: translateY(0); }
.table-icon-btn.danger {
  background: rgba(239,68,68,.10);
  color: var(--danger);
  border-color: rgba(239,68,68,.20);
}
.table-icon-btn.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(239,68,68,.25);
}
.table-icon-btn svg {
  width: 15px;
  height: 15px;
  display: block;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════
   Modal
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,25,34,.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
  z-index: 10000; padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--white); border-radius: 18px;
  width: 100%; max-width: 600px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 30px 80px rgba(0,0,0,.35);
  animation: modalIn .25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-1);
  background: var(--brand-soft);
  border-radius: 18px 18px 0 0;
}
.modal-header h3 {
  margin: 0; font-size: 15px;
  color: var(--brand-darker); font-weight: 700;
}
.modal-close {
  width: 34px; height: 34px; border-radius: 10px;
  border: none; background: rgba(0,191,166,.10);
  color: var(--brand-darker); cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--danger); color: #fff; transform: rotate(90deg); }
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1; min-height: 0;
}
.modal-footer {
  display: flex; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-1);
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid button { grid-column: span 2; justify-self: start; }

/* ─── Modal QR ─── */
.modal.qr-modal {
  max-width: 380px;
}

.qr-modal-body {
  text-align: center;
  padding: 24px 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-image-wrap {
  background: #fff;
  padding: 12px;
  border-radius: 14px;
  display: inline-block;
  box-shadow: 0 4px 18px rgba(0,0,0,.10), 0 0 0 1px rgba(0,0,0,.04);
  line-height: 0;
}
.qr-image-wrap img {
  display: block;
  width: 260px;
  height: 260px;
  max-width: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.qr-label {
  direction: ltr;
  font-family: 'Courier New', monospace;
  font-size: 11.5px;
  color: var(--text-2);
  word-break: break-all;
  text-align: center;
  margin: 0;
  font-weight: 500;
}

.qr-hint {
  font-size: 11.5px;
  color: var(--text-3);
  margin: 0;
  line-height: 1.7;
  text-align: center;
}

[data-theme="dark"] .qr-image-wrap {
  background: #fff;
}

/* ═══════════════════════════════════════════════════════════
   Builder
   ═══════════════════════════════════════════════════════════ */
.builder-wrap {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  align-items: start;
}
.builder-card, .preview-card { padding: 18px; }

.builder-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--border-1);
  border-bottom: 1px solid var(--border-1);
  margin: 14px 0;
}
.builder-toolbar-label {
  font-size: 12.5px; font-weight: 700; color: var(--text-2);
}
.tool-btn {
  height: 34px; padding: 0 14px;
  border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-darker);
  border: 1px solid var(--border-3);
  cursor: pointer;
  font-size: 12.5px; font-weight: 600;
  transition: all var(--transition);
  font-family: inherit;
}
.tool-btn:hover {
  background: var(--brand); color: #fff;
  border-color: transparent;
  transform: translateY(-1px);
}

.fields-list { display: flex; flex-direction: column; gap: 10px; }
.fields-empty {
  text-align: center; padding: 30px 20px;
  border: 2px dashed var(--border-2);
  border-radius: 12px;
  color: var(--text-3); font-size: 12.5px;
}

.field-card {
  border: 1px solid var(--border-1);
  border-radius: 12px;
  background: var(--white);
  overflow: hidden;
  transition: all var(--transition);
}
.field-card.open {
  border-color: var(--border-3);
  box-shadow: 0 4px 14px rgba(0,191,166,.10);
}
.field-card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
}
.field-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-darker);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.field-icon svg { width: 16px; height: 16px; }
.field-head-info { flex: 1; min-width: 0; }
.field-head-info strong {
  display: block; font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field-head-info small {
  display: block; font-size: 11px; color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field-card-actions { display: flex; gap: 4px; flex-wrap: wrap; }

.field-card-body {
  padding: 14px;
  background: var(--brand-soft);
  border-top: 1px solid var(--border-1);
}
[data-theme="dark"] .field-card-body { background: rgba(0,191,166,.04); }

.field-config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.form-field-wrap { display: flex; flex-direction: column; }
.form-label {
  font-size: 12.5px; font-weight: 600;
  margin-bottom: 6px; color: var(--text-1);
}
.req { color: var(--danger); margin-inline-start: 3px; }
.form-help {
  display: block; margin-top: 4px;
  font-size: 11px; color: var(--text-2);
}

/* بخش قوانین ورودی در فرم‌ساز */
.rules-section .rules-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--border-2);
  border-radius: 10px;
}
.rules-section .rules-list .check {
  height: auto;
  font-size: 12.5px;
  gap: 8px;
}
.rules-section .rules-list input[type="checkbox"] {
  accent-color: var(--brand);
  width: 16px;
  height: 16px;
}

.rules-note {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-2);
  font-weight: 500;
  padding: 6px 10px;
  background: var(--brand-soft);
  border: 1px dashed var(--border-3);
  border-radius: 8px;
  margin-top: 4px;
}
.rules-note svg { flex-shrink: 0; color: var(--brand-darker); }
.rules-note strong { color: var(--brand-darker); font-weight: 700; }

.options-editor .options-list {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px;
}
.option-row { display: flex; gap: 6px; }
.option-row input { flex: 1; }

.builder-actions {
  display: flex; gap: 10px;
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border-1);
  flex-wrap: wrap;
}

.preview-head {
  font-size: 13px; font-weight: 700;
  color: var(--brand-darker);
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-1);
}
.preview-body { min-height: 100px; }
.preview-empty {
  text-align: center; padding: 40px 10px;
  color: var(--text-3); font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════
   Grid 12
   ═══════════════════════════════════════════════════════════ */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}
.col-12    { grid-column: span 12; }
.col-md-6  { grid-column: span 6; }
.col-md-4  { grid-column: span 4; }

/* ═══════════════════════════════════════════════════════════
   Choice group
   ═══════════════════════════════════════════════════════════ */
.choice-group { display: flex; flex-direction: column; gap: 6px; }
.choice-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border-1);
  border-radius: 10px;
  cursor: pointer; font-size: 13px;
  transition: all var(--transition);
}
.choice-item:hover {
  background: var(--brand-soft);
  border-color: var(--border-3);
}
.choice-item input { cursor: pointer; accent-color: var(--brand); }

/* ═══════════════════════════════════════════════════════════
   Filter bar
   ═══════════════════════════════════════════════════════════ */
.filter-bar { padding: 12px 16px; }
.filter-field {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: var(--field-h);
  background: var(--bg-2);
  border: 1.5px solid var(--border-1);
  border-radius: 10px;
  transition: all var(--transition);
}
.filter-field:focus-within {
  border-color: var(--brand);
  background: var(--white);
  box-shadow: 0 0 0 4px rgba(0,191,166,.08);
}
.filter-field label {
  font-size: 12px; color: var(--text-2); margin: 0;
  font-weight: 600;
}
.filter-field input {
  border: 0; background: transparent;
  outline: none;
  font-family: inherit; font-size: 13px;
  width: 110px; color: var(--text-1);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════
   Avatar (فرم دسترسی)
   ═══════════════════════════════════════════════════════════ */
.avatar-sm {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand-soft));
  color: var(--brand-darker);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  border: 1px solid var(--border-3);
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ═══════════════════════════════════════════════════════════
   Checkbox بزرگ
   ═══════════════════════════════════════════════════════════ */
.check-inline {
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.check-inline input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--brand);
  cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════
   Public Form
   ═══════════════════════════════════════════════════════════ */
body.public-body {
  background: linear-gradient(135deg, #003D34 0%, #00BFA6 100%);
  height: auto; min-height: 100vh;
  overflow-y: auto;
  padding: 30px 20px;
  display: flex; justify-content: center; align-items: flex-start;
}
.public-card {
  background: #fff; border-radius: 20px; padding: 0;
  width: 100%; max-width: 780px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
  overflow: hidden;
  animation: loginSlide .4s ease;
}
.public-header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 28px 30px 22px;
  text-align: center;
}
.public-logo {
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,.20);
}
.public-logo img { width: 100%; height: 100%; display: block; object-fit: contain; }
.public-header h1 { font-size: 21px; font-weight: 700; margin-bottom: 6px; }
.public-header p  { font-size: 13px; opacity: .9; line-height: 1.7; }

.public-form { padding: 24px 30px 20px; }

.public-success {
  padding: 40px 30px; text-align: center; color: var(--text-1);
}
.public-success svg { color: var(--success); margin-bottom: 12px; }
.public-success h2 {
  font-size: 18px; font-weight: 700; margin-bottom: 6px;
}
.public-success p { color: var(--text-2); font-size: 13.5px; }

.public-footer {
  padding: 14px 30px;
  border-top: 1px solid var(--border-1);
  text-align: center;
  font-size: 11.5px; color: var(--text-3);
  background: var(--bg-2);
}
.public-footer a {
  color: var(--brand-dark);
  font-weight: 600;
}
.public-footer a:hover {
  color: var(--brand);
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════
   Jalali Date Picker
   ═══════════════════════════════════════════════════════════ */
.jp-pop {
  background: #fff;
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,.20);
  padding: 12px;
  z-index: 99999;
  min-width: 280px;
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
  animation: jpFade .18s ease;
}
@keyframes jpFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.jp-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 10px;
}
.jp-nav {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand-soft);
  border: 1px solid var(--border-3);
  color: var(--brand-darker); cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--transition);
}
.jp-nav:hover {
  background: var(--brand); color: #fff;
  border-color: transparent;
}
.jp-title {
  flex: 1; text-align: center;
  font-size: 13px; font-weight: 700;
  color: var(--text-1);
}
.jp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.jp-weekday {
  text-align: center;
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  padding: 4px 0;
}
.jp-day {
  aspect-ratio: 1; padding: 0;
  border: 0; background: transparent;
  border-radius: 8px;
  font-size: 12px; cursor: pointer;
  color: var(--text-1);
  transition: all .15s;
  font-family: inherit;
}
.jp-day:hover { background: var(--brand-soft); color: var(--brand-darker); }
.jp-day.jp-selected {
  background: var(--brand); color: #fff; font-weight: 700;
}
.jp-day.jp-today-cell { border: 1px solid var(--brand); }
.jp-empty { pointer-events: none; }
.jp-foot {
  display: flex; gap: 6px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border-1);
}
.jp-foot button {
  flex: 1; height: 32px;
  border-radius: 8px;
  background: var(--brand-soft);
  border: 1px solid var(--border-3);
  color: var(--brand-darker);
  cursor: pointer; font-size: 12px;
  font-family: inherit; font-weight: 600;
  transition: all var(--transition);
}
.jp-foot button:hover {
  background: var(--brand); color: #fff;
  border-color: transparent;
}

/* ═══════════════════════════════════════════════════════════
   شمارنده‌ی کاراکتر — فقط در حالت فوکوس
   ═══════════════════════════════════════════════════════════ */
.char-counter {
  display: none;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  transition: color var(--transition);
  min-height: 16px;
}
.form-field-wrap:focus-within .char-counter {
  display: block;
}
.char-counter.warn { color: #B45309; }
.char-counter.ok   { color: #047857; }
.char-counter.bad  { color: #B91C1C; }

/* ═══════════════════════════════════════════════════════════
   Scrollbar (عمومی)
   ═══════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(0,191,166,.30);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(0,191,166,.50); }

/* ═══════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 1000px) {
  .builder-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  html, body { height: auto; min-height: 100vh; overflow: auto; }
  .app-layout { height: auto; min-height: 100vh; flex-direction: column; overflow: visible; }
  .sidebar {
    position: fixed; top: 0; right: 0; bottom: 0;
    height: 100vh;
    width: 240px !important;
    transform: translateX(100%);
    transition: transform .3s;
    z-index: 9999;
    overflow-y: auto;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar .nav-label { display: inline-block; }
  .sidebar .brand-text { opacity: 1; max-height: 60px; }
  .sidebar .nav-link { justify-content: flex-start; }
  .sidebar .brand-logo-wrap { width: 68px; height: 68px; }
  .sidebar-toggle { display: none; }

  .main-content {
    height: auto;
    overflow: visible;
    padding: 12px;
  }
  .menu-toggle { display: flex; }

  .forms-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field-config-grid { grid-template-columns: 1fr; }
  .col-md-6, .col-md-4 { grid-column: span 12; }
  .table-scroll { max-height: 65vh; }

  .user-chip-btn .user-info { display: none; }
  .user-dropdown { left: auto; right: 0; }
}

@media (max-width: 640px) {
  .public-card { border-radius: 14px; }
  .public-header,
  .public-form,
  .public-success,
  .public-footer { padding-left: 18px; padding-right: 18px; }

  .dash-head { flex-direction: column; align-items: stretch; }
  .dash-head .btn { width: 100%; }

  .card-icon-btn { height: 34px; }
  .card-icon-btn svg { width: 15px; height: 15px; }
  .form-card-actions { gap: 4px; }

  .table-icon-btn { width: 28px; height: 28px; }
  .table-icon-btn svg { width: 13px; height: 13px; }
}

@media (max-width: 520px) {
  .filter-bar { padding: 10px; }
  .inline-form { gap: 8px; }
  .filter-field { width: 100%; }
  .filter-field input { width: 100%; }
  .topbar { padding: 10px 14px; }

  .qr-image-wrap img { width: 220px; height: 220px; }
  .modal.qr-modal { max-width: 320px; }
  .qr-modal-body { padding: 18px 16px 12px; }
}