:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --track: #eef0f3;
  --s1: #2563eb; --s2: #db2777; --s3: #0891b2; --s4: #ca8a04;
  --s5: #7c3aed; --s6: #16a34a; --s7: #ea580c; --s8: #64748b;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a21;
    --text: #e6e8ec;
    --muted: #8b93a1;
    --line: #262b35;
    --accent: #60a5fa;
    --ok: #22c55e;
    --warn: #f59e0b;
    --bad: #f87171;
    --track: #232833;
    --s1: #60a5fa; --s2: #f472b6; --s3: #22d3ee; --s4: #facc15;
    --s5: #a78bfa; --s6: #4ade80; --s7: #fb923c; --s8: #94a3b8;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h2, h3, h4 { margin: 0; font-weight: 600; }
h3 { font-size: 14px; }
h4 { font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.stale { background: var(--bad); }
.top-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.link { color: var(--accent); text-decoration: none; background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  background: transparent; border: 0; color: var(--muted); padding: 5px 10px; cursor: pointer; font: inherit;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
.seg.small button { padding: 3px 8px; font-size: 12px; }

main { padding: 20px 24px 40px; display: grid; gap: 16px; max-width: 1600px; margin: 0 auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.tile .lbl { color: var(--muted); font-size: 12px; }
.tile .val { font-size: 24px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bar { height: 5px; border-radius: 3px; background: var(--track); margin-top: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.card > h3 { margin-bottom: 10px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.head-tools { display: flex; gap: 12px; align-items: center; }
.head-tools input[type=search] {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font: inherit; width: 200px;
}
.chk { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }

.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2.tight { gap: 12px; margin: 12px 0; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

.chart { position: relative; height: 200px; }
.chart.tall { height: 280px; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px;
  padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
#ct-table th { cursor: pointer; user-select: none; }
#ct-table th.sorted::after { content: " ▾"; }
#ct-table th.sorted.asc::after { content: " ▴"; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:last-child td { border-bottom: 0; }
#ct-table tbody tr { cursor: pointer; }
#ct-table tbody tr:hover, #site-table tbody tr:hover { background: var(--bg); }
.tbl td.cmd { max-width: 280px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.name-cell b { font-weight: 600; }
.name-cell .muted { font-size: 12px; margin-left: 6px; }
.mini { display: inline-block; width: 60px; height: 4px; background: var(--track); border-radius: 2px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.mini > i { display: block; height: 100%; background: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.off { color: var(--muted); }

.strip { display: inline-flex; gap: 1px; vertical-align: middle; }
.strip i { width: 3px; height: 16px; border-radius: 1px; background: var(--ok); opacity: .85; }
.strip i.down { background: var(--bad); }
.strip i.none { background: var(--track); }

.events { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 13px; }
.events li { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.events li:last-child { border-bottom: 0; }
.events .t { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .empty { display: block; color: var(--muted); }

.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; justify-content: flex-end; }
.drawer[hidden] { display: none; }
.drawer-inner { width: min(760px, 100%); height: 100%; background: var(--card); padding: 20px; overflow-y: auto; border-left: 1px solid var(--line); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.kv div { background: var(--bg); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.kv span { display: block; color: var(--muted); font-size: 11px; }
.kv b { font-weight: 600; font-size: 13px; word-break: break-all; }
.logs {
  background: #0b0d11; color: #cfd6e2; border-radius: 8px; padding: 12px; font-size: 11.5px;
  line-height: 1.5; max-height: 420px; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0;
}

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(360px, 100%); display: grid; gap: 12px; }
.login-card p { margin: 0; }
.login-card input {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 10px 12px; font: inherit;
}
.login-card button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; }
  main { padding: 16px; }
  .head-tools input[type=search] { width: 140px; }
}

/* tıklanabilir kutular ve kırılım paneli */
.tile.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
.tile.clickable:hover, .tile.clickable:focus-visible { border-color: var(--accent); outline: none; }
.tile .lbl { display: flex; justify-content: space-between; gap: 6px; }
.tile .more { color: var(--accent); font-size: 11px; opacity: 0; transition: opacity .15s; }
.tile.clickable:hover .more, .tile.clickable:focus-visible .more { opacity: 1; }
@media (hover: none) { .tile .more { opacity: 1; } }
#bd-body .intro { margin: 4px 0 8px; }
#bd-body .note { background: var(--bg); border-left: 3px solid var(--warn); padding: 6px 10px; border-radius: 4px; font-size: 12px; }
#bd-body .sec { margin: 18px 0 6px; color: var(--text); font-size: 13px; }
#bd-body .table-wrap { margin-bottom: 6px; }
.tbl tr.total td { color: var(--muted); font-weight: 500; border-top: 1px solid var(--line); }
.tbl td.share { min-width: 130px; font-variant-numeric: tabular-nums; color: var(--muted); }
.sbar { display: inline-block; width: 70px; height: 6px; background: var(--track); border-radius: 3px; margin-right: 8px; vertical-align: middle; overflow: hidden; }
.sbar > i { display: block; height: 100%; background: var(--accent); }
.tag { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
a.link[data-ct] { cursor: pointer; }
