:root {
  --ims-surface: #f4f7fb;
  --ims-border: #d7e0ea;
  --ims-side-gap: 50px;
  --ims-primary: #0d6efd;
  --ims-primary-deep: #0a58ca;
  --ims-ink: #1e293b;
  --ims-muted: #64748b;
  --ims-line: #d7dee7;
  --ims-panel: #ffffff;
  --ims-sidebar: #0f172a;
  --ims-sidebar-2: #020617;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Candara", "Trebuchet MS", sans-serif;
  color: var(--ims-ink);
  background: var(--ims-surface);
}

/* ——— App shell (Akreditasyon sol menü) ——— */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .22s ease;
}
.app-shell.sidebar-hidden,
html.sidebar-hidden-init .app-shell {
  --sidebar-width: 0px;
}
.app-sidebar {
  background: linear-gradient(180deg, var(--ims-sidebar), var(--ims-sidebar-2));
  color: #fff;
  padding: 1rem .85rem;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity .18s ease;
}
.app-shell.sidebar-hidden .app-sidebar,
html.sidebar-hidden-init .app-sidebar {
  opacity: 0;
  pointer-events: none;
}
.sidebar-brand {
  display: flex;
  gap: .85rem;
  align-items: center;
  margin-bottom: .75rem;
  padding: .5rem;
  flex-shrink: 0;
}
.sidebar-brand small { display: block; opacity: .7; }
.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: .9rem;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--ims-primary), var(--ims-primary-deep));
  color: #fff;
  font-weight: 700;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: .15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.25) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.22);
  border-radius: 999px;
}
.sidebar-nav .nav-link {
  color: rgba(255,255,255,.85);
  border-radius: .7rem;
  padding: .65rem .85rem;
  display: flex;
  gap: .65rem;
  align-items: center;
  text-decoration: none;
  font-size: .92rem;
}
.sidebar-nav .nav-link-sub { padding-left: 1.35rem; font-size: .88rem; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav .nav-link.active {
  background: rgba(13, 110, 253, .22);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.nav-group-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,.78);
  text-align: left;
  padding: .55rem .85rem;
  font-size: .88rem;
  display: flex;
  align-items: center;
  cursor: pointer;
  border-radius: .7rem;
}
.nav-group-toggle:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-group-label { display: inline-flex; align-items: center; gap: .35rem; }
.nav-chevron {
  font-size: .65rem;
  transition: transform .2s ease;
}
.nav-group-toggle.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-group-panel { display: flex; flex-direction: column; gap: .15rem; }
.nav-section {
  margin: .85rem 0 .25rem;
  padding: 0 .85rem;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .45;
  color: rgba(255,255,255,.9);
}
.sidebar-toggle-btn { flex-shrink: 0; }
.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--ims-panel);
  border-bottom: 1px solid var(--ims-line);
  gap: 1rem;
}
.app-content {
  padding: 1.5rem;
  flex: 1;
}
.app-content-guest {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding-top: 2rem;
}
.app-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ims-border);
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
  background:
    radial-gradient(circle at 10% 20%, rgba(13, 110, 253, 0.14), transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(15, 23, 42, 0.12), transparent 35%),
    linear-gradient(160deg, #eef3f7, #dfe8f0 55%, #cfdce8);
}
.auth-shell {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  flex: 0 1 400px;
}
.auth-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 1.25rem;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}
.auth-brand { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.25rem; }
.auth-page .form-control,
.auth-page .btn,
.auth-page .cf-turnstile {
  max-width: 100%;
}
.auth-turnstile {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-shell:not(.sidebar-hidden) { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1040;
    width: min(280px, 88vw);
    box-shadow: 8px 0 32px rgba(0,0,0,.2);
    transform: translateX(0);
    transition: transform .22s ease, opacity .18s ease;
  }
  .app-shell.sidebar-hidden .app-sidebar,
  html.sidebar-hidden-init .app-sidebar {
    transform: translateX(-105%);
    opacity: 1;
    pointer-events: none;
  }
  .app-main { min-height: 100vh; }
}

