/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 1;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-text);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  text-decoration: none;
  color: var(--brand-text);
}

.btn-primary:active {
  background: var(--brand-active);
}

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

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

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

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

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-hover);
  text-decoration: none;
  color: white;
}

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

.btn-success:hover {
  background: var(--success-hover);
  text-decoration: none;
  color: white;
}

.btn-outline-brand {
  background: transparent;
  color: var(--brand);
  border-color: var(--brand);
}

.btn-outline-brand:hover {
  background: var(--brand);
  color: var(--brand-text);
  text-decoration: none;
}

.btn-icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  padding: var(--space-1);
}

.btn-full {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: var(--space-2);
}

.btn-group .btn {
  flex: 1;
}

/* ========== Cards ========== */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: all var(--transition-base);
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-light);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
}

.card-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

.card-body {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: var(--line-height-relaxed);
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-light);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  margin-bottom: var(--space-4);
}

.card-icon.brand { background: var(--brand-soft); color: var(--brand); }
.card-icon.success { background: var(--success-soft); color: var(--success); }
.card-icon.warning { background: var(--warning-soft); color: var(--warning); }
.card-icon.danger { background: var(--danger-soft); color: var(--danger); }
.card-icon.info { background: var(--info-soft); color: var(--info); }

.card-compact {
  padding: var(--space-4);
}

.card-flat {
  border: none;
  box-shadow: none;
  background: var(--surface-muted);
}

/* ========== Forms ========== */
.form-group {
  margin-bottom: var(--space-5);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
  margin-bottom: var(--space-2);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--danger);
  margin-top: var(--space-1);
}

.form-input {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-input.error {
  border-color: var(--danger);
}

.form-input.error:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.form-input-group {
  display: flex;
  align-items: center;
  gap: 0;
}

.form-input-group .form-input {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.form-input-group .btn {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-left: none;
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
  position: relative;
  flex-shrink: 0;
}

.toggle input:checked + .toggle-track {
  background: var(--brand);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(20px);
}

/* Checkbox / Radio */
.checkbox,
.radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}

.checkbox input,
.radio input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-box,
.radio-dot {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  background: var(--surface-input);
}

.radio-dot {
  border-radius: 50%;
}

.checkbox input:checked + .checkbox-box,
.radio input:checked + .radio-dot {
  border-color: var(--brand);
  background: var(--brand);
}

.checkbox-box::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) scale(0);
  transition: transform var(--transition-fast);
}

.checkbox input:checked + .checkbox-box::after {
  transform: rotate(45deg) scale(1);
}

.radio-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  transform: scale(0);
  transition: transform var(--transition-fast);
}

.radio input:checked + .radio-dot::after {
  transform: scale(1);
}

/* ========== Badges & Tags ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
}

.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-muted); color: var(--text-muted); }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  background: var(--surface-muted);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid var(--border);
}

.tag:hover {
  background: var(--surface-hover);
  border-color: var(--brand-light);
  color: var(--brand);
}

.tag-remove {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.tag-remove:hover {
  opacity: 1;
}

/* ========== Modal / Dialog ========== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.95);
  transition: transform var(--transition-slow);
}

.modal-backdrop.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--surface-card);
  z-index: 1;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.modal-body {
  padding: var(--space-6);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }

/* ========== Toast Notifications ========== */
.toast-container {
  position: fixed;
  top: calc(var(--header-height) + var(--space-4));
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 400px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  max-width: 100%;
}

.toast.toast-leaving {
  animation: toastOut 0.3s ease forwards;
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin-bottom: 2px;
}

.toast-message {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.toast-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--transition-fast);
}

.toast-close:hover {
  color: var(--text);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ========== Loading Spinner ========== */
.spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.spinner::after {
  content: '';
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm::after { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg::after { width: 40px; height: 40px; border-width: 4px; }

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  gap: var(--space-4);
}

.loading-state .spinner::after {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

.loading-state-text {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ========== Empty States ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  text-align: center;
  gap: var(--space-4);
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-2xl);
  background: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.empty-state-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 360px;
}

/* ========== Error States ========== */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  text-align: center;
  gap: var(--space-4);
}

.error-state-icon {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-2xl);
  background: var(--danger-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--danger);
}

