:root {
  --primary-color: #0f766e;
  --secondary-color: #115e59;
  --accent-color: #c4a35a;
  --background-color: #f3f6f6;
  --text-color: #12312f;
  --sidebar-color: #042f2e;
  --header-color: #ffffff;
  --success-color: #198754;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --info-color: #0dcaf0;

  --th-primary: var(--primary-color);
  --th-primary-hover: color-mix(in srgb, var(--primary-color) 78%, #04110f);
  --th-secondary: var(--secondary-color);
  --th-accent: var(--accent-color);
  --th-bg: var(--background-color);
  --th-surface: var(--header-color);
  --th-surface-elevated: color-mix(in srgb, var(--header-color) 94%, var(--primary-color));
  --th-border: color-mix(in srgb, var(--text-color) 12%, transparent);
  --th-text: var(--text-color);
  --th-text-muted: color-mix(in srgb, var(--text-color) 58%, var(--background-color));
  --th-success: var(--success-color);
  --th-warning: var(--warning-color);
  --th-danger: var(--danger-color);
  --th-info: var(--info-color);

  --th-sidebar: 232px;
  --th-topbar: 64px;
  --th-radius-sm: 6px;
  --th-radius: 10px;
  --th-radius-lg: 16px;
  --th-space-1: 4px;
  --th-space-2: 8px;
  --th-space-3: 12px;
  --th-space-4: 16px;
  --th-space-5: 24px;
  --th-space-6: 32px;
  --th-shadow: 0 1px 2px color-mix(in srgb, var(--th-text) 6%, transparent);
  --th-font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --th-focus: 0 0 0 3px color-mix(in srgb, var(--th-primary) 28%, transparent);
}

[data-bs-theme="dark"] {
  color-scheme: dark;
  --th-bg: color-mix(in srgb, var(--sidebar-color) 78%, #030808);
  --th-surface: color-mix(in srgb, var(--sidebar-color) 42%, #0e1716);
  --th-surface-elevated: color-mix(in srgb, var(--primary-color) 16%, #15201f);
  --th-text: #e7eeed;
  --th-text-muted: color-mix(in srgb, #e7eeed 62%, #6b7c7a);
  --th-border: color-mix(in srgb, #ffffff 9%, transparent);
  --th-shadow: none;
}

html,
body {
  min-height: 100%;
}

html {
  overflow-x: hidden;
}

.admin-main,
.admin-content,
.admin-topbar {
  min-width: 0;
}

body.admin-body {
  background: var(--th-bg);
  color: var(--th-text);
  font-family: var(--th-font);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

a {
  color: var(--th-primary);
}

a:hover {
  color: var(--th-primary-hover);
}

:focus-visible {
  outline: none;
  box-shadow: var(--th-focus);
}

.th-skip {
  position: absolute;
  inset-inline-start: -999px;
  padding: 0.5rem 1rem;
  background: var(--th-primary);
  color: #fff;
  z-index: 2000;
}

.th-skip:focus {
  inset-inline-start: 1rem;
  inset-block-start: 1rem;
}

.th-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 2px;
  z-index: 2000;
  transform: scaleX(0);
  transform-origin: right;
  background: var(--th-accent);
  pointer-events: none;
}

.th-progress.is-on {
  animation: th-load 0.9s ease infinite;
}

@keyframes th-load {
  0% { transform: scaleX(0.08); opacity: 0.4; }
  50% { transform: scaleX(0.7); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0.2; }
}

/* Layout */
.admin-shell {
  min-height: 100vh;
}

.admin-sidebar {
  width: var(--th-sidebar);
  background: var(--sidebar-color);
  color: #f4f7f6;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  border-inline-end: 1px solid color-mix(in srgb, #fff 8%, transparent);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1rem 1.1rem 0.85rem;
  min-height: var(--th-topbar);
}

.admin-brand img,
.brand-monogram {
  width: 36px;
  height: 36px;
  border-radius: var(--th-radius-sm);
  object-fit: cover;
  background: #fff;
  flex: 0 0 36px;
}

.brand-monogram {
  display: grid;
  place-items: center;
  color: var(--th-primary);
  font-weight: 700;
}

.admin-brand strong {
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.2;
}

.admin-brand small {
  color: color-mix(in srgb, var(--th-accent) 80%, #fff);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-nav {
  overflow-y: auto;
  padding: 0.4rem 0.7rem 1.5rem;
  flex: 1;
}

.th-nav-group {
  margin-bottom: 1rem;
}

.th-nav-label {
  display: block;
  padding: 0.35rem 0.7rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: color-mix(in srgb, #fff 38%, transparent);
}

.admin-nav a {
  color: color-mix(in srgb, #fff 72%, transparent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.42rem 0.7rem;
  margin: 0.08rem 0;
  border-radius: var(--th-radius-sm);
  font-weight: 500;
  font-size: 0.9rem;
  border-inline-start: 2px solid transparent;
}

.admin-nav a i {
  font-size: 1.05rem;
  width: 1.15rem;
  text-align: center;
  opacity: 0.9;
}

.admin-nav a:hover {
  background: color-mix(in srgb, #fff 7%, transparent);
  color: #fff;
}

.admin-nav a.active {
  background: color-mix(in srgb, var(--th-primary) 28%, transparent);
  color: #fff;
  border-inline-start-color: var(--th-accent);
}

.admin-main {
  margin-inline-start: var(--th-sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  background: color-mix(in srgb, var(--th-surface) 88%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--th-border);
  padding: 0 1.25rem;
  min-height: var(--th-topbar);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.th-topbar-title {
  font-weight: 650;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: min(52vw, 22rem);
}

.th-topbar-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--th-radius-sm);
  object-fit: cover;
  background: #fff;
  flex: 0 0 28px;
}

.th-topbar-meta {
  color: var(--th-text-muted);
  font-size: 0.78rem;
}

.th-icon-btn {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--th-border);
  background: var(--th-surface);
  color: var(--th-text);
  border-radius: var(--th-radius-sm);
  padding: 0;
}

.th-icon-btn:hover {
  background: var(--th-surface-elevated);
  color: var(--th-text);
}

.th-icon-btn .th-dot {
  position: absolute;
  inset-block-start: 7px;
  inset-inline-end: 8px;
  width: 8px;
  height: 8px;
  border-radius: 99px;
  background: var(--th-danger);
}

.th-avatar {
  width: 32px;
  height: 32px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--th-primary) 16%, var(--th-surface));
  color: var(--th-primary);
  font-weight: 700;
  font-size: 0.78rem;
}

.admin-content {
  padding: 1.35rem 1.5rem 2.5rem;
  flex: 1;
}

/* Cards / surfaces */
.admin-card,
.stat-card,
.file-tile,
.login-card,
.support-list,
.support-thread {
  background: var(--th-surface);
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius);
  box-shadow: var(--th-shadow);
  color: var(--th-text);
}

.admin-card .card-body,
.stat-card .card-body {
  padding: 1.1rem 1.2rem;
}

.admin-card .card-footer {
  border-top: 1px solid var(--th-border);
  background: transparent;
}

form.admin-card {
  box-shadow: none;
}

form.admin-card .card-body {
  padding: 0.85rem 1rem;
}

.th-section {
  margin-bottom: 1.5rem;
}

.th-section-title {
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--th-text-muted);
  margin-bottom: 0.75rem;
}

.th-page-header h1 {
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 0.2rem;
}

.th-page-header p {
  color: var(--th-text-muted);
  margin: 0;
  font-size: 0.92rem;
}

/* KPI */
.stat-card {
  overflow: hidden;
  position: relative;
}

.stat-card::after {
  display: none;
}

.stat-card .stat-label {
  color: var(--th-text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.stat-card .stat-value {
  font-size: 1.55rem;
  font-weight: 650;
  color: var(--th-text);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.th-kpi {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  padding: 1.05rem 1.15rem;
  background: var(--th-surface);
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius);
  height: 100%;
}

.th-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--th-radius-sm);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--th-primary) 12%, transparent);
  color: var(--th-primary);
  flex: 0 0 36px;
}

.th-kpi.is-accent .th-kpi-icon {
  background: color-mix(in srgb, var(--th-accent) 18%, transparent);
  color: color-mix(in srgb, var(--th-accent) 70%, var(--th-text));
}

.th-kpi.is-muted .th-kpi-icon {
  background: color-mix(in srgb, var(--th-text) 8%, transparent);
  color: var(--th-text-muted);
}

.th-welcome {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.th-banner {
  display: flex;
  gap: 0.9rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius);
  background: var(--th-surface);
  margin-bottom: 1rem;
}

.th-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.th-quick a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-sm);
  color: var(--th-text);
  text-decoration: none;
  background: var(--th-surface);
  font-size: 0.86rem;
}

.th-quick a:hover {
  border-color: color-mix(in srgb, var(--th-primary) 40%, var(--th-border));
  color: var(--th-primary);
}

/* Tables */
.table-responsive {
  border-radius: var(--th-radius);
}

.admin-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--th-text);
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: color-mix(in srgb, var(--th-primary) 6%, transparent);
  --bs-table-border-color: var(--th-border);
  margin: 0;
}

