/* ==========================================================================
       DESIGN SYSTEM TOKENS & CUSTOM PROPERTIES
       ========================================================================== */
:root {
  /* Brand Color Palette */
  --color-primary: #80AD01;
  --color-primary-hover: #6F9601;
  --color-primary-light: rgba(128, 173, 1, 0.10);
  --color-primary-subtle: rgba(128, 173, 1, 0.04);
  --color-primary-glow: rgba(128, 173, 1, 0.20);

  /* Surface & Background Neutrals */
  --bg-main: #F7F8F5;
  --bg-surface: #FFFFFF;
  --bg-surface-secondary: #FAFBF8;

  /* Borders & Dividers */
  --border-color: #E7E9E2;
  --border-hover: #D8DCD0;

  /* Typography Neutrals */
  --text-primary: #171A14;
  --text-secondary: #6F7568;
  --text-muted: #9AA092;

  /* Status Indicator Palette (Soft & Refined) */
  --badge-success-bg: rgba(128, 173, 1, 0.12);
  --badge-success-text: #537000;
  --badge-warning-bg: rgba(217, 119, 6, 0.08);
  --badge-warning-text: #B45309;
  --badge-danger-bg: rgba(220, 38, 38, 0.08);
  --badge-danger-text: #DC2626;
  --badge-info-bg: rgba(71, 85, 105, 0.08);
  --badge-info-text: #475569;

  /* Radii Standards */
  --radius-card: 20px;
  --radius-container: 24px;
  --radius-button: 12px;
  --radius-input: 12px;
  --radius-badge: 999px;
  --radius-table: 18px;
  --radius-dropdown: 14px;
  --radius-modal: 24px;

  /* Shadow Architecture */
  --shadow-card: 0 8px 30px rgba(20, 30, 10, 0.04);
  --shadow-card-hover: 0 12px 36px rgba(20, 30, 10, 0.07);
  --shadow-floating: 0 16px 50px rgba(20, 30, 10, 0.08);

  /* Typography Stack */
  --font-family: 'PeydaWeb', sans-serif;
  --transition-smooth: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Reset & Base Setup */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: clip;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: clip;
}

/* App Shell Layout Framework */
.app-layout {
  display: flex;
  min-height: 100vh;
  padding: 20px;
  gap: 24px;
  max-width: 1720px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
}

/* RTL Layout Direction Support */
[dir="rtl"] .app-layout {
  flex-direction: row;
}

/* ==========================================================================
       SIDEBAR NAVIGATION
       ========================================================================== */
.sidebar {
  width: 270px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  flex-shrink: 0;
  overflow: hidden;
  z-index: 50;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  flex-shrink: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.nav-groups {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar > .nav-groups {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

.sidebar > .nav-groups::-webkit-scrollbar {
  width: 6px;
}

.sidebar > .nav-groups::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: var(--radius-badge);
}

.nav-group {
  margin-bottom: 0;
}

.nav-group + .nav-group {
  position: relative;
  padding-top: 22px;
}

.nav-group + .nav-group::before {
  content: '';
  position: absolute;
  inset-inline: 12px;
  top: 0;
  height: 1px;
  background: linear-gradient(
    to inline-end,
    transparent 0%,
    var(--border-color) 16%,
    var(--border-color) 84%,
    transparent 100%
  );
}

.nav-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 12px 10px 12px;
}

.nav-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(
    to inline-end,
    var(--border-hover) 0%,
    transparent 100%
  );
  opacity: 0.9;
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-button);
  transition: var(--transition-smooth);
  position: relative;
}

.nav-item a:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.nav-item.active a {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-item.active a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3.5px;
  background: var(--color-primary);
  border-radius: 0 4px 4px 0;
}

[dir="rtl"] .nav-item.active a::before {
  left: auto;
  right: 0;
  border-radius: 4px 0 0 4px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

/* Nav group with sub-items — pure HTML <details>, no JS */
.nav-details {
  list-style: none;
}

.nav-details details {
  border-radius: var(--radius-button);
}

.nav-details summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-button);
  cursor: pointer;
  list-style: none;
  transition: var(--transition-smooth);
  user-select: none;
}

.nav-details summary::-webkit-details-marker {
  display: none;
}

.nav-details summary::marker {
  content: '';
}

.nav-details summary:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.nav-details.is-active > details > summary {
  color: var(--color-primary);
  font-weight: 600;
}

