/* فونت وزیرمتن — آفلاین */
@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-SemiBold.woff2') format('woff2');
  font-weight: 600;
  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;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('fonts/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

/* پنل مدیریت — تم شرکتی RTL */
:root {
  --bg: #f0f2f7;
  --surface: #ffffff;
  --sidebar: #0c1222;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: rgba(13, 148, 136, 0.22);
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: 'Vazirmatn', 'Tahoma', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body.panel-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ——— لاگین ——— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(145deg, #0c1222 0%, #134e4a 45%, #f0f2f7 45%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2rem 1.75rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-brand h1 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.login-brand p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.login-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background-color: var(--surface);
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center;
  background-size: 0.85rem;
  padding-left: 2.2rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.form-group select:hover {
  border-color: #cbd5e1;
}

.form-group textarea {
  width: 100%;
  min-height: 4.5rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
}

.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.2);
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-toggle-row {
  margin: 0.35rem 0 0.25rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 2.3rem;
  height: 1.35rem;
  border-radius: 999px;
  background: #cbd5e1;
  transition: background 0.2s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.24);
  transition: transform 0.2s ease;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(-0.95rem);
}

.toggle-text {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 500;
}

/* ——— مودال‌ها ——— */
dialog.modal {
  border: none;
  border-radius: 20px;
  box-shadow:
    0 8px 32px rgba(15, 23, 42, 0.12),
    0 32px 64px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  padding: 0;
  width: min(560px, 94vw);
  max-height: 90vh;
  overflow: hidden;
  animation: modal-in 0.22s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: backdrop-in 0.22s ease;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.5rem;
  background: linear-gradient(to bottom, #f8fafc, var(--surface));
}

.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
  background: #f1f5f9;
  color: var(--text);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 9rem);
}

.modal-body .form-group:last-of-type {
  margin-bottom: 0.5rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 0 0 20px 20px;
}

.modal-footer .btn-primary {
  width: auto;
}

.modal-msg {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  min-height: 1.3em;
}

.modal-msg.ok  { color: #047857; }
.modal-msg.err { color: #b91c1c; }

.modal-loading-bar {
  display: none;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
  padding: 0.7rem 0.9rem;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  font-size: 0.84rem;
  color: #115e59;
  animation: modal-bar-in 0.2s ease;
}

.modal-loading-bar.visible { display: flex; }

.modal-loading-bar .ml-spinner {
  width: 1rem;
  height: 1rem;
  border: 2.5px solid #99f6e4;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pg-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes modal-bar-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal.is-busy .modal-body input,
.modal.is-busy .modal-body textarea,
.modal.is-busy .modal-body select,
.modal.is-busy .modal-body .toggle {
  opacity: 0.5;
  pointer-events: none;
}

.modal.is-busy .modal-footer .btn {
  opacity: 0.55;
  pointer-events: none;
}

.modal.is-busy .modal-close {
  opacity: 0.3;
  pointer-events: none;
}

.modal-footer .btn-primary.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

.modal-msg-error {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #991b1b;
  font-size: 0.84rem;
  display: none;
  animation: modal-bar-in 0.2s ease;
}

.modal-msg-error.visible { display: block; }

.table-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
  white-space: nowrap;
}

.table-actions button {
  font-size: 0.8125rem;
}

.search-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.search-bar input {
  width: min(320px, 46vw);
  max-width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.86rem;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.16);
}

.pagination-wrap {
  margin-top: 0.9rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pagination .page-btn {
  min-width: 2.2rem;
}

.pager-meta {
  margin-right: 0.6rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn-danger:hover {
  background: #fecaca;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
}

.login-footer {
  margin-top: 1.25rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* ——— چیدمان پنل ——— */
.panel-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.35rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .logo {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: #fff;
}

.sidebar-brand .tagline {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

.nav-section {
  padding: 0.75rem 0.65rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
}

.nav-menu {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem 1rem;
}

.nav-menu a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.12s, color 0.12s;
}

.nav-menu a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-menu a.active {
  background: var(--sidebar-active);
  color: #5eead4;
  font-weight: 600;
}

.nav-icon-svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  opacity: 0.92;
}

.shell {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.topbar-user strong {
  color: var(--text);
}

.logout-form {
  display: inline;
  margin: 0;
}

.main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ——— کارت‌ها و جداول ——— */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card-stat {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.card-stat .label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.card-stat .value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(226, 232, 240, 0.8);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.95rem;
}

.card-body {
  padding: 1.25rem;
}

/* ویجت تب استخراج (نوار تمام‌عرض + بدنهٔ متصل) */
.extract-tabs-widget {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #eef2f7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.extract-tabs-nav {
  display: flex;
  flex-direction: row;
  width: 100%;
  padding: 0.4rem;
  gap: 0.4rem;
  box-sizing: border-box;
}

.extract-tabs-nav--settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
}

.extract-tabs-nav--settings .extract-tab {
  flex: unset;
  min-width: 0;
  font-size: 0.8rem;
  padding: 0.55rem 0.3rem;
  line-height: 1.3;
  word-break: break-word;
}

@media (min-width: 640px) {
  .extract-tabs-nav--settings .extract-tab {
    font-size: 0.9rem;
    padding: 0.62rem 0.5rem;
  }
}

.extract-tab {
  flex: 1 1 50%;
  min-height: 2.75rem;
  appearance: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 0.65rem 1rem;
  margin: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.extract-tab:hover:not(.is-active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.55);
}

.extract-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.extract-tab.is-active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(226, 232, 240, 0.9);
}

.extract-tabs-body {
  background: var(--surface);
  padding: 1.15rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  min-height: 6rem;
}

.extract-tab-panel[hidden] {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  height: auto;
  min-height: 72px;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
}

.data-table tr:hover td {
  background: #fafbfc;
}

.data-table td.cell-long {
  white-space: normal;
  word-break: break-word;
  line-height: 1.5;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-pending {
  background: #fef3c7;
  color: #b45309;
}

.badge-running {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-done {
  background: #d1fae5;
  color: #047857;
}

.badge-fail {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

/* ——— تولتیپ سفارشی ——— */
.has-tooltip {
  position: relative;
  cursor: default;
  display: inline-block;
}

.has-tooltip .tip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--sidebar);
  color: #e2e8f0;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.55;
  width: max-content;
  max-width: 320px;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
  pointer-events: none;
}

.has-tooltip .tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--sidebar);
}

.has-tooltip .tip .tip-row {
  display: block;
  padding: 0.15rem 0;
}

.has-tooltip .tip .tip-row + .tip-row {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 0.15rem;
  padding-top: 0.25rem;
}

.has-tooltip .tip .tip-label {
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.7rem;
  display: block;
  margin-bottom: 0.1rem;
}

.has-tooltip .tip .tip-val {
  color: #f1f5f9;
  display: block;
  overflow-wrap: break-word;
  word-break: break-word;
}

.has-tooltip:hover .tip {
  display: block;
  animation: tooltip-in 0.15s ease;
}

@keyframes tooltip-in {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.muted {
  color: var(--muted);
  font-size: 0.875rem;
}

.hint-box {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  color: #115e59;
  margin-bottom: 1rem;
}

.danger-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  line-height: 1.55;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  /* وزیرمتن برای رشته‌های فارسی داخل JSON/curl؛ اعداد و ساختار هم خوانا می‌مانند */
  font-family: 'Vazirmatn', ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-variant-ligatures: none;
  tab-size: 2;
  -moz-tab-size: 2;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

pre.code-block {
  margin: 0 0 0.85rem;
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
}

pre.code-block:last-child {
  margin-bottom: 0;
}

pre.code-block code {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: transparent;
  padding: 0;
  margin: 0;
  border: 0;
  display: block;
  white-space: pre;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  background: #fafbfc;
}

.upload-zone input[type='file'] {
  margin-top: 0.75rem;
}

.flex-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

#job-status-box,
#upload-result {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.playground-result {
  margin-top: 1rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}

.playground-loading {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #115e59;
}

.playground-loading .spinner {
  width: 1.15rem;
  height: 1.15rem;
  border: 2.5px solid #99f6e4;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: pg-spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes pg-spin {
  to { transform: rotate(360deg); }
}

.btn.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

#playground-err {
  margin-top: 1rem;
}

