/* ============================================================
   Page: cari detay (müşteri / tedarikçi)
   ============================================================ */
.cari-back { display: inline-block; font-size: var(--fs-sm); color: var(--text-muted); margin-bottom: var(--space-3); }
.cari-back:hover { color: var(--brand); }

/* Liste bakiye kolonu — müşteri alacak (turuncu) / tedarikçi borç (kırmızı) / avans (yeşil) */
.bal-credit { color: var(--brand); font-weight: 600; }
.bal-debt   { color: var(--red);   font-weight: 600; }
.bal-advance { color: var(--green); font-weight: 600; }
/* Cari ekstresi hareket tutarı (işaretli+renkli): alacaklanma +yeşil / borçlanma −kırmızı */
.ekstre-amt-up   { color: var(--green); font-weight: 600; }
.ekstre-amt-down { color: var(--red);   font-weight: 600; }

/* Cari Bakiye kartında yön etiketi (Alacak / Borç / Avans) */
.cari-bal-dir { display: inline-block; margin-left: 8px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); vertical-align: middle; }

/* Çek/Senet sekmesi açık-özet barı */
.cari-cek-ozet { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-3); font-size: var(--fs-sm); }
.cari-cek-ozet .stb-count { font-weight: 700; color: var(--text-muted); }
.cari-cek-ozet .stb-net { font-weight: 700; color: var(--text); }

.cari-head {
  display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: var(--space-5); margin-bottom: var(--space-4);
}
.cari-avatar { display: grid; place-items: center; width: 50px; height: 60px; border-radius: 14px; background: var(--navy); color: #fff; font-size: 20px; font-weight: 800; flex-shrink: 0; }
/* flex-basis 200px: dar ekranda isim ezilip dikey (harf-harf) sarmasın; sığmazsa
   eylem butonları flex-wrap ile alt satıra düşer (isim hep yatay/okunur kalır). */
.cari-head-info { flex: 1 1 200px; min-width: 0; }
.cari-head-info h2 { font-size: var(--fs-xl); overflow-wrap: anywhere; }
.cari-head-meta { font-size: var(--fs-sm); color: var(--text-muted); }

/* Başlık eylem kümesi (Tahsilat/Ödeme · Düzenle · Diğer) */
.cari-head-actions { display: flex; align-items: stretch; gap: var(--space-2); flex-shrink: 0; }
.cari-head-actions .btn { height: 40px; }
.cari-head-actions .btn svg { margin: 0; }
.cari-bal { text-align: right; }
.cari-bal-label { display: block; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.cari-bal-val { font-size: var(--fs-xl); font-weight: 800; color: var(--brand); }

/* Segment kontrol (pill grubu): tüm sekmeler tek kapsülde; aktif = beyaz pill + gölge +
   turuncu yazı → gri zeminden net ayrışır, aktif sekme asla gözden kaçmaz. */
.cari-tabs {
  display: inline-flex; flex-wrap: wrap; gap: 2px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 11px; padding: 4px; margin-bottom: var(--space-4); max-width: 100%;
}
.cari-tab {
  padding: 8px 16px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
  background: transparent; border: none; border-radius: 8px; cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}
.cari-tab:hover { color: var(--text); }
.cari-tab.is-active { background: var(--surface); color: var(--brand); font-weight: 700; box-shadow: 0 1px 3px rgba(26, 24, 54, .16); }
.cari-tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-glow); }

.cari-tab-body { min-height: 200px; }

