﻿@import url("/fonts/tabler-icons/webfont/tabler-icons.css");

@font-face {
  font-family: 'iransans-light';
  font-style: normal;
  font-weight: normal;
  src: url("/fonts/IRANSansWeb_Light.eot");
  src: url("/fonts/IRANSansWeb_Light.eot?#iefix") format("embedded-opentype"), url("/fonts/IRANSansWeb_Light.woff2") format("woff2"), url("/fonts/IRANSansWeb_Light.woff") format("woff"), url("/fonts/IRANSansWeb_Light.ttf") format("truetype");
}

@font-face {
  font-family: iransans-ulight;
  font-style: normal;
  font-weight: normal;
  src: url("/fonts/IRANSansWeb_UltraLight.eot");
  src: url("/fonts/IRANSansWeb_UltraLight.eot#iefix") format("embedded-opentype"), url("/fonts/IRANSansWeb_UltraLight.woff2") format("woff2"), url("/fonts/IRANSansWeb_UltraLight.woff") format("woff"), url("/fonts/IRANSansWeb_UltraLight.ttf") format("truetype");
}

@font-face {
  font-family: iransans-medium;
  font-style: normal;
  font-weight: normal;
  src: url("/fonts/IRANSansWeb_Medium.eot");
  src: url("/fonts/IRANSansWeb_Medium.eot?#iefix") format("embedded-opentype"), url("/fonts/IRANSansWeb_Medium.woff2") format("woff2"), url("/fonts/IRANSansWeb_Medium.woff") format("woff"), url("/fonts/IRANSansWeb_Medium.ttf") format("truetype");
}


:root {
  --primary: #FF6B00;
  --primary-light: #FFF0E5;
  --primary-hover: #E05E00;
  --secondary: #10B981;
  --secondary-light: #E6F9F1;
  --secondary-hover: #059669;
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --text-dark: #1F2937;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --danger: #EF4444;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'iransans-light', sans-serif;
}

body {
  background-color: var(--bg);
  color: var(--text-dark);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

/* Auth */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg) 100%);
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  padding: 40px;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
  border-top: 5px solid var(--primary);
}

  .auth-card h2 {
    text-align: center;
    margin-bottom: 25px;
    color: var(--primary);
    font-size: 1.5rem;
  }

.auth-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: bold;
}

/* Navbar */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-company-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-menu {
  display: flex;
  list-style: none;
  gap: 5px;
  height: 60px;
  align-items: center;
}

  .nav-menu li {
    padding: 10px 15px;
    cursor: pointer;
    border-radius: var(--radius);
    color: var(--text-muted);
    transition: 0.2s;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
  }

    .nav-menu li:hover {
      background: var(--bg);
      color: var(--text-dark);
    }

    .nav-menu li.active {
      background: var(--primary-light);
      color: var(--primary);
      font-weight: bold;
    }

.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.mobile-toggle {
  display: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-dark);
  border: 0;
  background: transparent;
  padding: 0;
}

.ticket-status-filter {
  position: relative;
  width: 220px;
}

  .ticket-status-filter summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    list-style: none;
    user-select: none;
  }

    .ticket-status-filter summary::-webkit-details-marker {
      display: none;
    }

.ticket-status-filter-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dee2e6);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.ticket-status-filter-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  cursor: pointer;
  white-space: nowrap;
}

  .ticket-status-filter-option input {
    margin: 0;
  }

.mobile-toggle-icon {
  display: block;
  font-size: 1.45rem;
  line-height: 1;
  color: currentColor;
}

/* Dropdowns */
.notif-bell {
  position: relative;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-muted);
}

  .notif-bell .dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
  }

.notif-dropdown {
  position: absolute;
  top: 40px;
  left: 0;
  width: 300px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  z-index: 1000;
}

.notif-item {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

  .notif-item:last-child {
    border-bottom: none;
  }

.user-area {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.nav-user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.user-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 0.9rem;
  overflow: hidden;
}

.user-dropdown {
  position: absolute;
  top: 45px;
  left: 0;
  width: 150px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  z-index: 1000;
}

  .user-dropdown a {
    display: block;
    padding: 10px;
    font-size: 0.9rem;
    color: var(--text-dark);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
  }

    .user-dropdown a:hover {
      background: var(--bg);
    }

/* Layout */
.main-wrapper {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: bold;
}

.link-btn {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  font-weight: bold;
}

  .link-btn:hover {
    text-decoration: underline;
  }

/* Cards & Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-right: 4px solid var(--primary);
}

  .stat-card.green {
    border-right-color: var(--secondary);
  }

  .stat-card .info h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
  }

  .stat-card .info .number {
    font-size: 1.8rem;
    font-weight: bold;
  }

  .stat-card .icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
  }

.icon-orange {
  background: var(--primary-light);
  color: var(--primary);
}

.icon-green {
  background: var(--secondary-light);
  color: var(--secondary);
}

/* Dashboard promotion */
.dashboard-promo {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 142px;
  margin-bottom: 25px;
  padding: 22px 26px;
  overflow: hidden;
  color: #fff;
  border-radius: 14px;
  background: linear-gradient(105deg, #d95700 0%, #ff7a18 52%, #ff9b48 100%);
  box-shadow: 0 10px 24px rgba(224, 94, 0, .2);
}

.dashboard-promo-content {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1;
}

.dashboard-promo-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: rgba(255, 255, 255, .78);
  font-size: .76rem;
}

.dashboard-promo h3 {
  margin: 0 0 3px;
  color: #fff;
  font-size: 1.22rem;
  font-weight: 700;
}

.dashboard-promo p {
  margin: 0;
  color: rgba(255, 255, 255, .96);
  font-size: .88rem;
}

.dashboard-promo-subtitle {
  margin-top: 2px !important;
  color: rgba(255, 255, 255, .78) !important;
  font-size: .78rem !important;
}

.dashboard-promo-icon {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 0 0 58px;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  color: #fff;
  font-size: 1.8rem;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 16px;
  background: rgba(255, 255, 255, .16);
}

.dashboard-promo-btn {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  min-height: 44px;
  max-width: 300px;
  color: var(--primary);
  text-align: center;
  text-decoration: none;
  background: #fff;
  box-shadow: 0 5px 12px rgba(120, 45, 0, .16);
}

  .dashboard-promo-btn:hover {
    color: var(--primary-hover);
    background: #fffaf7;
    transform: translateY(-1px);
  }

.dashboard-promo-decoration {
  position: absolute;
  z-index: 0;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 50%;
}

.dashboard-promo-decoration-one {
  width: 220px;
  height: 220px;
  top: -132px;
  left: 23%;
}

.dashboard-promo-decoration-two {
  width: 170px;
  height: 170px;
  right: -54px;
  bottom: -112px;
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* Tables */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FAFAFA;
  flex-wrap: wrap;
  gap: 10px;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 12px 15px;
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  background: #FAFAFA;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 15px;
  text-align: right;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.helpdesk-users-page td,
.helpdesk-users-page strong {
  color: var(--text-dark);
}

.badge.helpdesk-role-badge {
  background: #eef2ff;
  color: #4338ca !important;
  border: 1px solid #c7d2fe;
}

.badge.helpdesk-active-badge {
  background: #dcfce7;
  color: #166534 !important;
  border: 1px solid #86efac;
}

.badge.helpdesk-inactive-badge {
  background: #fee2e2;
  color: #b91c1c !important;
  border: 1px solid #fca5a5;
}

.badge.helpdesk-system-badge {
  background: #f3f4f6;
  color: #4b5563 !important;
  border: 1px solid #d1d5db;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--bg);
}

.table-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  margin-left: 10px;
  vertical-align: middle;
  display: inline-block;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

  .btn-primary:hover {
    background: var(--primary-hover);
  }

.btn-secondary {
  background: var(--secondary);
  color: white;
}

  .btn-secondary:hover {
    background: var(--secondary-hover);
  }

.btn-danger {
  background: white;
  color: var(--danger);
  border: 1px solid #FCA5A5;
}

  .btn-danger:hover {
    background: #FEF2F2;
  }

.btn-outline {
  background: white;
  color: var(--text-dark);
  border: 1px solid var(--border);
}

  .btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
  }

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* Forms */
.form-group {
  margin-bottom: 15px;
}

  .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 500;
  }

