/* ---------- düğme */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .ic { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--sunken); color: var(--ink); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn.icon-only { padding: 6px; min-width: 36px; }
.btn.sm.icon-only { min-width: 30px; padding: 4px; }
.btn.block { width: 100%; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--muted); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

/* ---------- rozet ve çip */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 550; line-height: 1; padding: 4px 8px; border-radius: 99px; white-space: nowrap;
  background: var(--sunken); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface); }
.chip.on { border-color: var(--ok); color: var(--ok); }
.chip.on::before, .chip.off::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.chip.off { border-color: var(--line-strong); color: var(--muted); }

/* ---------- sayfa başlığı */
.page-head { display: flex; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; padding-bottom: var(--s2); }
.page-title { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.page-title .sub { color: var(--muted); max-width: 72ch; }
.page-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.page-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); margin-left: -4px; width: fit-content; }
.back .ic { width: 16px; height: 16px; }
.back:hover { color: var(--ink); text-decoration: none; }

/* ---------- kart */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) var(--s5); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: var(--s4) var(--s5) 0; }
.card.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.card.bad { border-color: var(--bad); }
.card.dashed { border-style: dashed; background: transparent; box-shadow: none; }
.card.clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.card.clickable:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; gap: var(--s3); flex-wrap: wrap; }
.card-head > div:first-child { flex: 1; min-width: 180px; }
.card-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s4); }
.card-grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.link-card h2 { font-size: 16px; }
.add-card { align-items: center; justify-content: center; text-align: center; min-height: 140px; color: var(--muted); cursor: pointer; }
.add-card:hover { color: var(--ink); border-color: var(--accent); }
.add-card .ic { width: 22px; height: 22px; }
.card.narrow { max-width: 560px; }

/* ---------- yerleşim yardımcıları */
.stack { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: var(--s4); align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: var(--s3) var(--s4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.flabel { font-size: 13px; font-weight: 550; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.hint, .help { font-size: 12px; color: var(--muted); }
.checks { display: flex; gap: var(--s4); flex-wrap: wrap; align-items: center; min-height: 38px; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.note { border-radius: var(--r); padding: var(--s3) var(--s4); background: var(--sunken); color: var(--ink-2); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.info { background: var(--info-soft); color: var(--info); }
.note strong { display: inline-flex; align-items: center; gap: 6px; }
.note ul { margin: 2px 0 0; }
.note .ic { width: 16px; height: 16px; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
@media (max-width: 560px) { dl.kv { grid-template-columns: 1fr; gap: 0; } dl.kv dd { margin-bottom: 8px; } }
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s3); padding: var(--s6) var(--s4); color: var(--muted); text-align: center; }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 80px 0; color: var(--muted); }
.spin { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-right-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
details.explain summary { cursor: pointer; color: var(--muted); font-size: 13px; }
details.explain p { margin-top: 6px; font-size: 13px; color: var(--ink-2); }

/* ---------- metrikler */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3) var(--s4); min-width: 0; }
.stat-l { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-v { font-size: 22px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-s { font-size: 12px; color: var(--muted); }
.stat.ok .stat-v { color: var(--ok); }
.stat.bad .stat-v { color: var(--bad); }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } .stat-v { font-size: 18px; } }

/* ---------- ilerleme */
.progress { display: flex; align-items: center; gap: var(--s3); }
.progress-track { flex: 1; height: 8px; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.progress-label { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- tablo: dar ekranda satırlar karta döner */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl.dense { font-size: 13px; }
.tbl.dense th, .tbl.dense td { padding: 7px 8px; }
.card:not(.flush) .tbl th { background: transparent; }
.card:not(.flush) .tbl th:first-child, .card:not(.flush) .tbl td:first-child { padding-left: 0; }
.card:not(.flush) .tbl th:last-child, .card:not(.flush) .tbl td:last-child { padding-right: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.wrap { min-width: 220px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl select, .tbl input { min-height: 32px; padding: 5px 8px; }
@media (max-width: 720px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
  .card.flush .tbl tr { padding: var(--s3) var(--s4); }
  .tbl tbody tr:last-child { border-bottom: 0; }
  .tbl td, .card:not(.flush) .tbl td:first-child, .card:not(.flush) .tbl td:last-child { border: 0; padding: 3px 0; display: flex; justify-content: space-between; align-items: center; gap: var(--s3); text-align: right; }
  .tbl td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; max-width: 45%; }
  .tbl td:not([data-label])::before, .tbl td[data-label=""]::before { content: none; }
  .tbl td:not([data-label]) { justify-content: flex-start; }
  .tbl td:first-child { font-weight: 600; }
  .tbl td.wrap { min-width: 0; }
  .tbl .num { text-align: right; }
}

/* ---------- sekmeler */
.tabs { display: flex; flex-direction: column; gap: var(--s4); }
.tab-list { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab-list::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; font: inherit; font-weight: 550; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- grafikler */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: var(--s4); }
.chart-box { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s3) var(--s4); }
.chart-box figcaption { display: flex; justify-content: space-between; gap: var(--s2); font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.chart-box figcaption .muted { font-weight: 400; }
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .col { fill: var(--chart); }
svg.chart .hit { fill: transparent; cursor: crosshair; }
svg.chart .hit:hover { fill: color-mix(in srgb, var(--ink) 6%, transparent); }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart-tip { position: absolute; top: 0; background: var(--ink); color: var(--bg); border-radius: 6px; padding: 3px 8px; font-size: 12px; pointer-events: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(60px, 110px) 1fr 56px; align-items: center; gap: var(--s2); font-size: 13px; }
.hbar-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-t { height: 10px; background: var(--sunken); border-radius: 0 4px 4px 0; }
.hbar-f { display: block; height: 100%; background: var(--chart); border-radius: 0 4px 4px 0; }
.hbar-v { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* ---------- pencere */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .4); display: grid; place-items: center; padding: var(--s4); animation: fade .15s; }
.modal { width: min(480px, 100%); background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.modal-body { color: var(--ink-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal-back { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom)); }
  .modal-actions .btn { flex: 1; }
}
@keyframes fade { from { opacity: 0; } }

/* ---------- bildirim */
.toasts { position: fixed; z-index: 70; right: var(--s4); bottom: var(--s4); display: flex; flex-direction: column; gap: var(--s2); max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.in { opacity: 1; transform: none; }
.toast.bad { background: var(--bad); color: #fff; }
@media (max-width: 560px) { .toasts { left: var(--s3); right: var(--s3); bottom: calc(var(--s3) + env(safe-area-inset-bottom)); max-width: none; } }

/* ---------- seçim düğmeleri (sihirbaz soruları) */
.opts { display: flex; flex-wrap: wrap; gap: var(--s2); }
.opt { min-height: 40px; min-width: 96px; padding: 8px 16px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; }
.opt:hover { border-color: var(--muted); }
.opt.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.opt.on::before { content: "✓ "; }
