:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --ink: #111c3a;
  --ink-2: #4b5670;
  --muted: #8a93a8;
  --line: #e6eaf2;
  --accent: #4361ee;
  --accent-soft: #eef1ff;
  --green: #17a673;
  --green-soft: #e7f7f0;
  --orange: #f2813a;
  --orange-soft: #fff1e8;
  --red: #e0474c;
  --red-soft: #fdeceD;
  --brand: #f5c518;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(17, 28, 58, .04), 0 10px 30px -12px rgba(17, 28, 58, .12);
}
body { font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif; letter-spacing: -.005em; }
.topbar { background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(8px); box-shadow: 0 1px 0 var(--line); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); }
.nav-head { border-radius: 12px; }
.nav-group.open > .nav-head { background: var(--accent-soft); }
.card { border: 1px solid var(--line); }
.page-title { letter-spacing: -.02em; }
.btn { box-shadow: 0 1px 2px rgba(67, 97, 238, .25); transition: transform .12s ease, filter .12s ease; }
.btn:hover { transform: translateY(-1px); }
.input, .select { border-color: var(--line); background: #fbfcfe; }
th { background: #f8f9fc; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.4;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 72px; background: var(--surface);
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  box-shadow: 0 1px 0 var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 36px; height: 36px; }
.brand-logo { height: 44px; width: auto; display: block; border-radius: 6px; }
.brand-text { font-size: 15px; color: var(--ink-2); }
.brand-text b { font-weight: 600; }
.brand-sub { font-size: 30px; font-weight: 800; color: var(--ink); margin-left: 6px; letter-spacing: .5px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 24px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 700; cursor: pointer; }
.caret { font-size: 12px; }
.icon-btn {
  background: none; border: 0; padding: 6px; border-radius: 10px;
  color: var(--ink); cursor: pointer; display: inline-flex;
}
.icon-btn:hover { background: var(--accent-soft); }
#menuBtn { display: none; }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - 72px); }
.sidebar {
  width: 260px; flex: 0 0 260px; background: var(--surface);
  padding: 14px 12px 40px; border-right: 1px solid var(--line);
  overflow-y: auto; position: sticky; top: 72px; height: calc(100vh - 72px);
}
.content { flex: 1; min-width: 0; padding: 26px 28px 60px; }

/* ---------- Sidebar ---------- */
.nav-group { margin-bottom: 4px; }
.nav-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; border: 0; background: none; border-radius: 10px;
  font-weight: 700; color: var(--ink); cursor: pointer; text-align: left;
}
.nav-head:hover { background: var(--bg); }
.nav-head .chev { margin-left: auto; color: var(--muted); transition: transform .2s; }
.nav-group.open > .nav-head .chev { transform: rotate(180deg); }
.nav-head svg { flex: 0 0 22px; color: var(--ink-2); }
.nav-group.open > .nav-head { color: var(--accent); background: var(--accent-soft); }
.nav-group.open > .nav-head svg { color: var(--accent); }
.nav-items { display: none; padding: 4px 0 8px 12px; }
.nav-group.open .nav-items { display: block; }
.nav-items a {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-size: 14px;
}
.nav-items a::before {
  content: ""; width: 7px; height: 7px; border: 1.5px solid var(--muted);
  border-radius: 50%; margin-top: 6px; flex: 0 0 7px;
}
.nav-items a:hover { background: var(--bg); color: var(--ink); }
.nav-items a.active { color: var(--accent); background: var(--accent-soft); }
.nav-items a.active::before { border-color: var(--accent); background: var(--accent); }

/* ---------- Cards ---------- */
.grid { display: grid; gap: 18px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.dash-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); margin-bottom: 18px; }
.dash-bottom { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.dash-bottom td { white-space: nowrap; }
.dash-bottom td:first-child { white-space: normal; min-width: 150px; }
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; min-width: 0;
}
.card-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 19px; font-weight: 700; margin: 0; }
.card-sub { color: var(--muted); font-size: 14px; }
.card-head .more { margin-left: auto; color: var(--muted); letter-spacing: 2px; cursor: pointer; background: none; border: 0; }