.nav-details-chevron {
  width: 16px;
  height: 16px;
  margin-inline-start: auto;
  stroke-width: 2;
  opacity: 0.45;
  flex-shrink: 0;
  transition: transform 200ms ease;
}

.nav-details details[open] .nav-details-chevron {
  transform: rotate(180deg);
  opacity: 0.7;
}

/* Tree sub-nav */
.nav-sub {
  --nav-tree-x: 23px;
  --nav-tree-branch: 20px;
  --nav-tree-color: var(--border-color);

  list-style: none;
  margin: 0;
  margin-inline-start: var(--nav-tree-x);
  padding: 0 0 4px var(--nav-tree-branch);
  display: flex;
  flex-direction: column;
}

.nav-sub-item {
  position: relative;
}

.nav-tree-guide {
  position: absolute;
  inset-inline-start: calc(-1 * var(--nav-tree-branch));
  top: 0;
  bottom: 0;
  width: var(--nav-tree-branch);
  pointer-events: none;
}

.nav-tree-elbow {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 100%;
  height: 50%;
  border-inline-start: 1.5px solid var(--nav-tree-color);
  border-bottom: 1.5px solid var(--nav-tree-color);
  border-end-start-radius: 8px;
}

.nav-sub-item:not(.is-last) .nav-tree-guide::after {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  bottom: 0;
  border-inline-start: 1.5px solid var(--nav-tree-color);
}

.nav-sub-item.active .nav-tree-elbow,
.nav-sub-item.active .nav-tree-guide::after {
  border-color: var(--color-primary);
}

.nav-sub-item a {
  position: relative;
  z-index: 1;
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-button);
  transition: var(--transition-smooth);
}

.nav-sub-item a:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.nav-sub-item.active a {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.mobile-nav-toggle {
  position: fixed;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.mobile-nav {
  position: fixed;
  inset: 0;
  z-index: 140;
  visibility: hidden;
  pointer-events: none;
}

.mobile-nav-toggle:checked ~ .mobile-nav {
  visibility: visible;
  pointer-events: auto;
}

body:has(.mobile-nav-toggle:checked) {
  overflow: hidden;
}

.mobile-nav-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 26, 20, 0.42);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 180ms ease;
  cursor: pointer;
}

.mobile-nav-toggle:checked ~ .mobile-nav .mobile-nav-backdrop {
  opacity: 1;
}

.mobile-nav-panel {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(100%, 320px);
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border-color);
  box-shadow: var(--shadow-floating);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  transform: translateX(100%);
  transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-nav-toggle:checked ~ .mobile-nav .mobile-nav-panel {
  transform: translateX(0);
}

.mobile-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.mobile-nav-brand {
  border: none;
  margin: 0;
  padding: 0;
}

.mobile-nav-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  transition: var(--transition-smooth);
  display: grid;
  place-items: center;
}

.mobile-nav-close:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.mobile-nav-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0;
}

.mobile-nav-foot {
  padding-top: 16px;
  margin-top: auto;
  border-top: 1px solid var(--border-color);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-surface-secondary);
  border-radius: var(--radius-button);
  font-size: 12px;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* ==========================================================================
       MAIN CONTENT CONTAINER
       ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
  min-width: 0;
  /* Prevents flex overflow */
}

/* ==========================================================================
       HEADER BAR
       ========================================================================== */
.header {
  height: 76px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-input);
  padding: 10px 16px;
  width: 320px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.search-trigger:hover {
  border-color: var(--border-hover);
  background: #FFFFFF;
}

.search-placeholder {
  font-size: 14px;
  color: var(--text-muted);
  flex: 1;
}

.kbd-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-button);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: var(--transition-smooth);
  color: var(--text-secondary);
}

.icon-btn:hover {
  background: var(--bg-surface-secondary);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.icon-btn.mobile-nav-trigger {
  display: none;
}

.notification-indicator {
  position: absolute;
  top: 11px;
  right: 11px;
  width: 7px;
  height: 7px;
  background: var(--color-primary);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 12px;
  border-left: 1px solid var(--border-color);
}

[dir="rtl"] .user-profile {
  padding-left: 0;
  padding-right: 12px;
  border-left: none;
  border-right: 1px solid var(--border-color);
}

.user-profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -6px;
  padding: 6px 8px 6px 6px;
  border: none;
  border-radius: 14px;
  background: transparent;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: var(--transition-smooth);
}

