/* ============================================================
   COMPONENTS — Butonlar, Kartlar, Formlar, Tablolar, Modal...
   ============================================================ */

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  line-height: 1.5;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-decoration: none;
  user-select: none;
  position: relative;
  overflow: hidden;
}
.btn:disabled, .btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: var(--text-base); border-radius: var(--radius-lg); }
.btn-xl { padding: 1rem 2rem; font-size: var(--text-lg); border-radius: var(--radius-lg); }

/* Primary */
.btn-primary {
  background: var(--color-primary-600);
  color: #fff;
  border-color: var(--color-primary-600);
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { background: var(--color-primary-700); border-color: var(--color-primary-700); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,235,.35); }
.btn-primary:active { transform: translateY(0); }

/* Secondary */
.btn-secondary {
  background: var(--color-neutral-100);
  color: var(--color-neutral-700);
  border-color: var(--color-neutral-200);
}
.btn-secondary:hover { background: var(--color-neutral-200); border-color: var(--color-neutral-300); }

/* Success */
.btn-success { background: var(--color-success-500); color: #fff; border-color: var(--color-success-500); }
.btn-success:hover { background: var(--color-success-600); }

/* Danger */
.btn-danger { background: var(--color-danger-500); color: #fff; border-color: var(--color-danger-500); }
.btn-danger:hover { background: var(--color-danger-600); }

/* Warning */
.btn-warning { background: var(--color-warning-500); color: #fff; border-color: var(--color-warning-500); }
.btn-warning:hover { background: var(--color-warning-600); }

/* Ghost */
.btn-ghost { background: transparent; color: var(--color-primary-600); border-color: transparent; }
.btn-ghost:hover { background: var(--color-primary-50); }

/* Outline */
.btn-outline { background: transparent; color: var(--color-primary-600); border-color: var(--color-primary-400); }
.btn-outline:hover { background: var(--color-primary-50); border-color: var(--color-primary-600); }

/* Outline Danger */
.btn-outline-danger { background: transparent; color: var(--color-danger-600); border-color: var(--color-danger-300); }
.btn-outline-danger:hover { background: var(--color-danger-50); border-color: var(--color-danger-600); }

/* Icon only */
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-md); }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-icon.btn-lg { width: 44px; height: 44px; }

/* Loading */
.btn-loading { color: transparent !important; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.card-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--color-neutral-800);
  margin: 0;
}
.card-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-top: 2px; }

.card-body { padding: var(--space-6); }
.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  background: var(--color-neutral-50);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* Stat Card */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--stat-color, var(--color-primary-500));
  border-radius: 0 2px 2px 0;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: var(--stat-bg, var(--color-primary-50));
  color: var(--stat-color, var(--color-primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }

.stat-content { flex: 1; min-width: 0; }
.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
  margin-bottom: var(--space-1);
}
.stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-neutral-900);
  line-height: 1.2;
}
.stat-trend {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-trend.up   { color: var(--color-success-600); }
.stat-trend.down { color: var(--color-danger-600); }

/* Chart Card */
.chart-card { padding: 0; }
.chart-card .card-body { padding: var(--space-4); }
.chart-container { position: relative; }

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

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-2);
}
.form-label .required { color: var(--color-danger-500); margin-left: 2px; }

.form-control {
  display: block;
  width: 100%;
  padding: 0.5rem 0.875rem;
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--color-neutral-900);
  background: #fff;
  border: 1.5px solid var(--color-neutral-300);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  appearance: none;
  line-height: 1.5;
}
.form-control::placeholder { color: var(--color-neutral-400); }
.form-control:focus {
  outline: none;
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.form-control:disabled, .form-control[readonly] {
  background: var(--color-neutral-100);
  color: var(--color-neutral-500);
  cursor: not-allowed;
}
.form-control.is-invalid {
  border-color: var(--color-danger-500);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.10);
}
.form-control.is-valid {
  border-color: var(--color-success-500);
}

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}
.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger-600);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input Group (icon + input) */
.input-group {
  position: relative;
  display: flex;
  align-items: stretch;
}
.input-group .input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-neutral-400);
  pointer-events: none;
  width: 16px; height: 16px;
}
.input-group .form-control { padding-left: 2.5rem; }
.input-group .input-icon-right {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-neutral-400);
  cursor: pointer;
}
.input-group .form-control.has-icon-right { padding-right: 2.5rem; }