/* Özet kartlar: masaüstünde 4'lü tek satır (mobilde global 2×2 kalır) */
@media (min-width: 760px) { #cariCards { grid-template-columns: repeat(4, 1fr); } }

/* Diğer İşlemler dropdown (başlık eylem kümesinde) */
.cari-diger { position: relative; }
.cari-diger-trigger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 14px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text);
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: color .15s, border-color .15s;
}
.cari-diger-trigger:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-glow); }
.cari-diger-trigger:hover { color: var(--brand); border-color: var(--brand); }
.cari-diger-lead { color: var(--text-muted); transition: color .15s; }
.cari-diger-trigger:hover .cari-diger-lead { color: var(--brand); }
.cari-diger-caret { transition: transform .15s; }
.cari-diger.is-open .cari-diger-trigger { color: var(--brand); border-color: var(--brand); }
.cari-diger.is-open .cari-diger-lead { color: var(--brand); }
.cari-diger.is-open .cari-diger-caret { transform: rotate(180deg); }
.cari-diger-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 240px;
  display: none; flex-direction: column; padding: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.cari-diger.is-open .cari-diger-menu { display: flex; }
.cari-diger-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
  border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-align: left;
  transition: background .12s;
}
.cari-diger-item svg { flex: 0 0 auto; color: var(--text-muted); }
.cari-diger-item:hover { background: var(--surface-alt); }
.cari-diger-item--danger { color: var(--red); }
.cari-diger-item--danger svg { color: var(--red); }
.cari-diger-item:disabled { opacity: .5; cursor: default; }
.cari-diger-item:disabled:hover { background: transparent; }

/* Ekstre satırında irsaliye rozeti (tıklanır → irsaliyeyi görüntüle/paylaş) */
.ekstre-irs {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: var(--radius-full);
  background: var(--surface-alt); border: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); white-space: nowrap;
  text-decoration: none;
}
a.ekstre-irs { cursor: pointer; transition: border-color .15s, color .15s; }
a.ekstre-irs:hover { border-color: var(--brand); color: var(--brand); }

/* İrsaliye görüntüleme modalı (iframe önizleme) */
.irs-view { width: 100%; }
.irs-frame { display: block; width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }

/* Müşteriler/Tedarikçiler listesi: işlem ikonları gri yuvarlak kutucukta, hover'da turuncu. */
#custList .row-act, #supList .row-act {
  background: var(--surface); border-color: var(--border); color: var(--text-muted); opacity: 1;
}
#custList .row-act:hover, #supList .row-act:hover {
  background: var(--brand-tint); border-color: var(--brand); color: var(--brand);
}

/* Ekstre araç çubuğu (Yazdır · PDF · Mutabakat) */
.ekstre-tools { display: flex; justify-content: flex-end; gap: 6px; margin-top: var(--space-3); }
.ekstre-tool {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-muted);
  cursor: pointer; font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em;
  transition: border-color .15s, color .15s;
}
.ekstre-tool:hover { border-color: var(--brand); color: var(--brand); }
.ekstre-tool:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-glow); border-color: var(--brand); }
.ekstre-tool--ghost:hover { border-color: var(--text-muted); color: var(--text); }
.ekstre-tool:disabled { opacity: .55; cursor: default; }
.ekstre-tool:disabled:hover { border-color: var(--border); color: var(--text-muted); }

/* Ekstre ekran-içi tarih aralığı filtresi */
.ekstre-filter { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: var(--space-3); }
.ekstre-filter-lbl { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); letter-spacing: .02em; }
.ekstre-filter-date { height: 34px; max-width: 160px; padding: 0 8px; }
.ekstre-filter-sep { color: var(--text-muted); }

/* Ekstre satırı: Geri Al butonu + ters/iptal kayıt görünümü */
.ekstre-act { text-align: right; }
.ekstre-undo {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text-muted);
  cursor: pointer; transition: border-color .15s, color .15s;
}
.ekstre-undo:hover { border-color: var(--red); color: var(--red); }
.ekstre-undo:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-glow); border-color: var(--red); }

/* Ekstre bakiye kolonu: mutlak değer + yön etiketi (Alacak/Borç/Avans) */
.ekstre-bal-dir { display: inline-block; margin-left: 6px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
.ekstre-reversed-tag { font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); font-style: italic; }
.ekstre-reversed td { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--text-muted); }
.ekstre-reversed td.ekstre-act { text-decoration: none; }
.ekstre-reversal td { color: var(--text-muted); font-style: italic; }
.ekstre-devir td { background: var(--surface-alt); font-style: italic; color: var(--text-muted); }

