/* Layout: sabit üst bar + sekmeler, altında tek sütun çalışma alanı; özet önce, detay sonra. */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --ink: #141820;
  --muted: #5d6474;
  --line: #e0e3ea;
  --accent: #2443c4;
  --accent-ink: #ffffff;
  --accent-soft: #e7ebfb;
  --good: #1d7349; --good-soft: #e1f2e8;
  --warn: #985600; --warn-soft: #fbeed6;
  --bad: #b02a1d; --bad-soft: #fbe4e1;
  --info: #3c4b78; --info-soft: #eceff6;
  --font-display: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1117; --surface: #161a22; --ink: #e7e9ef; --muted: #9aa1b1; --line: #2a303b;
    --accent: #8ea3ff; --accent-ink: #0e1117; --accent-soft: #1c2442;
    --good: #63c993; --good-soft: #12281c; --warn: #f0b45c; --warn-soft: #2d2313;
    --bad: #ff8c80; --bad-soft: #321a18; --info: #aab6dc; --info-soft: #1d2230;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1117; --surface: #161a22; --ink: #e7e9ef; --muted: #9aa1b1; --line: #2a303b;
  --accent: #8ea3ff; --accent-ink: #0e1117; --accent-soft: #1c2442;
  --good: #63c993; --good-soft: #12281c; --warn: #f0b45c; --warn-soft: #2d2313;
  --bad: #ff8c80; --bad-soft: #321a18; --info: #aab6dc; --info-soft: #1d2230;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Üst bar */
.top { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1240px; margin: 0 auto; padding: 10px 20px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.mark { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: 0.04em; color: var(--accent); }
.brand .sub { color: var(--muted); font-size: 13px; }
.sync { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync.live::before { background: var(--good); }
.sync.err::before { background: var(--bad); }
nav.tabs { flex-basis: 100%; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
nav.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; display: grid; gap: 20px; }
.banner { max-width: 1240px; margin: 14px auto 0; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); font-size: 14px; }
.banner[hidden] { display: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 2px; }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-val { font-family: var(--font-display); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12.5px; color: var(--muted); }
.kpi.bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); box-shadow: inset 4px 0 0 var(--bad); }
.kpi.bad .k-val { color: var(--bad); }

/* Kartlar ve tablolar */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; align-content: start; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-h p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.two { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.group td { background: var(--bg); font-weight: 600; font-size: 13px; color: var(--muted); padding: 6px 10px; }
tr.group td.num { color: var(--ink); }
tr.detail > td { background: var(--bg); padding: 14px; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); padding: 18px 4px; font-size: 14px; }

.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.mute { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); margin-left: 6px; vertical-align: 1px; }

/* Butonlar ve formlar */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 14px; white-space: nowrap; }
a.btn { text-decoration: none; color: var(--ink); display: inline-block; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { padding: 3px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.linkish { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font-weight: 600; text-align: left; }
.linkish:hover { color: var(--accent); }
.linkish .caret { display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
.linkish[aria-expanded="true"] .caret { transform: rotate(90deg); }
@media (prefers-reduced-motion: reduce) { .linkish .caret { transition: none; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar .grow { flex: 1 1 220px; }
input[type="text"], input[type="search"], input[type="date"], input[type="email"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
}
textarea { min-height: 64px; resize: vertical; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font-size: 13.5px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.detail-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.checklist li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--good); }
.dot.warn { background: var(--warn); }
.checklist .t { font-weight: 500; }
.checklist .d { color: var(--muted); font-size: 13px; }

/* Ekstre */
.statement { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 18px; }
.st-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.st-head .co { font-size: 12.5px; color: var(--muted); }
.st-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.st-sum div { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.st-sum span { display: block; font-size: 12px; color: var(--muted); }
.st-sum b { font-variant-numeric: tabular-nums; font-size: 16px; }
.st-book h3 { margin-bottom: 4px; }
.st-note { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 22, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; width: min(620px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.m-body { padding: 16px 18px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.m-body .full { grid-column: 1 / -1; }
@media (max-width: 520px) { .m-body { grid-template-columns: 1fr; } }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.m-err { color: var(--bad); font-size: 13px; margin-right: auto; }
.f { display: grid; gap: 4px; align-content: start; }
.f label, .f .lbl { font-size: 13px; font-weight: 500; }
.f small { color: var(--muted); font-size: 12px; }
.radios { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.radios label { font-weight: 400; display: flex; gap: 6px; align-items: center; font-size: 14px; }
.preview { background: var(--accent-soft); color: var(--ink); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.summary-box { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; display: grid; gap: 2px; }
[data-grp][hidden] { display: none; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.ro .write { display: none !important; }
.nodl .dl { display: none !important; }

/* Oturum alanı */
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.who b { color: var(--ink); font-weight: 500; }
.top.bare nav.tabs { display: none; }
.top.bare .top-inner { padding-bottom: 10px; }

/* Giriş ekranları */
.auth { max-width: 420px; width: 100%; margin: 40px auto; justify-self: center; }
.auth .card { padding: 24px; gap: 14px; }
.auth h2 { font-size: 22px; }
.auth p { margin: 0; color: var(--muted); font-size: 14px; }
.auth form { display: grid; gap: 12px; }
.auth input[type="password"], .auth input[type="email"] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.auth .btn.primary { padding: 10px 14px; }
.auth .alt { font-size: 13.5px; text-align: center; }
.auth .alt button { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font-weight: 500; }
.msg { border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.msg.err { background: var(--bad-soft); color: var(--bad); }
.msg.ok { background: var(--good-soft); color: var(--good); }
.msg:empty { display: none; }
input[type="password"], input[type="number"] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1; font-size: 13px; }
.hello { font-size: 14px; color: var(--muted); }

@media print {
  .top, .toolbar, .banner, .no-print, #toast, #modal-root { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .statement { border: 0; padding: 0; }
  .chip { border: 1px solid #999; background: none !important; color: #000 !important; }
  .table-wrap { overflow: visible; }
  th, td { padding: 4px 5px; }
}
.sync:empty { display: none; }
.sync.busy::before { background: var(--warn); }
#who { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
main > * { min-width: 0; }
.statement { min-width: 0; }
.copyrow select { flex: 1; min-width: 0; }
.statement > *, .st-book { min-width: 0; }
@media (max-width: 600px) { .statement { padding: 14px; } main { padding: 16px 12px 48px; } .st-head h2 { font-size: 19px; } }