.form-control {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  transition: 0.2s;
  background: white;
}

  .form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.1);
  }

.file-upload {
  border: 2px dashed var(--border);
  padding: 20px;
  text-align: center;
  border-radius: var(--radius);
  cursor: pointer;
}

  .file-upload i {
    font-size: 2rem;
    color: var(--primary);
  }

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

  .checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
  }

/* Editor */
.editor-toolbar {
  display: flex;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #FAFAFA;
}

.editor-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-content {
  min-height: 150px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 10px;
  outline: none;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

  .modal-overlay.show {
    display: flex;
  }

.modal-content {
  background: var(--surface);
  width: 90%;
  max-width: 600px;
  border-radius: 12px;
  overflow: hidden;
  animation: slideDown 0.3s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 15px 20px;
  background: #FAFAFA;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-body {
  padding: 20px;
}

/* Chat & TimeLog */
.chat-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 300px;
  overflow-y: auto;
  padding: 15px;
  background: #f8f9fa;
  border-radius: var(--radius);
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: white;
}

  .chat-bubble.customer {
    align-self: flex-start;
    border-bottom-right-radius: 2px;
  }

  .chat-bubble.agent {
    align-self: flex-end;
    background: var(--primary-light);
    border-color: #ffd8a8;
  }

.chat-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  color: #fff;
}

.badge {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  border-radius: 999px;
  color: #fff;
}

.badge-secondary {
  background-color: #6c757d;
  color: #fff;
}

.badge-primary {
  background-color: #007bff;
  color: #fff;
}

.badge-success {
  background-color: #28a745;
  color: #fff;
}

.badge-danger {
  background-color: #dc3545;
  color: #fff;
}

.badge-warning {
  background-color: #ffc107;
  color: #212529;
}

.badge-info {
  background-color: #17a2b8;
  color: #fff;
}

.badge-light {
  background-color: #f8f9fa;
  color: #212529;
  border: 1px solid #dee2e6;
}

.badge-dark {
  background-color: #343a40;
  color: #fff;
}

.badge-status-open {
  background-color: #28a745;
}

.badge-status-closed {
  background-color: #dc3545;
}

.badge-status-pending {
  background-color: #ffc107;
  color: #212529;
}

.badge-status-inprogress {
  background-color: #007bff;
}

.timelog-item {
  padding: 10px;
  border-right: 3px solid var(--secondary);
  background: #f8f9fa;
  margin-bottom: 10px;
  border-radius: 5px;
}

/* Modern Pagination */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 25px;
  align-items: center;
}

.page-btn {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 0.9rem;
}

  .page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
  }

  .page-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
  }

.page-nav {
  width: auto;
  padding: 0 15px;
  border-radius: 20px;
}

/* Knowledge Base */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.kb-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: 0.3s;
  border: 1px solid var(--border);
  cursor: pointer;
}

  .kb-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-5px);
  }

.kb-card-body {
  padding: 15px;
}

.blog-post {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.blog-post-content {
  padding: 30px;
  line-height: 2;
  text-align: justify;
}

/* Responsive */
@media (max-width: 768px) {
  .nav-menu {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 60px;
    right: 0;
    width: 100%;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    padding: 10px;
    height: auto;
  }

    .nav-menu.open {
      display: flex;
    }

  .mobile-toggle {
    display: block;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-grid, .chart-grid, .settings-grid {
    grid-template-columns: 1fr !important;
  }

  .kb-grid {
    grid-template-columns: 1fr;
  }

  .form-inline {
    flex-direction: column;
  }

  .checkbox-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
/* استایل‌های بخش چت مدرن */
.chat-wrapper {
  background: #f8f9fa;
  padding: 20px;
  max-height: 45dvh; /* نسبت به ارتفاع صفحه، نه پیکسل ثابت */
  min-height: 200px; /* حداقل برای صفحه‌های خیلی کوچک */
  overflow-y: auto; /* این خط اسکرول رو فعال میکنه */
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth; /* اسکرول رو نرم میکنه */
}

  .chat-wrapper::-webkit-scrollbar {
    width: 6px;
  }

  .chat-wrapper::-webkit-scrollbar-track {
    background: transparent;
  }

  .chat-wrapper::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
  }

    .chat-wrapper::-webkit-scrollbar-thumb:hover {
      background: #aaa;
    }

.msg-container {
  display: flex;
  gap: 10px;
  width: 100%;
  align-items: flex-start;
}

  .msg-container.agent-side {
    flex-direction: row-reverse;
  }

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.agent-side .msg-avatar {
  background: var(--primary);
  color: white;
}

.msg-box {
  max-width: 75%;
  display: flex;
  flex-direction: column;
}

.agent-side .msg-box {
  align-items: flex-end;
}

.msg-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 5px;
  padding: 0 5px;
}

.msg-author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
}

