/* PHP projesi: eski proje (client) ile aynı arayüz – shell, layout, tablo */

/* Shell: eski projedeki gibi max-width 1320px, ortada */
body {
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}
.shell {
  max-width: 1320px;
  width: 100%;
  box-sizing: border-box;
}
.main-content {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* ========== TÜM PROJEDE TEK BUTON SİSTEMİ (dashboard filtre gibi) ==========
   Seçili değilse: çerçeveli (border renkli, iç boş, yazı koyu).
   Hover veya seçili (.active): renkli (dolu arka plan, beyaz yazı).
*/

.btn,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-accent,
.btn-success {
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  opacity: 1;
  filter: none;
}

/* --- Varsayılan: hepsi çerçeveli (seçili değil) --- */
.btn,
.btn-primary,
.btn-secondary {
  background: var(--card-bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--primary) !important;
}
.btn-danger {
  background: var(--card-bg) !important;
  color: var(--danger) !important;
  border: 1px solid var(--danger) !important;
}
.btn-accent,
.btn-success {
  background: var(--card-bg) !important;
  color: var(--accent) !important;
  border: 1px solid var(--accent) !important;
}

/* --- Hover: renkli (dolu) --- */
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}
.btn-danger:hover {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}
.btn-accent:hover,
.btn-success:hover {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* --- Seçili (.active): renkli (dolu) --- */
.btn.active,
.btn-primary.active,
.btn-secondary.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}
.btn-danger.active {
  background: var(--danger) !important;
  color: #fff !important;
  border-color: var(--danger) !important;
}
.btn-accent.active,
.btn-success.active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* Disabled butonlar: çerçeveli kalır, soluk */
.btn[disabled],
.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--card-bg) !important;
  color: var(--text-soft) !important;
  border-color: var(--border-subtle) !important;
}
.btn[disabled]:hover,
.btn:disabled:hover {
  background: var(--card-bg) !important;
  color: var(--text-soft) !important;
  border-color: var(--border-subtle) !important;
}

/* Tüm alt çizgileri kaldır – tasarımsal bütünlük */
a,
a:hover,
a:focus,
.nav-link,
.table-wrapper .th-sort,
.table-wrapper .th-sort:hover {
  text-decoration: none !important;
}

.layout {
  width: 100%;
  min-width: 0;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1.4fr);
}

/* Tek grafik alanı (Gider Kategori Dağılımı) */
.charts-grid-1 {
  grid-template-columns: 1fr;
}

/* Gider kategori dağılımı liste görünümü */
.expense-category-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.expense-category-item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 4px 0;
  border-bottom: 1px dashed var(--border-subtle);
}
.expense-category-item:last-child {
  border-bottom: none;
}
.expense-category-name {
  font-size: 12px;
  font-weight: 500;
}
.expense-category-amount {
  font-size: 12px;
}
.expense-category-percent {
  font-size: 11px;
  color: var(--text-soft);
}

/* Kontrol paneli metrikleri: ekrana göre esnek, kesilme yok */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-sm);
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Grafik kutuları ve Chart.js canvas'ları taşma yapmasın */
.charts-grid,
.charts-grid-1,
.charts-grid-4,
.chart-box,
.chart-box-full,
.chart-box-right {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.chart-box canvas,
.chart-box-full canvas,
.chart-box-right canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
  height: auto !important;
}
/* Dashboard özeti: 3 sütun × 2 satır (daha az dikey yer) */
.metrics-row-3x2 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 820px) {
  .metrics-row-3x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px) {
  .metrics-row-3x2 {
    grid-template-columns: 1fr;
  }
}
.metric {
  min-width: 0;
  overflow: visible;
}
.metric-value {
  word-break: break-all;
  white-space: normal;
  min-height: 1.5em;
}
.metric-sub {
  word-break: break-word;
  white-space: normal;
}

/* Tablo: responsive container (yalnızca tablo alanı yatay scroll alır) */
.table-responsive-wrapper,
.table-responsive-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.table-responsive-container table {
  min-width: 600px;
}

