:root {
  --brand: #0e7490;
  --brand-2: #0891b2;
  --brand-ink: #ffffff;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
  --radius: 14px;
}
:root[data-theme="dark"] {
  --brand: #22d3ee;
  --brand-2: #06b6d4;
  --brand-ink: #06222a;
  --bg: #0b1220;
  --surface: #111a2b;
  --surface-2: #0f1726;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: #1e293b;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
#app { min-height: 100%; display: flex; flex-direction: column; }

/* --- Splash --- */
.splash {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px;
  background: linear-gradient(160deg, var(--brand), var(--brand-2));
  color: var(--brand-ink);
  transition: opacity .4s ease;
}
.splash.hide { opacity: 0; pointer-events: none; }
.splash .logo { font-size: 44px; font-weight: 800; letter-spacing: 4px; }
.splash .sub { opacity: .85; font-size: 14px; letter-spacing: 2px; }
.spinner { width: 34px; height: 34px; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Hareketli (indeterminate) ilerleme çubuğu — uzun beklemeler için */
.loadbar { position: relative; height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.loadbar::before { content: ''; position: absolute; top: 0; left: -45%; height: 100%; width: 45%; border-radius: 6px;
  background: linear-gradient(90deg, var(--brand-2, var(--brand)), var(--brand)); animation: loadbar 1.1s cubic-bezier(.4,0,.2,1) infinite; }
@keyframes loadbar { 0% { left: -45%; } 100% { left: 100%; } }
/* Yanıp sönen "hazırlanıyor" noktaları */
.loadpulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-right: 4px; animation: loadpulse 1s ease-in-out infinite; }
@keyframes loadpulse { 0%,100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }

/* --- Generic --- */
.center-screen { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn {
  appearance: none; border: 0; border-radius: 10px; padding: 13px 16px;
  font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
  background: var(--brand); color: var(--brand-ink); transition: filter .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { filter: brightness(.95); }
.btn:disabled { opacity: .6; cursor: default; }
/* Tüm tıklanabilir butonlarda el imleci (inline stilli özel butonlar dahil) */
button:not(:disabled), [role="button"]:not([aria-disabled="true"]) { cursor: pointer; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.input {
  width: 100%; padding: 12px 14px; font-size: 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.muted { color: var(--text-muted); font-size: 13px; }
.error-msg { color: var(--danger); font-size: 14px; margin: 6px 0; min-height: 18px; }
.link { color: var(--brand); cursor: pointer; font-weight: 600; }

/* --- Login --- */
.login-col { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; }
.login-wrap { width: 100%; max-width: 400px; padding: 26px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .name { font-size: 30px; font-weight: 800; letter-spacing: 5px; color: var(--brand); }
.login-brand .tag { font-size: 12px; color: var(--text-muted); letter-spacing: 2px; }
.topbar-mini { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.chip { padding: 7px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer; }

/* --- App shell --- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  /* iOS PWA: çentik/Dynamic Island'ın altında kalmaması için güvenli alan kadar boşluk
     (env() çentiksiz Android/masaüstünde 0 döner → değişiklik olmaz) */
  padding: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 12px calc(14px + env(safe-area-inset-left));
  background: var(--brand); color: var(--brand-ink);
  box-shadow: var(--shadow);
}
.appbar .title { font-weight: 800; letter-spacing: 3px; }
.appbar-clock {
  display: flex; flex-direction: column; line-height: 1.05;
  padding-left: 12px; margin-left: 2px;
  border-left: 1px solid rgba(255,255,255,.25);
  font-variant-numeric: tabular-nums;
}
.appbar-clock .t { font-weight: 700; font-size: 14px; }
.appbar-clock .d { font-size: 11px; opacity: .8; }
.btn-install, .btn-refresh {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); color: inherit;
  height: 36px; padding: 0 12px; margin-right: 6px; border-radius: 10px;
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn-install:hover, .btn-refresh:hover { background: rgba(255,255,255,.28); }
@media (max-width: 420px) {
  .appbar .title { letter-spacing: 1px; }
  .appbar-clock { padding-left: 8px; }
  .appbar-clock .t { font-size: 13px; }
  .appbar-clock .d { display: none; }
  .btn-install, .btn-refresh { padding: 0 10px; }
  .btn-install .lbl, .btn-refresh .lbl { display: none; }
}
.icon-btn { background: rgba(255,255,255,.15); border: 0; color: inherit; width: 40px; height: 40px; border-radius: 10px; font-size: 20px; cursor: pointer; }
.content { flex: 1; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
.an-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
/* Geniş ekranlar (rapor/tablo) — PC'de daha fazla genişlik kullanır, mobilde fark etmez */
.content.wide { max-width: 1180px; }
/* Çok geniş (Proje İlerleme — detaylı matris) */
.content.xwide { max-width: 1300px; }

/* --- Mobil yerleşim: dar ekranlarda yan yana alan satırları taşmasın, alt alta sarsın --- */
@media (max-width: 600px) {
  .row { flex-wrap: wrap; }
  .seg { flex-wrap: wrap; }
  /* satır içi alan grupları (flex:1 + inline min-width) tam genişliğe insin */
  .row > .field { flex: 1 1 100% !important; min-width: 0 !important; }
  /* "width:auto" butonlar (ör. arama yanındaki) gerekirse tam satır olsun */
  .content { padding-left: 12px; padding-right: 12px; }
}

/* --- Drawer --- */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: 78%; max-width: 300px; z-index: 31;
  background: var(--surface); transform: translateX(-100%); transition: transform .25s ease;
  display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.drawer.open { transform: none; }
.drawer-head { padding: calc(20px + env(safe-area-inset-top)) 18px 20px calc(18px + env(safe-area-inset-left)); background: linear-gradient(160deg, var(--brand), var(--brand-2)); color: var(--brand-ink); }
.drawer-head .who { font-weight: 700; font-size: 18px; }
.drawer-head .role { opacity: .85; font-size: 13px; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; }
.nav a.active, .nav a:hover { background: var(--surface-2); color: var(--brand); }
.nav .ico { width: 22px; text-align: center; }
.drawer-foot { padding: 12px calc(12px + env(safe-area-inset-left)) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }

/* --- KVKK --- */
.consent-box { max-width: 560px; width: 100%; padding: 22px; max-height: 90vh; display: flex; flex-direction: column; }
.consent-text { overflow-y: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; font-size: 14px; line-height: 1.5; margin: 12px 0; flex: 1; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.check-row input { width: 20px; height: 20px; margin-top: 1px; }

.placeholder { text-align: center; color: var(--text-muted); padding: 40px 10px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface); color: var(--text); padding: 12px 18px; border-radius: 10px; z-index: 60; font-size: 14px; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s; max-width: 90vw; }

/* --- Modal --- */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal { background: var(--surface); width: 100%; max-width: 480px; border-radius: 16px 16px 0 0; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slideup .25s ease; }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.icon-btn.dark { background: var(--surface-2); color: var(--text); }
@media (min-width: 560px) { .modal-mask { align-items: center; } .modal { border-radius: 16px; } }

/* --- List items --- */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); }
.item .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.item .who { font-weight: 700; }
.item .meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
.badge.on { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.off { background: color-mix(in srgb, var(--text-muted) 18%, transparent); color: var(--text-muted); }
.badge.warn { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.toolbar { margin-bottom: 14px; }
.select { width: 100%; padding: 12px 14px; font-size: 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 11px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; }
.seg button.sel { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* --- Map picker --- */
.map-pick { height: 260px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); margin-bottom: 12px; }
.ep-pin { font-size: 26px; line-height: 1; text-align: center; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4)); }
.leaflet-container { background: var(--surface-2); font: inherit; }
.geo-results { list-style: none; margin: 4px 0 12px; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; max-height: 180px; overflow-y: auto; }
.geo-results li { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.geo-results li:last-child { border-bottom: 0; }
.geo-results li:hover { background: var(--surface-2); }

/* --- Destek ticket sohbeti --- */
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.bubble { max-width: 82%; padding: 9px 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.bubble.mine { align-self: flex-end; background: color-mix(in srgb, var(--brand) 14%, var(--surface)); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }
.bubble.other { align-self: flex-start; }
.bmeta { font-size: 11px; opacity: .6; margin-bottom: 3px; }
.btext { white-space: pre-wrap; font-size: 14px; line-height: 1.45; word-break: break-word; }
.batt { max-width: 220px; max-height: 220px; border-radius: 10px; margin-top: 6px; display: block; }
.bfile { display: inline-block; margin-top: 6px; font-size: 13px; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0; }