.msg-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.msg-content {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.6;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.customer-side .msg-content {
  background: white;
  border: 1px solid var(--border);
  border-bottom-right-radius: 2px;
}

.agent-side .msg-content {
  background: var(--primary-light);
  border: 1px solid #ffd8a8;
  border-bottom-left-radius: 2px;
  color: var(--text-dark);
}

/* بخش فرم پاسخ */
.reply-area {
  background: white;
  padding: 15px;
  border-top: 1px solid var(--border);
}

.reply-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.reply-tools {
  display: flex;
  gap: 8px;
}

.reply-tools {
  position: relative;
}

.ticket-emoji-picker {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(8, 34px);
  gap: 4px;
  padding: 8px;
  max-width: min(300px, 90vw);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

.ticket-emoji-option {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font-size: 21px;
  line-height: 34px;
}

  .ticket-emoji-option:hover {
    background: var(--bg);
  }

/* استایل‌های ستون اطلاعات (سایدبار) */
.info-card {
  padding: 0;
  margin-bottom: 20px;
  overflow: hidden;
}

.info-card-title {
  padding: 15px 20px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

  .info-card-title i {
    color: var(--primary);
  }

.info-list {
  padding: 15px 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.info-text {
  display: flex;
  flex-direction: column;
}

  .info-text small {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 2px;
  }

  .info-text strong {
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 600;
  }
/* استایل‌های Overlay Loading */
.loading-overlay {
  position: fixed; /* یا absolute اگه main-wrapper داره position: relative */
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255,255,255,0.8);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-dark);
  font-weight: 700;
}

.loading-brand img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  border-radius: 18px;
  animation: loading-brand-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes loading-brand-pulse {
  to { transform: scale(.94); opacity: .72; }
}

  .loading-overlay.hidden {
    display: none;
  }

/* طراحی اسپینر مدرن */
.spinner-modern {
  width: 50px;
  height: 50px;
  border: 5px solid var(--primary-light);
  border-bottom-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  animation: rotation 1s linear infinite;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

  .btn-loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 8px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
    vertical-align: middle;
  }

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

/* =========================
   Settings
========================= */

.settings-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.settings-sidebar {
  padding: 0;
  overflow: hidden;
  position: sticky;
  top: 80px;
}

.settings-sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--border);
  background: #FAFAFA;
}

  .settings-sidebar-header strong {
    display: block;
    font-size: 0.95rem;
  }

  .settings-sidebar-header small {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: 2px;
  }

.settings-sidebar-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.settings-menu {
  padding: 8px;
}

.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 3px;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

  .settings-menu-item:hover {
    background: var(--bg);
    color: var(--text-dark);
  }

  .settings-menu-item.active {
    background: var(--primary-light);
    color: var(--primary);
  }

.settings-menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.05rem;
}

.settings-menu-item.active .settings-menu-icon {
  background: white;
  box-shadow: var(--shadow-sm);
}

.settings-menu-content {
  flex: 1;
  min-width: 0;
}

  .settings-menu-content strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
  }

  .settings-menu-content small {
    display: block;
    font-size: 0.7rem;
    margin-top: 2px;
    color: var(--text-muted);
  }

.settings-menu-item.active .settings-menu-content small {
  color: var(--primary);
  opacity: 0.8;
}

.settings-menu-arrow {
  font-size: 0.9rem;
  opacity: 0;
  transition: 0.2s;
}

.settings-menu-item:hover .settings-menu-arrow,
.settings-menu-item.active .settings-menu-arrow {
  opacity: 1;
}


/* Content */

.settings-content {
  padding: 0;
  min-height: 500px;
}

.settings-panel {
  min-height: 500px;
}

.settings-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: #FAFAFA;
}

  .settings-panel-header h3 {
    margin: 0;
    font-size: 1.05rem;
  }

  .settings-panel-header p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
  }

.settings-panel-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.settings-panel-body {
  padding: 25px;
}

.settings-actions {
  display: flex;
  justify-content: flex-start;
  margin-top: 25px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.settings-empty {
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

  .settings-empty i {
    font-size: 1.8rem;
    opacity: 0.5;
  }


/* Responsive */

@media (max-width: 768px) {

  .settings-layout {
    grid-template-columns: 1fr;
  }

  .settings-sidebar {
    position: static;
  }

  .settings-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  .settings-menu-item {
    margin-bottom: 0;
  }

  .settings-panel-header {
    flex-wrap: wrap;
  }

    .settings-panel-header > .btn {
      width: 100%;
      justify-content: center;
    }
}


@media (max-width: 480px) {

  .settings-menu {
    grid-template-columns: 1fr;
  }

  .settings-panel-body {
    padding: 18px;
  }
}

.quill-editor {
  direction: rtl;
  text-align: right;
}

.modal-content:has(.ticket-create-form) {
  max-width: 820px;
}

#settings-general .settings-panel-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}

  #settings-general .settings-panel-body > .form-group,
  #settings-general .settings-panel-body > .settings-actions {
    margin-bottom: 0;
  }

    #settings-general .settings-panel-body > .form-group:has(textarea),
    #settings-general .settings-panel-body > .settings-actions {
      grid-column: 1 / -1;
    }

/* فرم ثبت/ویرایش فاکتور به‌دلیل ستون‌های قیمت و توضیحات عریض‌تر است. */
.modal-content:has(#inv-items) {
  width: min(96vw, 860px);
  max-width: 860px;
}

.invoice-item-row .inv-service {
  min-width: 0;
}

.invoice-item-row .inv-item-description {
  min-width: 0;
}

.ticket-description-editor .ql-editor {
  min-height: 260px;
  font-size: 0.95rem;
  line-height: 2;
}

.ticket-reply-editor .ql-editor {
  min-height: 120px;
  font-size: 0.95rem;
  line-height: 2;
}

.invoice-print-sheet {
  background: #fff;
  color: #222;
  width: 210mm;
  min-height: 297mm;
  max-width: 100%;
  margin: auto;
  padding: 14mm;
  font-family: Tahoma,Arial,sans-serif;
  font-size: 12px;
  box-sizing: border-box;
}

.invoice-top {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  align-items: center;
  border-bottom: 2px solid #333;
  padding-bottom: 12px;
}

.invoice-heading {
  text-align: center;
}

  .invoice-heading h1 {
    margin: 0 0 5px;
    font-size: 28px;
  }

  .invoice-heading small {
    color: #555;
  }

.invoice-meta {
  line-height: 2;
}

.invoice-logo {
  border: 2px dashed #377f84;
  padding: 15px 8px;
  text-align: center;
  color: #377f84;
  font-size: 17px;
  font-weight: bold;
}

  .invoice-logo img {
    max-width: 130px;
    max-height: 65px;
    object-fit: contain;
  }

.invoice-section-title {
  background: #ddd;
  border: 1px solid #333;
  text-align: center;
  font-weight: bold;
  padding: 6px;
  margin-top: 8px;
}

