
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe3ef;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --success: #0f766e;
  --warning: #b45309;
  --warning-soft: #fff7ed;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
body[dir="rtl"] { font-family: "Noto Naskh Arabic", Tahoma, Arial, sans-serif; }
.container { width: min(1120px, calc(100vw - 32px)); margin: 0 auto; }
.main-container { padding: 28px 0 56px; }

.topbar { background: #0f172a; color: white; position: sticky; top: 0; z-index: 20; }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; }
.brand-block { display: flex; flex-direction: column; gap: 4px; }
.brand { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.02em; }
.subtitle { font-size: 0.92rem; color: rgba(255,255,255,0.74); }
.topnav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.topnav a { color: rgba(255,255,255,0.88); font-size: 0.95rem; }
.topnav a:hover { color: white; }
.lang-switcher { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-inline-start: 6px; }
.lang-pill { padding: 8px 12px; border-radius: 999px; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); font-size: 0.92rem; }
.lang-pill.is-active { background: rgba(255,255,255,0.18); color: white; border-color: rgba(255,255,255,0.28); }

.hero-card, .detail-card, .login-card, .success-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-card, .detail-card, .success-card, .login-card { padding: 24px; }
.detail-card--plain { box-shadow: none; margin-bottom: 20px; }
.hero-card { margin-bottom: 24px; }