.error-state-title {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
}

.error-state-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 360px;
}

/* ========== Chat Bubbles ========== */
.chat-bubble {
  max-width: 80%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--line-height-relaxed);
  word-wrap: break-word;
  position: relative;
}

.chat-bubble-user {
  background: var(--brand);
  color: var(--brand-text);
  border-bottom-right-radius: var(--radius-sm);
  align-self: flex-end;
}

.chat-bubble-ai {
  background: var(--surface-muted);
  color: var(--text);
  border-bottom-left-radius: var(--radius-sm);
  align-self: flex-start;
}

.chat-bubble-system {
  background: var(--warning-soft);
  color: var(--warning);
  align-self: center;
  font-size: var(--text-xs);
  max-width: 90%;
  text-align: center;
}

.chat-bubble-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--space-1);
  opacity: 0.7;
}

.chat-bubble-user .chat-bubble-time {
  color: rgba(255, 255, 255, 0.7);
}

/* ========== Progress Bars ========== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--surface-muted);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar-sm { height: 4px; }
.progress-bar-lg { height: 12px; }

.progress-bar-success .progress-bar-fill { background: var(--success); }
.progress-bar-warning .progress-bar-fill { background: var(--warning); }
.progress-bar-danger .progress-bar-fill { background: var(--danger); }

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ========== Tables ========== */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
}

table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}

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

table tr:hover td {
  background: var(--surface-hover);
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

.pagination-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 36px;
  text-align: center;
  border: 1px solid transparent;
}

.pagination-item:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.pagination-item.active {
  background: var(--brand);
  color: var(--brand-text);
  border-color: var(--brand);
}

.pagination-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== Avatar ========== */
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-base);
  color: var(--brand-text);
  background: var(--brand);
  flex-shrink: 0;
  overflow: hidden;
}

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

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-xl); }
.avatar-xl { width: 80px; height: 80px; font-size: var(--text-3xl); }

/* ========== Divider ========== */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

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

.tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

.tab-panel {
  display: none;
  padding-top: var(--space-6);
}

.tab-panel.active {
  display: block;
}

/* ========== Skeleton Loading ========== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface-hover) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
  width: 100%;
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-title {
  height: 20px;
  width: 40%;
  margin-bottom: var(--space-4);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.skeleton-card {
  height: 120px;
  margin-bottom: var(--space-4);
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== Tooltip ========== */
.tooltip {
  position: relative;
  display: inline-flex;
}

.tooltip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  background: var(--text);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: var(--z-tooltip);
}

.tooltip:hover .tooltip-content,
.tooltip:focus-within .tooltip-content {
  opacity: 1;
}

/* ========== Dropdown ========== */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  padding: var(--space-2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--transition-fast);
}

.dropdown.open .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  width: 100%;
  text-align: left;
  background: none;
  border: none;
}

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

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

.dropdown-item-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: var(--space-1) 0;
}

/* ========== Accordion ========== */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid var(--border-light);
}

.accordion-item:last-child {
  border-bottom: none;
}

.accordion-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  transition: background var(--transition-fast);
}

.accordion-trigger:hover {
  background: var(--surface-hover);
}

.accordion-arrow {
  transition: transform var(--transition-fast);
  color: var(--text-muted);
}

.accordion-item.open .accordion-arrow {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 var(--space-5) var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-relaxed);
  display: none;
}

.accordion-item.open .accordion-content {
  display: block;
}

/* ========== Markdown Content ========== */
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
}

.markdown p {
  margin-bottom: var(--space-3);
}

.markdown ul,
.markdown ol {
  margin-bottom: var(--space-3);
  padding-left: var(--space-6);
}