.forbidden-page {
  max-width: 480px;
  margin: 3rem auto;
  text-align: center;
  padding: 2rem;
}

.forbidden-page h1 {
  font-size: 1.5rem;
}

/* ——— توست اعلان ——— */
.toast-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(520px, 92vw);
  width: 100%;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12), 0 1px 3px rgba(15, 23, 42, 0.08);
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  word-break: break-word;
}

.toast.toast-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.toast.toast-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.toast.toast-info {
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  color: #115e59;
}

.toast-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.4;
}

.toast-dismiss {
  margin-right: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.5;
  padding: 0 0.2rem;
  color: inherit;
}

.toast-dismiss:hover { opacity: 1; }

.toast.removing {
  animation: toast-out 0.2s ease forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

/* ——— لودینگ ردیف جدول ——— */
.btn.btn-row-loading {
  opacity: 0.65;
  pointer-events: none;
  position: relative;
}

.btn-row-spinner {
  display: inline-block;
  width: 0.8rem;
  height: 0.8rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: pg-spin 0.7s linear infinite;
  vertical-align: -1px;
  margin-left: 0.3rem;
}

tr.row-busy td {
  opacity: 0.5;
  pointer-events: none;
}

/* ——— عملیات گروهی ——— */
.bulk-bar {
  display: none;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #f0fdfa 0%, #ecfdf5 100%);
  border: 1px solid #99f6e4;
  border-radius: 10px;
  font-size: 0.85rem;
  color: #115e59;
  animation: modal-bar-in 0.2s ease;
  flex-wrap: wrap;
}

.bulk-bar.visible {
  display: flex;
}

.bulk-bar .bulk-count {
  font-weight: 700;
  min-width: 5rem;
}

.bulk-bar .bulk-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-right: auto;
}

.bulk-bar .btn-bulk-clear {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  padding: 0.2rem 0.4rem;
}

.bulk-bar .btn-bulk-clear:hover {
  color: var(--text);
}

.data-table .col-check {
  width: 2.5rem;
  text-align: center;
}

#knowledge-table .col-question { width: 28%; }
#knowledge-table .col-answer { width: 22%; }
#knowledge-table .col-action { width: 10%; }
#knowledge-table .col-ops { width: 18%; }

.data-table .col-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent);
}

.data-table tr.row-selected td {
  background: #f0fdfa;
}

@media (max-width: 900px) {
  .panel-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
  }

  .nav-menu {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
