:root {
  --bg: #f2f3f7;
  --card-bg: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #6b6b70;
  /* Natek marka renkleri - iOS uygulamasindaki AccentColor/BrandOrange ile ayni. */
  --accent: #00547f;
  --accent-light: #2e769e;
  --brand-orange: #faa633;
  --danger: #ff3b30;
  --border: #e3e4e8;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

/* ---------- LOGIN (ArizaTakip iOS LoginView.swift ile ayni tasarim) ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 0;
  background: var(--bg);
}

/* [hidden] normalde display:none yapar ama display:flex kurali onu ezer;
   basarili girişten sonra ekran kapanmadan kalmasin diye acikca ekliyoruz. */
.login-screen[hidden] {
  display: none;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  padding-bottom: 48px;
}

.login-header {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  border-radius: 0 0 44px 44px;
  padding: 56px 24px 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: white;
  text-align: center;
}

.login-logo-card {
  width: 132px;
  height: 92px;
  background: #ffffff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0,0,0,0.18);
}

.login-logo-card img {
  width: 104px;
  height: 68px;
  object-fit: contain;
}

.login-header h1 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 700;
}

.login-subtitle {
  margin: 0;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.login-card {
  background: var(--card-bg);
  border-radius: 24px;
  padding: 28px 24px;
  margin: -48px 20px 0;
  position: relative;
  z-index: 1;
  box-shadow: 0 8px 30px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.login-card input {
  padding: 13px 14px;
  border-radius: 14px;
  border: none;
  background: var(--bg);
  font-size: 15px;
  color: var(--text);
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#login-button {
  margin-top: 4px;
  padding: 13px;
  border: none;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

#login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
  text-align: center;
}

/* ---------- APP SHELL ---------- */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 60px;
}

.topbar-title {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-logo {
  height: 26px;
  width: auto;
  object-fit: contain;
}

.topbar-title span {
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 4px;
}

.tabs {
  display: flex;
  gap: 4px;
  flex: 1;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
}

.tab-btn:hover { background: var(--bg); }

.tab-btn.active {
  background: var(--accent);
  color: white;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

/* ---------- BUTTONS ---------- */
.btn-primary, .btn-secondary, .btn-danger {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
  opacity: 0.5; cursor: not-allowed;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 4px 8px;
}
.icon-btn.danger { color: var(--danger); }

/* ---------- CARDS (OZET) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.summary-card .icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-card .count { font-size: 26px; font-weight: 700; }
.summary-card .name { color: var(--text-secondary); font-size: 13px; }

.total-panel {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  max-width: 320px;
}

.total-panel .icon { font-size: 24px; }
.total-panel .count { font-size: 24px; font-weight: 700; margin-left: auto; }

/* ---------- TABLE ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.data-table th, .data-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.data-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td { border-bottom: none; }

.role-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text-secondary);
}

.empty-row td {
  text-align: center;
  color: var(--text-secondary);
  padding: 30px;
}

/* ---------- MODAL ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

/* Onemli: [hidden] normalde tarayicinin varsayilan stiliyle display:none
   yapar, ama yukaridaki .modal-overlay { display: flex } kurali bunu
   override edip modali her zaman gorunur kilar (login formunun onunu
   tikar). Bu kural olmadan modal hic kapanmaz. */
.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 16px; }

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-secondary);
  line-height: 1;
}

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.modal-body input, .modal-body select, .modal-body textarea {
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.checkbox-list label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.modal-error {
  color: var(--danger);
  font-size: 13px;
  margin: 0;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1c1c1e;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
}

.toast.error { background: var(--danger); }

/* ---------- ARIZALAR ---------- */
.fault-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.fault-toolbar input[type="search"] {
  flex: 1;
  min-width: 220px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 14px;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.data-table tbody tr[data-clickable] { cursor: pointer; }
.data-table tbody tr[data-clickable]:hover { background: var(--bg); }

.status-badge, .priority-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.acik { background: rgba(255,59,48,0.12); color: #ff3b30; }
.status-badge.mudahale_ediliyor { background: rgba(255,149,0,0.14); color: #ff9500; }
.status-badge.kapatildi { background: rgba(52,199,89,0.14); color: #248a3d; }

.priority-badge.kritik { background: rgba(255,59,48,0.12); color: #ff3b30; }
.priority-badge.orta { background: rgba(250,166,51,0.16); color: #b06b00; }
.priority-badge.dusuk { background: var(--bg); color: var(--text-secondary); }

/* ---------- FAULT DETAIL MODAL ---------- */
.modal-card.wide { max-width: 640px; }

.detail-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-section h4 {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.detail-row:last-child { border-bottom: none; }
.detail-row .label { color: var(--text-secondary); }
.detail-row .value { text-align: right; }

.detail-description {
  font-size: 14px;
  background: var(--bg);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-grid a {
  display: block;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.note-item .note-meta {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 4px;
}

.note-item .note-text { white-space: pre-wrap; }

.close-note-box {
  background: rgba(52,199,89,0.08);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  white-space: pre-wrap;
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------- SAHA HARITASI ---------- */
#saha-map {
  height: 480px;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content .popup-title { font-weight: 700; margin-bottom: 4px; }
.leaflet-popup-content .popup-address { color: var(--text-secondary); margin-bottom: 8px; }
.leaflet-popup-content .popup-links { display: flex; gap: 10px; }
.leaflet-popup-content .popup-links a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---------- RAPORLAR ---------- */
.rapor-filter-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.rapor-filter-label input, .rapor-filter-label select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: inherit;
}

.report-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 760px) {
  .report-columns { grid-template-columns: 1fr; }
}

.report-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}

.dist-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dist-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dist-row .dist-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.dist-row .dist-label .count { color: var(--text-secondary); }

.dist-bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--bg);
  overflow: hidden;
}

.dist-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.empty-hint {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0;
}

/* ---------- GRUPLAR / ICE AKTARMA ---------- */
.role-badge-inline {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: var(--bg);
  color: var(--text-secondary);
  margin-left: 4px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
}

@media (max-width: 640px) {
  .mapping-grid { grid-template-columns: 1fr; }
}

.import-preview-wrap {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.import-preview-wrap .data-table { margin: 0; }

.import-row-problem { background: rgba(255, 59, 48, 0.06); }

.import-row-status { text-align: center; white-space: nowrap; }

/* ---------- YAZDIRMA / PDF ---------- */
@media print {
  .topbar, .fault-toolbar, #rapor-print-btn, #rapor-csv-btn, #rapor-clear-filters,
  .login-screen, .toast, .modal-overlay {
    display: none !important;
  }
  .content { max-width: 100%; padding: 0; }
  body { background: white; }
  .report-card, .card-grid, .data-table { box-shadow: none; }
}