[dir="rtl"] .user-profile-trigger {
  padding: 6px 6px 6px 8px;
}

.user-profile-trigger:hover,
.user-profile-trigger[aria-expanded="true"] {
  background: var(--bg-surface-secondary);
}

.user-profile-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.user-profile-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.user-profile-trigger[aria-expanded="true"] .user-profile-chevron {
  transform: rotate(180deg);
  color: var(--color-primary);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: #2D3128;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  text-align: start;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.user-role {
  font-size: 12px;
  color: var(--text-muted);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.user-menu {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 26, 20, 0.42);
  backdrop-filter: blur(4px);
  animation: user-menu-fade 180ms ease;
}

.user-menu[hidden] {
  display: none !important;
}

.user-menu-panel {
  width: min(100%, 360px);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-floating);
  padding: 22px 18px 16px;
  position: relative;
  animation: ui-modal-pop 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.user-menu-handle {
  display: none;
  width: 40px;
  height: 4px;
  margin: 0 auto 16px;
  border-radius: var(--radius-badge);
  background: var(--border-hover);
}

.user-menu-close {
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  transition: var(--transition-smooth);
}

.user-menu-close:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.user-menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.user-menu-avatar {
  width: 48px;
  height: 48px;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.user-menu-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 10px;
  border: none;
  border-radius: 14px;
  background: transparent;
  font-family: inherit;
  color: var(--text-primary);
  text-decoration: none;
  text-align: start;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.user-menu-item:hover {
  background: var(--bg-surface-secondary);
}

.user-menu-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.user-menu-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.user-menu-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.user-menu-copy span {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.user-menu-copy small {
  font-size: 12px;
  color: var(--text-muted);
}

.user-menu-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

[dir="rtl"] .user-menu-arrow {
  transform: scaleX(-1);
}

.user-menu-sep {
  height: 1px;
  margin: 6px 10px;
  background: var(--border-color);
}

.user-menu-item--danger {
  color: var(--badge-danger-text);
}

.user-menu-item--danger .user-menu-icon {
  background: var(--badge-danger-bg);
  border-color: transparent;
  color: var(--badge-danger-text);
}

.user-menu-item--danger:hover {
  background: var(--badge-danger-bg);
}

@keyframes user-menu-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes user-menu-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .user-menu,
  .user-menu-panel,
  .mobile-nav-panel,
  .mobile-nav-backdrop,
  .user-profile-chevron {
    animation: none;
    transition: none;
  }
}

/* ==========================================================================
       DASHBOARD HERO SECTION
       ========================================================================== */
.hero-banner {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-container);
  padding: 32px 36px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.hero-banner::after {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, var(--color-primary-light) 0%, rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.hero-content h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.hero-content p {
  font-size: 15px;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2;
}

.btn-primary {
  background: var(--color-primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-button);
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: var(--transition-smooth);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px var(--color-primary-glow);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

/* ==========================================================================
       KPI METRIC CARDS
       ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-hover);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.metric-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.metric-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-surface-secondary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.metric-body {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  line-height: 1;
}

.metric-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-badge);
  font-size: 12px;
  font-weight: 600;
}

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

.sparkline-svg {
  width: 70px;
  height: 33px;
}

/* ==========================================================================
       ANALYTICS & CHARTS SECTION
       ========================================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  min-width: 0;
  width: 100%;
}

.analytics-grid>* {
  min-width: 0;
  max-width: 100%;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.time-filter {
  display: flex;
  background: var(--bg-main);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.filter-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 7px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.filter-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.chart-container {
  position: relative;
  height: 240px;
  width: 100%;
  margin-top: auto;
}

/* Custom SVG Graphic Styles */
.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--border-color);
  stroke-dasharray: 4 4;
  stroke-width: 1;
}

.chart-path {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 3;
  stroke-linecap: round;
}

.chart-area {
  fill: url(#gradient-area);
}

/* Traffic Sources Bars */
.source-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 8px;
}

.source-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.source-name {
  font-weight: 600;
  color: var(--text-primary);
}

.source-val {
  color: var(--text-secondary);
  font-weight: 500;
}

.progress-bar-bg {
  height: 8px;
  width: 100%;
  background: var(--bg-main);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
}

/* ==========================================================================
       BOTTOM SECTION: DATA TABLE & ACTIVITY
       ========================================================================== */
.content-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr;
  gap: 20px;
  min-width: 0;
  width: 100%;
}