.admin-table thead th {
  white-space: nowrap;
  color: var(--th-text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--th-surface-elevated);
  border-bottom: 1px solid var(--th-border);
  padding: 0.7rem 1rem;
}

.admin-table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--th-border);
  vertical-align: middle;
  border-top: 0;
}

.admin-table tbody tr:last-child td {
  border-bottom: 0;
}

.admin-table tbody tr:hover td {
  background: color-mix(in srgb, var(--th-primary) 5%, transparent);
}

.entity-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--th-radius-sm);
  background: color-mix(in srgb, var(--th-primary) 10%, var(--th-surface));
}

/* Buttons */
.btn {
  border-radius: var(--th-radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
}

.btn-thiqa,
.btn-primary {
  background: var(--th-primary);
  border-color: var(--th-primary);
  color: #fff;
}

.btn-thiqa:hover,
.btn-thiqa:focus,
.btn-primary:hover {
  background: var(--th-primary-hover);
  border-color: var(--th-primary-hover);
  color: #fff;
}

.btn-outline-secondary,
.btn-ghost {
  background: transparent;
  border-color: var(--th-border);
  color: var(--th-text);
}

.btn-outline-secondary:hover {
  background: var(--th-surface-elevated);
  border-color: var(--th-border);
  color: var(--th-text);
}

.btn-outline-danger {
  color: var(--th-danger);
  border-color: color-mix(in srgb, var(--th-danger) 35%, var(--th-border));
  background: transparent;
}

.btn-outline-danger:hover {
  background: color-mix(in srgb, var(--th-danger) 10%, transparent);
  color: var(--th-danger);
  border-color: var(--th-danger);
}

.btn-success {
  background: var(--th-success);
  border-color: var(--th-success);
}

.btn-link {
  color: var(--th-primary);
}

/* Forms */
.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--th-text);
  margin-bottom: 0.35rem;
}