.invoice-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #333;
  border-top: 0;
}

  .invoice-info-grid div {
    padding: 7px 10px;
    border-left: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    min-height: 18px;
  }

  .invoice-info-grid .wide {
    grid-column: 1/-1;
  }

.invoice-items {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

  .invoice-items th, .invoice-items td {
    border: 1px solid #333;
    padding: 7px 5px;
    text-align: center;
  }

  .invoice-items th {
    background: #eee;
  }

  .invoice-items tfoot td {
    font-weight: bold;
  }

  .invoice-items .grand td {
    background: #e7e7e7;
    font-size: 13px;
  }

.invoice-notes {
  border: 1px solid #333;
  min-height: 55px;
  padding: 10px;
  margin-top: 8px;
}

.invoice-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #333;
  border-top: 0;
  min-height: 75px;
  padding: 12px;
}

  .invoice-signatures div:last-child {
    text-align: left;
  }

.invoice-stamp {
  margin-top: 6px;
  min-height: 45px;
}

  .invoice-stamp img {
    max-width: 100px;
    max-height: 70px;
    object-fit: contain;
  }

.invoice-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

.invoice-simple-sheet .invoice-heading small {
  display: none;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  body {
    background: #fff !important;
  }

  .invoice-print-sheet {
    width: 210mm;
    min-height: 297mm;
    max-width: none;
    padding: 14mm;
    font-size: 10px;
  }

  .invoice-heading h1 {
    font-size: 22px;
  }

  .invoice-print-sheet .invoice-top {
    padding-bottom: 7px;
  }

  .invoice-actions {
    display: none !important;
  }
}

/* Knowledge base */
.kb-page-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: .85rem;
}

.kb-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

  .kb-filter .form-control {
    max-width: 260px;
  }

.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
}

.kb-card {
  overflow: hidden;
  cursor: pointer;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}

  .kb-card:hover,
  .kb-card:focus {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    outline: none;
  }

.kb-cover {
  height: 170px;
  background: #f4f1ff;
  overflow: hidden;
}

  .kb-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

.kb-card-body {
  padding: 16px;
}

  .kb-card-body h3 {
    margin: 12px 0 8px;
    font-size: 1rem;
  }

  .kb-card-body p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: .84rem;
    line-height: 1.8;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
  }

.kb-read-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  color: var(--primary);
  font-size: .83rem;
  font-weight: 600;
}

.kb-empty {
  grid-column: 1 / -1;
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
}

.kb-article {
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
}

.kb-article-header {
  padding: 28px 32px 20px;
}

  .kb-article-header .badge {
    display: inline-flex;
    margin-top: 24px;
  }

  .kb-article-header h1 {
    margin: 12px 0 0;
    font-size: clamp(1.45rem, 3vw, 2.15rem);
    line-height: 1.55;
  }

.kb-article-cover {
  display: block;
  width: 100%;
  max-height: 430px;
  object-fit: cover;
}

.kb-article-content {
  padding: 28px 32px 36px;
}

  .kb-article-content .ql-editor {
    min-height: auto;
    padding: 0;
    font: inherit;
    font-size: 1rem;
    line-height: 2.15;
  }

    .kb-article-content .ql-editor img {
      max-width: 100%;
      height: auto;
    }

.kb-content-editor .ql-editor {
  min-height: 300px;
  line-height: 2;
}

.kb-publish-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
}

.kb-category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

  .kb-category-row:last-child {
    border-bottom: 0;
  }

  .kb-category-row strong,
  .kb-category-row small {
    display: block;
  }

  .kb-category-row small {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: .8rem;
  }

.kb-category-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .kb-filter,
  .kb-category-row {
    align-items: stretch;
    flex-direction: column;
  }

    .kb-filter .form-control {
      max-width: none;
    }

  .kb-category-actions {
    justify-content: flex-start;
  }

  .kb-article-header,
  .kb-article-content {
    padding-right: 18px;
    padding-left: 18px;
  }
}

.quill-editor .ql-editor {
  direction: rtl;
  text-align: right;
  min-height: 180px;
  font-family: inherit;
  font-size: 14px;
}

  .quill-editor .ql-editor.ql-blank::before {
    right: 15px;
    left: auto;
    text-align: right;
    font-style: normal;
  }

.ql-toolbar {
  direction: rtl;
}

.ticket-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.ticket-action-btn {
  --action-color: #6b7280;
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix( in srgb, var(--action-color) 30%, var(--border) );
  background: color-mix( in srgb, var(--action-color) 8%, var(--surface) );
  color: var(--action-color);
  border-radius: 10px;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .15s ease;
}

  .ticket-action-btn:hover {
    background: color-mix( in srgb, var(--action-color) 16%, var(--surface) );
    border-color: var(--action-color);
    color: var(--action-color);
    transform: translateY(-1px);
  }

  .ticket-action-btn:active {
    transform: translateY(0);
  }

.ticket-action-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--action-color);
  background: color-mix( in srgb, var(--action-color) 12%, transparent );
}

.ticket-action-btn:hover .ticket-action-icon {
  background: color-mix( in srgb, var(--action-color) 20%, transparent );
}

.ticket-action-btn > span:last-child {
  flex: 1;
  text-align: right;
  font-weight: 600;
  color: var(--action-color);
}

.ticket-action-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  background: var(--action-color);
}

.ticket-action-text {
  flex: 1;
  text-align: right;
  font-weight: 600;
  color: var(--action-color);
}

.ticket-action-arrow {
  color: var(--action-color);
  font-size: 18px;
}

.ticket-message-attachments,
.ticket-selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ticket-attachment,
.ticket-selected-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: .82rem;
  text-decoration: none;
}

  .ticket-attachment span,
  .ticket-selected-file span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ticket-attachment small {
    color: var(--text-muted);
    white-space: nowrap;
  }

.ticket-customer-link {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: right;
}

/* Mobile usability */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

button,
.btn,
select,
input,
textarea,
.nav-menu li,
.user-dropdown a {
  touch-action: manipulation;
}