.content-grid>* {
  min-width: 0;
  max-width: 100%;
}

.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: 28px;
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.custom-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  text-align: left;
}

[dir="rtl"] .custom-table {
  text-align: right;
}

.custom-table th {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 16px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.custom-table tr:last-child td {
  border-bottom: none;
}

.custom-table tr:hover td {
  background-color: var(--bg-surface-secondary);
}

.customer-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-badge);
  font-size: 12px;
  font-weight: 600;
}

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

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

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

/* Activity Feed */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.timeline-item {
  display: flex;
  gap: 14px;
  position: relative;
}

.timeline-icon-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
  z-index: 2;
}

.timeline-content {
  display: flex;
  flex-direction: column;
}

.timeline-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-time {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
       PAGE HEADER & EMPTY STATE
       ========================================================================== */
.page-header {
  margin-bottom: 24px;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.page-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition-smooth);
}

.page-breadcrumb a:hover {
  color: var(--color-primary);
}

.breadcrumb-sep {
  opacity: 0.45;
}

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-desc {
  margin-top: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 52ch;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-empty {
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-card);
  padding: 56px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.page-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: grid;
  place-items: center;
}

.page-empty-icon svg {
  width: 26px;
  height: 26px;
  stroke-width: 2;
}

.page-empty h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-empty p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 40ch;
}

