:root {
  --bg: #f4f6fa; --panel: #ffffff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --accent: #1e3a8a; --accent-2: #2563eb; --danger: #dc2626; --hover: #f1f5f9;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--accent); color: #fff; }
.brand { font-weight: 700; font-size: 16px; }
.brand .muted { color: #c7d2fe; font-weight: 400; }
.logo { color: #93c5fd; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
header button.ghost { color: #fff; border-color: rgba(255,255,255,.4); }
header button:not(.ghost) { background: #fff; color: var(--accent); }

main { flex: 1; display: flex; min-height: 0; }
#side { width: 400px; max-width: 100%; display: flex; flex-direction: column; background: var(--panel);
  border-right: 1px solid var(--line); min-height: 0; }
.box { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; align-items: flex-end; }
.row > label { flex: 1; min-width: 0; }
label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 8px; color: var(--text); }
input, select, textarea { font: inherit; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--text); width: 100%; }
input[type=checkbox] { width: auto; }
input[type=color] { padding: 2px; height: 34px; }
button { font: inherit; cursor: pointer; padding: 7px 12px; border-radius: 6px; border: 1px solid var(--accent-2);
  background: var(--accent-2); color: #fff; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--accent-2); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.wide { width: 100%; padding: 9px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; }
.hidden { display: none !important; }

#chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 8px;
  border-radius: 999px; background: var(--hover); cursor: pointer; border: 1px solid transparent; }
.chip.on { border-color: var(--accent-2); background: #dbeafe; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

#listHead { padding: 8px 14px; border-bottom: 1px solid var(--line); }
#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#list li { padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; align-items: flex-start; }
#list li:hover, #list li.sel { background: var(--hover); }
#list li .dot { margin-top: 5px; }
#list .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#list .s { font-size: 12px; color: var(--muted); }
#list .grow { flex: 1; min-width: 0; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--hover); color: var(--muted); white-space: nowrap; }
.badge.Yeni { background: #e0e7ff; color: #3730a3; }
.badge.Arandı { background: #fef3c7; color: #92400e; }
.badge.Ulaşılamadı { background: #f1f5f9; color: #475569; }
.badge.Teklif-Verildi { background: #cffafe; color: #155e75; }
.badge.Anlaşıldı { background: #dcfce7; color: #166534; }
.badge.İlgilenmiyor { background: #fee2e2; color: #991b1b; }
.badge.Uygun-Değil { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
#list .more { justify-content: center; color: var(--accent-2); font-weight: 600; }
#list li.bos-uyari { display: block; cursor: default; background: #fef3c7; color: #92400e; font-size: 13px; line-height: 1.45; }

#mapWrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.hint { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000;
  background: var(--accent); color: #fff; padding: 8px 14px; border-radius: 6px; }
.hint a { color: #bfdbfe; }

#detail { position: absolute; top: 10px; right: 10px; bottom: 10px; width: 380px; max-width: calc(100% - 20px);
  background: var(--panel); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); z-index: 1000;
  overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
#detail h3 { margin: 0; font-size: 17px; }
#detail .close { position: absolute; top: 8px; right: 10px; border: none; background: none; color: var(--muted); font-size: 20px; padding: 2px 6px; }
#detail dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 8px; margin: 0; font-size: 13px; }
#detail dt { color: var(--muted); }
#detail dd { margin: 0; word-break: break-word; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.links a { font-size: 13px; text-decoration: none; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); color: var(--accent-2); font-weight: 600; }
.links a.primary { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
#detail .saved { color: #16a34a; font-size: 12px; }

#overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 3000; display: flex;
  flex-direction: column; align-items: center; justify-content: center; color: #fff; gap: 14px; text-align: center; padding: 16px; }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { border: none; border-radius: 10px; padding: 16px 18px; width: 760px; max-width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(15,23,42,.5); }
#dlgCat { width: 560px; }
#catForm { display: flex; flex-direction: column; gap: 10px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-foot { display: flex; gap: 8px; align-items: center; }
#catTable { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 13px; }
#catTable th, #catTable td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
#catTable th { color: var(--muted); font-weight: 600; font-size: 12px; }
#catTable tr.off td { opacity: .45; }
#catTable td.kw { max-width: 220px; color: var(--muted); font-size: 12px; }
code { background: var(--hover); padding: 1px 4px; border-radius: 3px; font-size: 12px; }

.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; min-width: 0; }
#mobileNav, .mobile-only, .close-txt { display: none; }

#gomulu { position: fixed; inset: 0; z-index: 2700; background: var(--panel); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top); }
.gomulu-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
#gomuluBaslik { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#gomuluDis { text-decoration: none; font-weight: 600; color: #fff; background: var(--accent-2); padding: 9px 12px; border-radius: 6px; white-space: nowrap; }
#gomuluCerceve { flex: 1; width: 100%; border: 0; }

/* Telefon: liste ve harita ayrı tam ekran görünümler, altta geçiş çubuğu; detay tam ekran açılır */
@media (max-width: 800px) {
  /* Sayfa yana kaymasın: yatay taşma kırpılır, kenarda lastik efekti ve çift dokunuşla yakınlaştırma kapalı */
  html, body { height: 100dvh; overflow-x: hidden; overscroll-behavior: none; }
  button, a, label, select, input, .chip, #list li { touch-action: manipulation; }
  :root { font-size: 15px; }
  input, select, textarea { font-size: 16px; padding: 9px 10px; } /* iOS odaklanınca yakınlaştırmasın */
  button { min-height: 40px; }
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }

  header { position: relative; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand .muted { display: none; }
  #btnMenu { font-size: 20px; padding: 4px 12px; }
  header .actions { display: none; }
  header.open .actions { display: flex; flex-direction: column; align-items: stretch; position: absolute; top: 100%; left: 0; right: 0;
    z-index: 2500; background: var(--accent); padding: 8px 12px 12px; gap: 8px; box-shadow: 0 10px 20px rgba(0,0,0,.25); }
  header.open .actions > button, header.open .menu > button { width: 100%; }
  #meMenu { position: static; margin-top: 6px; box-shadow: none; }

  main { flex-direction: column; }
  #side { width: 100%; flex: 1; border-right: none; }
  #mapWrap { flex: 1; }
  body.view-map #side { display: none; }
  /* Harita gizliyken kabı sıfır yükseklikte kalır (tamamen gizlenirse içindeki detay paneli de açılamaz) */
  body:not(.view-map) #mapWrap { flex: none; height: 0; }
  .box { padding: 10px 12px; }
  #side:not(.filters-open) .filter-more { display: none; }
  #btnFilters { flex: none; gap: 6px; padding: 0 12px; }
  #filterCount:not(:empty) { background: var(--accent-2); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
  #chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px; }
  .chip { flex: none; padding: 6px 10px; font-size: 13px; }
  #listHead { padding: 8px 12px; }
  #list li { padding: 12px; }
  #list .s { font-size: 13px; }
  #list li.more { padding: 16px; }

  #mobileNav { display: flex; background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom); }
  #mobileNav button { flex: 1; min-height: 52px; border: none; border-radius: 0; background: none; color: var(--muted); font-size: 15px; }
  #mobileNav button.on { color: var(--accent-2); box-shadow: inset 0 3px 0 var(--accent-2); }
  #navCount { font-weight: 400; font-size: 13px; }

  #detail { position: fixed; inset: 0; width: auto; max-width: none; border-radius: 0; z-index: 2600; padding: 0 16px 0;
    padding-top: env(safe-area-inset-top); gap: 12px; }
  #detail .close { position: sticky; top: 0; align-self: flex-end; margin: 0 -16px; width: calc(100% + 32px); text-align: left;
    background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 16px; font-size: 16px; color: var(--accent-2); z-index: 1; }
  #detail .close-txt { display: inline; }
  #detail dl { grid-template-columns: 100px 1fr; font-size: 14px; }
  .links a { flex: 1 1 40%; text-align: center; padding: 11px 10px; font-size: 14px; }
  #detail .row { flex-wrap: wrap; }
  #detail .row > label { flex-basis: 140px; }
  #detail .save-bar { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line);
    margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); flex-wrap: nowrap; }
  #detail .save-bar button[type=submit] { flex: 1; }
  #detail .save-bar span:empty { display: none; }

  .hint { width: calc(100% - 24px); text-align: center; }
  #toast { bottom: 72px; }
  dialog { width: 100%; max-width: 100%; max-height: 100dvh; margin: 0; border-radius: 0; height: 100dvh; }
  #dlgCat, #dlgPw { width: 100%; }
  dialog .row { flex-wrap: wrap; }
  .tbl, #catTable { display: block; overflow-x: auto; }
  #catTable td.kw { display: none; }
}

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 4000; background: #0f172a;
  color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
#toast.err-toast { background: var(--danger); }

.menu { position: relative; }
#meMenu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border-radius: 8px; min-width: 170px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 2000; display: flex; flex-direction: column; padding: 4px; }
#meMenu a { color: var(--text); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
#meMenu a:hover { background: var(--hover); }
body:not(.is-admin) .admin-only { display: none !important; }
.box .row > button { flex: 1; padding: 8px 6px; font-size: 13px; }
.job { background: var(--hover); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.job-top { display: flex; justify-content: space-between; align-items: center; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#jobBar { height: 100%; width: 0; background: var(--accent-2); transition: width .4s; }
.userform { display: flex; flex-direction: column; gap: 10px; }
.userform h3 { margin: 8px 0 0; font-size: 15px; }
.tbl { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tbl tr.off td { opacity: .45; }

/* PHP sürümünde tarama yok: tarama butonları gizli */
body.no-scan #btnScan, body.no-scan #btnScanIl, body.no-scan #btnScanAll, body.no-scan #btnSokak, body.no-scan #job { display: none !important; }

/* Sokak Görünümü aranırken buton */
.links a.loading { pointer-events: none; opacity: .75; }
.links a.loading::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }

#overlayText { white-space: pre-line; font-size: 15px; line-height: 1.5; }
