:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --sidebar: #16263d;
  --sidebar-fg: #cfd8e3;
  --sidebar-active: #24395a;
  --fg: #1c2430;
  --muted: #677385;
  --border: #e1e5eb;
  --accent: #2563eb;
  --accent-fg: #ffffff;
  --row-alt: #fafbfc;
  --row-hover: #eef4ff;
  --head-bg: #f0f2f5;
  --total-bg: #e9eef6;
  --error: #b42318;
  --error-bg: #fef3f2;
  --zero: #b6bdc8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b;
    --panel: #161d27;
    --sidebar: #0b1017;
    --sidebar-fg: #aeb9c7;
    --sidebar-active: #1c2a3d;
    --fg: #e4e9f0;
    --muted: #8b97a8;
    --border: #263142;
    --accent: #4f8cff;
    --row-alt: #18202b;
    --row-hover: #1d2b40;
    --head-bg: #1b2430;
    --total-bg: #1f2b3b;
    --error: #ff8a80;
    --error-bg: #2a1716;
    --zero: #4b5666;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; background: var(--bg); color: var(--fg); }

/* Sidebar */
.sidebar {
  width: 260px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-fg);
  display: flex; flex-direction: column; padding: 16px 12px; height: 100vh; position: sticky; top: 0; align-self: flex-start;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 16px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.brand-title { color: #fff; font-weight: 600; }
.brand-sub { font-size: 12px; opacity: .75; }
.sidebar .search { background: rgba(255,255,255,.07); border-color: transparent; color: #fff; margin-bottom: 12px; }
nav { flex: 1; overflow-y: auto; }
.nav-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .6; margin: 14px 8px 6px; }
.nav-item { display: block; padding: 8px 10px; border-radius: 6px; color: inherit; text-decoration: none; cursor: pointer; }
.nav-item:hover { background: rgba(255,255,255,.05); }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.sidebar-foot { font-size: 11px; opacity: .55; padding: 8px 6px 0; }

/* Main */
main { flex: 1; min-width: 0; padding: 24px 28px; }
h1 { font-size: 22px; margin: 0 0 4px; }
.crumb { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.desc { color: var(--muted); margin: 4px 0 0; max-width: 900px; line-height: 1.45; }
.empty { padding: 80px 0; text-align: center; color: var(--muted); }

.params {
  margin-top: 18px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end;
}
.param-fields { display: flex; flex-wrap: wrap; gap: 12px 16px; flex: 1; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.field label { font-size: 12px; color: var(--muted); }
.param-actions { display: flex; gap: 8px; }
input, select {
  font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 7px 9px; min-height: 34px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search { width: 100%; }
.search.small { width: 240px; }
.btn { font: inherit; border: 1px solid var(--border); background: var(--panel); color: var(--fg);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; min-height: 34px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn:disabled { opacity: .5; cursor: default; }

.status { margin: 12px 0; color: var(--muted); min-height: 18px; }
.status.error { color: var(--error); background: var(--error-bg); padding: 10px 12px; border-radius: 6px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.tab { border: 0; background: none; color: var(--muted); padding: 6px 14px; border-radius: 6px; cursor: pointer; font: inherit; }
.tab.active { background: var(--accent); color: var(--accent-fg); }

.kpis { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; }
.kpi .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 11px; color: var(--muted); }

.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: calc(100vh - 330px); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: left; }
th { background: var(--head-bg); position: sticky; top: 0; z-index: 1; cursor: pointer; user-select: none; font-weight: 600; }
th .arrow { opacity: .5; font-size: 10px; margin-left: 4px; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.zero { color: var(--zero); }
td.neg { color: var(--error); font-weight: 600; }
tr.drill { cursor: pointer; }
tfoot td { background: var(--total-bg); font-weight: 600; position: sticky; bottom: 0; }
td.sticky, th.sticky { position: sticky; left: 0; background: inherit; }
.more { padding: 10px; text-align: center; color: var(--muted); }

@media (max-width: 800px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  main { padding: 16px; }
  .search.small { width: 100%; }
}

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--head-bg); }
.badge.ok { background: #e3f6e8; color: #17663a; }
.badge.warn { background: #fff4d6; color: #8a5a00; }
.badge.bad { background: #fde8e7; color: #b42318; }
.badge.info { background: #e6efff; color: #1d4ed8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge.ok { background: #143323; color: #7ee2a8; }
  :root:not([data-theme="light"]) .badge.warn { background: #3a2c0b; color: #f5c26b; }
  :root:not([data-theme="light"]) .badge.bad { background: #3a1715; color: #ff8a80; }
  :root:not([data-theme="light"]) .badge.info { background: #172846; color: #8fb4ff; }
}

/* Harita */
.map-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 12px; height: max(460px, calc(100vh - 330px)); }
.map-wrap[hidden] { display: none; }
#map { border: 1px solid var(--border); border-radius: 10px; min-height: 420px; z-index: 0; }
.map-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px; overflow-y: auto; font-size: 13px; }
.map-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.btn.small { padding: 4px 10px; min-height: 28px; font-size: 12px; }
.auto { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.auto input { min-height: auto; }
.rep { border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px; margin-bottom: 6px; cursor: pointer; }
.rep:hover { border-color: var(--accent); }
.rep.off { opacity: .45; }
.rep-name { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.rep-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.rep-stats { color: var(--muted); margin-top: 3px; line-height: 1.5; }
.rep-stats b { color: var(--fg); font-weight: 600; }
.rep-bar { height: 5px; background: var(--head-bg); border-radius: 3px; margin-top: 5px; overflow: hidden; }
.rep-bar span { display: block; height: 100%; }
.stale { color: var(--error); }
.legend { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.9; }
.lg { display: inline-block; vertical-align: middle; margin-right: 7px; }
.lg.dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #2563eb; }
.lg.full { background: #2563eb; }
.lg.half { background: rgba(37, 99, 235, .3); }
.lg.dash { background: #2563eb; border-style: dashed; border-color: #111; }
.lg.ring { background: transparent; }
.lg.pin { width: 14px; height: 14px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: #2563eb; border: 2px solid #fff; box-shadow: 0 0 0 1px #2563eb; }
.lg.line { width: 18px; height: 3px; background: #2563eb; border-radius: 2px; }
.pin-icon { background: none; border: 0; }
.pin-icon div { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.45); display: grid; place-items: center; }
.pin-icon span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 11px; }
.leaflet-popup-content { font-size: 13px; line-height: 1.45; }
@media (max-width: 900px) {
  .map-wrap { grid-template-columns: 1fr; height: auto; }
  #map { height: 60vh; }
}

.map-panel-head.opts { justify-content: flex-start; gap: 14px; flex-wrap: wrap; }
.road-status { font-size: 11px; color: var(--muted); }
.road-status.err { color: var(--error); }
.lg.line.dashed { background: repeating-linear-gradient(90deg, #2563eb 0 5px, transparent 5px 8px); }
.rep-road { color: var(--muted); }
.lg.line.dotted { background: repeating-linear-gradient(90deg, #111 0 3px, transparent 3px 6px); height: 4px; }
.seq-icon { background: none; border: 0; }
.seq-icon div { width: 20px; height: 20px; border-radius: 50%; background: #111; color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.saving { color: #16a34a; font-weight: 600; }
#userBox { margin-bottom: 4px; word-break: break-all; }
#userBox a { color: inherit; }

/* Giriş ve hesap sayfaları */
.auth-page { align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.auth-brand { padding: 0 0 6px; }
.auth-brand .brand-title { color: var(--fg); }
.auth-card .btn { width: 100%; }
.auth-note { color: var(--muted); font-size: 12px; margin: 0; text-align: center; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-top: 18px; }
.panel h2 { font-size: 16px; margin: 0 0 8px; }
.panel .params { margin-top: 8px; border: 0; padding: 0; background: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.user-form { flex-direction: column; align-items: stretch !important; border-top: 1px solid var(--border) !important; margin-top: 16px !important; padding-top: 14px !important; }
.user-form h3 { margin: 0; font-size: 15px; }
.perm-title { font-size: 12px; color: var(--muted); margin: 10px 0 6px; }
.perm-list { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.muted { color: var(--muted); }
.btn.danger { border-color: var(--error); color: var(--error); }
#userBox a, .user-links a { color: inherit; }
.user-links { margin-bottom: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