/* Select */
.select-wrapper { position: relative; }
.select-wrapper::after {
  content: '';
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--color-neutral-500);
  pointer-events: none;
}
.select-wrapper select.form-control { padding-right: 2.5rem; cursor: pointer; }

/* Checkbox & Radio */
.checkbox-label, .radio-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-neutral-700);
  user-select: none;
}
.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--color-primary-600);
  cursor: pointer;
}

/* Form Grid */
.form-row { display: flex; gap: var(--space-4); }
.form-row .form-group { flex: 1; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }

@media (max-width: 640px) {
  .form-row { flex-direction: column; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.2rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-full);
  white-space: nowrap;
  line-height: 1.4;
}
.badge svg { width: 10px; height: 10px; }

.badge-active, .badge-paid, .badge-success {
  background: var(--color-success-100);
  color: var(--color-success-700);
}
.badge-pending, .badge-warning {
  background: var(--color-warning-100);
  color: var(--color-warning-700);
}
.badge-danger, .badge-overdue, .badge-disconnected {
  background: var(--color-danger-100);
  color: var(--color-danger-700);
}
.badge-info, .badge-trial {
  background: var(--color-info-100);
  color: var(--color-info-600);
}
.badge-neutral, .badge-passive, .badge-cancelled {
  background: var(--color-neutral-100);
  color: var(--color-neutral-600);
}
.badge-primary {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}
.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 4px;
}

/* ================================================================
   ALERTS
   ================================================================ */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--color-success-50); border-color: var(--color-success-200); color: var(--color-success-700); }
.alert-warning { background: var(--color-warning-50); border-color: var(--color-warning-200); color: var(--color-warning-700); }
.alert-danger  { background: var(--color-danger-50);  border-color: var(--color-danger-200);  color: var(--color-danger-700); }
.alert-info    { background: var(--color-info-50);    border-color: var(--color-info-200); color: var(--color-info-600); }
.alert-neutral { background: var(--color-neutral-50); border-color: var(--color-neutral-200); color: var(--color-neutral-700); }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
.data-table thead th {
  background: var(--color-primary-50);
  color: var(--color-primary-800);
  font-weight: var(--font-semibold);
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--color-primary-200);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table thead th.sortable { cursor: pointer; user-select: none; }
.data-table thead th.sortable:hover { background: var(--color-primary-100); }
.data-table thead th .sort-icon { margin-left: 4px; opacity: 0.4; }
.data-table thead th.sort-asc .sort-icon,
.data-table thead th.sort-desc .sort-icon { opacity: 1; color: var(--color-primary-600); }

.data-table tbody tr {
  border-bottom: 1px solid var(--color-neutral-100);
  transition: background var(--transition-fast);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--color-primary-50); }
.data-table tbody tr.selected { background: var(--color-primary-50); }
.data-table tbody td { padding: 0.875rem 1rem; color: var(--color-neutral-700); vertical-align: middle; }

.data-table .col-check { width: 40px; text-align: center; }
.data-table .col-actions { width: auto; min-width: 110px; text-align: right; white-space: nowrap; }

.table-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-1); flex-wrap: nowrap; }
.table-actions .btn-ghost { border: 1px solid var(--border-color) !important; color: var(--text-secondary); }
.table-actions .btn-ghost:hover { border-color: var(--color-primary-400) !important; color: var(--color-primary-600); background: var(--color-primary-50); }
.dt-act-lbl { font-size: 11px; margin-left: 3px; vertical-align: middle; }