.section-block { margin-top: 28px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h1, .section-head h2 { margin: 0; }
.muted { color: var(--muted); }

.search-form .search-grid {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 14px;
  align-items: end;
}
.search-main, .search-side, .search-actions { display: flex; flex-direction: column; gap: 8px; }

.label { display: block; font-size: 0.92rem; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.input, .textarea, select.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.98rem;
  background: white;
  color: var(--text);
  outline: none;
}
.input:focus, .textarea:focus, select.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}
.textarea { resize: vertical; min-height: 120px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { filter: brightness(1.02); transform: translateY(-1px); }
.btn-secondary { background: white; border-color: var(--line); color: var(--text); }
.btn-secondary:hover { background: var(--surface-alt); }
.btn-link { padding: 0; color: var(--primary); background: none; border: none; }

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.category-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.category-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.category-card__title { font-size: 1.02rem; font-weight: 800; margin-bottom: 8px; }
.category-card__desc { color: var(--muted); line-height: 1.55; }

.faq-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.faq-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.faq-card h3 { margin: 0 0 10px; font-size: 1.06rem; line-height: 1.45; }
.answer-preview { color: var(--muted); line-height: 1.7; min-height: 78px; }
.faq-meta, .ticket-badges, .action-row, .card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.faq-meta { margin-bottom: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.action-row { margin-top: 20px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.compact-form .form-item--full { grid-column: span 2; }
.form-item--full { grid-column: span 2; }
.checkbox-item { display: flex; align-items: center; padding-top: 34px; }

.notice {
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 16px;
  line-height: 1.6;
}
.notice.warning { background: var(--warning-soft); color: var(--warning); border: 1px solid #fed7aa; }
.notice.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.detail-box, .detail-list div {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.detail-list { display: grid; gap: 10px; }
.rich-answer {
  line-height: 1.85;
  color: var(--text);
  word-break: break-word;
}

.timeline { display: grid; gap: 14px; }
.timeline-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  background: white;
}
.timeline-item--internal { background: #fffef5; }
.timeline-item__meta { color: var(--muted); font-size: 0.88rem; margin-bottom: 8px; }
.timeline-item__body { line-height: 1.75; }

.success-grid, .admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}
.stat-card__label { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.stat-card__value { font-size: 1.4rem; font-weight: 900; }

.admin-panels {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.panel { padding: 20px; }
.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel__head h2 { margin: 0; }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
.data-table th, .data-table td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  vertical-align: top;
}
body[dir="rtl"] .data-table th,
body[dir="rtl"] .data-table td { text-align: right; }
body[dir="rtl"] .topbar__inner,
body[dir="rtl"] .section-head,
body[dir="rtl"] .panel__head { direction: rtl; }
body[dir="rtl"] .brand-block { align-items: flex-start; }
body[dir="rtl"] .topnav { justify-content: flex-start; }
.data-table th { color: var(--muted); font-weight: 700; }
.data-table tbody tr:hover { background: #fafcff; }

.attachment-list { margin: 10px 0 0; padding-left: 20px; }
body[dir="rtl"] .attachment-list { padding-right: 20px; padding-left: 0; }

.empty-state {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.login-card {
  width: min(520px, 100%);
  margin: 60px auto 0;
}

.extra-field { display: none; }
.extra-field.is-visible { display: block; }

@media (max-width: 920px) {
  .search-form .search-grid,
  .faq-list,
  .category-grid,
  .form-grid,
  .detail-grid,
  .success-grid,
  .admin-stats,
  .admin-panels,
  .filter-grid {
    grid-template-columns: 1fr;
  }
  .form-item--full,
  .compact-form .form-item--full { grid-column: span 1; }
  .topbar__inner,
  .section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .topnav { justify-content: flex-start; }
  .search-actions { flex-direction: row; }
}


body.admin-shell { background: #f3f6fb; }
body.public-shell { background: var(--bg); }

.centered-card {
  width: min(760px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.notice.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 4px;
  color: var(--text);
}

.checkbox-row--compact { min-height: 36px; }

.btn-sm { padding: 8px 12px; font-size: 0.88rem; border-radius: 10px; }

.inline-form { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.input--sm { max-width: 160px; padding: 8px 10px; }

.admin-panels--wide { grid-template-columns: 1.2fr 0.8fr; }


.permission-editor {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.permission-editor__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.permission-editor__head h2 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.permission-editor__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.permission-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.permission-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-alt);
  padding: 16px;
}

.permission-card h3 {
  margin: 0 0 12px;
  font-size: 0.98rem;
}

.permission-grid {
  display: grid;
  gap: 12px;
}

.permission-item {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.permission-item--scope {
  padding: 12px;
}

.permission-editor__hint {
  margin-top: 12px;
}

/* v5.3 polish overrides */
:root {
  --bg: #eef3fb;
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --text: #0f172a;
  --muted: #5b6b84;
  --line: #d7e0ee;
  --primary: #2f6fed;
  --primary-soft: #e7efff;
  --success: #0f766e;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

html, body {
  line-height: 1.55;
}

body {
  background:
    radial-gradient(circle at top right, rgba(47,111,237,0.08), transparent 32%),
    linear-gradient(180deg, #f7faff 0%, var(--bg) 100%);
}

.container {
  width: min(1220px, calc(100vw - 32px));
}

.main-container {
  padding: 28px 0 64px;
}

.topbar {
  position: sticky;
  top: 0;
  overflow: hidden;
  background: linear-gradient(135deg, #081225 0%, #0d1d42 58%, #12326f 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 18px 36px rgba(8, 18, 37, 0.28);
  backdrop-filter: blur(10px);
}

.topbar__glow {
  position: absolute;
  inset: auto -10% -35px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(126,180,255,0.22), transparent 70%);
  pointer-events: none;
}

.topbar__inner {
  position: relative;
  align-items: flex-start;
  gap: 18px 26px;
  padding: 18px 0 20px;
}

.brand {
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}

.subtitle {
  color: rgba(255,255,255,0.74);
  max-width: 420px;
}

.topbar__nav-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  flex: 1;
}

.topnav {
  justify-content: flex-end;
  gap: 10px;
}

.topnav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 14px;
  border-radius: 999px;
  color: rgba(255,255,255,0.88);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.topnav__link:hover {
  color: #fff;
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.16);
  transform: translateY(-1px);
}

.topnav__link.is-active {
  color: #fff;
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.26);
  box-shadow: 0 10px 18px rgba(8, 18, 37, 0.18);
}

.lang-switcher {
  margin-inline-start: 0;
  gap: 10px;
}

.lang-pill {
  min-height: 40px;
  padding: 9px 16px;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.lang-pill:hover {
  background: rgba(255,255,255,0.13);
}

.lang-pill.is-active {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.28);
}

.hero-card, .detail-card, .login-card, .success-card, .panel {
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.panel + .panel,
.detail-card + .panel,
.panel + .detail-card,
.detail-card + .detail-card {
  margin-top: 22px;
}

.panel--soft {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.panel__head--stacked {
  align-items: flex-start;
}

.panel__head h1,
.panel__head h2,
.section-head h1,
.section-head h2 {
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
}

.label {
  font-weight: 700;
  color: #5f718c;
}

.input, .textarea, select.input {
  border-radius: 14px;
  border-color: #d5deec;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.input:hover, .textarea:hover, select.input:hover {
  border-color: #bfd0ea;
}

.input--ghost {
  background: #fff;
}

.textarea {
  min-height: 132px;
}

.btn {
  min-height: 44px;
  box-shadow: 0 10px 18px rgba(47,111,237,0.08);
}

.btn-primary {
  background: linear-gradient(135deg, #2f6fed 0%, #275ee0 100%);
}

.btn-secondary {
  background: rgba(255,255,255,0.96);
}

.btn-sm {
  min-height: 36px;
  box-shadow: none;
}

.checkbox-row {
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff 0%, #fafcff 100%);
}

.checkbox-row--compact {
  min-height: 38px;
  padding: 7px 10px;
}

.notice {
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.detail-box, .detail-list div {
  background: linear-gradient(180deg, #f8fbff 0%, #f4f7fb 100%);
}

.table-wrap--card {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: auto;
  background: #fff;
}

.data-table {
  min-width: 100%;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7faff;
  backdrop-filter: blur(8px);
}

.data-table th, .data-table td {
  padding: 14px 12px;
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

.data-table--phones td,
.data-table--phones th {
  white-space: nowrap;
}

.data-table--phones td:nth-child(2) {
  min-width: 170px;
  white-space: normal;
}

.data-table--phones td:last-child,
.data-table--phones th:last-child {
  min-width: 230px;
}

.table-primary {
  font-weight: 700;
  color: var(--text);
}

.table-secondary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form--tight {
  gap: 8px;
}

.inline-form--status .input--sm {
  min-width: 128px;
  max-width: 160px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-pill--new {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}

.status-pill--dialed {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.status-pill--reached,
.status-pill--reached-flag {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.status-pill--follow_up {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.status-pill--invalid {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.status-pill--converted {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

.status-pill--not-reached {
  background: #f8fafc;
  color: #475569;
  border-color: #cbd5e1;
}

.search-form .search-grid,
.filter-grid {
  gap: 18px;
}

body[dir="rtl"] .brand-block {
  align-items: flex-start;
}

body[dir="rtl"] .topbar__nav-block {
  align-items: flex-start;
}

body[dir="rtl"] .topnav {
  justify-content: flex-start;
}

body[dir="rtl"] .input,
body[dir="rtl"] .textarea,
body[dir="rtl"] select.input,
body[dir="rtl"] .label,
body[dir="rtl"] .subtitle,
body[dir="rtl"] .muted,
body[dir="rtl"] .table-secondary {
  text-align: right;
}

body[dir="rtl"] .table-actions,
body[dir="rtl"] .inline-form {
  justify-content: flex-start;
}

@media (max-width: 1180px) {
  .topbar__inner {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar__nav-block {
    align-items: stretch;
  }

  .topnav {
    justify-content: flex-start;
  }
}

@media (max-width: 920px) {
  .container {
    width: min(100vw - 20px, 1220px);
  }

  .panel,
  .hero-card,
  .detail-card,
  .success-card,
  .login-card {
    padding: 18px;
  }

  .topnav__link,
  .lang-pill {
    min-height: 36px;
    padding: 8px 12px;
  }

  .table-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form--status {
    width: 100%;
  }

  .inline-form--status .input--sm {
    max-width: none;
    width: 100%;
  }
}