.kpi { display: flex; flex-direction: column; gap: 12px; }
.kpi-top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-title { font-size: 17px; font-weight: 700; color: var(--ink); }
.kpi-row { display: flex; align-items: center; gap: 16px; }
.kpi-val { font-size: 34px; font-weight: 800; letter-spacing: .3px; }
.kpi-ico {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 74px;
}
.kpi-ico.blue { background: #f0f3ff; color: #5b6df0; }
.kpi-ico.green { background: var(--green-soft); color: var(--green); }
.kpi-ico.orange { background: var(--orange-soft); color: var(--orange); }
.kpi-num {
  width: 44px; height: 44px; border: 2.5px solid currentColor; border-radius: 6px;
  display: grid; place-items: center; font-weight: 800; font-size: 22px;
}

/* ---------- Chart ---------- */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 18px; justify-content: center; margin-top: 8px; font-size: 14px; color: var(--ink-2); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.tip {
  position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px; display: none; min-width: 170px;
}
.tip b { display: block; margin-bottom: 6px; }
.tip span { display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--ink); font-weight: 700; background: #fafbfe; white-space: nowrap; }
td { color: var(--ink-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: #fbfcff; }
tr.muted td { color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.blue { background: var(--accent-soft); color: var(--accent); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.orange { background: var(--orange-soft); color: var(--orange); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.gray { background: #eef0f5; color: var(--ink-2); }
.empty { text-align: center; padding: 40px 10px; color: var(--ink-2); font-size: 17px; }

/* ---------- Page header & toolbar ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.crumbs a:hover { color: var(--accent); }
.page-title { font-size: 24px; font-weight: 800; margin: 0; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.input, .select {
  height: 40px; border: 1px solid #d5dcea; border-radius: 10px; padding: 0 12px;
  background: #fff; min-width: 0;
}
.input:focus, .select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn {
  height: 40px; border: 0; border-radius: 10px; padding: 0 18px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn:hover { filter: brightness(.96); }
.btn.ghost { background: #fff; color: var(--accent); border: 1px solid #cfdcff; }
.btn.light { background: #eef1f7; color: var(--ink); }
.note {
  background: #e9f7fb; border: 1px solid #c4e7f2; color: #1d4f63; border-radius: 12px;
  padding: 14px 18px; margin-bottom: 16px; font-size: 14px;
}
.note.warn { background: var(--red-soft); border-color: #f2c9c9; color: #7a2323; }

/* ---------- Announcements ---------- */
.news-title { font-size: 19px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.news-date { color: var(--muted); font-weight: 500; font-size: 15px; }
.news-body p { margin: 0 0 12px; color: var(--ink-2); }
.news-body b { color: var(--ink); }
.news-card + .news-card { margin-top: 18px; }

/* ---------- Averages ---------- */
.avg-table td, .avg-table th { padding: 13px 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: .25s; font-size: 14px; z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-main, .dash-bottom { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #menuBtn { display: inline-flex; }
  .brand-sub { font-size: 22px; }
  .brand-text { display: none; }
  .sidebar {
    position: fixed; top: 72px; left: 0; height: calc(100vh - 72px); z-index: 30;
    transform: translateX(-105%); transition: transform .25s; box-shadow: var(--shadow);
  }
  body.menu-open .sidebar { transform: translateX(0); }
  .content { padding: 18px 16px 48px; }
  .user-chip span:not(.caret) { display: none; }
  .top-right { gap: 8px; }
  .kpi-val { font-size: 28px; }
  .kpi-ico { width: 60px; height: 60px; flex-basis: 60px; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .field { min-width: 0; flex: 1 1 100%; }
}

/* ---------- Giriş ekranı ---------- */
body.auth .sidebar { display: none; }
body.auth .content { padding-top: 40px; }
.login-wrap { display: grid; place-items: center; min-height: 60vh; }
.login-card { width: min(420px, 100%); }

/* ---------- Giriş güvenliği (QR) ---------- */
.mfa-qr img { background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--line); max-width: 100%; height: auto; }
.mfa-qr { margin: 8px 0 4px; }
code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }

/* ---------- Kayıt penceresi ve ağaç listesi ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 42, 107, .35); display: grid; place-items: center; padding: 16px; z-index: 60; }
.modal { width: min(760px, 100%); max-height: 90vh; overflow: auto; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0 2px; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- Türkiye ölçüm haritası ---------- */
.rad-map { height: 340px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.rad-empty { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 15px; }
.rad-frame { width: 100%; height: 520px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); display: block; }
@media (max-width: 480px) { .rad-frame { height: 420px; } }

/* ---------- Akıcılık ve cila ---------- */
.content > * { animation: pg-in .35s ease both; }
@keyframes pg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { transition: box-shadow .2s ease, transform .2s ease; }
.card:hover { box-shadow: 0 2px 4px rgba(17, 28, 58, .05), 0 16px 36px -14px rgba(17, 28, 58, .18); }

.nav-head, .nav-items a { transition: background-color .15s ease, color .15s ease; }
.nav-items a.active { font-weight: 600; }

tr { transition: background-color .15s ease; }
tbody tr:hover td { background: #f7f9ff; }

.btn, .btn.ghost, .chat-send, .chat-chip, .icon-btn { transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease, border-color .15s ease; }
.btn:active, .chat-send:active { transform: scale(.98); }
.icon-btn:hover { background: var(--accent-soft); }

.input, .select { transition: border-color .15s ease, box-shadow .15s ease; }
.input:focus, .select:focus { box-shadow: 0 0 0 3px var(--accent-soft); }

.toast { backdrop-filter: blur(6px); border-radius: 14px; }

.kpi-ico { transition: transform .25s ease; }
.card:hover .kpi-ico { transform: scale(1.06); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