@media (max-width: 560px) {
  .cari-head { flex-wrap: wrap; }
  .cari-bal { text-align: left; }
  .cari-head-actions { width: 100%; }
  .cari-head-actions .btn { flex: 1; }
}

/* — Kargo Etiketi modalı (cari-detay; müşteri+tedarikçi ortak) — */
.ke-wrap { display: flex; flex-direction: column; gap: var(--space-3); }
.ke-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.ke-field { display: flex; flex-direction: column; gap: 4px; }
.ke-tpl-lbl { font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.ke-tpl-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ke-tpl-chip { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 6px 12px; font-size: var(--text-sm); cursor: pointer; transition: border-color .15s, color .15s; }
.ke-tpl-chip:hover { border-color: var(--brand); color: var(--brand); }
.ke-tpl-chip.is-active { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); font-weight: 600; box-shadow: 0 0 0 1px var(--brand) inset; }
.ke-tpl-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.ke-tpl-hint a { color: var(--brand); font-weight: 600; }
.ke-preview { border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-alt); padding: var(--space-3); overflow: auto; min-height: 80px; display: flex; justify-content: center; }
.ke-tpl-scale { display: inline-block; }
/* Küçük (yalnız-yazdır) kargo önizlemesi: ölçekli etiket görünür boyutuna sığar. */
.ke-preview--sm { min-height: 0; padding: var(--space-4); align-items: center; }
.ke-prev-box { position: relative; flex: 0 0 auto; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.14); }
.ke-prev-scale { position: absolute; top: 0; left: 0; }
.ke-tpl-name { font-size: var(--text-sm); font-weight: 700; color: var(--text); }
.ke-empty { text-align: center; color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-5) var(--space-3); line-height: 1.6; }
.ke-empty a { color: var(--brand); font-weight: 600; }
@media (max-width: 560px) { .ke-grid { grid-template-columns: 1fr; } }

/* CRM aktivite sekmesi (cari-detay) */
.cari-akt-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; flex-wrap: wrap; }
.cari-akt-count { font-size: var(--text-sm); color: var(--text-muted); font-weight: 600; }
.cari-akt-list { display: flex; flex-direction: column; gap: var(--space-2); }
.cari-akt-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.cari-akt-top { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.cari-akt-date { font-size: var(--text-sm); color: var(--text-muted); }
.cari-akt-by { font-size: var(--text-xs); color: var(--text-muted); background: var(--surface-alt); border-radius: var(--radius-full); padding: 1px var(--space-2); }
.cari-akt-del { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--text-muted); display: inline-flex; padding: 2px; border-radius: var(--radius-sm); }
.cari-akt-del:hover { color: var(--red); background: var(--row-hover); }
.cari-akt-del svg { width: 16px; height: 16px; }
.cari-akt-note { margin-top: var(--space-2); font-size: var(--text-sm); white-space: pre-wrap; line-height: 1.5; }
.cari-akt-fu { display: inline-block; margin-top: var(--space-2); font-size: var(--text-sm); color: var(--blue); font-weight: 600; }
.cari-akt-fu.overdue { color: var(--red); }
.cari-akt-fu.done { color: var(--green); }
.cari-akt-fudone { margin-left: 4px; background: none; border: 1px solid currentColor; color: inherit; border-radius: var(--radius-full); font-size: var(--text-xs); padding: 0 var(--space-2); cursor: pointer; }

/* İlgili işlemi olan satır (belge → belgeyi aç · tahsilat/ödeme → makbuz).
   Satırın tamamı tıklanabilir; içindeki buton/linkler kendi işini yapar. */
.ekstre-row-link { cursor: pointer; }
.ekstre-row-link:hover > td { background: color-mix(in srgb, var(--brand) 7%, transparent); }