@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  .navbar {
    height: 58px;
    padding: 0 12px;
    gap: 8px;
  }

  .nav-brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 7px;
    font-size: 1rem;
  }

  .nav-company-name {
    max-width: min(42vw, 180px);
  }

  .mobile-toggle {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    border-radius: 10px;
    color: var(--text-dark);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
  }

    .mobile-toggle:active,
    .mobile-toggle:hover {
      background: var(--bg);
    }

  .nav-menu {
    top: 58px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
  }

    .nav-menu li {
      width: 100%;
      min-height: 46px;
      padding: 11px 13px;
      font-size: .9rem;
    }

  .nav-right {
    gap: 6px;
    flex: 0 0 auto;
  }

  .nav-user-name {
    display: none;
  }

  .user-avatar {
    width: 36px;
    height: 36px;
  }

  .user-dropdown {
    top: 44px;
    left: 0;
    right: auto;
    width: 170px;
  }

    .user-dropdown a {
      min-height: 44px;
      padding: 11px 13px;
    }

  .main-wrapper {
    padding: 12px;
  }

  .page-header {
    align-items: stretch;
    gap: 12px;
    margin-bottom: 14px;
  }

  .page-title {
    font-size: 1.2rem;
  }

  .page-header > .btn,
  .page-header > button,
  .card-header > .btn,
  .card-header > button {
    width: 100%;
    justify-content: center;
  }

  .stats-grid {
    gap: 10px;
    margin-bottom: 14px;
  }

  .dashboard-promo {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 13px;
    min-height: 0;
    margin-bottom: 14px;
    padding: 18px;
  }

  .dashboard-promo-icon {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
    font-size: 1.45rem;
    border-radius: 13px;
  }

  .dashboard-promo-content {
    flex: 1 1 calc(100% - 66px);
  }

  .dashboard-promo h3 {
    font-size: 1.05rem;
  }

  .dashboard-promo p {
    font-size: .82rem;
  }

  .dashboard-promo-subtitle {
    font-size: .74rem !important;
  }

  .dashboard-promo-btn {
    flex-basis: 100%;
    max-width: none;
    width: 100%;
  }

  .stat-card {
    min-height: 92px;
    padding: 13px;
  }

    .stat-card .info .number {
      font-size: 1.45rem;
    }

    .stat-card .icon {
      width: 40px;
      height: 40px;
      font-size: 1.15rem;
    }

  .card {
    margin-bottom: 14px;
    border-radius: 10px;
  }

  .card-header {
    padding: 13px;
  }

  .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

    .table-responsive table {
      min-width: 620px;
    }

  th,
  td {
    padding: 10px 11px;
    font-size: .82rem;
    white-space: nowrap;
  }

  .form-group {
    margin-bottom: 13px;
  }

    .form-group label {
      font-size: .86rem;
    }

  .form-control {
    min-height: 44px;
    padding: 10px 11px;
    font-size: 16px; /* جلوگیری از زوم اجباری iOS */
  }

  textarea.form-control {
    min-height: 96px;
  }

  .btn {
    min-height: 44px;
    padding: 10px 13px;
    justify-content: center;
  }

  .btn-sm {
    min-height: 40px;
    padding: 8px 10px;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content,
  .modal-content:has(.ticket-create-form),
  .modal-content:has(#inv-items) {
    width: 100%;
    max-width: none;
    max-height: min(94dvh, 760px);
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  #settings-general .settings-panel-body {
    grid-template-columns: 1fr;
  }

    #settings-general .settings-panel-body > .form-group:has(textarea),
    #settings-general .settings-panel-body > .settings-actions {
      grid-column: auto;
    }

  .modal-header {
    min-height: 56px;
    padding: 11px 14px;
  }

  .modal-body {
    padding: 14px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

    .modal-body .btn {
      width: 100%;
    }

  .reply-actions,
  .settings-actions,
  .kb-filter,
  .kb-category-row,
  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .reply-tools {
    width: 100%;
    flex-wrap: wrap;
  }

    .reply-tools .btn,
    .reply-actions > .btn,
    .settings-actions > .btn,
    .kb-filter .form-control {
      width: 100%;
      max-width: none;
    }

  .chat-wrapper {
    max-height: 48dvh;
    min-height: 180px;
    padding: 12px 8px;
    gap: 14px;
  }

  .msg-box {
    max-width: calc(100% - 44px);
  }

  .msg-content {
    padding: 10px 12px;
    font-size: .86rem;
    overflow-wrap: anywhere;
  }

  .ticket-actions {
    gap: 7px;
  }

  .ticket-action-btn {
    min-height: 46px;
  }

  .settings-menu {
    grid-template-columns: 1fr !important;
  }

  .settings-panel-header,
  .settings-panel-body {
    padding: 15px;
  }

    .settings-panel-header > .btn {
      width: 100%;
    }

  .kb-article-header,
  .kb-article-content,
  .blog-post-content {
    padding: 18px;
  }

  .kb-article-content,
  .blog-post-content {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .main-wrapper {
    padding: 9px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .auth-container {
    min-height: 100dvh;
    padding: 12px;
  }

  .auth-card {
    padding: 24px 16px;
    border-radius: 12px;
  }

    .auth-card h2,
    .auth-card h1 {
      font-size: 1.25rem;
    }

  .checkbox-grid {
    gap: 8px;
  }

  .modal-content,
  .modal-content:has(.ticket-create-form),
  .modal-content:has(#inv-items) {
    max-height: 96dvh;
  }


  .table-responsive table {
    min-width: 560px;
  }

  .pagination {
    gap: 5px;
    flex-wrap: wrap;
  }

  .page-nav {
    padding: 0 11px;
  }
}
/* ==========================================================
   MOBILE SUITE — انتهای فایل اضافه شود
   ========================================================== */

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

img,
video {
  max-width: 100%;
  height: auto;
}

canvas {
  max-width: 100%;
}

@media (max-width: 768px) {

  /* جلوگیری از زوم خودکار iOS روی همه inputها */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px;
  }

  /* فیدبک لمسی */
  .btn:active,
  .page-btn:active,
  .ticket-action-btn:active {
    transform: scale(0.98);
  }

  /* اسکرول داخلی به بیرون نشت نکنه */
  .modal-content,
  .nav-menu,
  .chat-wrapper,
  .notif-dropdown,
  .ticket-status-filter-menu {
    overscroll-behavior: contain;
  }

  /* ---------- Navbar ---------- */
  .navbar {
    padding: 0 10px;
  }

  .notif-bell {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
  }

  .nav-menu {
    animation: navDrop 0.18s ease;
  }

  @keyframes navDrop {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* ---------- Dropdownها: ثابت داخل کادر صفحه ---------- */
  .notif-dropdown {
    position: fixed;
    top: 64px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: 380px;
    margin: 0 auto;
    max-height: 65dvh;
    overflow-y: auto;
  }

  .user-dropdown {
    position: fixed;
    top: 64px;
    left: 10px;
    right: auto;
    width: min(200px, calc(100vw - 20px));
  }

  /* فیلتر وضعیت همیشه تمام‌عرض */
  .ticket-status-filter {
    width: 100%;
  }

  /* ---------- پیکر ایموجی: شیت پایین صفحه ---------- */
  .ticket-emoji-picker {
    position: fixed;
    top: auto;
    bottom: 12px;
    left: 10px;
    right: 10px;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    max-width: none;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, .16);
  }

  /* ---------- مودال: دستگیره شیت پایین ---------- */
  .modal-header {
    padding-top: 16px;
  }

    .modal-header::before {
      content: "";
      position: absolute;
      top: 6px;
      left: 50%;
      transform: translateX(-50%);
      width: 42px;
      height: 4px;
      border-radius: 999px;
      background: var(--border);
    }

  /* ---------- Editor ---------- */
  .editor-toolbar {
    flex-wrap: wrap;
  }

  /* ---------- فاکتور: نسخه نمایشی سیال (چاپ دست‌نخورده می‌مونه) ---------- */
  .invoice-print-sheet {
    width: 100%;
    min-height: 0;
    padding: 14px 10px;
    font-size: 11px;
  }

  .invoice-top {
    grid-template-columns: 1fr;
    gap: 8px;
    text-align: center;
  }

  .invoice-info-grid,
  .invoice-signatures {
    grid-template-columns: 1fr;
  }

  .invoice-print-sheet .invoice-items {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .invoice-items th,
  .invoice-items td {
    padding: 5px 4px;
    white-space: nowrap;
  }

  .invoice-actions {
    flex-wrap: wrap;
  }

    .invoice-actions .btn {
      flex: 1 1 calc(50% - 8px);
    }

  /* فاصله امن پایین صفحه (ناوبار آیفون) */
  .main-wrapper {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .nav-company-name {
    max-width: 46vw;
    font-size: 0.95rem;
  }

  .kb-cover {
    height: 140px;
  }
}

/* ----------------------------------------------------------
   اختیاری — جدول‌های کارتی در موبایل:
   برای فعال‌سازی، به هر <td> صفت data-label="عنوان ستون" بده
   و کامنت این بخش را باز کن.
-----------------------------------------------------------
@media (max-width: 768px) {
  .table-responsive table { min-width: 0; }
  .table-responsive thead { display: none; }
  .table-responsive tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    background: var(--surface);
  }
  .table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    white-space: normal;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
  }
}
*/
/* ==========================================================
   MOBILE SUITE v2 — نیازمند helpdesk-mobile.js
   ========================================================== */

:root {
  --hd-nav-h: 0px;
  --hd-dock-h: 0px;
}

.hd-bottom-nav {
  display: none;
}

@media (max-width: 768px) {

  /* منوی همبرگر باید بالای داک پاسخ بیاد */
  .navbar {
    z-index: 950;
  }

  /* ---------- نوار ناوبری پایین ---------- */
  body.hd-has-bottom-nav {
    --hd-nav-h: calc(58px + env(safe-area-inset-bottom, 0px));
    padding-bottom: var(--hd-nav-h);
  }

  .hd-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 890;
    display: flex;
    align-items: stretch;
    height: var(--hd-nav-h);
    margin: 0;
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    list-style: none;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 16px rgba(0,0,0,.07);
  }

    .hd-bottom-nav li {
      flex: 1 1 0;
      min-width: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      padding: 6px 2px;
      font-size: .66rem;
      color: var(--text-muted);
      cursor: pointer;
      white-space: nowrap;
      overflow: hidden;
      border-radius: 10px;
      -webkit-tap-highlight-color: transparent;
    }

      .hd-bottom-nav li i {
        font-size: 1.3rem;
        line-height: 1;
      }

      .hd-bottom-nav li.active {
        color: var(--primary);
        font-weight: 700;
      }

      .hd-bottom-nav li:active {
        background: var(--bg);
      }

  /* وقتی کیبورد باز می‌شود، نوار پایین جمع شود */
  body.hd-keyboard-open {
    padding-bottom: 0 !important;
  }

    body.hd-keyboard-open .hd-bottom-nav {
      display: none;
    }

  /* ---------- داک پاسخ به تیکت (همیشه دم دست) ---------- */
  .hd-reply-dock {
    position: fixed;
    bottom: var(--hd-nav-h);
    left: 0;
    right: 0;
    z-index: 880;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 24px rgba(0,0,0,.14);
    max-height: 72dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  body.hd-keyboard-open .hd-reply-dock {
    bottom: 0;
  }

  .hd-reply-dock .reply-area {
    border-top: 0;
    border-radius: 0;
    box-shadow: none;
  }

  /* ---------- ادیتور جمع‌وجور ---------- */
  .chat-wrapper {
    max-height: 46dvh;
  }

  .ql-toolbar {
    display: flex !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

    .ql-toolbar::-webkit-scrollbar {
      display: none;
    }

    .ql-toolbar .ql-formats {
      flex: 0 0 auto;
      display: inline-flex;
    }

  .ticket-reply-editor .ql-editor,
  .ticket-description-editor .ql-editor {
    min-height: 76px;
    max-height: 28dvh;
    overflow-y: auto;
    font-size: 16px; /* جلوگیری از زوم iOS */
  }

  /* ---------- جدول‌ها به شکل کارت ---------- */
  .table-responsive {
    overflow-x: visible !important;
  }

    .table-responsive table {
      min-width: 0 !important;
    }

    .table-responsive thead {
      display: none;
    }

    .table-responsive tr {
      display: block;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 12px;
      margin-bottom: 10px;
      padding: 4px 0;
    }

    .table-responsive td {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      white-space: normal !important;
    }

      .table-responsive td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: .74rem;
        font-weight: 600;
        color: var(--text-muted);
      }

      .table-responsive td:not([data-label]) {
        justify-content: flex-start;
      }

      .table-responsive td[colspan] {
        display: block;
        text-align: center;
        color: var(--text-muted);
      }

        .table-responsive td[colspan]::before {
          content: none !important;
        }

    .table-responsive tr:hover td {
      background: transparent;
    }

  /* ---------- جزئیات صفحات ---------- */
  .info-card-title {
    padding: 12px 14px;
    font-size: .92rem;
  }

  .info-list {
    padding: 12px 14px;
    gap: 10px;
  }

  /* دکمه بازگشت تمام‌عرض نشود */
  .page-header > .btn-outline,
  .page-header > .link-btn {
    width: auto;
  }

  /* پیکر ایموجی بالای داک */
  .ticket-emoji-picker {
    z-index: 1300;
    bottom: calc(var(--hd-dock-h, 0px) + 10px);
    max-height: 42dvh;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  /* آمار داشبورد ۲×۲ به‌جای تک‌ستون */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 10px 12px;
    min-height: 0;
  }

    .stat-card .info .number {
      font-size: 1.25rem;
    }

    .stat-card .info h3 {
      font-size: .72rem;
      margin-bottom: 2px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .stat-card .icon {
      width: 34px;
      height: 34px;
      font-size: 1rem;
    }
}
/* ---------- حذف همبرگر وقتی منوی پایین فعال است ---------- */
@media (max-width: 768px) {
  body.hd-has-bottom-nav .mobile-toggle {
    display: none !important;
  }
}

/* ---------- شیت «بیشتر» ---------- */
.hd-sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 940;
  background: rgba(0, 0, 0, .45);
}

  .hd-sheet-overlay.show {
    display: block;
  }

.hd-sheet {
  display: none;
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(var(--hd-nav-h, 0px) + 8px);
  z-index: 945;
  margin: 0;
  padding: 8px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
  max-height: 60dvh;
  overflow-y: auto;
}

  .hd-sheet.show {
    display: block;
    animation: navDrop 0.18s ease;
  }

  .hd-sheet li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    border-radius: 10px;
    font-size: .9rem;
    color: var(--text-dark);
    cursor: pointer;
  }

    .hd-sheet li i {
      font-size: 1.2rem;
      color: var(--text-muted);
    }

    .hd-sheet li.active {
      background: var(--primary-light);
      color: var(--primary);
      font-weight: 700;
    }

      .hd-sheet li.active i {
        color: var(--primary);
      }

/* ==========================================================
   MOBILE SUITE v3 — جزئیات تیکت + لیست مینیمال
   ========================================================== */

@media (max-width: 768px) {

  /* ---- هدر فشرده و چسبان صفحه جزئیات ---- */
  body.hd-detail-page .page-header {
    position: relative;
    top: auto;
    z-index: auto;
    background: var(--bg);
    margin-bottom: 10px;
    padding: 8px 0;
  }

    body.hd-detail-page .page-header > .btn {
      width: auto;
    }

    body.hd-detail-page .page-header > div:first-child {
      min-width: 0;
      flex: 1 1 auto;
      gap: 10px !important;
    }

  body.hd-detail-page .page-title {
    font-size: .95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.hd-detail-page .page-header small {
    display: none;
  }

  body.hd-detail-page .page-header > .badge {
    flex: 0 0 auto;
  }

  .hd-back-btn {
    flex: 0 0 40px;
    width: 40px;
    min-width: 40px;
    padding: 8px 0 !important;
    justify-content: center;
  }

  /* ---- تب‌های جزئیات ---- */
  .hd-detail-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
  }

    .hd-detail-tabs button {
      flex: 1;
      min-height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      border: 0;
      border-radius: 9px;
      background: transparent;
      font-family: inherit;
      font-size: .84rem;
      font-weight: 600;
      color: var(--text-muted);
      cursor: pointer;
    }

      .hd-detail-tabs button.active {
        background: var(--primary-light);
        color: var(--primary);
      }

  /* کارت گفتگو: حذف هدر تکراری (تب خودش می‌گوید «گفتگو») */
  body.hd-detail-page .hd-tab-panel[data-panel="chat"] .card-header {
    display: none;
  }

  body.hd-detail-page .chat-wrapper {
    max-height: clamp(180px, calc(100dvh - var(--hd-dock-h, 220px) - 250px), 48dvh);
    min-height: 160px;
    background: var(--surface);
  }

  /* آیتم‌ای که محتواش به داک منتقل شده */
  .info-item.hd-consumed {
    display: none;
  }

  /* ---- نوار عملیات وضعیت داخل داک ---- */
  .hd-action-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
  }

    .hd-action-bar::-webkit-scrollbar {
      display: none;
    }

    .hd-action-bar:empty {
      display: none;
    }

    .hd-action-bar .ticket-action-btn {
      width: auto;
      flex: 0 0 auto;
      min-height: 38px;
      padding: 7px 14px;
      gap: 7px;
      border-radius: 999px;
      font-size: .82rem;
    }

      .hd-action-bar .ticket-action-btn .ticket-action-icon {
        width: 24px;
        height: 24px;
        flex-basis: 24px;
        border-radius: 6px;
        font-size: .8rem;
      }

  /* ---- فیلترهای جمع‌شونده لیست تیکت‌ها ---- */
  .hd-filters-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
  }

    .hd-filters-toggle .hd-filters-count {
      min-width: 20px;
      height: 20px;
      padding: 0 6px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      background: var(--primary);
      color: #fff;
      border-radius: 999px;
      font-size: .7rem;
    }

    .hd-filters-toggle .hd-filters-caret {
      margin-right: auto;
      transition: transform .2s;
    }

    .hd-filters-toggle.open .hd-filters-caret {
      transform: rotate(180deg);
    }

  .hd-filters-body {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

    .hd-filters-body.open {
      display: flex;
    }

  /* ---- تولبار Quill جمع‌وجور ---- */
  .ql-toolbar {
    padding: 6px 8px !important;
  }

    .ql-toolbar .ql-formats {
      margin-right: 6px !important;
    }
}

@media (max-width: 768px) {
  .hd-reply-dock form {
    display: block;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  }

    .hd-reply-dock form textarea.form-control {
      width: 100%;
      resize: vertical;
    }
}
/* ==========================================================
   MOBILE SUITE v4 — فیکس داک (همیشه آخرین بلوک باشد)
   ========================================================== */
@media (max-width: 768px) {

  /* چیپ‌های وضعیت: افقی کنار هم، نه عمودی */
  .hd-action-bar .ticket-actions {
    display: flex;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    min-width: max-content;
  }

  .hd-action-bar .ticket-action-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 38px;
    padding: 7px 14px;
  }

  /* فرم پاسخ فشرده داخل داک */
  .hd-reply-dock .reply-area {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 0;
  }

  .hd-reply-dock form {
    padding: 0;
  }
  /* خنثی‌کردن padding دوبل */

  .hd-reply-dock textarea.form-control {
    min-height: 64px;
    max-height: 24dvh;
  }

  .hd-reply-dock .ql-editor {
    min-height: 56px;
    max-height: 22dvh;
    font-size: 16px;
  }

  .hd-reply-dock .reply-actions {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }

  .hd-reply-dock .reply-tools {
    width: auto;
    flex: 1 1 auto;
  }

    .hd-reply-dock .reply-tools .btn,
    .hd-reply-dock .reply-actions > .btn {
      width: auto;
      min-width: 44px;
    }

  .hd-reply-dock .reply-actions > button[type="submit"] {
    min-width: 120px;
  }
}
/* ==========================================================
   MOBILE SUITE v5 — تولبار + شیت اطلاعات (جایگزین تب‌ها)
   ========================================================== */
