:root {
  --bg: #0f0f0e;
  --bg-elevated: #171715;
  --surface: #1c1c19;
  --surface-strong: #232320;
  --surface-hover: #292925;
  --border: #33332e;
  --text: #f3f2ee;
  --text-secondary: #cfcdc4;
  --text-muted: #a9a79d;
  --text-faint: #7a7870;
  --gold-300: #f3cd77;
  --gold-500: #d19429;
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ---------- app shell ---------- */

.app-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.app-header__brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  color: #201a08;
  font-weight: 800;
  font-size: 13px;
}

.app-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

/* ---------- login ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 25px 70px -20px rgba(0, 0, 0, 0.65);
}

.login-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-card h1 {
  font-size: 18px;
  margin: 0 0 4px;
}

.login-card p {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 22px;
}

/* ---------- form controls ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(209, 148, 41, 0.6);
  background: var(--surface-hover);
}

.field textarea {
  resize: vertical;
  min-height: 90px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  font-family: inherit;
}

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

.btn--primary {
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  color: #201a08;
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--secondary {
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--surface-hover);
}

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

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

.btn--sm {
  padding: 7px 12px;
  font-size: 12.5px;
}

.btn--block {
  width: 100%;
}

/* ---------- alerts ---------- */

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

.alert--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert--muted {
  background: var(--surface-strong);
  color: var(--text-muted);
}

/* ---------- page header ---------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.page-head h1 {
  font-size: 21px;
  margin: 0 0 4px;
}

.page-head p {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 0;
}

/* ---------- filters ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.filters input,
.filters select {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
}

/* ---------- ticket list ---------- */

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  transition: background 0.15s;
}

.ticket-row:hover {
  background: var(--surface-hover);
}

.ticket-row__subject {
  font-weight: 600;
  font-size: 14.5px;
  margin: 0 0 4px;
}

.ticket-row__meta {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--neutral {
  background: var(--surface-strong);
  color: var(--text-secondary);
}

.badge--warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

.badge--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* ---------- empty state ---------- */

.empty-state {
  text-align: center;
  padding: 64px 20px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ---------- ticket thread ---------- */

.thread-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.thread-head h1 {
  font-size: 19px;
  margin: 0 0 6px;
}

.thread-head__meta {
  font-size: 12.5px;
  color: var(--text-faint);
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.bubble-row {
  display: flex;
}

.bubble-row--agency {
  justify-content: flex-start;
}

.bubble-row--client {
  justify-content: flex-end;
}

.bubble {
  max-width: 78%;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 14px;
}

.bubble--agency {
  background: linear-gradient(180deg, rgba(243, 205, 119, 0.14), rgba(209, 148, 41, 0.09));
  border: 1px solid rgba(209, 148, 41, 0.25);
  border-top-right-radius: 6px;
}

.bubble--client {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-top-left-radius: 6px;
}

.bubble__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.bubble__meta b {
  color: var(--text-secondary);
  font-weight: 600;
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.7;
}

.bubble__attachments {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bubble__attachments a {
  font-size: 12px;
  color: var(--gold-300);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  padding: 6px 10px;
}

.bubble__attachments a:hover {
  text-decoration: underline;
}

/* ---------- reply box ---------- */

.reply-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.reply-box__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.reply-box__actions-start {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.pagination .btn {
  padding: 8px 14px;
}

@media (max-width: 640px) {
  .ticket-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .bubble {
    max-width: 90%;
  }
}