@media (max-width: 768px) {
  :root {
    --ims-side-gap: 12px;
  }
}

/* Sag/sol en fazla 50px bosluk (eski sayfa kalibi; app-content icinde sifirla) */
.ims-shell,
.container-fluid.ims-shell {
  --bs-gutter-x: 0;
  width: 100%;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: var(--ims-side-gap) !important;
  padding-right: var(--ims-side-gap) !important;
}

.app-content .ims-shell,
.app-content .container-fluid.ims-shell {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

body > .container-fluid.ims-shell,
header .container-fluid.ims-shell,
footer .container-fluid.ims-shell {
  padding-left: var(--ims-side-gap) !important;
  padding-right: var(--ims-side-gap) !important;
}

/* ——— Modal form ——— */
.ims-entity-modal .modal-dialog {
  max-width: min(1140px, calc(100vw - 1.5rem));
}

.ims-modal-content {
  border: 0;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow:
    0 22px 50px rgba(15, 23, 42, 0.22),
    0 2px 8px rgba(15, 23, 42, 0.08);
}

.ims-modal-header {
  background:
    linear-gradient(135deg, #0b5ed7 0%, #0d6efd 48%, #3b82f6 100%);
  color: #fff;
  border-bottom: 0;
  padding: 1.15rem 1.35rem;
  align-items: flex-start;
}

.ims-modal-header-text {
  min-width: 0;
}

.ims-modal-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.82;
  margin-bottom: 0.2rem;
}

.ims-modal-header .modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.25;
}

.ims-modal-body {
  background:
    radial-gradient(1200px 280px at 0% 0%, rgba(13, 110, 253, 0.06), transparent 55%),
    var(--ims-surface);
  padding: 1.25rem 1.35rem 1.1rem;
}

.ims-modal-footer {
  background: #fff;
  border-top: 1px solid var(--ims-border);
  padding: 0.9rem 1.35rem;
  gap: 0.5rem;
}

.ims-modal-save {
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(13, 110, 253, 0.28);
}

.ims-edit-form {
  row-gap: 1rem !important;
}

.ims-edit-form .form-label {
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #334155;
  font-size: 0.86rem;
}

.ims-edit-form textarea.form-control {
  min-height: 7rem;
  line-height: 1.45;
}

.ims-edit-form textarea.form-control.ims-textarea-lg {
  min-height: 9rem;
}

.ims-edit-form .form-control,
.ims-edit-form .form-select {
  padding: 0.55rem 0.75rem;
  border-color: #cbd5e1;
  border-radius: 0.5rem;
  background: #fff;
}

.ims-edit-form .form-control:focus,
.ims-edit-form .form-select:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.ims-edit-section {
  background: #fff;
  border: 1px solid var(--ims-border);
  border-radius: 0.85rem;
  padding: 0 1.2rem 1.2rem;
  margin-bottom: 0.15rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  position: relative;
  overflow: hidden;
}

.ims-edit-section::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #0d6efd, #60a5fa);
}

.ims-edit-section-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ims-ink);
  margin: 0 -1.2rem 1rem;
  padding: 0.85rem 1.2rem 0.85rem 1.35rem;
  background: linear-gradient(90deg, rgba(13, 110, 253, 0.08), transparent 70%);
  border-bottom: 1px solid var(--ims-border);
  letter-spacing: -0.01em;
}

.ims-edit-section-title::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--ims-primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.18);
  flex: 0 0 auto;
}

.ims-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ims-page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  line-height: 1.3;
}

.ims-page-subtitle {
  color: #6c757d;
  font-size: 0.875rem;
  margin-top: 0.15rem;
}

.ims-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.ims-filter-card .card-header,
.card.ims-filter-card .card-header {
  font-weight: 600;
  background: var(--ims-surface);
}

.ims-panel > .card-header {
  background: var(--ims-surface);
  border-bottom: 1px solid var(--ims-border);
}