@media (max-width: 768px) {

  /* پشتیبان مخفی‌سازی همبرگر (JS هم مستقیم مخفی می‌کند) */
  body.hd-has-bottom-nav .navbar .mobile-toggle {
    display: none !important;
  }

  /* گفتگو تمام‌عرض */
  .detail-grid.hd-one-col {
    grid-template-columns: 1fr !important;
  }

  /* ----- ردیف تولبار + چیپ‌های وضعیت داخل داک ----- */
  .hd-action-bar {
    align-items: center;
    min-height: 52px;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

    .hd-action-bar::-webkit-scrollbar {
      display: none;
    }

  .hd-dock-tools {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
    padding: 4px 0;
  }

  .hd-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 44px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-dark);
    font-family: inherit;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
  }

    .hd-tool-btn i {
      font-size: 1.05rem;
      color: var(--primary);
    }

  .hd-tools-sep {
    flex: 0 0 1px;
    align-self: stretch;
    margin: 6px 3px;
    background: var(--border);
  }

  .hd-action-bar .ticket-actions {
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    margin: 0 !important;
    min-width: max-content;
  }

  .hd-action-bar .ticket-action-btn {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 6px 10px;
    gap: 6px;
    border-radius: 10px;
  }

    .hd-action-bar .ticket-action-btn .ticket-action-icon {
      width: 26px;
      height: 26px;
      flex: 0 0 26px;
      border-radius: 6px;
      font-size: .8rem;
    }

    .hd-action-bar .ticket-action-btn > span:last-child {
      font-size: .78rem;
    }

  /* ----- فرم پاسخ فشرده ----- */
  .hd-reply-dock .reply-area {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 0;
  }

  .hd-reply-dock form {
    padding: 0;
  }

  .hd-reply-dock textarea.form-control {
    min-height: 64px;
    max-height: 24dvh;
  }

  .hd-reply-dock .ql-editor {
    min-height: 56px;
    max-height: 22dvh;
    font-size: 16px;
  }

  .hd-reply-dock .reply-actions {
    flex-direction: row !important;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }

  .hd-reply-dock .reply-tools {
    width: auto;
    flex: 1 1 auto;
  }

    .hd-reply-dock .reply-tools .btn,
    .hd-reply-dock .reply-actions > .btn {
      width: auto;
      min-width: 44px;
    }

  .hd-reply-dock .reply-actions > button[type="submit"] {
    min-width: 120px;
  }

  /* ----- شیت اطلاعات تیکت ----- */
  .hd-info-sheet {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(var(--hd-dock-h, 0px) + 8px);
    z-index: 945;
    max-height: 62dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
  }

    .hd-info-sheet.show {
      display: block;
      animation: navDrop 0.18s ease;
    }

  .hd-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
  }

  .hd-sheet-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
  }

  .info-item.hd-consumed {
    display: none;
  }
}

