:root {
  --sidebar-width: 235px;
  --sidebar-bg: #14304a;
  --sidebar-text: #c3d4e4;
  --sidebar-hover: #1f4467;
  --sidebar-active: #2d7ff9;
  --topbar-height: 56px;
}

* { -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: 'Segoe UI', sans-serif; background: #f1f5f9; -webkit-text-size-adjust: 100%; }

/* ---- Giris ---- */
.login-wrapper {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #14304a 0%, #2d7ff9 100%); padding: 1rem;
}
.login-card { background: #fff; border-radius: 16px; padding: 2rem; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); }

/* ---- Yerlesim ---- */
#sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-width);
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 1040; overflow-y: auto;
  transition: transform 0.25s ease;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.sidebar-header { padding: 1rem; font-size: 1.05rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; }
.sidebar-user-bar { padding: 0.6rem 1rem; display: flex; align-items: center; font-size: 0.85rem;
  background: rgba(0,0,0,0.18); border-bottom: 1px solid rgba(255,255,255,0.06); }
.sidebar-user-bar .bi-person-circle { font-size: 1.4rem; }
.sidebar-user-bar small { color: #8fa8bf !important; }
#sidebar .nav-link { color: var(--sidebar-text); padding: 0.65rem 1rem; border-radius: 6px;
  margin: 1px 6px; font-size: 0.92rem; transition: background 0.15s; }
#sidebar .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
#sidebar .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-footer { margin-top: auto; padding: 0.85rem; border-top: 1px solid rgba(255,255,255,0.08); }

#mainContent { margin-left: var(--sidebar-width); min-height: 100vh; padding: 1.5rem;
  padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }

#topbar {
  display: none; background: var(--sidebar-bg); color: #fff; align-items: center; gap: 0.5rem;
  position: sticky; top: 0; z-index: 1030; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: env(safe-area-inset-top) 0.75rem 0 0.75rem;
  min-height: calc(var(--topbar-height) + env(safe-area-inset-top));
}
#topbar .topbar-title { font-weight: 700; flex: 1; font-size: 1rem; }
#sidebarToggle, #topbarLogout { background: transparent; border: 0; color: #fff; font-size: 1.5rem;
  width: 42px; height: 42px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
#topbarLogout { color: #ff9aa5; font-size: 1.35rem; }
#sidebarBackdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1035; }
#sidebarBackdrop.show { display: block; }

/* ---- Kartlar ---- */
.stat-card { background: #fff; border-radius: 12px; padding: 0.9rem 1.1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid transparent;
  display: flex; align-items: center; gap: 0.85rem; height: 100%; }