.form-control,
.form-select {
  border-radius: var(--th-radius-sm);
  border-color: var(--th-border);
  background: var(--th-surface);
  color: var(--th-text);
  min-height: 40px;
}

.form-control:focus,
.form-select:focus {
  border-color: color-mix(in srgb, var(--th-primary) 55%, var(--th-border));
  box-shadow: var(--th-focus);
  background: var(--th-surface);
  color: var(--th-text);
}

.form-text,
.text-muted {
  color: var(--th-text-muted) !important;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--th-danger);
}

.invalid-feedback {
  color: var(--th-danger);
}

/* Badges */
.badge,
.th-badge {
  font-weight: 600;
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 0.35em 0.7em;
  letter-spacing: 0;
}

.text-bg-success { background: color-mix(in srgb, var(--th-success) 16%, transparent) !important; color: var(--th-success) !important; }
.text-bg-danger { background: color-mix(in srgb, var(--th-danger) 16%, transparent) !important; color: var(--th-danger) !important; }
.text-bg-warning { background: color-mix(in srgb, var(--th-warning) 22%, transparent) !important; color: color-mix(in srgb, var(--th-text) 80%, #8a6d00) !important; }
.text-bg-primary { background: color-mix(in srgb, var(--th-primary) 14%, transparent) !important; color: var(--th-primary) !important; }
.text-bg-secondary { background: color-mix(in srgb, var(--th-text) 8%, transparent) !important; color: var(--th-text-muted) !important; }
.text-bg-info { background: color-mix(in srgb, var(--th-info) 18%, transparent) !important; color: color-mix(in srgb, var(--th-text) 70%, var(--th-info)) !important; }

[data-bs-theme="dark"] .text-bg-warning {
  color: #f3d48a !important;
}

/* Empty / toast / modal */
.th-empty {
  text-align: center;
  padding: 2.75rem 1rem;
  color: var(--th-text-muted);
}

.th-empty i {
  font-size: 1.6rem;
  color: var(--th-primary);
  opacity: 0.7;
  display: block;
  margin-bottom: 0.6rem;
}

.th-toast-host {
  position: fixed;
  inset-block-start: 1rem;
  inset-inline-end: 1rem;
  z-index: 1090;
}

.toast {
  background: var(--th-surface);
  color: var(--th-text);
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius);
  box-shadow: var(--th-shadow);
}

.dropdown-menu,
.modal-content,
.offcanvas,
.accordion-item {
  background: var(--th-surface);
  color: var(--th-text);
  border-color: var(--th-border);
}

.dropdown-item {
  color: var(--th-text);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--th-surface-elevated);
  color: var(--th-text);
}