/* Mevcut table-wrapper tasarımını koru (border, padding vs.) */
.table-wrapper {
  overflow: visible;
  max-height: none;
}
/* Tema thead { position: sticky } kaymaya neden oluyor; tablo layout’u zorla */
.table-wrapper table {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}
.table-responsive-wrapper thead {
  position: static;
  top: auto;
  z-index: auto;
}
.table-responsive-wrapper thead th {
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box;
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border-subtle);
}
.table-responsive-wrapper tbody td {
  box-sizing: border-box;
  padding: var(--space-sm) var(--space-md);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.table-responsive-wrapper th,
.table-responsive-wrapper td {
  vertical-align: middle;
}
/* Açıklama / uzun metin sütunlarında satır kaydırmaya izin ver */
.table-responsive-wrapper td.col-aciklama,
.table-responsive-wrapper .col-aciklama {
  white-space: normal;
  word-break: break-word;
}
/* İşlemler hücresi: butonlar kesilmesin */
.table-responsive-wrapper td.actions-cell {
  overflow: visible;
  text-overflow: clip;
}
/* Tarih/tutar tek satır */
.table-responsive-wrapper .col-no,
.table-responsive-wrapper .col-tarih,
.table-responsive-wrapper .col-tutar {
  white-space: nowrap;
}
.table-responsive-wrapper .col-tarih {
  word-break: keep-all;
}
/* Sütun genişlikleri: başlık ve veri aynı kalır */
.table-responsive-wrapper .col-no   { width: 56px;  min-width: 56px;  text-align: center; }
.table-responsive-wrapper .col-tur  { width: 130px; min-width: 130px; }
.table-responsive-wrapper .col-tutar { width: 120px; min-width: 120px; text-align: right; padding-left: 8px; }
.table-responsive-wrapper .col-odeme { width: 150px; min-width: 150px; }
.table-responsive-wrapper .col-detay { width: 120px; min-width: 120px; }
.table-responsive-wrapper .col-aciklama { width: 180px; min-width: 180px; white-space: normal; word-break: break-word; }
.table-responsive-wrapper .col-tarih { width: 110px; min-width: 110px; }

/* data-table: 4 sütun (kategoriler: sıra, kategori adı, oluşturulma, işlemler) – kayma/üst üste binme önleme */
.table-wrapper table.data-table th:nth-child(1),
.table-wrapper table.data-table td:nth-child(1) { width: 64px; min-width: 64px; max-width: 64px; text-align: center; }
.table-wrapper table.data-table th:nth-child(2),
.table-wrapper table.data-table td:nth-child(2) { width: 38%; min-width: 140px; }
.table-wrapper table.data-table th:nth-child(3),
.table-wrapper table.data-table td:nth-child(3) { width: 165px; min-width: 165px; max-width: 200px; }
.table-wrapper table.data-table th:nth-child(4),
.table-wrapper table.data-table td:nth-child(4) { width: 140px; min-width: 140px; max-width: 160px; }
/* 6 sütunlu tablolar (gelir/gider: no, tarih, tutar, ödeme, açıklama, işlemler) */
.table-wrapper table.data-table-6 th:nth-child(1),
.table-wrapper table.data-table-6 td:nth-child(1) { width: 64px; min-width: 64px; max-width: 64px; }
.table-wrapper table.data-table-6 th:nth-child(2),
.table-wrapper table.data-table-6 td:nth-child(2) { width: 140px; min-width: 140px; }
.table-wrapper table.data-table-6 th:nth-child(3),
.table-wrapper table.data-table-6 td:nth-child(3) { width: 120px; min-width: 120px; text-align: right; }
.table-wrapper table.data-table-6 th:nth-child(4),
.table-wrapper table.data-table-6 td:nth-child(4) { width: 140px; min-width: 140px; }
.table-wrapper table.data-table-6 th:nth-child(5),
.table-wrapper table.data-table-6 td:nth-child(5) { width: 28%; min-width: 100px; }
.table-wrapper table.data-table-6 th:nth-child(6),
.table-wrapper table.data-table-6 td:nth-child(6) { width: 140px; min-width: 140px; max-width: 180px; }
/* 7 sütunlu (gider: +kategori) */
.table-wrapper table.data-table-7 th:nth-child(1),
.table-wrapper table.data-table-7 td:nth-child(1) { width: 64px; min-width: 64px; max-width: 64px; }
.table-wrapper table.data-table-7 th:nth-child(2),
.table-wrapper table.data-table-7 td:nth-child(2) { width: 140px; min-width: 140px; }
.table-wrapper table.data-table-7 th:nth-child(3),
.table-wrapper table.data-table-7 td:nth-child(3) { width: 120px; min-width: 120px; text-align: right; }
.table-wrapper table.data-table-7 th:nth-child(4),
.table-wrapper table.data-table-7 td:nth-child(4) { width: 130px; min-width: 130px; }
.table-wrapper table.data-table-7 th:nth-child(5),
.table-wrapper table.data-table-7 td:nth-child(5) { width: 140px; min-width: 140px; }
.table-wrapper table.data-table-7 th:nth-child(6),
.table-wrapper table.data-table-7 td:nth-child(6) { width: 22%; min-width: 100px; }
.table-wrapper table.data-table-7 th:nth-child(7),
.table-wrapper table.data-table-7 td:nth-child(7) { width: 140px; min-width: 140px; max-width: 180px; }
/* 8 sütun (ortaklar işlem listesi) */
.table-wrapper table.data-table-8 th:nth-child(1),
.table-wrapper table.data-table-8 td:nth-child(1) { width: 64px; min-width: 64px; max-width: 64px; }
.table-wrapper table.data-table-8 th:nth-child(2),
.table-wrapper table.data-table-8 td:nth-child(2) { width: 18%; min-width: 100px; }
.table-wrapper table.data-table-8 th:nth-child(3),
.table-wrapper table.data-table-8 td:nth-child(3) { width: 100px; min-width: 100px; }
.table-wrapper table.data-table-8 th:nth-child(4),
.table-wrapper table.data-table-8 td:nth-child(4) { width: 140px; min-width: 140px; }
.table-wrapper table.data-table-8 th:nth-child(5),
.table-wrapper table.data-table-8 td:nth-child(5) { width: 120px; min-width: 120px; text-align: right; }
.table-wrapper table.data-table-8 th:nth-child(6),
.table-wrapper table.data-table-8 td:nth-child(6) { width: 18%; min-width: 90px; }
.table-wrapper table.data-table-8 th:nth-child(7),
.table-wrapper table.data-table-8 td:nth-child(7) { width: 140px; min-width: 140px; }
.table-wrapper table.data-table-8 th:nth-child(8),
.table-wrapper table.data-table-8 td:nth-child(8) { width: 140px; min-width: 140px; max-width: 180px; }
/* 5 sütun (kullanıcılar/roller: no, ad, rol/tür, tarih, işlemler) */
.table-wrapper table.data-table-5 th:nth-child(1),
.table-wrapper table.data-table-5 td:nth-child(1) { width: 64px; min-width: 64px; max-width: 64px; }
.table-wrapper table.data-table-5 th:nth-child(2),
.table-wrapper table.data-table-5 td:nth-child(2) { width: 28%; min-width: 120px; }
.table-wrapper table.data-table-5 th:nth-child(3),
.table-wrapper table.data-table-5 td:nth-child(3) { width: 120px; min-width: 120px; }
.table-wrapper table.data-table-5 th:nth-child(4),
.table-wrapper table.data-table-5 td:nth-child(4) { width: 160px; min-width: 160px; }
.table-wrapper table.data-table-5 th:nth-child(5),
.table-wrapper table.data-table-5 td:nth-child(5) { width: 140px; min-width: 140px; max-width: 180px; }
/* 6 sütun cari firma listesi (sıra, firma, borç, alacak, bakiye, işlemler) */
.table-wrapper table.data-table-cari th:nth-child(1),
.table-wrapper table.data-table-cari td:nth-child(1) { width: 56px; min-width: 56px; max-width: 56px; }
.table-wrapper table.data-table-cari th:nth-child(2),
.table-wrapper table.data-table-cari td:nth-child(2) { width: 25%; min-width: 120px; }
.table-wrapper table.data-table-cari th:nth-child(3),
.table-wrapper table.data-table-cari td:nth-child(3) { width: 110px; min-width: 110px; text-align: right; }
.table-wrapper table.data-table-cari th:nth-child(4),
.table-wrapper table.data-table-cari td:nth-child(4) { width: 110px; min-width: 110px; text-align: right; }
.table-wrapper table.data-table-cari th:nth-child(5),
.table-wrapper table.data-table-cari td:nth-child(5) { width: 110px; min-width: 110px; text-align: right; }
.table-wrapper table.data-table-cari th:nth-child(6),
.table-wrapper table.data-table-cari td:nth-child(6) { width: 160px; min-width: 160px; max-width: 200px; }

/* 7 sütun kasa hareketleri (no, tür, tutar, ödeme, detay, açıklama, tarih) */
.table-wrapper table.data-table-cashlog th:nth-child(1),
.table-wrapper table.data-table-cashlog td:nth-child(1) { width: 56px; min-width: 56px; max-width: 56px; }
.table-wrapper table.data-table-cashlog th:nth-child(2),
.table-wrapper table.data-table-cashlog td:nth-child(2) { width: 100px; min-width: 100px; }
.table-wrapper table.data-table-cashlog th:nth-child(3),
.table-wrapper table.data-table-cashlog td:nth-child(3) { width: 110px; min-width: 110px; text-align: right; }
.table-wrapper table.data-table-cashlog th:nth-child(4),
.table-wrapper table.data-table-cashlog td:nth-child(4) { width: 150px; min-width: 150px; }
.table-wrapper table.data-table-cashlog th:nth-child(5),
.table-wrapper table.data-table-cashlog td:nth-child(5) { width: 100px; min-width: 100px; }
.table-wrapper table.data-table-cashlog th:nth-child(6),
.table-wrapper table.data-table-cashlog td:nth-child(6) { width: 22%; min-width: 100px; }
.table-wrapper table.data-table-cashlog th:nth-child(7),
.table-wrapper table.data-table-cashlog td:nth-child(7) { width: 120px; min-width: 120px; }

/* Sıralanabilir başlık linki */
.table-wrapper .th-sort {
  color: inherit;
  text-decoration: none;
  font-weight: inherit;
}
.table-wrapper .th-sort:hover {
  color: var(--primary);
}

/* Form etiket ve input hizası: tüm projede kayma önleme */
.form-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.form-label {
  display: block;
  margin-bottom: var(--space-xs);
  line-height: 1.35;
  flex-shrink: 0;
}
.form-field .input,
.form-field .select {
  margin-top: 0;
}

/* Filtre / form satırları: placeholder ve metin kesilmesin */
.filters-row .form-field {
  min-width: 200px;
}
.filters-row .form-field .input,
.filters-row .form-field .select {
  min-width: 180px;
}

/* Tutar alanlarında ₺ kesilmesin */
.metric-value,
.pill strong {
  padding-left: 2px;
  letter-spacing: 0.02em;
}
.pill {
  padding-left: 12px;
  padding-right: 12px;
}

/* İşlemler hücresi */
.actions-cell {
  white-space: nowrap;
}
.actions-cell .btn,
.actions-cell .inline-form {
  margin-right: 4px;
}
.actions-cell .inline-form {
  display: inline-block;
  vertical-align: middle;
}

/* Tablo içi action butonları (Düzenle / Sil vb.) tek satırda yan yana olsun */
.table-wrapper .action-buttons,
.table-responsive-wrapper .action-buttons {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--space-xs);
}

