:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #dcdfe5;
  --text: #1c2230;
  --muted: #5d6677;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --accent-soft: #e4edfa;
  --ok: #17794a;
  --ok-soft: #e0f3e9;
  --warn: #93590a;
  --warn-soft: #fbf0d9;
  --bad: #b3261e;
  --bad-soft: #fbe6e4;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --surface-2: #242934;
    --border: #333947;
    --text: #e8eaef;
    --muted: #a0a8b7;
    --accent: #7fb0f5;
    --accent-text: #0d1420;
    --accent-soft: #1f2e45;
    --ok: #62cf98;
    --ok-soft: #17322a;
    --warn: #e6b65c;
    --warn-soft: #3a2f17;
    --bad: #f28b82;
    --bad-soft: #402220;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
[hidden] { display: none !important; }

/* Üst bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 0 20px; min-height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; }
.nav { display: flex; gap: 2px; align-self: stretch; }
.nav a {
  display: flex; align-items: center; padding: 0 12px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; border-top: 2px solid transparent;
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
main { max-width: 1320px; margin: 0 auto; padding: 20px; }

/* Düğme ve alanlar */
button {
  font: inherit; font-weight: 500; cursor: pointer;
  padding: 6px 12px; min-height: 32px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0 2px; min-height: 0; }
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 8px; min-height: 32px; max-width: 100%;
}
input[type="checkbox"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }

/* Kart ve tablolar */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.card-body { padding: 14px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
th.num { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
tr.changed td { background: var(--accent-soft); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

/* Etiketler */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--accent-soft); color: var(--accent); }

/* Özet kutuları */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tile .value { font-size: 26px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .label { color: var(--muted); font-size: 12.5px; }
.tile.warn .value { color: var(--warn); }
.tile.bad .value { color: var(--bad); }

.statusbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--warn); }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.checklist li::before { content: "✓"; display: inline-block; width: 18px; color: var(--ok); font-weight: 700; }
.checklist li.missing::before { content: "!"; color: var(--warn); }

.subtabs { display: flex; gap: 4px; }
.subtabs button { border-color: transparent; background: none; color: var(--muted); }
.subtabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }

/* Eşleme */
.progress { width: 180px; height: 8px; accent-color: var(--accent); }
.bulkbar {
  position: sticky; top: 52px; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}
.savebar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: var(--surface);
  border-top: 1px solid var(--border);
}
td input.resp { width: 190px; }
td select { max-width: 170px; }
td.wrap { min-width: 140px; }

/* Ayarlar */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px 20px; }
.form-grid input:not([type="checkbox"]) { width: 100%; }
.check-field { display: flex; gap: 8px; align-items: center; font-weight: 500; min-height: 32px; }
.result { font-size: 13px; }
.result.ok { color: var(--ok); }
.result.bad { color: var(--bad); }

/* Giriş */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 18px; }
.error { color: var(--bad); }

/* Pencere */
dialog {
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog.narrow { width: min(460px, calc(100vw - 32px)); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dlg-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 6px; background: var(--text); color: var(--bg); }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .kv { grid-template-columns: 1fr; }
}

input[type="search"] { flex: 1 1 280px; min-width: 200px; }