.pagination {
  margin: 0;
  gap: 0.25rem;
}

.pagination .page-link {
  border-radius: var(--th-radius-sm) !important;
  border-color: var(--th-border);
  color: var(--th-text);
  background: var(--th-surface);
}

.pagination .active .page-link {
  background: var(--th-primary);
  border-color: var(--th-primary);
  color: #fff;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
}

.login-panel {
  background: var(--sidebar-color);
  color: #f6f8f7;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem;
}

.login-panel p {
  color: color-mix(in srgb, #fff 72%, transparent);
  max-width: 28rem;
}

.login-form-col {
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background: var(--th-bg);
}

.login-card {
  width: min(420px, 100%);
  box-shadow: none;
}

.brand-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border-radius: var(--th-radius);
  background: var(--th-surface-elevated);
  border: 1px solid var(--th-border);
}

.th-brand-hero {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.th-brand-hero .th-kpi {
  align-items: center;
  flex-direction: column;
  text-align: center;
}

.th-appearance-preview {
  border: 1px dashed var(--th-border);
  border-radius: var(--th-radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.th-appearance-preview .fake-side {
  width: 88px;
  background: var(--sidebar-color);
  min-height: 120px;
}

.th-appearance-preview .fake-main {
  background: var(--th-bg);
  padding: 0.75rem;
  flex: 1;
}

.th-appearance-preview .fake-bar {
  height: 28px;
  background: var(--th-surface);
  border: 1px solid var(--th-border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.th-appearance-preview .fake-card {
  height: 48px;
  background: var(--th-surface);
  border: 1px solid var(--th-border);
  border-radius: 6px;
}

.th-swatch {
  width: 100%;
  height: 42px;
  border-radius: var(--th-radius-sm);
  border: 1px solid var(--th-border);
}

/* Files / support / inbox */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}

.file-grid.is-list {
  grid-template-columns: 1fr;
}

.file-grid.is-list .file-tile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.file-grid.is-list .file-tile img {
  width: 64px;
  height: 48px;
}

.file-tile img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--th-radius-sm);
}

.th-drop {
  border: 1px dashed var(--th-border);
  border-radius: var(--th-radius);
  padding: 1rem;
  text-align: center;
  color: var(--th-text-muted);
  background: var(--th-surface-elevated);
}

.support-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 240px;
  gap: 1rem;
  min-height: calc(100vh - 8rem);
}

.support-list,
.support-thread,
.support-meta {
  background: var(--th-surface);
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius);
}