/* Düzenle formu: ilgili satırın hemen altında, ekle formundan ayrı – hizalama ve kayma önleme */
tr.edit-row {
  background: rgba(59, 130, 246, 0.08);
  vertical-align: top;
}
tr.edit-row td {
  border-bottom: 1px solid var(--border-subtle);
  padding: var(--space-md);
}
.inline-edit-panel {
  padding: var(--space-md);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  min-width: 0;
  text-align: left;
}
.inline-edit-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-md);
  line-height: 1.3;
  text-align: left;
}
.inline-edit-form {
  text-align: left;
}
.inline-edit-form .form-grid {
  margin-bottom: var(--space-sm);
  min-width: 0;
}
.inline-edit-form .form-grid .form-field {
  min-width: 0;
}
.inline-edit-form .form-actions {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}
/* Düzenle içi filters-row: etiket üstte, input ile butonlar aynı satırda (kayma yok) */
.inline-edit-form .filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-md);
}
.inline-edit-form .filters-row .form-field {
  min-width: 0;
}
.inline-edit-form .filters-row .form-field:first-child {
  flex: 1;
  min-width: 180px;
}
.inline-edit-form .filters-row .form-field:last-child {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  align-self: flex-end !important;
}
.inline-edit-form .filters-row .form-field:last-child .btn,
.inline-edit-form .filters-row .form-field:last-child a.btn {
  flex-shrink: 0;
}
/* Düzenle içi form-actions: butonlar yan yana, taşma yok */
.inline-edit-form .form-actions .btn,
.inline-edit-form .form-actions a.btn {
  flex-shrink: 0;
}