/* ================================================================
   PAGINATION
   ================================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
}
.pagination-info { font-size: var(--text-sm); color: var(--text-secondary); flex: 1; }

.page-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #fff;
  font-size: var(--text-sm);
  color: var(--color-neutral-600);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.page-btn:hover { background: var(--color-primary-50); border-color: var(--color-primary-300); color: var(--color-primary-700); }
.page-btn.active {
  background: var(--color-primary-600);
  border-color: var(--color-primary-600);
  color: #fff;
  font-weight: var(--font-semibold);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ================================================================
   MODAL
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal, 1000);
  padding: var(--space-4);
}

.modal-backdrop > .modal {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--transition-base);
}

.modal-container {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2xl);
  width: 100%;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  animation: scaleIn var(--transition-base);
}
.modal-sm { max-width: 420px; }
.modal-md { max-width: 560px; }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1000px; }

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title { font-size: var(--text-lg); font-weight: var(--font-semibold); margin: 0; }

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

.modal-body { padding: var(--space-6); overflow-y: auto; flex: 1; }
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ================================================================
   TOAST
   ================================================================ */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  min-width: 280px;
  max-width: 400px;
  pointer-events: all;
  animation: slideInRight var(--transition-base);
  position: relative;
  overflow: hidden;
}
.toast.removing { animation: slideOutRight var(--transition-base) forwards; }

.toast-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: var(--font-semibold); font-size: var(--text-sm); margin-bottom: 2px; }
.toast-message { font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.4; }
.toast-close {
  flex-shrink: 0;
  width: 20px; height: 20px;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-fast);
  border: none; background: none;
}
.toast-close:hover { color: var(--text-primary); }

.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  transition: width linear;
  border-radius: 0 3px 3px 0;
}

.toast-success { border-left: 4px solid var(--color-success-500); }
.toast-success .toast-icon { color: var(--color-success-500); }
.toast-error   { border-left: 4px solid var(--color-danger-500); }
.toast-error .toast-icon { color: var(--color-danger-500); }
.toast-warning { border-left: 4px solid var(--color-warning-500); }
.toast-warning .toast-icon { color: var(--color-warning-500); }
.toast-info    { border-left: 4px solid var(--color-info-500); }
.toast-info .toast-icon { color: var(--color-info-500); }

/* ================================================================
   LOADING STATES
   ================================================================ */
.spinner {
  display: inline-block;
  width: 24px; height: 24px;
  border: 3px solid var(--color-primary-200);
  border-top-color: var(--color-primary-600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

.skeleton {
  background: linear-gradient(90deg, var(--color-neutral-200) 25%, var(--color-neutral-100) 50%, var(--color-neutral-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
.skeleton-text { height: 1em; margin-bottom: 0.5em; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 1.5em; width: 40%; margin-bottom: 1em; }
.skeleton-card { height: 120px; }
.skeleton-circle { border-radius: 50%; }

/* Loading overlay */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-raised);
  border-radius: inherit;
}

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  color: var(--text-secondary);
}
.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--color-primary-50);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--color-primary-400);
}
.empty-state-icon svg { width: 32px; height: 32px; }
.empty-state h3 { font-size: var(--text-lg); color: var(--color-neutral-700); margin-bottom: var(--space-2); }
.empty-state p  { font-size: var(--text-sm); max-width: 300px; margin-bottom: var(--space-6); }

/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress {
  height: 8px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--color-primary-600);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.progress-bar.success { background: var(--color-success-500); }
.progress-bar.warning { background: var(--color-warning-500); }
.progress-bar.danger  { background: var(--color-danger-500); }

/* ================================================================
   TABS
   ================================================================ */
.tabs {}
.tab-list {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: var(--space-6);
}
.tab-btn {
  padding: 0.75rem 1.25rem;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.tab-btn:hover { color: var(--color-primary-600); }
.tab-btn.active {
  color: var(--color-primary-700);
  border-bottom-color: var(--color-primary-600);
  font-weight: var(--font-semibold);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ================================================================
   DROPDOWN
   ================================================================ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  animation: scaleIn var(--transition-fast);
  overflow: hidden;
  padding: var(--space-1) 0;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  color: var(--color-neutral-700);
  cursor: pointer;
  transition: background var(--transition-fast);
  white-space: nowrap;
}
.dropdown-item:hover { background: var(--color-primary-50); color: var(--color-primary-700); }
.dropdown-item.danger:hover { background: var(--color-danger-50); color: var(--color-danger-700); }
.dropdown-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.dropdown-divider { height: 1px; background: var(--border-color); margin: var(--space-1) 0; }
.dropdown-header {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ================================================================
   SEARCH BAR
   ================================================================ */
.search-bar {
  position: relative;
  max-width: 320px;
}
.search-bar input {
  width: 100%;
  padding: 0.5rem 0.875rem 0.5rem 2.5rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  background: #fff;
  transition: all var(--transition-fast);
}
.search-bar input:focus {
  border-color: var(--color-primary-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  outline: none;
}
.search-bar .search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px; height: 16px;
}

/* ================================================================
   FILTER BAR
   ================================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  background: var(--color-neutral-50);
  border-bottom: 1px solid var(--border-color);
}
.filter-bar .filter-label { font-size: var(--text-sm); color: var(--text-secondary); font-weight: var(--font-medium); }

/* ================================================================
   TOOLBAR (Toplu İşlem)
   ================================================================ */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary-900);
  color: #fff;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  animation: slideInUp var(--transition-base);
}
.bulk-toolbar .bulk-count { font-size: var(--text-sm); font-weight: var(--font-semibold); flex: 1; }
.bulk-toolbar .btn-ghost { color: rgba(255,255,255,0.8); }
.bulk-toolbar .btn-ghost:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ================================================================
   FIELD MODE PREMIUM (Bottom Sheet, Swipe, Numpad)
   ================================================================ */