.th-ticket {
  display: block;
  padding: 0.7rem 0.75rem;
  border-radius: var(--th-radius-sm);
  color: inherit;
  text-decoration: none;
  border: 1px solid transparent;
}

.th-ticket:hover,
.th-ticket.is-active {
  background: var(--th-surface-elevated);
  border-color: var(--th-border);
  color: inherit;
}

.th-bubble {
  max-width: 80%;
  padding: 0.7rem 0.85rem;
  border-radius: var(--th-radius);
  background: var(--th-surface-elevated);
}

.th-bubble.is-admin {
  background: color-mix(in srgb, var(--th-primary) 12%, var(--th-surface));
  margin-inline-start: auto;
}

.th-inbox-item {
  display: flex;
  gap: 0.85rem;
  padding: 0.9rem 1rem;
  border: 0;
  border-bottom: 1px solid var(--th-border);
  width: 100%;
  background: transparent;
  text-align: start;
}

.th-inbox-item.is-unread {
  background: color-mix(in srgb, var(--th-accent) 8%, transparent);
}

.th-inbox-item:hover {
  background: var(--th-surface-elevated);
  color: inherit;
}

.cms-content img {
  max-width: 100%;
  height: auto;
}

.nav-tabs {
  border-bottom-color: var(--th-border);
}

.nav-tabs .nav-link {
  color: var(--th-text-muted);
  border: 0;
  border-bottom: 2px solid transparent;
}

.nav-tabs .nav-link.active {
  color: var(--th-primary);
  background: transparent;
  border-bottom-color: var(--th-primary);
}

.offcanvas.admin-nav a {
  margin-inline: 0;
}

@media (max-width: 1199.98px) {
  .support-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .support-meta {
    display: none;
  }
}

@media (max-width: 991.98px) {
  .admin-sidebar {
    display: none !important;
  }

  .admin-main {
    margin-inline-start: 0;
  }

  .login-wrap {
    grid-template-columns: 1fr;
  }

  .login-panel {
    min-height: 180px;
    padding: 1.5rem;
  }

  .support-shell {
    grid-template-columns: 1fr;
  }

  .support-list {
    display: none;
  }

  .support-index-only .support-list {
    display: block;
  }

  .admin-content {
    padding: 1rem 0.9rem 2rem;
  }

  .th-brand-hero {
    grid-template-columns: 1fr;
  }
}

.cc-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-inline-start: 2px solid var(--th-border);
}

.cc-timeline li {
  position: relative;
  padding: 0 0 1rem 1rem;
}

.cc-timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: -5px;
  top: 0.35rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--th-border);
}

.cc-timeline li.is-done::before {
  background: var(--th-primary);
}

.cc-timeline li:last-child {
  padding-bottom: 0;
}

.cc-map {
  height: 320px;
  border-radius: var(--th-radius);
}

.cc-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--th-border);
  border-radius: var(--th-radius-sm);
  margin-bottom: 0.4rem;
  cursor: pointer;
}

.cc-radio:has(input:checked) {
  border-color: var(--th-primary);
  background: color-mix(in srgb, var(--th-primary) 8%, transparent);
}

.cc-actions {
  position: sticky;
  top: calc(var(--th-topbar) + 12px);
}

@media (max-width: 991px) {
  .cc-actions {
    position: static;
  }
}

.partner-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.partner-tabs .nav-link {
  white-space: nowrap;
}

.partner-cover {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--th-radius) var(--th-radius) 0 0;
}

@media (prefers-reduced-motion: reduce) {
  .th-progress.is-on {
    animation: none;
    transform: scaleX(1);
  }
}
