:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #171c26;
  --text-2: #475467;
  --muted: #7a8699;
  --primary: #2563eb;
  --primary-hover: #1d4fd7;
  --primary-soft: #eff4ff;
  --green: #12924a;
  --green-soft: #e8f6ee;
  --red: #d92d20;
  --red-hover: #b9251a;
  --red-soft: #fdecea;
  --amber: #b76e00;
  --amber-soft: #fdf3dc;
  --gray-dot: #98a2b3;
  --gray-soft: #f0f2f5;
  --sidebar: #111827;
  --sidebar-text: #aab3c2;
  --sidebar-head: #6b7689;
  --sidebar-active: #1f2a40;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .18);
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #151b24;
  --surface-2: #1a212c;
  --border: #262f3d;
  --border-strong: #364152;
  --text: #e6eaf0;
  --text-2: #b3bccb;
  --muted: #7d8899;
  --primary: #4f8cff;
  --primary-hover: #6b9eff;
  --primary-soft: #16233d;
  --green: #3ecf7c;
  --green-soft: #11281c;
  --red: #f26b60;
  --red-hover: #f58379;
  --red-soft: #33181a;
  --amber: #f0b54a;
  --amber-soft: #33270f;
  --gray-dot: #5d6878;
  --gray-soft: #1f2733;
  --sidebar: #0a0e14;
  --sidebar-active: #18212f;
  --shadow: none;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
.mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- yerleşim ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px; color: #fff; font-weight: 600; font-size: 15px; letter-spacing: .1px; }
.brand img { width: 26px; height: 26px; }
.nav { padding: 4px 8px 16px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-title { padding: 0 10px 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--sidebar-head); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--sidebar-text); font-weight: 500; border-left: 2px solid transparent; }
.nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--primary); }
.nav a.active svg { color: #7fa8ff; }
.nav svg { width: 16px; height: 16px; flex: none; }
.sidebar-foot { padding: 12px 16px; font-size: 11.5px; color: var(--sidebar-head); border-top: 1px solid rgba(255, 255, 255, .06); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 16px; font-weight: 600; margin-right: auto; white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.btn.menu-btn { display: none; }
.sync { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.user { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--border); font-size: 12.5px; white-space: nowrap; }
.user b { font-weight: 600; }
.content { padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- temel bileşenler ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { background: var(--red-hover); }
.btn.icon { width: 32px; padding: 0; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-soft); }
.spin svg, svg.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select { height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); min-width: 0; }
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11.5px; font-weight: 600; color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2 { font-size: 13.5px; font-weight: 600; }
.card-body { padding: 16px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--gray-dot); flex: none; }
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.warn { background: var(--amber); }
.state { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.state.off { color: var(--muted); }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.tag { display: inline-block; padding: 1px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 11px; color: var(--muted); }

.switch { position: relative; width: 32px; height: 18px; flex: none; padding: 0; border: 0; border-radius: 9px; background: var(--gray-dot); cursor: pointer; transition: background .12s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .12s; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(14px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }
.switch.busy { cursor: progress; opacity: .6; }
.switch.busy::after { border: 2px solid var(--gray-dot); border-top-color: transparent; background: #fff; animation: spin .7s linear infinite; }
.switch.busy[aria-checked="true"]::after { animation: spin-on .7s linear infinite; }
@keyframes spin-on { from { transform: translateX(14px) rotate(0); } to { transform: translateX(14px) rotate(360deg); } }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 8px; border: 1px solid; font-size: 13px; }
.banner svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.banner.bad { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 30%, transparent); color: var(--red); }
.banner.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.banner.info { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 25%, transparent); color: var(--text-2); }
.banner span { color: var(--text); }

/* ---------- filtre çubuğu ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters .grow { flex: 1 1 220px; }
.filters .input, .filters .select { width: 100%; }
.filters .field { min-width: 130px; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; height: 32px; }
.seg button { border: 0; background: var(--surface); padding: 0 11px; cursor: pointer; font-weight: 500; color: var(--text-2); border-right: 1px solid var(--border-strong); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary-soft); color: var(--primary); }

/* ---------- tablolar ---------- */
.table-wrap { overflow: auto; max-height: max(320px, calc(100vh - 290px)); min-height: 120px; }
.table-wrap.free { max-height: none; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 8px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 11.5px; font-weight: 600; color: var(--text-2); letter-spacing: .02em; vertical-align: bottom; }
th small { display: block; margin-top: 1px; font: 400 11.5px var(--mono); color: var(--muted); letter-spacing: 0; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
td.wrap { white-space: normal; min-width: 220px; }
.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); border-right: 1px solid var(--border); }
th.sticky-col { z-index: 3; background: var(--surface-2); }
.cell { display: flex; align-items: center; justify-content: center; gap: 8px; }
/* Prefix matrisi: sütunlar dar tutulur ki tüm operatörler ekrana sığsın. */
.matrix th, .matrix td { padding: 8px 10px; }
.matrix th:not(.sticky-col), .matrix td:not(.sticky-col) { text-align: center; }
.matrix th:not(.sticky-col) { white-space: normal; min-width: 76px; max-width: 132px; line-height: 1.25; }
.matrix th small { font-size: 10.5px; overflow-wrap: anywhere; }
.none { color: var(--muted); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.pager { display: flex; align-items: center; gap: 8px; }
.pager .select { height: 28px; }
.pager .btn { height: 28px; }

.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 48px 20px; text-align: center; color: var(--muted); }
.placeholder svg { width: 28px; height: 28px; }
.placeholder b { color: var(--text); font-size: 14px; font-weight: 600; }
.placeholder.err svg { color: var(--red); }
.skeleton { padding: 14px 16px; display: grid; gap: 10px; }
.skeleton i { display: block; height: 14px; border-radius: 4px; background: var(--gray-soft); animation: pulse 1.2s ease-in-out infinite; }
.skeleton i:nth-child(3n) { width: 72%; }
.skeleton i:nth-child(3n+1) { width: 90%; }
@keyframes pulse { 50% { opacity: .45; } }