.ims-table {
  font-size: 0.875rem;
  width: 100%;
}

/* Bootstrap .card = flex; tabloya verilirse sütun hizası bozulur */
table.card {
  display: table !important;
  flex-direction: unset !important;
}

.ims-table thead th {
  white-space: nowrap;
  background: var(--ims-surface);
  font-weight: 600;
  font-size: 0.8rem;
}

.ims-empty-state {
  text-align: center;
  color: #6c757d;
  padding: 2rem 1rem;
}

.ims-empty-state i {
  font-size: 1.75rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.55;
}

.risk-heat td {
  width: 2.5rem;
  height: 2.5rem;
  vertical-align: middle;
  font-weight: 600;
}

/* PDF modal */
.ims-pdf-modal .modal-dialog {
  max-width: min(1100px, calc(100vw - 1.5rem));
  height: calc(100vh - 2rem);
  margin: 1rem auto;
}

.ims-pdf-modal .modal-content {
  height: 100%;
}

.ims-pdf-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  background: #e8edf3;
  display: flex;
  flex-direction: column;
}

.ims-pdf-frame {
  width: 100%;
  flex: 1 1 auto;
  min-height: 70vh;
  border: 0;
  background: #525659;
}

.ims-pdf-loading {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* ——— Şube haritası (Leaflet / Emlak deseni) ——— */
.branch-map-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1rem;
  min-height: calc(100vh - 220px);
}
.branch-map-side {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-height: 0;
}
.branch-map-search {
  display: flex;
  gap: .5rem;
}
.branch-map-list-head {
  font-weight: 600;
  font-size: .9rem;
  color: var(--ims-ink);
}
.branch-map-results {
  flex: 1;
  min-height: 200px;
  max-height: calc(100vh - 360px);
  overflow: auto;
  border: 1px solid var(--ims-border);
  border-radius: .75rem;
  background: #fff;
}
.branch-map-result {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--ims-border);
  background: #fff;
  padding: .75rem .85rem;
}
.branch-map-result:hover,
.branch-map-result.is-on {
  background: rgba(13, 110, 253, .08);
}
.branch-map-result strong {
  display: block;
  font-size: .92rem;
}
.branch-map-result span {
  display: block;
  font-size: .78rem;
  color: var(--ims-muted);
  margin-top: .15rem;
}
.branch-map-canvas {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--ims-border);
  border-radius: .85rem;
  overflow: hidden;
  background: #e8edf3;
}
#branchMap {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 220px);
}
.branch-map-full {
  position: absolute;
  top: .75rem;
  right: .75rem;
  z-index: 500;
}
.branch-map-suggest {
  border: 1px solid var(--ims-border);
  border-radius: .65rem;
  background: #fff;
  max-height: 180px;
  overflow: auto;
}
.branch-map-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: .55rem .75rem;
  font-size: .82rem;
}
.branch-map-suggest-item:hover {
  background: rgba(13, 110, 253, .08);
}
.branch-map-pin {
  background: transparent;
  border: 0;
}
.branch-map-pin-dot {
  display: block;
  width: 14px;
  height: 14px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--ims-primary);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .25);
}
.branch-map-pin-label {
  display: block;
  margin-top: 2px;
  max-width: 120px;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: #0f172a;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.branch-map-pop strong {
  font-size: .95rem;
}
.branch-map-shell:fullscreen {
  padding: 1rem;
  background: var(--ims-surface);
}
.branch-map-shell:fullscreen #branchMap {
  min-height: calc(100vh - 2rem);
}
.branch-harita-map {
  height: 280px;
  border: 1px solid var(--ims-border);
  border-radius: .75rem;
  background: #e8edf3;
}
.branch-harita-results {
  max-height: 140px;
  overflow: auto;
}
@media (max-width: 992px) {
  .branch-map-shell {
    grid-template-columns: 1fr;
  }
  #branchMap {
    min-height: 55vh;
  }
}