/* Command Palette Modal (Interactive UI Accent) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 26, 20, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.command-palette {
  width: 100%;
  max-width: 580px;
  background: var(--bg-surface);
  border-radius: var(--radius-modal);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-floating);
  overflow: hidden;
  transform: translateY(-10px);
  transition: var(--transition-smooth);
}

.modal-overlay.active .command-palette {
  transform: translateY(0);
}

.ui-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: rgba(23, 26, 20, 0.42);
  backdrop-filter: blur(4px);
  padding: 20px;
}

.ui-modal[hidden] {
  display: none !important;
}

.ui-modal-card {
  width: min(100%, 560px);
  max-width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-floating);
  padding: 24px;
  position: relative;
  overflow: auto;
  max-height: min(90vh, 900px);
  animation: ui-modal-pop 220ms cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.ui-modal-size-sm {
  width: min(100%, 360px);
}

.ui-modal-size-md {
  width: min(100%, 560px);
}

.ui-modal-size-lg {
  width: min(100%, 640px);
}

.ui-modal-size-xl {
  width: min(100%, 880px);
}

.ui-modal-close {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.ui-modal-close:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

.ui-modal-body {
  margin-top: 4px;
}

.welcome-modal-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

.welcome-modal-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--badge-success-bg);
  color: var(--badge-success-text);
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
}

.welcome-modal-card h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.welcome-modal-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.welcome-modal-card .btn-primary {
  min-width: 140px;
  justify-content: center;
}

@keyframes ui-modal-pop {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.cmd-input-wrapper {
  display: flex;
  gap: 3px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.cmd-input {
  border: none;
  outline: none;
  width: 100%;
  font-size: 16px;
  font-family: var(--font-family);
  color: var(--text-primary);
  background: transparent;
  margin-left: 12px;
}

.cmd-results {
  padding: 12px;
  max-height: 320px;
  overflow-y: auto;
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.cmd-item:hover {
  background: var(--bg-surface-secondary);
  color: var(--text-primary);
}

/* Responsive Controls */
@media (max-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .analytics-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-layout {
    padding: 12px;
    gap: 12px;
  }

  .sidebar {
    display: none;
  }

  .icon-btn.mobile-nav-trigger {
    display: flex;
    grid-column: 1;
    grid-row: 1;
  }

  .header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 64px;
    padding: 12px 14px;
    gap: 12px;
    align-items: center;
  }

  .header-actions {
    grid-column: 3;
    grid-row: 1;
    margin-inline-start: 0;
  }

  .search-trigger {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    order: unset;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .hero-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  .user-profile-chevron {
    display: none;
  }

  .user-profile .user-info {
    display: none;
  }

  .user-menu {
    place-items: end center;
    padding: 10px;
  }

  .user-menu-panel {
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 20px 20px;
    padding-top: 12px;
    animation: user-menu-up 280ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .user-menu-handle {
    display: block;
  }

  .table-card {
    padding: 16px;
  }

  .table-wrapper {
    overflow-x: visible;
  }

  .custom-table {
    min-width: 0;
    width: 100%;
  }

  .custom-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .custom-table tbody,
  .custom-table tr,
  .custom-table td {
    display: block;
    width: 100%;
  }

  .custom-table tr {
    background: var(--bg-surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  .custom-table tr:last-child {
    margin-bottom: 0;
  }

  .custom-table tr:hover td {
    background: transparent;
  }

  .custom-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 13px;
    text-align: left;
  }

  [dir="rtl"] .custom-table td {
    text-align: right;
  }

  .custom-table td:last-child {
    border-bottom: none;
    padding-bottom: 0;
  }

  .custom-table td:first-child {
    padding-top: 0;
  }

  .custom-table td::before {
    content: attr(data-label);
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
  }

  .customer-cell {
    justify-content: flex-end;
    min-width: 0;
  }

  .customer-cell span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ==========================================================================
       SUPPORT GROUPS
       ========================================================================== */

.sg {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sg-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px;
}

.sg-panel-h {
  margin-bottom: 16px;
}

.sg-panel-h h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sg-panel-h p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.sg-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.sg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.sg-field.grow {
  flex: 1;
}

.sg-field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.sg-field input {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  background: var(--bg-main);
  padding: 11px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sg-field input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow, rgb(128 173 1 / 18%));
  background: var(--bg-surface);
}

.sg-submit {
  white-space: nowrap;
}

.sg-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.sg-err {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fef3f2;
  color: #b42318;
  border: 1px solid #fecdca;
  font-size: 13px;
}

.sg-empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.sg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.sg-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--bg-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sg-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
  background: var(--bg-surface);
}

.sg-card.inactive {
  opacity: 0.72;
}

.sg-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sg-card-top h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.sg-badge {
  flex: none;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.sg-badge.on {
  background: var(--color-primary-light, #eaf5dc);
  color: var(--color-primary);
}

.sg-badge.off {
  background: #eee;
  color: var(--text-muted);
}

.sg-desc {
  margin: 0;
  flex: 1;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.sg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.sg-actions .btn-secondary {
  padding: 8px 12px;
  font-size: 12.5px;
}

.sg-del {
  border: 1px solid #f0b4ae;
  background: #fff;
  color: #b42318;
  border-radius: var(--radius-button);
  padding: 8px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.sg-del:hover {
  background: #fef3f2;
}

@media (max-width: 960px) {
  .sg-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .sg-grid {
    grid-template-columns: 1fr;
  }

  .sg-form {
    flex-direction: column;
    align-items: stretch;
  }

  .sg-field {
    min-width: 0;
  }
}


/* ==========================================================================
       SUPPORT TICKETS
       ========================================================================== */

.sp-head {
  margin-bottom: 0;
}

.sp-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 16px;
}

.sp-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  white-space: nowrap;
}

.sp-tab:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.sp-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.sp-tab i {
  font-style: normal;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgb(255 255 255 / 18%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.sp-tab:not(.active) i {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.sp-title {
  font-weight: 600;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sp-phone {
  display: block;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
}

.sp-err {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fef3f2;
  color: #b42318;
  border: 1px solid #fecdca;
  font-size: 13px;
}

.sp-detail-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sp-detail .card-header {
  align-items: flex-start;
}

.sp-meta {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.sp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.sp-toolbar .page-input {
  min-width: 160px;
  flex: 1;
}

.sp-sat {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  font-size: 13px;
  color: var(--text-secondary);
}

.sp-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(560px, 65vh);
  overflow: auto;
  padding: 4px 2px 8px;
}

.sp-msg {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
}

.sp-msg.admin {
  background: var(--color-primary-light, #eaf5dc);
  border-color: transparent;
}

.sp-msg-h {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.sp-msg-h strong {
  font-size: 12.5px;
  color: var(--text-primary);
}

.sp-msg-h time,
.sp-log time {
  font-size: 11px;
  color: var(--text-muted);
}

.sp-msg p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.sp-file {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
}

.sp-empty {
  margin: 0;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.sp-logs {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sp-logs strong {
  font-size: 13px;
  color: var(--text-primary);
}

.sp-log {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.sp-reply {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.sp-reply textarea.page-input {
  width: 100%;
  min-height: 96px;
  resize: vertical;
}

.sp-reply .btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- Q&A detail (questions / answers) ---------- */

.qa-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qa-ok {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--color-primary-light);
  color: var(--color-primary-hover);
  border: 1px solid rgba(128, 173, 1, 0.28);
  font-size: 13px;
  font-weight: 600;
}

.qa-card {
  overflow: hidden;
}

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

.qa-kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-primary);
  margin-bottom: 4px;
}

.qa-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.45;
  color: var(--text-primary);
  font-weight: 700;
}

.qa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.qa-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}

.qa-chip.muted {
  color: var(--text-muted);
}

.qa-chip.accent {
  background: var(--color-primary-light);
  border-color: transparent;
  color: var(--color-primary-hover);
  font-weight: 700;
}

.qa-head-side {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.qa-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.qa-stats span {
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--color-primary-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
}

.qa-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0 4px;
  max-height: min(520px, 58vh);
  overflow: auto;
}

.qa-bubble {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: qa-in 0.28s ease both;
}

.qa-bubble.admin {
  flex-direction: row-reverse;
}

.qa-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  background: #e8ebe3;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 800;
}

.qa-avatar.admin {
  background: var(--color-primary);
  color: #fff;
}

.qa-bubble-body {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
}

.qa-bubble.question .qa-bubble-body {
  background: #fff;
  box-shadow: 0 1px 0 rgba(23, 26, 20, 0.04);
}

.qa-bubble.admin .qa-bubble-body {
  background: var(--color-primary-light);
  border-color: transparent;
}

.qa-bubble-h {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.qa-bubble-h strong {
  font-size: 12.5px;
  color: var(--text-primary);
}

.qa-bubble-h time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.qa-bubble-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.qa-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
}

.qa-link:hover {
  color: var(--color-primary-hover);
}

.qa-empty-thread {
  margin: 0;
  padding: 18px;
  text-align: center;
  border: 1px dashed var(--border-color);
  border-radius: 14px;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--color-primary-subtle);
}

.qa-composer {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--color-primary-subtle), transparent 88%);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qa-composer-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.qa-composer textarea.page-input {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border-radius: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qa-composer textarea.page-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  outline: none;
}

.qa-composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.qa-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.qa-composer .btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

@keyframes qa-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 768px) {
  .sp-tabs {
    gap: 6px;
  }

  .sp-tab {
    flex: 1 1 calc(50% - 6px);
    justify-content: space-between;
  }

  .sp-detail .card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .qa-head {
    flex-direction: column;
  }

  .qa-head-side {
    justify-content: flex-start;
  }

  .qa-bubble.admin {
    flex-direction: row;
  }

  .qa-composer-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .qa-composer-bar .btn-primary {
    width: 100%;
  }
}

/* ---------- Switch (checkbox) ---------- */

.ui-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 2px;
  margin: 0;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.ui-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.ui-switch-track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d5dacb;
  flex: none;
  transition: background 0.18s ease;
}

.ui-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 30, 10, 0.18);
  transition: transform 0.18s ease;
}

.ui-switch:has(input:checked) .ui-switch-track,
.ui-switch.is-on .ui-switch-track {
  background: var(--color-primary);
}

.ui-switch:has(input:checked) .ui-switch-track::after,
.ui-switch.is-on .ui-switch-track::after {
  transform: translateX(18px);
}

.ui-switch:has(input:checked),
.ui-switch.is-on {
  color: var(--badge-success-text);
}

.ui-switch-on {
  display: none;
}

.ui-switch:has(input:checked) .ui-switch-on,
.ui-switch.is-on .ui-switch-on {
  display: inline;
}

.ui-switch:has(input:checked) .ui-switch-off,
.ui-switch.is-on .ui-switch-off {
  display: none;
}

.ui-switch.is-sm {
  gap: 6px;
  font-size: 12px;
}

.ui-switch.is-sm .ui-switch-track {
  width: 36px;
  height: 22px;
}

.ui-switch.is-sm .ui-switch-track::after {
  width: 16px;
  height: 16px;
}

.ui-switch.is-sm:has(input:checked) .ui-switch-track::after,
.ui-switch.is-sm.is-on .ui-switch-track::after {
  transform: translateX(14px);
}

.ui-switch:has(input:disabled),
.ui-switch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ui-switch:focus-within,
.ui-switch:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: 10px;
}