/* ---------- genel bakış ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 14px 16px; }
.stat h3 { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.stat .big { margin: 6px 0 10px; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-top: 1px solid var(--border); font-size: 12.5px; }
.kv > span:first-child { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); }
.kv b { font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .val { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row .sub { font-size: 12px; color: var(--muted); }

td.rate { min-width: 170px; }
.bar { height: 4px; margin-top: 4px; border-radius: 2px; background: var(--gray-soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 2px; background: var(--primary); }
.bar.tx i { background: var(--green); }
.head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.if-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; padding: 16px; }
.if-tile { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: grid; gap: 8px; min-width: 0; }
.if-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.if-name { display: grid; min-width: 0; }
.if-name b, .if-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.if-name span { font-size: 12px; min-height: 16px; }
.if-gauges { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.if-foot { font-size: 11.5px; border-top: 1px solid var(--border); padding-top: 8px; }
.gauge { display: grid; justify-items: center; min-width: 0; }
.g-svg { width: 100%; max-width: 150px; display: block; overflow: visible; }
.g-track, .g-val { fill: none; stroke-width: 9; stroke-linecap: round; }
.g-track { stroke: var(--gray-soft); }
.g-val { stroke: var(--primary); }
.gauge.warn .g-val { stroke: var(--amber); }
.gauge.crit .g-val { stroke: var(--red); }
.g-tick { stroke: var(--border-strong); stroke-width: 1; }
.g-needle { stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.g-hub { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.gauge.idle .g-hub { fill: var(--gray-dot); }
.g-scale { width: 100%; max-width: 150px; display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.g-value { font-size: 15px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.g-label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 11.5px; color: var(--text-2); min-height: 20px; }
.settings .wide { grid-column: 1 / -1; }
.input.cap { width: 120px; height: 28px; }
.btn.mini { height: 24px; min-width: 24px; padding: 0 6px; }
td.order { white-space: nowrap; }
td.order .mono { display: inline-block; min-width: 20px; }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; background: rgba(10, 14, 22, .5); overflow-y: auto; }
.modal { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 10px 10px; }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.dl dt, .dl dd { margin: 0; padding: 7px 12px; border-bottom: 1px solid var(--border); }
.dl dt { background: var(--surface-2); color: var(--text-2); font-size: 12.5px; }
.dl dd { overflow-wrap: anywhere; }
.dl dt:nth-last-of-type(1), .dl dd:nth-last-of-type(1) { border-bottom: 0; }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline .ev { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; display: grid; gap: 4px; }
.timeline .ev-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline .err { color: var(--red); overflow-wrap: anywhere; }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(400px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 8px; box-shadow: var(--shadow-lg); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--green); }
.toast.err svg { color: var(--red); }
.toast.warn svg { color: var(--amber); }
.toast .msg { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .msg small { display: block; margin-top: 2px; color: var(--muted); font-family: var(--mono); }
.toast .x { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 16px; line-height: 1; }

/* ---------- giriş ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login .brand { padding: 0; color: var(--text); font-size: 17px; }
.login p { color: var(--text-2); }
.login .btn { height: 36px; }
.form-err { color: var(--red); font-size: 12.5px; min-height: 18px; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- duyarlı ---------- */
.scrim { display: none; }
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 60; left: 0; width: 240px; transform: translateX(-100%); transition: transform .15s; }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 50; background: rgba(10, 14, 22, .5); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .content { padding: 14px 12px 32px; }
  .sync span:not(.dot), .user > span, .refresh-text { display: none; }
  .user { padding-left: 4px; border-left: 0; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { max-height: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Kullanıcılar */
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions .btn { height: 28px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
td b + .badge { margin-left: 8px; }

/* Bildirim ayarları */
.notify-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; align-items: start; }
.group { display: flex; flex-direction: column; gap: 10px; min-width: 0; margin: 0; padding: 12px 14px 14px; border: 1px solid var(--border); border-radius: 8px; }
.group legend { padding: 0 6px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.group p { margin: 0; font-size: 12.5px; }
.group .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.group .row .grow { flex: 1 1 140px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
/* API belgesi */
.code { position: relative; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.code pre { margin: 0; padding: 12px 14px; padding-right: 84px; overflow-x: auto; font: 12.5px/1.55 var(--mono); color: var(--text); white-space: pre; }
.code .btn { position: absolute; top: 6px; right: 6px; background: var(--surface); border-color: var(--border); }
.method { display: inline-block; min-width: 54px; margin-right: 10px; padding: 2px 8px; border-radius: 4px; font: 600 11.5px var(--mono); text-align: center; background: var(--gray-soft); color: var(--text-2); }
.method.get { background: var(--green-soft); color: var(--green); }
.method.post { background: var(--primary-soft); color: var(--primary); }
.method.delete { background: var(--red-soft); color: var(--red); }
.notes { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
td.bh-actions { white-space: nowrap; }
td.bh-actions .btn { margin-left: 10px; vertical-align: middle; }
td.bh-actions .switch { vertical-align: middle; }