/* Sayfalama: minimalist, saydam, temaya uyumlu butonlar */
.pagination.section-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}
.pagination-info {
  color: var(--text-soft);
  font-size: 0.9rem;
}
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}
.pagination-current {
  color: var(--text-soft);
  font-size: 0.9rem;
  padding: 0 var(--space-sm);
}
/* Sayfalama butonları: global buton sistemi (çerçeveli, hover renkli); sadece disabled özel */
.pagination .btn {
  text-decoration: none;
  font-weight: 500;
}
.pagination .btn[disabled],
.pagination .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--card-bg) !important;
  color: var(--text-soft) !important;
  border-color: var(--border-subtle) !important;
}
.pagination .btn[disabled]:hover,
.pagination .btn[aria-disabled="true"]:hover {
  background: var(--card-bg) !important;
  color: var(--text-soft) !important;
  border-color: var(--border-subtle) !important;
}

/* Login: logo alanı (resim yoksa C fallback) */
.login-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  flex-shrink: 0;
}

/* Genel marka logosu (sidebar) için resim desteği */
.brand-logo-img {
  max-width: 48px;
  max-height: 48px;
  object-fit: contain;
  display: block;
}

/* ========== Mobil / Tablet / Web optimizasyonları ========== */

/* Menü butonu: sadece sidebar’ın gizlendiği çözünürlüklerde görünsün (≤1040px) */
.topbar-menu-toggle {
  display: none;
}
@media (max-width: 1040px) {
  .topbar-menu-toggle {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }
}