.stat-card .stat-icon { font-size: 1.9rem; opacity: 0.85; }
.stat-card .stat-val { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { font-size: 0.76rem; color: #6c757d; margin-top: 2px; }
.stat-card .stat-sub { font-size: 0.72rem; color: #94a3b8; }
.stat-card.blue { border-color: #2d7ff9; } .stat-card.blue .stat-icon { color: #2d7ff9; }
.stat-card.green { border-color: #16a34a; } .stat-card.green .stat-icon { color: #16a34a; }
.stat-card.orange { border-color: #f59e0b; } .stat-card.orange .stat-icon { color: #f59e0b; }
.stat-card.red { border-color: #dc2626; } .stat-card.red .stat-icon { color: #dc2626; }
.stat-card.purple { border-color: #7c3aed; } .stat-card.purple .stat-icon { color: #7c3aed; }
.stat-card.teal { border-color: #0d9488; } .stat-card.teal .stat-icon { color: #0d9488; }

.panel { background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.panel-head { padding: 0.75rem 1rem; border-bottom: 1px solid #e9edf2; font-weight: 600;
  color: #14304a; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.panel-body { padding: 1rem; }

.page-header { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.1rem; flex-wrap: wrap; gap: 0.5rem; }
.page-header h4 { margin: 0; font-weight: 700; color: #14304a; font-size: 1.25rem; }

/* ---- Tablo ---- */
.table-card { background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow: hidden; }
.table-card .table { margin: 0; font-size: 0.85rem; }
.table-card .table thead th { background: #f8fafc; border-bottom: 2px solid #e2e8f0; font-weight: 600;
  color: #475569; white-space: nowrap; font-size: 0.78rem; text-transform: uppercase; letter-spacing: .02em; }
.table-card .table tbody tr:hover { background: #f0f7ff; }
.table-card .table tfoot td { background: #f8fafc; font-weight: 700; border-top: 2px solid #e2e8f0; }
.table-responsive { max-height: 68vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.table-responsive thead th { position: sticky; top: 0; z-index: 2; }
.item-name-cell { min-width: 220px; max-width: 460px; white-space: normal; word-break: break-word;
  overflow-wrap: anywhere; line-height: 1.3; }
.code-cell { font-family: 'Consolas', monospace; font-size: 0.74rem; color: #475569; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Ilerleme cubugu ---- */
.mini-bar { height: 7px; border-radius: 4px; background: #e2e8f0; overflow: hidden; min-width: 60px; }
.mini-bar > span { display: block; height: 100%; background: #2d7ff9; }
.mini-bar.ok > span { background: #16a34a; }
.mini-bar.warn > span { background: #f59e0b; }
.mini-bar.bad > span { background: #dc2626; }

/* ---- Rozet ---- */
.badge-soft { padding: 3px 8px; border-radius: 20px; font-size: 0.74rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-idle { background: #e2e8f0; color: #475569; }

.verim-ok { color: #16a34a; font-weight: 600; }
.verim-warn { color: #f59e0b; font-weight: 600; }
.verim-bad { color: #dc2626; font-weight: 600; }

/* ---- Gunluk giris satirlari ---- */
.entry-row { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 0.75rem;
  margin-bottom: 0.6rem; }
.entry-row.filled { border-color: #86b7fe; box-shadow: 0 0 0 2px rgba(45,127,249,0.08); }
.entry-row .row-title { font-weight: 600; font-size: 0.88rem; color: #14304a; line-height: 1.3; }
.entry-row .row-code { font-family: 'Consolas', monospace; font-size: 0.72rem; color: #64748b; }
.calc-box { background: #f8fafc; border-radius: 8px; padding: 0.5rem 0.75rem; font-size: 0.8rem; }
.calc-box b { color: #14304a; }

/* ---- Arama sonuc listesi ---- */
.search-results { position: absolute; z-index: 1060; background: #fff; border: 1px solid #cbd5e1;
  border-radius: 8px; max-height: 320px; overflow-y: auto; box-shadow: 0 12px 28px rgba(0,0,0,0.15);
  width: 100%; }
.search-results .sr-item { padding: 0.5rem 0.7rem; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.search-results .sr-item:hover, .search-results .sr-item.active { background: #eff6ff; }
.search-results .sr-code { font-family: 'Consolas', monospace; font-size: 0.72rem; color: #2563eb; }
.search-results .sr-name { font-size: 0.84rem; color: #1e293b; line-height: 1.25; }
.search-results .sr-meta { font-size: 0.72rem; color: #64748b; }

/* ---- Grafikler ---- */
.chart-wrap { width: 100%; overflow-x: auto; }
.chart-wrap svg { display: block; }

.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; max-width: calc(100vw - 2rem); }

input[type=text], input[type=password], input[type=number], input[type=date], select, textarea { font-size: 16px; }

.form-label { font-size: .82rem; font-weight: 600; color: #475569; margin-bottom: .25rem; }
.help-text { font-size: .76rem; color: #64748b; }

/* ---- Duyarli ---- */
@media (max-width: 991px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.4); }
  #mainContent { margin-left: 0; padding: 1rem; }
  #topbar { display: flex; }
}
@media (max-width: 575px) {
  #mainContent { padding: 0.7rem; }
  .page-header h4 { font-size: 1.08rem; }
  .stat-card { padding: 0.7rem; gap: 0.55rem; }
  .stat-card .stat-icon { font-size: 1.5rem; }
  .stat-card .stat-val { font-size: 1.2rem; }
  .table-card .table { font-size: 0.76rem; }
  .table-card .table thead th, .table-card .table tbody td { padding: 0.4rem 0.35rem; }
  .btn-sm { padding: 0.3rem 0.55rem; font-size: 0.8rem; }
  .login-card { padding: 1.5rem; }
}
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #mainContent { margin: 0; padding: 0; }
  .table-responsive { max-height: none; overflow: visible; }
}

/* ---- Kapsam secici (proje / bina) ---- */
#contextBar {
  display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap;
  background: #fff; border-radius: 12px; padding: 0.7rem 0.9rem; margin-bottom: 1.1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); border-left: 4px solid #14304a;
}
#contextBar .ctx-field { display: flex; flex-direction: column; min-width: 200px; flex: 0 1 260px; }
#contextBar .ctx-field label { font-size: 0.72rem; font-weight: 600; color: #64748b;
  text-transform: uppercase; letter-spacing: .03em; margin-bottom: .2rem; }
#contextBar .ctx-info { flex: 1 1 200px; font-size: 0.8rem; color: #64748b; text-align: right;
  padding-bottom: .35rem; min-width: 160px; }
#contextBar .ctx-info b { color: #14304a; }
#contextBar select { font-size: 0.9rem; }

/* Proje / bina rozeti */
.chip { display: inline-flex; align-items: center; gap: .3rem; background: #eef2f7; color: #334155;
  border-radius: 20px; padding: 2px 10px; font-size: 0.75rem; font-weight: 600; }
.chip.proje { background: #e0edff; color: #1e40af; }
.chip.bina { background: #e7f7ee; color: #166534; }

/* Proje karti */
.proje-card { background: #fff; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  padding: 1rem; height: 100%; border-top: 3px solid #2d7ff9; }
.proje-card.pasif { opacity: .6; border-top-color: #94a3b8; }
.proje-card h6 { font-weight: 700; color: #14304a; margin-bottom: .15rem; }
.proje-card .kod { font-family: 'Consolas', monospace; font-size: .74rem; color: #64748b; }
.proje-card .metrik { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-top: .7rem; }
.proje-card .metrik div span { display: block; font-size: .72rem; color: #64748b; }
.proje-card .metrik div b { font-size: .95rem; color: #14304a; }

@media (max-width: 575px) {
  #contextBar { padding: 0.6rem; gap: 0.5rem; }
  #contextBar .ctx-field { flex: 1 1 100%; min-width: 0; }
  #contextBar .ctx-info { text-align: left; flex: 1 1 100%; }
}