/* Bottom Sheet */
.bottom-sheet-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(2px);
}
.bottom-sheet-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-surface, #fff);
  border-radius: 24px 24px 0 0;
  z-index: 10000;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  max-height: 95vh;
}
.bottom-sheet.active {
  transform: translateY(0);
}
.bottom-sheet-header {
  padding: 16px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border-color);
}
.bottom-sheet-handle {
  width: 40px;
  height: 5px;
  background: var(--border-color);
  border-radius: 4px;
  margin: 0 auto 12px;
}
.bottom-sheet-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
.field-scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
}
.field-numpad-dock {
  flex-shrink: 0;
  background: var(--bg-card, #fff);
  border-top: 1px solid var(--border-color);
  padding: 6px 8px 8px;
}

/* Numpad endeks display */
.numpad-display {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  padding: var(--space-3) var(--space-4);
  letter-spacing: 2px;
  border-radius: var(--radius-lg, 12px);
  background: var(--color-neutral-50, #F8FAFC);
  border: 2px solid var(--color-primary-200, #BFDBFE);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

/* Custom Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 0;
}
.numpad-btn {
  background: var(--color-neutral-50);
  border: none;
  border-radius: 10px;
  padding: 0;
  height: 48px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.1s;
}
.numpad-btn:active {
  background: var(--color-primary-100);
  transform: scale(0.94);
}
.numpad-btn--action {
  background: var(--color-neutral-100);
  color: var(--text-secondary);
}
.numpad-btn--action:active {
  background: var(--color-neutral-200);
  transform: scale(0.94);
}
.numpad-btn--decimal {
  background: var(--color-neutral-100);
  color: var(--text-secondary);
}
.numpad-btn--clear {
  grid-column: 1 / -1;
  height: 40px;
  font-size: 17px;
}

/* Swipe Actions */
.swipe-item {
  position: relative;
  overflow: hidden;
  background: var(--danger-bg, #fee2e2); /* Background when swiped right */
}
.swipe-content {
  position: relative;
  background: var(--bg-surface);
  z-index: 2;
  transition: transform 0.2s ease-out;
  /* padding and border are on this element instead of wrapper */
}
.swipe-actions-left, .swipe-actions-right {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  padding: 0 20px;
  z-index: 1;
}
.swipe-actions-left { left: 0; background: var(--color-danger); }
.swipe-actions-right { right: 0; background: var(--color-primary); }

/* OCR Tarama Animasyonu */
.scan-overlay {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius-lg, 12px);
  pointer-events: none;
}
.scan-line {
  position: absolute;
  left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--color-primary, #2563EB), transparent);
  animation: scan-sweep 1.4s ease-in-out infinite;
}
@keyframes scan-sweep {
  0%   { top: 0; }
  100% { top: 100%; }
}

/* ── Kamera İzin Overlay ─────────────────────────────────────────── */
.camera-perm-overlay {
  position: fixed; inset: 0; z-index: 10010;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.camera-perm-box {
  background: var(--bg-card, #fff);
  border-radius: var(--radius-2xl, 24px);
  padding: var(--space-8, 2rem);
  max-width: 320px; width: 90%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.35);
}
.camera-perm-icon { margin-bottom: var(--space-4, 1rem); }
.camera-perm-title {
  font-size: var(--text-lg, 1.125rem);
  font-weight: 700;
  margin: 0 0 var(--space-3, 0.75rem);
  color: var(--text-primary);
}
.camera-perm-msg {
  font-size: var(--text-sm, 0.875rem);
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 0 0 var(--space-6, 1.5rem);
}
.camera-perm-actions {
  display: flex; gap: var(--space-3, 0.75rem); justify-content: center;
}

/* ── OCR Tam Ekran Tarama Simülasyonu ────────────────────────────── */
.ocr-scanner-overlay {
  position: fixed; inset: 0; z-index: 10005;
  background: rgba(0,0,0,0.80); backdrop-filter: blur(2px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 24px;
}
.ocr-viewfinder {
  position: relative; width: 260px; height: 180px;
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 8px; overflow: hidden;
  transition: border-color 0.3s;
}
.ocr-viewfinder--success { border-color: var(--color-success-500, #10B981); }
.ocr-corner {
  position: absolute; width: 22px; height: 22px;
  border-color: #fff; border-style: solid; border-width: 0;
}
.ocr-corner--tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-radius: 4px 0 0 0; }
.ocr-corner--tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-radius: 0 4px 0 0; }
.ocr-corner--bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-radius: 0 0 0 4px; }
.ocr-corner--br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-radius: 0 0 4px 0; }
.ocr-laser {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-danger-400, #F87171), transparent);
  animation: ocr-laser-sweep 1.2s ease-in-out infinite;
}
.ocr-viewfinder--success .ocr-laser {
  background: linear-gradient(90deg, transparent, var(--color-success-500, #10B981), transparent);
  animation: none; top: 50%;
}
@keyframes ocr-laser-sweep { 0% { top: 0; } 100% { top: 100%; } }
.ocr-scanner-label {
  color: rgba(255,255,255,0.88);
  font-size: 14px; font-weight: 500;
  letter-spacing: 0.5px; margin: 0;
  min-height: 1.2em; text-align: center;
}
.ocr-scanner-cancel {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.9);
  padding: 10px 28px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ocr-scanner-cancel:hover,
.ocr-scanner-cancel:active {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.6);
}

/* ── Canlı Otomatik Tarayıcı ─────────────────────────────────────── */
.live-scanner {
  position: fixed; inset: 0; z-index: 10020;
  background: #000;
  overflow: hidden;
}
.live-scanner-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  background: #000;
}
/* Viewfinder disini karart — dev box-shadow ile "delik" etkisi */
.live-scanner-mask {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.live-viewfinder {
  position: relative;
  width: min(78vw, 340px);
  height: min(30vh, 150px);
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.55);
  outline: 2px solid rgba(255,255,255,0.25);
  transition: outline-color 0.25s;
}
.live-viewfinder--ok { outline-color: var(--color-success-500, #10B981); }
.live-viewfinder--ok .ocr-laser {
  background: linear-gradient(90deg, transparent, var(--color-success-500, #10B981), transparent);
  animation: none; top: 50%;
}
.live-scanner-top {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 18px;
  color: rgba(255,255,255,0.92);
  font-size: 14px; font-weight: 600; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.live-scanner-bottom {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
}
.live-scanner-status {
  margin: 0; min-height: 1.3em;
  color: #fff; font-size: 15px; font-weight: 600;
  text-align: center; letter-spacing: 0.3px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
.live-scanner-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center;
}
.live-btn {
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12);
  color: #fff;
  transition: background 0.15s, border-color 0.15s;
}
.live-btn:hover, .live-btn:active { background: rgba(255,255,255,0.24); }
.live-btn--shot {
  background: var(--color-primary, #2563EB);
  border-color: var(--color-primary, #2563EB);
}
.live-btn--shot:hover, .live-btn--shot:active {
  background: var(--color-primary-700, #1D4ED8);
}
.live-btn--torch.is-on {
  background: var(--color-warning-500, #F59E0B);
  border-color: var(--color-warning-500, #F59E0B);
  color: #1a1a1a;
}

/* ================================================================
   MAIL CLIENT — 3-panel e-posta istemcisi (pages/mail.html)
   ================================================================ */
.mail-wrap {
  display: flex;
  height: calc(100vh - var(--topbar-height, 60px));
  overflow: hidden;
  gap: 0;
}

/* Sidebar */
.mail-sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.mail-compose-btn {
  width: 100%;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}
.mail-folder-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mail-folder {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: background 0.15s;
  user-select: none;
}
.mail-folder svg { width: 16px; height: 16px; flex-shrink: 0; }
.mail-folder:hover { background: var(--surface-hover); color: var(--text-primary); }
.mail-folder.active { background: var(--primary-alpha, rgba(37,99,235,.12)); color: var(--primary); font-weight: var(--font-medium); }
.mail-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  line-height: 18px;
}

/* List pane */
.mail-list-pane {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.mail-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mail-folder-title { font-weight: var(--font-semibold); font-size: var(--text-sm); }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.mail-list-body { flex: 1; overflow-y: auto; }
.mail-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.mail-item:hover { background: var(--surface-hover); }
.mail-item.active { background: var(--primary-alpha, rgba(37,99,235,.10)); }
.mail-item-from { font-size: var(--text-sm); font-weight: var(--font-medium); grid-column: 1; grid-row: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item.unread .mail-item-from { font-weight: var(--font-bold); }
.mail-item-date { font-size: 11px; color: var(--text-muted); grid-column: 2; grid-row: 1; white-space: nowrap; padding-left: var(--space-2); }
.mail-item-subject { font-size: 12px; color: var(--text-secondary); grid-column: 1 / -1; grid-row: 2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.mail-item.unread .mail-item-subject { color: var(--text-primary); }
.mail-list-loading,
.mail-list-empty,
.mail-list-error { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); padding: var(--space-8); color: var(--text-secondary); font-size: var(--text-sm); text-align: center; }
.mail-list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* Reader pane */
.mail-reader-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.mail-reader-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.mail-reader-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}
.mail-reader-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.mail-reader-subject {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
  line-height: 1.3;
}
.mail-reader-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.mail-meta-dot { color: var(--border); }
.mail-reader-actions { display: flex; gap: var(--space-2); }
.mail-reader-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}
.mail-text-body {
  font-size: var(--text-sm);
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text-primary);
  max-width: 680px;
}

/* ================================================================
   FIELD SECTION — Sayac okuma accordion (field-reading-modal)
   ================================================================ */
.field-sub-bar {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color, var(--border));
}
.field-sub-bar-name {
  font-weight: var(--font-semibold, 600);
  font-size: var(--text-base);
  margin-bottom: 4px;
}
.field-sub-bar-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.field-sub-bar-dot { color: var(--border-color, #ccc); }
.field-debt-val { color: var(--color-danger-500, #ef4444); }
.field-door-note {
  margin-top: 6px;
  font-size: var(--text-xs);
  background: #fff3cd;
  color: #856404;
  border-radius: 4px;
  padding: 4px 8px;
  font-weight: 500;
}

.field-total-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: var(--text-sm);
  border-top: 1px solid var(--border-color, var(--border));
  border-bottom: 1px solid var(--border-color, var(--border));
}
.field-total-line strong {
  font-size: var(--text-base);
  color: var(--color-primary-600, #2563eb);
}

.field-section {
  border-bottom: 1px solid var(--border-color, var(--border));
}
.field-section > summary {
  list-style: none;
  padding: 11px 16px;
  font-size: var(--text-sm);
  font-weight: var(--font-medium, 500);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.field-section > summary::-webkit-details-marker { display: none; }
.field-section > summary::before {
  content: '\25B6';
  font-size: 9px;
  color: var(--text-muted, #9ca3af);
  transition: transform 0.18s;
  flex-shrink: 0;
}
.field-section[open] > summary::before { transform: rotate(90deg); }
.field-section > summary:hover {
  color: var(--text-primary);
  background: var(--color-neutral-50, rgba(0,0,0,.03));
}
.field-section > div { padding: 8px 16px 14px; }

/* ================================================================
   Yazı Boyutu Seçici (Görünüm Ayarları)
   ================================================================ */
.font-size-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1;
  white-space: nowrap;
}
.font-size-btn:hover {
  background: var(--color-bg-secondary, rgba(0,0,0,.04));
}