/* Sidebar overlay: tıklanabilir perde (mobil/tablet), sadece açıkken görünür */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 10;
  cursor: pointer;
}
.shell.shell--sidebar-open .sidebar-overlay {
  display: block;
}
.shell.shell--sidebar-open::after {
  display: none;
}
@media (min-width: 1041px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* Sidebar overlay açıkken body scroll kilidi (mobil) */
body.sidebar-overlay-open {
  overflow: hidden;
  touch-action: none;
}
@media (min-width: 1041px) {
  body.sidebar-overlay-open {
    overflow: visible;
    touch-action: auto;
  }
}

/* Viewport / dokunma: form ve butonlar mobilde yeterli hedef boyutu */
@media (max-width: 640px) {
  .btn,
  .nav-link,
  .input,
  .select {
    min-height: 44px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  /* Dashboard kartları ve Gider Kategori Dağılımı mobil hizalaması */
  .layout,
  .layout > .card,
  .layout .card,
  .layout .metrics-row,
  .layout .charts-grid,
  .layout .charts-grid-1,
  .layout .charts-grid-4 {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  .layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  .charts-grid-1 .chart-box {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .charts-grid-1 .chart-title {
    width: 100%;
    text-align: center;
    margin-bottom: var(--space-sm);
  }
  #chartExpenseByCategory {
    display: block;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
  }

  /* Dashboard içindeki tablo: sadece tablo alanı yatay scroll alsın */
  .layout .table-wrapper.section-block {
    overflow-x: visible;
  }
  .layout .table-responsive-wrapper,
  .layout .table-responsive-container {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .layout .table-responsive-wrapper table,
  .layout .table-responsive-container table {
    min-width: 600px;
  }

  /* Mobilde hücre içerikleri ve metinler taşmasın */
  .layout .card,
  .layout .card-title,
  .layout .metric-label,
  .layout .metric-value,
  .layout .metric-sub,
  .layout .expense-category-name,
  .layout .expense-category-amount,
  .layout .expense-category-percent,
  .layout .table-wrapper td,
  .layout .table-wrapper th {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  /* Filtre satırları ve formlar: genişlik zorlamayıp ekranı doldursun */
  .filters-row .form-field,
  .table-filters .form-field {
    min-width: 0;
  }
}

/* Tüm sayfalarda tablolar tam yükseklik: iç scroll yerine sayfa yukarı-aşağı kayar */
.table-wrapper {
  max-height: none !important;
  overflow-y: visible !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Ana içerik yüksekliği kısıtlamasın; mobilde sayfa sonuna inilebilsin */
.main {
  overflow-y: visible;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Tablet: 2 sütun form, metrikler 2 sütun */
@media (min-width: 641px) and (max-width: 820px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Web: geniş ekranda shell max-width korunsun */
@media (min-width: 1041px) {
  .shell {
    grid-template-columns: 260px 1fr;
  }
}

/* Genel: yatay taşma önleme */
html, body {
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

/* Küçük ekranlarda shell ve body tam genişlik, kayma olmasın */
@media (max-width: 820px) {
  body {
    display: block;
    justify-content: flex-start;
    align-items: stretch;
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
  }
  .shell {
    max-width: 100%;
    width: 100%;
  }
}
.shell, .main, .main-content {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Dashboard: tarih etiketi – mavi çerçeve, içi mavi değil (siyah text absürt durmasın) */
.dashboard-datetime {
  background: var(--card-bg) !important;
  color: var(--text) !important;
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Dashboard: başlık ve metinlerde uzun kelimeler taşmasın */
.layout .card,
.layout .card-title,
.layout .metric-label,
.layout .metric-value,
.layout .metric-sub,
.layout .expense-category-name,
.layout .expense-category-amount,
.layout .expense-category-percent {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Dashboard: filtre butonları global buton sistemiyle (çerçeveli / .active renkli). Mobilde wrap */
@media (max-width: 640px) {
  .dashboard-filters .filter-presets {
    flex-wrap: wrap;
  }
  .dashboard-datetime {
    font-size: 11px;
    padding: 6px 8px;
  }
}

/* ========== Mobil: tüm yan yana öğeler alt alta ========== */
@media (max-width: 640px) {
  /* Ana layout: 2 sütun → 1 sütun (kartlar alt alta) */
  .layout {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  /* Tüm metrik satırları tek sütun */
  .metrics-row {
    grid-template-columns: 1fr !important;
  }

  /* Topbar: aksiyonlar, başlık, pill alt alta */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
  }
  .topbar-actions {
    order: 1;
    flex-wrap: wrap;
    justify-content: space-between;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-subtle);
  }
  .topbar-left {
    order: 2;
    text-align: center;
  }
  .topbar-left .page-title {
    justify-content: center;
  }
  .topbar-left .page-subtitle {
    text-align: center;
  }
  .topbar-info {
    order: 3;
    justify-content: center;
    flex-wrap: wrap;
  }
  .topbar-user-logout {
    flex-wrap: wrap;
  }

  /* Form grid: her zaman tek sütun */
  .form-grid {
    grid-template-columns: 1fr !important;
  }
  .form-grid .form-field[style*="grid-column"] {
    grid-column: 1 !important;
  }

  /* Filtre satırları: alt alta */
  .filters-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filters-row .form-field {
    min-width: 0;
    width: 100%;
  }
  .filters-row form {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Kart başlığı: başlık ve aksiyon alt alta */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  /* Bölüm başlığı: başlık ve buton alt alta */
  .section-header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Grafik alanı: 2 sütun → 1 sütun; mobilde boyut sabit, büyümesin */
  .charts-grid,
  .charts-grid-4 {
    grid-template-columns: 1fr !important;
  }
  .chart-box-full,
  .chart-box-right {
    grid-column: 1 !important;
  }
  /* Grafik kutusu: mobilde ortalanmış ve oranını koruyan daire grafik */
  .chart-box {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: none;
  }
  .chart-box canvas {
    display: block;
    width: 100% !important;
    max-width: 260px;
    height: auto !important;
    max-height: none !important;
    margin: 0 auto;
  }
  .chart-loading {
    height: 200px;
    max-height: 200px;
  }

  /* Tablo filtreleri: tek sütun, min-width kaldır */
  .table-filters {
    flex-direction: column;
    align-items: stretch;
  }
  .table-filters .form-field {
    min-width: 0;
  }
  .table-filters .input,
  .table-filters .select {
    min-width: 0;
  }

  /* Tema toggle: tek satırda kalabilir, küçük */
  .theme-toggle {
    display: inline-flex;
  }

  /* Inline grid kullanan bloklar (cari form-grid vb.) mobilde tek sütun */
  .form-grid[style*="grid-template-columns"],
  .metrics-row[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .filters-row form[style*="flex"],
  form.filters-row[style*="flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
}

/* ==========================================================================
   DASHBOARD (KONTROL PANELİ) – GENEL FİLTRE STİLİ
   (Tarih aralığı satırını modern ve minimal yapar)
   ========================================================================== */
.main-content > .layout .dashboard-filter-range {
  margin-top: var(--space-xs);
  max-width: 100%;
  overflow-x: hidden;
}
.main-content > .layout .dashboard-filter-range-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.4);
  max-width: 100%;
}
.main-content > .layout .dashboard-filter-range-row .input {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 12px;
  padding: 0 4px;
}
.main-content > .layout .dashboard-filter-range-row .input:focus {
  outline: none;
  box-shadow: none;
}
.main-content > .layout .dashboard-filter-range-sep {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-soft);
}
.main-content > .layout .dashboard-filter-range-row .btn {
  flex: 0 0 auto;
  padding-inline: 8px;
  padding-block: 3px;
  font-size: 12px;
}

/* ==========================================================================
   MOBİL DASHBOARD (KONTROL PANELİ MENÜSÜ) – TEMİZ RESPONSIVE OVERRIDE
   Sadece dashboard sayfasındaki .layout kapsayıcısını hedefler.
   Desktop / tablet layoutuna dokunmaz.
   ========================================================================== */
@media (max-width: 640px) {
  /* Ana dashboard kapsayıcısı: kartlar dikey akış, hiçbir şey 100vw'yi aşmasın */
  .main-content > .layout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-md);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
  }

  /* Kartlar ve iç bloklar: tam genişlik, yatay taşma yok */
  .main-content > .layout > .card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
  }

  /* Metrik blokları: tek sütun, dikey akış */
  .main-content > .layout .metrics-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .main-content > .layout .metric {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  /* Dashboard filtreleri ve tarih etiketi: satıra sığacak şekilde kırılabilsin */
  .main-content > .layout .dashboard-filters,
  .main-content > .layout .dashboard-datetime {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* Filtre bloğu mobilde dikey akış: preset butonlar üstte, tarih aralığı altta */
  .main-content > .layout .dashboard-filters {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
  }

  .main-content > .layout .dashboard-filters .filter-presets {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .main-content > .layout .dashboard-filters .btn {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
  }

  /* Mobilde tarih aralığı satırı: tek satıra yakın, minimal ve taşma yok */
  .main-content > .layout .dashboard-filter-range-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    flex-wrap: nowrap;
    box-sizing: border-box;
  }
  .main-content > .layout .dashboard-filter-range-row .btn {
    align-self: center;
    padding-inline: 6px;
    padding-block: 2px;
    font-size: 11px;
    min-height: auto;
    line-height: 1.2;
    margin-top: 0;
  }

  /* Grafik / liste alanı: tek sütun, yatay taşma yok */
  .main-content > .layout .charts-grid,
  .main-content > .layout .charts-grid-1 {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .main-content > .layout .chart-box,
  .main-content > .layout .chart-box-full,
  .main-content > .layout .chart-box-right {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* Olası Chart.js canvas'ları: viewport içine sığacak şekilde ölçeklenir */
  .main-content > .layout .chart-box canvas,
  .main-content > .layout .chart-box-full canvas,
  .main-content > .layout .chart-box-right canvas,
  .main-content > .layout #chartExpenseByCategory {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin-left: auto;
    margin-right: auto;
  }

  /* Dashboard tablosu: sayfa değil, sadece tablo alanı yatay scroll alır */
  .main-content > .layout .table-wrapper.section-block {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    overflow-x: visible;
  }

  .main-content > .layout .table-responsive-wrapper,
  .main-content > .layout .table-responsive-container {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .main-content > .layout .table-responsive-wrapper table,
  .main-content > .layout .table-responsive-container table {
    width: 100%;
    min-width: 520px; /* Gerekirse yatay scroll, ama sadece tablo içinde */
    box-sizing: border-box;
  }

  /* Uzun metinler (açıklamalar, başlıklar, metrikler) taşma yapmasın */
  .main-content > .layout .card,
  .main-content > .layout .card-title,
  .main-content > .layout .metric-label,
  .main-content > .layout .metric-value,
  .main-content > .layout .metric-sub,
  .main-content > .layout .expense-category-name,
  .main-content > .layout .expense-category-amount,
  .main-content > .layout .expense-category-percent,
  .main-content > .layout .table-wrapper th,
  .main-content > .layout .table-wrapper td {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    max-width: 100%;
  }

  /* Hücre içi küçük yapısal öğeler de viewport'u aşmasın */
  .main-content > .layout .cell-with-dot,
  .main-content > .layout .status-dot,
  .main-content > .layout .pill {
    max-width: 100%;
    overflow: hidden;
  }
}
