/* Dursun Takip — stiller
   Renk paleti tek yerde (CSS değişkenleri), responsive: telefon/tablet/masaüstü. */
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-d: #2563eb;

  /* durum renkleri */
  --bekleme: #f59e0b;
  --tamir: #3b82f6;
  --kargoya_hazir: #8b5cf6;
  --kargo: #10b981;
  --pasif: #94a3b8;
  --danger: #ef4444;

  --radius: 12px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);

  /* native form kontrollerini (açılır liste, tarih seçici, kaydırma çubuğu)
     koyu temada çiz — siyah/açık temadaki çirkin görünümü düzeltir */
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* tüm açılır menüler tema ile uyumlu, özel ok */
select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
}
select option { background: var(--panel); color: var(--text); }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

/* `hidden` özniteliği her zaman gizlesin — .modal-backdrop'taki display:grid'i ez.
   (Bu olmadan modal kapanmıyor / sayfada açık kalıyor.) */
[hidden] { display: none !important; }

/* ---- üst başlık ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px; color: #fff;
}
.topbar h1 { margin: 0; font-size: 20px; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- butonlar ---- */
.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-secondary { background: var(--panel-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #314056; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(239,68,68,.12); }
.icon-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ---- notlar ---- */
.not-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px;
}
.not-kart {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: transform .08s, box-shadow .12s;
  border-left: 4px solid var(--primary); display: flex; flex-direction: column; gap: 8px;
  min-height: 120px;
}
.not-kart:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.not-baslik { font-weight: 700; font-size: 15px; }
.not-metin {
  color: var(--text); font-size: 14px; white-space: pre-wrap; word-break: break-word;
  flex: 1; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;
}
.not-alt { color: var(--muted); font-size: 12px; margin-top: auto; }
.not-meta { color: var(--muted); font-size: 12px; margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 10px; }

/* ---- çöp kutusu ---- */
.cop-uyari {
  color: var(--muted); font-size: 13px; margin: 0 0 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
}
.cop-kart {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  border-left: 4px solid var(--muted); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.cop-ust { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cop-ozet { font-size: 14px; word-break: break-word; }
.cop-alt { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cop-tarih { font-size: 12px; color: var(--muted); }
.cop-alt .btn { padding: 6px 12px; font-size: 13px; }

/* ---- giriş ekranı ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg); display: grid; place-items: center; padding: 20px;
}
.login-box {
  width: min(360px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.login-box .logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: grid; place-items: center; font-weight: 800; font-size: 22px; color: #fff;
}
.login-box h2 { margin: 6px 0 0; }
.login-alt { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login-box input {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-size: 15px;
}
.login-box input:focus { outline: none; border-color: var(--primary); }
.login-box .btn { width: 100%; }
.login-hata { color: var(--danger); font-size: 13px; text-align: center; }

/* ---- sekmeler ---- */
.tabs {
  display: flex; gap: 4px; padding: 0 24px;
  background: var(--panel); border-bottom: 1px solid var(--border);
}
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 14px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  border-bottom: 3px solid transparent; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* adet rozeti (gelen ürün listesi) */
.adet-badge {
  display: inline-block; min-width: 30px; text-align: center;
  padding: 3px 11px; border-radius: 999px; font-weight: 700;
  background: var(--panel-2); border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

/* ---- durum sayaçları ---- */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; padding: 18px 24px;
}
.stat-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  border-left: 4px solid var(--border);
}
.stat-card .num { font-size: 26px; font-weight: 800; }
.stat-card .lbl { color: var(--muted); font-size: 13px; }
.stat-card.s-bekleme { border-left-color: var(--bekleme); }
.stat-card.s-tamir { border-left-color: var(--tamir); }
.stat-card.s-kargoya_hazir { border-left-color: var(--kargoya_hazir); }
.stat-card.s-kargo { border-left-color: var(--kargo); }
.stat-card.s-pasif { border-left-color: var(--pasif); }
.stat-card.s-c-hazirlaniyor { border-left-color: var(--bekleme); }
.stat-card.s-c-gonderildi { border-left-color: var(--tamir); }
.stat-card.s-c-geri_geldi { border-left-color: var(--kargoya_hazir); }
.stat-card.s-c-tamamlandi { border-left-color: var(--kargo); }
.stat-card.s-toplam { border-left-color: var(--primary); }

/* ---- proje/kimden dökümü (gelen ürün) — sayaç kartı düzeni ---- */
.breakdown {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 24px 14px;
}
.bd-group h3 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 10px; }
.bd-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
}
.bd-card { cursor: pointer; transition: transform .08s, box-shadow .12s; }
.bd-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.bd-card.bd-aktif { outline: 2px solid var(--primary); outline-offset: -1px; }
.bd-temizle {
  background: var(--primary); color: #fff; border: none; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.bd-temizle:hover { background: var(--primary-d); }

/* proje rozeti (tabloda her projeye özel renk) */
.proje-tag {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-weight: 700; font-size: 12px; border: 1px solid transparent;
}

/* ---- araç çubuğu ---- */
.toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 0 24px 12px;
}
.search { flex: 1; min-width: 220px; }
.search input {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- liste / tablo ---- */
.list-wrap { padding: 0 24px 60px; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; min-width: 760px; }
.list thead th {
  text-align: left; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.list thead th.sortable { cursor: pointer; user-select: none; }
.list thead th.sortable:hover { color: var(--text); }
.list thead th.sorted { color: var(--primary); }
.sort-ind { font-size: 10px; }
.list tbody tr {
  background: var(--panel); cursor: pointer; transition: background .12s;
}
.list tbody tr:hover { background: var(--panel-2); }
.list td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list .takip-no { font-weight: 700; color: #cbd5e1; font-variant-numeric: tabular-nums; }
.cell-sub { color: var(--muted); font-size: 12px; }

/* durum & sebep rozetleri */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge-durum.bekleme { background-color: rgba(245,158,11,.15); color: var(--bekleme); }
.badge-durum.tamir { background-color: rgba(59,130,246,.15); color: var(--tamir); }
.badge-durum.kargoya_hazir { background-color: rgba(139,92,246,.15); color: var(--kargoya_hazir); }
.badge-durum.kargo { background-color: rgba(16,185,129,.15); color: var(--kargo); }
.badge-durum.pasif { background-color: rgba(148,163,184,.15); color: var(--pasif); }
/* çıkan iade/garanti durum renkleri */
.badge-cdurum.hazirlaniyor { background-color: rgba(245,158,11,.15); color: var(--bekleme); }
.badge-cdurum.gonderildi { background-color: rgba(59,130,246,.15); color: var(--tamir); }
.badge-cdurum.geri_geldi { background-color: rgba(139,92,246,.15); color: var(--kargoya_hazir); }
.badge-cdurum.tamamlandi { background-color: rgba(16,185,129,.15); color: var(--kargo); }
.badge-sebep { background-color: var(--panel-2); color: var(--text); border: 1px solid var(--border); }

/* listede durumu doğrudan değiştiren açılır menü */
.durum-select {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 28px 5px 10px; font-size: 12px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  background-position: right 8px center;
}
.durum-select:hover { filter: brightness(1.15); }
.durum-select:focus { outline: none; border-color: var(--primary); }
.durum-select option { background: var(--panel); color: var(--text); font-weight: 600; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty p { font-size: 16px; margin-bottom: 16px; }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: grid; place-items: center; padding: 16px; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; width: min(760px, 100%);
  max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.modal-head, .modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-foot { border-bottom: none; border-top: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.spacer { flex: 1; }

.form-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span2 { grid-column: span 2; }
.field.span3 { grid-column: span 3; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field label .opt { font-weight: 400; font-size: 11px; opacity: .8; }
.field input, .field select, .field textarea {
  background-color: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 9px 11px; font-size: 14px; font-family: inherit;
}
.field select { padding-right: 32px; cursor: pointer; }

/* tema uyumlu otomatik tamamlama (datalist yerine) */
.ac { position: relative; display: block; }
.ac input { width: 100%; }
.ac-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px; z-index: 60;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; max-height: 220px; overflow-y: auto; box-shadow: var(--shadow);
}
.ac-list li {
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ac-list li:hover, .ac-list li.aktif { background: var(--primary); color: #fff; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
}

/* ---- işlem geçmişi (timeline) ---- */
.islem-section { margin-top: 22px; border-top: 1px dashed var(--border); padding-top: 18px; }
.islem-section h3 { margin: 0 0 12px; font-size: 15px; }
.islem-add { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.islem-add textarea {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 9px 11px; font-size: 14px;
  font-family: inherit; resize: vertical; min-height: 42px;
}
.islem-add textarea:focus { outline: none; border-color: var(--primary); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border);
}
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--primary);
}
.timeline .t-time { font-size: 12px; color: var(--muted); }
.timeline .t-text { margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.timeline .t-del {
  position: absolute; right: 0; top: 0; cursor: pointer; color: var(--muted);
  background: none; border: none; font-size: 13px;
}
.timeline .t-del:hover { color: var(--danger); }

/* ---- bekleme süresi rozetleri (listede) ---- */
.aging { font-size: 11px; font-weight: 700; }
.aging.a-ok { color: var(--muted); }
.aging.a-warn { color: var(--bekleme); }
.aging.a-late { color: var(--danger); }
.aging.a-done { color: var(--kargo); font-weight: 600; }
.aging.a-pasif { color: var(--pasif); font-weight: 600; }
.chip.chip-warn.active { background: var(--danger); border-color: var(--danger); }

/* ---- alt bölümler (parça / fotoğraf) ---- */
.sub-section { margin-top: 22px; border-top: 1px dashed var(--border); padding-top: 18px; }
.sub-section h3 { margin: 0 0 12px; font-size: 15px; }
.sub-section h3 .hint { font-weight: 400; font-size: 12px; color: var(--muted); }
.bos { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* parçalar */
.parca-add { display: flex; gap: 8px; margin-bottom: 12px; }
.parca-add input { background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 11px; font-size: 14px; }
.parca-add input#f_parcaAd { flex: 1; }
.parca-add input#f_parcaUcret { width: 120px; }
.parca-add input:focus { outline: none; border-color: var(--primary); }
.parca-list { list-style: none; margin: 0; padding: 0; }
.parca-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.parca-list .p-ad { flex: 1; }
.parca-list .p-ucret { font-variant-numeric: tabular-nums; color: var(--muted); }
.parca-list .p-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.parca-list .p-del:hover { color: var(--danger); }

/* fotoğraflar */
.foto-add { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.foto-add .btn { display: inline-flex; align-items: center; gap: 4px; }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.foto-item { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 1; }
.foto-item img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.foto-tip { position: absolute; left: 6px; top: 6px; font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; background: rgba(0,0,0,.65); color: #fff; }
.foto-tip.cikis { background: rgba(16,185,129,.85); }
.foto-tip.gelis { background: rgba(59,130,246,.85); }
.foto-del { position: absolute; right: 6px; top: 6px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px; line-height: 1; }
.foto-del:hover { background: var(--danger); }

/* ---- toast ---- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100;
}

/* ---- responsive ---- */
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .tabs { padding-left: 8px; padding-right: 8px; }
  .tab { padding: 12px 12px; font-size: 13px; }
  .stats, .toolbar, .list-wrap, .breakdown { padding-left: 12px; padding-right: 12px; }
  .breakdown { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span2, .field.span3 { grid-column: span 1; }
}