.markdown ul { list-style: disc; }
.markdown ol { list-style: decimal; }

.markdown li {
  margin-bottom: var(--space-1);
  line-height: var(--line-height-relaxed);
}

.markdown blockquote {
  border-left: 3px solid var(--brand);
  padding: var(--space-3) var(--space-4);
  margin: var(--space-4) 0;
  background: var(--surface-muted);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
}

.markdown code {
  background: var(--surface-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.9em;
}

.markdown pre {
  margin: var(--space-4) 0;
}

.markdown a {
  color: var(--brand);
  text-decoration: underline;
}

.markdown table {
  margin: var(--space-4) 0;
}

.markdown img {
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
}

/* ========== Steps / Progress Indicator ========== */
.steps {
  display: flex;
  align-items: flex-start;
  gap: 0;
  margin-bottom: var(--space-8);
}

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.step-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  border: 2px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
  z-index: 1;
  transition: all var(--transition-base);
}

.step.active .step-number {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-text);
}

.step.completed .step-number {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.step-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
  text-align: center;
  max-width: 80px;
}

.step.active .step-label {
  color: var(--text);
  font-weight: var(--font-weight-medium);
}

.step::after {
  content: '';
  position: absolute;
  top: 18px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.step:last-child::after {
  display: none;
}

.step.completed::after {
  background: var(--success);
}

.step.active::after {
  background: var(--border);
}

/* ========== Stepper Input ========== */
.stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.stepper-btn {
  padding: var(--space-2) var(--space-3);
  background: var(--surface-muted);
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: var(--text-lg);
  transition: all var(--transition-fast);
}

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

.stepper-value {
  padding: var(--space-2) var(--space-4);
  min-width: 48px;
  text-align: center;
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
}

/* ========== Search Bar ========== */
.search-bar {
  position: relative;
}

.search-bar-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  padding-left: 36px;
}

.search-bar-clear {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.search-bar input:not(:placeholder-shown) ~ .search-bar-clear {
  opacity: 1;
}

/* ========== Chip Input ========== */
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-input);
  cursor: text;
  min-height: 44px;
  align-items: center;
}

.chip-input:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.chip-input input {
  border: none;
  outline: none;
  padding: 0;
  min-width: 80px;
  flex: 1;
  background: none;
  box-shadow: none;
  font-size: var(--text-sm);
}

.chip-input input:focus {
  box-shadow: none;
}

/* ========== Float Action Button ========== */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--space-6));
  right: var(--space-6);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: var(--z-sticky);
  transition: all var(--transition-base);
  border: none;
}

.fab:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
  background: var(--brand-hover);
}

/* ========== Stats Card ========== */
.stat-card {
  text-align: center;
  padding: var(--space-5);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.stat-change {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  margin-top: var(--space-1);
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ========== Timeline ========== */
.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: var(--space-6);
}

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

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-8) + 4px);
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--brand);
  z-index: 1;
}

.timeline-dot.success { border-color: var(--success); }
.timeline-dot.warning { border-color: var(--warning); }
.timeline-dot.danger { border-color: var(--danger); }
.timeline-dot.muted { border-color: var(--text-muted); }

.timeline-content {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.timeline-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

.timeline-title {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text);
}

.timeline-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ========== Responsive table ========== */
@media (max-width: 640px) {
  .table-responsive table,
  .table-responsive thead,
  .table-responsive tbody,
  .table-responsive th,
  .table-responsive td,
  .table-responsive tr {
    display: block;
  }

  .table-responsive thead {
    display: none;
  }

  .table-responsive tr {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-light);
  }

  .table-responsive td {
    padding: var(--space-1) var(--space-4);
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .table-responsive td::before {
    content: attr(data-label);
    font-weight: var(--font-weight-semibold);
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
  }
}

/* ========== Utility Classes ========== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-brand { color: var(--brand); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: 700; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative { position: relative; }
.absolute { position: absolute; }
.hidden { display: none; }
.inline-flex { display: inline-flex; }