:root {
  --navy: #1a365d; --blue: #2b6cb0; --blue-light: #ebf8ff; --white: #ffffff;
  --gray-50: #f7fafc; --gray-100: #edf2f7; --gray-200: #e2e8f0; --gray-300: #cbd5e0;
  --gray-500: #718096; --gray-700: #4a5568; --gray-800: #2d3748;
  --green: #38a169; --red: #e53e3e; --orange: #dd6b20;
  --sidebar-w: 260px; --header-h: 60px; --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08); --shadow-md: 0 4px 12px rgba(0,0,0,.1);
}
@font-face { font-family: 'Vazirmatn'; src: local('Vazirmatn'), local('Tahoma'); font-display: swap; }
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: Vazirmatn, Tahoma, sans-serif; background: var(--gray-100); color: var(--gray-800); line-height: 1.6; min-height: 100vh; direction: rtl; }
a { color: var(--blue); text-decoration: none; } a:hover { text-decoration: underline; }
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--navy); color: #fff; position: fixed; top: 0; right: 0; bottom: 0; z-index: 100; display: flex; flex-direction: column; transition: transform .25s; }
.sidebar-brand { padding: 1.25rem 1.5rem; font-size: 1.15rem; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 1.5rem; color: rgba(255,255,255,.8); font-size: .9rem; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-section { padding: .75rem 1.5rem .35rem; font-size: .7rem; color: rgba(255,255,255,.4); }
.main-wrap { margin-right: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--header-h); background: var(--white); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; position: sticky; top: 0; z-index: 50; }
.content { padding: 1.5rem; flex: 1; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-200); font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.card-body { padding: 1.25rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); border-right: 4px solid var(--blue); }
.stat-card .label { font-size: .8rem; color: var(--gray-500); } .stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--navy); }
.stat-card.critical { border-color: var(--red); } .stat-card.success { border-color: var(--green); } .stat-card.warning { border-color: var(--orange); }
.table-wrap { overflow-x: auto; } table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .75rem 1rem; text-align: right; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-50); font-weight: 600; color: var(--gray-700); }
tr:hover td { background: var(--gray-50); }
.form-group { margin-bottom: 1rem; } .form-group label { display: block; margin-bottom: .35rem; font-weight: 600; font-size: .875rem; }
.form-control { width: 100%; padding: .65rem .9rem; border: 1px solid var(--gray-300); border-radius: 8px; font-family: inherit; font-size: .95rem; }
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43,108,176,.15); }
textarea.form-control { min-height: 120px; resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.15rem; border: none; border-radius: 8px; font-family: inherit; font-size: .9rem; cursor: pointer; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover { background: #2c5282; color: #fff; text-decoration: none; }
.btn-success { background: var(--green); color: #fff; } .btn-danger { background: var(--red); color: #fff; }
.btn-secondary { background: var(--gray-200); color: var(--gray-800); } .btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; font-weight: 600; color: #fff; }
.alert { padding: .85rem 1.15rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #c6f6d5; color: #276749; } .alert-error { background: #fed7d7; color: #9b2c2c; }
.thread { display: flex; flex-direction: column; gap: 1rem; }
.message { background: var(--gray-50); border-radius: var(--radius); padding: 1rem 1.25rem; border: 1px solid var(--gray-200); }
.message.agent { border-right: 3px solid var(--blue); } .message.rep { border-right: 3px solid var(--green); }
.message.internal { background: #fefcbf; border-right: 3px solid var(--orange); }
.message-meta { font-size: .8rem; color: var(--gray-500); margin-bottom: .5rem; display: flex; justify-content: space-between; }
.message-body { white-space: pre-wrap; line-height: 1.7; }
.pagination { display: flex; gap: .35rem; justify-content: center; margin-top: 1.25rem; }
.pagination a, .pagination span { padding: .4rem .75rem; border-radius: 6px; background: var(--white); border: 1px solid var(--gray-200); font-size: .85rem; }
.pagination .active { background: var(--blue); color: #fff; border-color: var(--blue); }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--gray-500); }
.menu-toggle { display: none; background: none; border: none; color: var(--navy); font-size: 1.5rem; cursor: pointer; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); } .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-right: 0; } .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy), var(--blue)); padding: 1rem; }
.auth-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-md); width: 100%; max-width: 420px; padding: 2rem; }
.auth-card h1 { text-align: center; color: var(--navy); margin-bottom: .25rem; font-size: 1.4rem; }
.auth-card .subtitle { text-align: center; color: var(--gray-500); margin-bottom: 1.75rem; font-size: .9rem; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; align-items: center; }
.filters .form-control { width: auto; min-width: 140px; }