/* ==========================================================
   MOBILE SUITE v6 — هدر تیکت و تب‌های تنظیمات
   ========================================================== */
@media (max-width: 768px) {
  body.hd-detail-page .hd-detail-toolbar {
    position: sticky;
    top: 60px;
    z-index: 785;
    width: 100%;
    margin: 0 0 8px;
    padding: 3px 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
  }

  body.hd-detail-page .page-header {
    position: relative;
    top: auto;
    z-index: auto;
  }

  body.hd-detail-page .hd-detail-toolbar .hd-action-bar {
    min-height: 48px;
  }

  body.hd-detail-page .hd-detail-toolbar .hd-dock-tools {
    padding: 2px 0;
  }

  body.hd-detail-page .hd-detail-toolbar .hd-tool-btn,
  body.hd-detail-page .hd-detail-toolbar .ticket-action-btn {
    min-height: 38px;
  }

  body.hd-detail-page .hd-detail-toolbar .ticket-action-btn {
    padding: 5px 9px;
  }

  body.hd-detail-page .hd-detail-toolbar .ticket-action-icon {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }

  body.hd-detail-page .hd-detail-toolbar .ticket-action-btn > span:last-child {
    text-align: center;
  }

  body.hd-detail-page .page-header > .badge {
    width: auto;
    max-width: 92px;
    text-align: center;
    justify-content: center;
  }

  .settings-layout {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
  }

  .settings-layout > *,
  .settings-content,
  .settings-panel {
    min-width: 0;
    width: 100%;
  }

  .settings-content {
    overflow: hidden;
  }

  body.hd-detail-page .page-header {
    align-items: center;
    gap: 8px;
    padding: 6px 0;
  }

  body.hd-detail-page .page-header > div:first-child {
    gap: 8px !important;
  }

  body.hd-detail-page .page-title {
    font-size: .84rem;
    line-height: 1.45;
  }

  body.hd-detail-page .ticket-back-button,
  body.hd-detail-page .hd-back-btn {
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0 !important;
    justify-content: center;
  }

  body.hd-detail-page .ticket-back-label {
    display: none;
  }

  body.hd-detail-page .ticket-header-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: .67rem;
    white-space: nowrap;
    overflow: hidden;
  }

  body.hd-detail-page .ticket-header-meta small:first-child {
    display: none;
  }

  body.hd-detail-page .ticket-created-at {
    display: inline-flex;
    align-items: center;
    gap: 3px;
  }

  body.hd-detail-page .page-header > .badge {
    padding: 3px 7px;
    border-radius: 999px;
    font-size: .65rem;
    line-height: 1.4;
    white-space: nowrap;
  }

  body.hd-detail-page .conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 9px 12px;
  }

  body.hd-detail-page .conversation-header h5 {
    font-size: .82rem;
  }

  body.hd-detail-page .conversation-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: .68rem;
    font-weight: 700;
  }

  .settings-layout {
    gap: 12px;
  }

  .settings-sidebar {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .settings-sidebar-header {
    display: none;
  }

  .settings-menu {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    padding: 0 0 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .settings-menu::-webkit-scrollbar {
    display: none;
  }

  .settings-menu-item {
    flex: 0 0 auto;
    gap: 6px;
    min-height: 42px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    white-space: nowrap;
  }

  .settings-menu-icon {
    width: auto;
    height: auto;
    font-size: 1rem;
  }

  .settings-menu-item.active .settings-menu-icon {
    background: transparent;
    box-shadow: none;
  }

  .settings-menu-content {
    flex: 0 0 auto;
  }

  .settings-menu-content strong {
    font-size: .75rem;
  }

  .settings-menu-content small,
  .settings-menu-arrow {
    display: none;
  }

  .settings-panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }

  .settings-panel-header > div:not(.settings-panel-icon) {
    min-width: 0;
  }

  .settings-panel-header h3 {
    font-size: .9rem;
  }

  .settings-panel-header p {
    display: none;
  }

  .settings-panel-header > .btn {
    min-height: 42px;
    margin-right: 54px;
    width: calc(100% - 54px);
  }

  .settings-panel-body {
    padding: 12px;
  }

  #settings-departments-list > div {
    gap: 10px;
    min-width: 0;
    padding: 10px 12px !important;
  }

  #settings-departments-list > div > div:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #settings-departments-list > div > div:last-child {
    flex: 0 0 auto;
  }
}