/* Belge-içi peşin tahsilat/ödeme satırı (satış/alıştan türer; bağımsız kayıt değil →
   düzenle/sil yok). Soluk zemin + "belge içi" etiketiyle bağımsız tahsilattan ayrılır. */
.ekstre-subrow > td { background: color-mix(in srgb, var(--surface-alt) 60%, transparent); }
.ekstre-subtxt { color: var(--text-muted); }
.ekstre-subtag {
  display: inline-block; margin-left: 7px; padding: 0 7px; border-radius: var(--radius-full);
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-faint, var(--text-muted));
  background: var(--surface-alt); border: 1px solid var(--border); vertical-align: 1px;
}

/* Ekstre satır Paylaş (WhatsApp) butonu — sil (kırmızı) değil, yeşil hover. */
.ekstre-act .ekstre-undo + .ekstre-undo { margin-left: 4px; }
.ekstre-share-btn:hover { border-color: var(--green); color: var(--green); }
.ekstre-share-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); border-color: var(--green); }

/* Ekstre belge linkleri (satış/alış no'su) — turuncu + tıklanabilir görünüm. .ekstre-belge
   kuralı, soluk .ekstre-subtxt içindeki satış-içi tahsilat linkini de turuncuya çevirir. */
.ekstre-belge { color: var(--brand); font-weight: 600; cursor: pointer; }
.ekstre-belge:hover { text-decoration: underline; }

/* Tahsilat/Ödeme Makbuzu — modal görünümü (yazdırma kendi inline stilini taşır) */
.mkb { font-size: var(--fs-sm); }
.mkb-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); border-bottom: 2px solid var(--brand); padding-bottom: 10px; margin-bottom: var(--space-3); }
.mkb-firma { font-size: var(--fs-lg); font-weight: 800; color: var(--navy); }
.mkb-baslik { font-size: var(--fs-xs); font-weight: 800; color: var(--brand); letter-spacing: .05em; white-space: nowrap; }
.mkb-meta { display: flex; justify-content: space-between; gap: var(--space-3); color: var(--text-muted); margin-bottom: var(--space-3); flex-wrap: wrap; }
.mkb-line { margin-bottom: var(--space-3); }
.mkb-amount { text-align: center; background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-3); }
.mkb-amount-num { font-size: 26px; font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; }
.mkb-amount-yazi { font-size: var(--fs-xs); color: var(--text-muted); font-style: italic; margin-top: 4px; }
.mkb-r { display: flex; justify-content: space-between; gap: var(--space-3); padding: 7px 0; border-bottom: 1px solid var(--border); }
.mkb-r span { color: var(--text-muted); }
.mkb-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-3); margin-top: var(--space-5); font-size: var(--fs-xs); color: var(--text-muted); }
.mkb-foot .mkb-sign { border-top: 1px solid var(--border-strong); padding-top: 4px; width: 150px; text-align: center; }
.mkb-actions { display: flex; gap: var(--space-2); justify-content: flex-end; flex-wrap: wrap; }

/* Geçmiş satış bağla modalı */
.cari-bagla-modal .cb-filtre input { width: 100%; }
.cari-bagla-modal .cb-hint { font-size: var(--fs-xs); color: var(--text-muted); margin: var(--space-2) 0 0; }
.cari-bagla-modal .cb-list { max-height: 340px; overflow: auto; margin-top: var(--space-2); }
.cari-bagla-modal .cb-row { display: flex; align-items: center; gap: var(--space-3); padding: 8px 6px; border-radius: var(--radius-sm); cursor: pointer; }
.cari-bagla-modal .cb-row:hover { background: var(--surface-alt); }
.cari-bagla-modal .cb-info { font-size: var(--fs-sm); }
.cari-bagla-modal .cb-empty { padding: var(--space-4); text-align: center; color: var(--text-muted); }
.modal-foot .cb-sel { margin-right: auto; font-size: var(--fs-sm); color: var(--text-muted); }
