/* insaatos tasarım sistemi — build yok, inline stil yok (CSP: style-src 'self').
   Tema: varsayılan sistem (açık/koyu). Zorlama: <html data-theme="light|dark">.
   Yüksek kontrast (güneş): <html data-contrast="high"> veya prefers-contrast: more. */

/* ---------- 1. Değişkenler ---------- */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
  --fs-xs: .8125rem; --fs-sm: .9375rem; --fs-md: 1.0625rem; --fs-lg: 1.25rem;
  --fs-xl: 1.625rem; --fs-amount: 2.5rem;
  --lh: 1.4;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --tap: 48px;          /* eldivenle rahat hedef; mutlak alt sınır 44px */
  --tap-min: 44px;
  --tabbar-h: 64px;
  --header-h: 56px;
  --bar-h: 40px;        /* çevrimdışı / sunum şeridi */

  /* açık tema */
  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #ebe9e1;
  --text: #1a1a17;
  --text-2: #4a4a43;        /* AA: 8.6:1 on --surface */
  --border: #8d8b80;        /* kontrol kenarı, 3:1+ */
  --border-soft: #d3d0c4;
  --primary: #0a58ab;       /* beyaz üstü 7:1 */
  --on-primary: #ffffff;
  --primary-soft: #dcebfa;
  --danger: #b3261e;
  --on-danger: #ffffff;
  --danger-soft: #fde4e1;
  --warn-text: #7a4a00;
  --warn-soft: #fff0c8;
  --ok-text: #14652f;
  --ok-soft: #d9f2e0;
  --info-text: #0a4a8c;
  --info-soft: #dcebfa;
  --neutral-soft: #e4e2d9;
  --focus: #ff9f0a;
  --shadow-1: 0 1px 2px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.12);
  --shadow-2: 0 4px 14px rgba(0,0,0,.22);
  --overlay: rgba(10,10,8,.6);

  /* grafik serileri (renk körü güvenli, Okabe-Ito tabanlı) */
  --c1: #0072b2; --c2: #e69f00; --c3: #009e73; --c4: #cc79a7; --c5: #56b4e9; --c6: #d55e00;
}

/* koyu değerler iki yerde tanımlanır (CSS'te koşullu değişken yok) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11130f; --surface: #1b1e19; --surface-2: #262a23;
    --text: #f2f1ea; --text-2: #c4c2b6;
    --border: #8a8a7c; --border-soft: #3a3e35;
    --primary: #8cc2ff; --on-primary: #04213f; --primary-soft: #14304f;
    --danger: #ff8a80; --on-danger: #3b0804; --danger-soft: #4a1814;
    --warn-text: #ffd27a; --warn-soft: #4a3600;
    --ok-text: #86e0a3; --ok-soft: #12381f;
    --info-text: #9ccbff; --info-soft: #14304f;
    --neutral-soft: #2e3229;
    --focus: #ffb340;
    --shadow-1: 0 1px 2px rgba(0,0,0,.6);
    --shadow-2: 0 4px 14px rgba(0,0,0,.7);
    --c1: #56b4e9; --c2: #f0b429; --c3: #2fd1a0; --c4: #e69ac4; --c5: #8fd0ff; --c6: #ff8f4d;
  }
}
:root[data-theme="dark"] {
  --bg: #11130f; --surface: #1b1e19; --surface-2: #262a23;
  --text: #f2f1ea; --text-2: #c4c2b6;
  --border: #8a8a7c; --border-soft: #3a3e35;
  --primary: #8cc2ff; --on-primary: #04213f; --primary-soft: #14304f;
  --danger: #ff8a80; --on-danger: #3b0804; --danger-soft: #4a1814;
  --warn-text: #ffd27a; --warn-soft: #4a3600;
  --ok-text: #86e0a3; --ok-soft: #12381f;
  --info-text: #9ccbff; --info-soft: #14304f;
  --neutral-soft: #2e3229;
  --focus: #ffb340;
  --shadow-1: 0 1px 2px rgba(0,0,0,.6);
  --shadow-2: 0 4px 14px rgba(0,0,0,.7);
  --c1: #56b4e9; --c2: #f0b429; --c3: #2fd1a0; --c4: #e69ac4; --c5: #8fd0ff; --c6: #ff8f4d;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* yüksek kontrast: güneş altı. Açık zemin: saf siyah/beyaz, kalın kenar. AA+ (AAA hedef). */
:root[data-contrast="high"] {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #eeeeee;
  --text: #000000; --text-2: #1a1a1a;
  --border: #000000; --border-soft: #000000;
  --primary: #003e8a; --on-primary: #ffffff; --primary-soft: #d6e6ff;
  --danger: #9b0000; --danger-soft: #ffd9d6;
  --warn-text: #5c3500; --warn-soft: #ffe08a;
  --ok-text: #004d1a; --ok-soft: #c4f0d0;
  --info-text: #003e8a; --info-soft: #d6e6ff;
  --neutral-soft: #dddddd;
  --focus: #b35c00;
  --shadow-1: none; --shadow-2: none;
  --tap: 56px;
  --fs-sm: 1rem; --fs-md: 1.125rem;
}
:root[data-contrast="high"][data-theme="dark"] {
  --bg: #000000; --surface: #000000; --surface-2: #1c1c1c;
  --text: #ffffff; --text-2: #f0f0f0;
  --border: #ffffff; --border-soft: #ffffff;
  --primary: #a9d1ff; --on-primary: #000000; --primary-soft: #0b2a4d;
  --danger: #ff9d94; --on-danger: #000000; --danger-soft: #4d0000;
  --warn-text: #ffe08a; --warn-soft: #3d2a00;
  --ok-text: #9af0b5; --ok-soft: #003d14;
  --info-text: #a9d1ff; --info-soft: #0b2a4d;
  --neutral-soft: #2a2a2a;
  --focus: #ffcc4d;
}
@media (prefers-contrast: more) {
  :root:not([data-contrast]):not([data-theme="dark"]) {
    --bg: #fff; --surface: #fff; --text: #000; --text-2: #1a1a1a;
    --border: #000; --border-soft: #000; --primary: #003e8a; --tap: 56px;
  }
}

/* ---------- 2. Temel ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fs-md)/var(--lh) var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0 0 var(--sp-2); line-height: 1.2; }
h1 { font-size: var(--fs-xl); } h2 { font-size: var(--fs-lg); } h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--primary); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.hidden, [hidden] { display: none !important; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-2); }
.small { font-size: var(--fs-xs); }
.right { text-align: right; }
.stack > * + * { margin-top: var(--sp-3); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.grow { flex: 1 1 auto; min-width: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 3. App shell ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 30; min-height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); padding-top: max(var(--sp-2), env(safe-area-inset-top));
  background: var(--surface); border-bottom: 2px solid var(--border-soft);
}
.app-title { font-size: var(--fs-lg); font-weight: 700; margin: 0; flex: 1 1 auto; }
.app-main {
  flex: 1 1 auto; width: 100%; max-width: 640px; margin: 0 auto;
  padding: var(--sp-4);
  padding-bottom: calc(var(--tabbar-h) + var(--sp-5) + env(safe-area-inset-bottom));
}
.app-main.has-savebar { padding-bottom: calc(var(--tabbar-h) + 88px + env(safe-area-inset-bottom)); }
.screen-title { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-lg { width: 32px; height: 32px; }
.icon-btn {
  min-width: var(--tap-min); min-height: var(--tap-min); display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 2px solid transparent; border-radius: var(--r-md); color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }

/* alt sekme çubuğu: en fazla 4 sekme */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 2px solid var(--border-soft);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tap); color: var(--text-2); text-decoration: none; font-size: var(--fs-xs); font-weight: 600;
  border: 0; background: transparent; position: relative;
}
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 20%; right: 20%; height: 4px; background: var(--primary); border-radius: 0 0 4px 4px;
}
.tab .badge-dot {
  position: absolute; top: 6px; left: calc(50% + 8px); min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--danger); color: var(--on-danger);
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}

/* şeritler */
.strip {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--bar-h);
  padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); font-weight: 600;
}
.strip .icon { width: 20px; height: 20px; }
.strip-offline { background: var(--neutral-soft); color: var(--text); border-bottom: 2px solid var(--border); }
.strip-present { background: var(--warn-soft); color: var(--warn-text); border-bottom: 3px solid var(--warn-text); position: sticky; top: var(--header-h); z-index: 29; }
.strip-error { background: var(--danger-soft); color: var(--danger); border-bottom: 2px solid var(--danger); }

/* mod rozeti (başlıkta) */
.mode-badge {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--sp-3);
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .03em;
  border: 2px solid currentColor; background: var(--surface);
}
.mode-badge[data-mode="full"] { color: var(--ok-text); }
.mode-badge[data-mode="presentation"] { color: var(--warn-text); background: var(--warn-soft); }
.mode-badge[data-mode="masked"] { color: var(--danger); background: var(--danger-soft); }

/* ---------- 4. Düğmeler ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 var(--sp-5); border-radius: var(--r-md);
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 700; font-size: var(--fs-md); text-decoration: none; text-align: center;
}
.btn:active { transform: translateY(1px); background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary); filter: brightness(.9); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-block { display: flex; width: 100%; }
.btn-sm { min-height: var(--tap-min); padding: 0 var(--sp-4); font-size: var(--fs-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* sabit Kaydet çubuğu (alt yarı, tek el) */
.savebar {
  position: fixed; left: 0; right: 0; z-index: 35; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: var(--sp-3) var(--sp-4); background: var(--surface); border-top: 2px solid var(--border-soft);
  display: flex; gap: var(--sp-3); align-items: center;
}
.savebar .btn-primary { flex: 1 1 auto; min-height: 56px; font-size: var(--fs-lg); }

/* ---------- 5. Form alanları ---------- */
.field { display: block; margin-bottom: var(--sp-4); }
.field > .label, .field > label { display: block; font-weight: 700; font-size: var(--fs-sm); margin-bottom: var(--sp-1); }
.input, .select, .textarea {
  display: block; width: 100%; min-height: var(--tap); padding: var(--sp-2) var(--sp-3);
  background: var(--surface); color: var(--text); border: 2px solid var(--border); border-radius: var(--r-md);
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder { color: var(--text-2); opacity: .8; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: var(--danger); border-width: 3px; }
.field-hint { font-size: var(--fs-xs); color: var(--text-2); margin-top: var(--sp-1); }
.field-error { font-size: var(--fs-sm); color: var(--danger); font-weight: 700; margin-top: var(--sp-1); }
.check {
  display: flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); padding: var(--sp-1) 0; font-weight: 600;
}
.check input { width: 28px; height: 28px; flex: none; accent-color: var(--primary); margin: 0; }
.note {
  padding: var(--sp-3); border-radius: var(--r-md); background: var(--info-soft); color: var(--info-text);
  font-size: var(--fs-sm); border: 2px solid var(--info-text);
}
.note-warn { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn-text); }
details.adv > summary {
  min-height: var(--tap); display: flex; align-items: center; font-weight: 700; cursor: pointer; list-style: none;
}
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary::before { content: "▸"; margin-right: var(--sp-2); }
details.adv[open] > summary::before { content: "▾"; }

/* ---------- 6. Tutar + tuş takımı ---------- */
.amount {
  display: flex; align-items: baseline; justify-content: flex-end; gap: var(--sp-2);
  min-height: 72px; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 3px solid var(--border); border-radius: var(--r-lg);
}
.amount-value { font: 700 var(--fs-amount)/1.1 var(--font-num); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }
.amount-value[data-empty="true"] { color: var(--text-2); font-weight: 400; }
.amount-ccy { font-size: var(--fs-lg); font-weight: 700; color: var(--text-2); }
.quick-amts { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); margin: var(--sp-2) 0; }
.quick-amts .key { min-height: var(--tap-min); font-size: var(--fs-sm); background: var(--primary-soft); color: var(--info-text); border-color: var(--info-text); }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.key {
  min-height: 60px; border-radius: var(--r-md); border: 2px solid var(--border); background: var(--surface);
  font: 700 1.5rem/1 var(--font-num); color: var(--text); display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
}
.key:active { background: var(--primary-soft); }
.key-fn { background: var(--surface-2); font-family: var(--font); font-size: var(--fs-md); }

/* ---------- 7. Çipler, anahtar, kamera ---------- */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  min-height: var(--tap); padding: 0 var(--sp-4); border-radius: var(--r-pill);
  border: 2px solid var(--border); background: var(--surface); font-weight: 700; font-size: var(--fs-md);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"], .chip[aria-checked="true"] {
  background: var(--primary); border-color: var(--primary); color: var(--on-primary);
}
.chip[aria-pressed="true"]::before { content: "✓"; font-weight: 800; }   /* renge bağımlı olmayan işaret */

/* resmi / gayriresmi: büyük iki parçalı anahtar */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.seg-opt {
  min-height: 60px; border: 0; background: var(--surface); font-weight: 800; font-size: var(--fs-lg);
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
}
.seg-opt + .seg-opt { border-left: 3px solid var(--border); }
.seg-opt[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }
.seg-opt[aria-checked="true"]::before { content: "✓"; }
.seg-opt.informal[aria-checked="true"] { background: var(--text); color: var(--bg); }

.camera-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-3);
  width: 100%; min-height: 64px; border: 3px dashed var(--border); border-radius: var(--r-lg);
  background: var(--surface); font-weight: 700; font-size: var(--fs-md);
}
.camera-btn .icon { width: 32px; height: 32px; }
.camera-btn.has-photo { border-style: solid; border-color: var(--ok-text); color: var(--ok-text); background: var(--ok-soft); }
.thumb { width: 64px; height: 64px; border-radius: var(--r-sm); object-fit: cover; border: 2px solid var(--border); background: var(--surface-2); }

/* ---------- 8. Kart, liste satırı ---------- */
.card { background: var(--surface); border: 2px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--sp-4); box-shadow: var(--shadow-1); }
.card + .card { margin-top: var(--sp-3); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); font-weight: 700; margin-bottom: var(--sp-2); }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.kpi { background: var(--surface); border: 2px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4); }
.kpi-label { font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; }
.kpi-value { font: 700 var(--fs-lg)/1.2 var(--font-num); margin-top: 2px; overflow-wrap: anywhere; }
.kpi-sub { font-size: var(--fs-xs); color: var(--text-2); }

/* liste satırı: swipe yok, tüm satır dokunulabilir; eylemler satır içi açık düğme */
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 2px solid var(--border-soft); border-radius: var(--r-lg); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 64px; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft); color: inherit; text-decoration: none; width: 100%; background: transparent; border-left: 0; border-right: 0; border-top: 0; text-align: left;
}
.list > li:last-child > .row, .list > .row:last-child { border-bottom: 0; }
a.row:active, button.row:active { background: var(--surface-2); }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: var(--fs-sm); color: var(--text-2); display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); align-items: center; }
.row-amount { font: 700 var(--fs-md)/1.2 var(--font-num); text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: var(--sp-2); }
.row.is-voided .row-title, .row.is-voided .row-amount { text-decoration: line-through; color: var(--text-2); }

/* ---------- 9. Rozetler ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 var(--sp-2);
  border-radius: var(--r-sm); border: 2px solid currentColor;
  font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; stroke-width: 3; }
.badge-filtered { color: var(--warn-text); background: var(--warn-soft); }
.badge-queued   { color: var(--info-text); background: var(--info-soft); }
.badge-synced   { color: var(--ok-text); background: var(--ok-soft); }
.badge-error    { color: var(--danger); background: var(--danger-soft); }
.badge-pending-doc { color: var(--warn-text); background: transparent; border-style: dashed; }
.badge-neutral  { color: var(--text-2); background: var(--neutral-soft); }

/* ---------- 10. Toast, boş durum, iskelet ---------- */
.toast-host {
  position: fixed; left: var(--sp-4); right: var(--sp-4); z-index: 80; display: flex; flex-direction: column; gap: var(--sp-2);
  bottom: calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom)); pointer-events: none; align-items: center;
}
.toast {
  pointer-events: auto; max-width: 560px; width: 100%; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--text); color: var(--bg);
  font-weight: 700; box-shadow: var(--shadow-2); border: 2px solid var(--bg);
}
.toast-ok { background: var(--ok-text); color: var(--bg); }
.toast-error { background: var(--danger); color: var(--on-danger); }
.toast .btn-ghost { color: inherit; text-decoration: underline; min-height: var(--tap-min); margin-left: auto; }

.empty { text-align: center; padding: var(--sp-6) var(--sp-4); color: var(--text-2); }
.empty .icon { width: 48px; height: 48px; margin-bottom: var(--sp-3); }
.empty h2 { color: var(--text); }

.skeleton { display: block; border-radius: var(--r-sm); background: var(--surface-2); position: relative; overflow: hidden; min-height: 16px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(128,128,128,.25), transparent); animation: shimmer 1.4s infinite;
}
.skeleton-row { height: 64px; border-radius: 0; border-bottom: 1px solid var(--border-soft); }
.skeleton-line { height: 14px; margin: 6px 0; width: 70%; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- 11. Tablo (masaüstü) -> kart (mobil) ---------- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
.tbl th { text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: var(--sp-2) var(--sp-3); border-bottom: 2px solid var(--border); }
.tbl td { padding: var(--sp-3); border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl tfoot td { font-weight: 800; border-top: 2px solid var(--border); }
@media (max-width: 899px) {
  .tbl, .tbl tbody, .tbl tfoot, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl tr { margin-bottom: var(--sp-3); border: 2px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--sp-2) var(--sp-3); background: var(--surface); }
  .tbl td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); padding: var(--sp-2) 0; border: 0; text-align: right; }
  .tbl td::before { content: attr(data-label); font-size: var(--fs-xs); font-weight: 700; color: var(--text-2); text-align: left; flex: none; }
}

/* ---------- 12. Grafik kapsayıcısı ---------- */
.chart-box { background: var(--surface); border: 2px solid var(--border-soft); border-radius: var(--r-lg); padding: var(--sp-3); }
.chart-box .chart-title { font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-2); }
.chart-canvas-wrap { position: relative; height: 240px; }
.chart-canvas-wrap canvas { max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); margin-top: var(--sp-2); }
.chart-legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 6px; vertical-align: -2px; border: 2px solid var(--surface); outline: 1px solid var(--border); }
.sw-1 { background: var(--c1); } .sw-2 { background: var(--c2); } .sw-3 { background: var(--c3); }
.sw-4 { background: var(--c4); } .sw-5 { background: var(--c5); } .sw-6 { background: var(--c6); }
.chart-fallback { font-size: var(--fs-sm); color: var(--text-2); }

/* ---------- 13. Modal (PIN) ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--sp-5) var(--sp-4); padding-bottom: calc(var(--sp-5) + env(safe-area-inset-bottom)); border: 2px solid var(--border); }
@media (min-width: 600px) { .modal-backdrop { align-items: center; } .modal { border-radius: var(--r-lg); } }
.pin-dots { display: flex; justify-content: center; gap: var(--sp-3); margin: var(--sp-3) 0; }
.pin-dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--border); }
.pin-dot[data-on="true"] { background: var(--text); }

/* ---------- 14. Acil maske ---------- */
.panic-btn {
  position: fixed; z-index: 70; right: var(--sp-3); bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom));
  width: 56px; height: 56px; min-width: 56px; min-height: 56px; border-radius: 50%;
  background: var(--danger); color: var(--on-danger); border: 3px solid var(--on-danger); box-shadow: var(--shadow-2);
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.app-main.has-savebar ~ .panic-btn, .panic-btn.above-savebar { bottom: calc(var(--tabbar-h) + 88px + env(safe-area-inset-bottom)); }
.panic-btn .icon { width: 28px; height: 28px; }

.mask-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999; background: #101010; color: #bdbdbd;
  align-items: center; justify-content: center; flex-direction: column; gap: var(--sp-4); text-align: center; padding: var(--sp-5);
}
/* masked: yalnızca örtü kalır; finansal veri DOM'dan temizlenmiş olsa da hiçbir şey görünmez */
body.masked { overflow: hidden; background: #101010; }
body.masked > *:not(.mask-overlay) { display: none !important; }
body.masked .mask-overlay { display: flex; }
.mask-overlay .icon { width: 56px; height: 56px; }
.mask-overlay .btn { background: #2a2a2a; border-color: #8a8a8a; color: #f0f0f0; min-width: 200px; }

/* ---------- 15. Masaüstü (owner paneli) ---------- */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 224px 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "side head" "side strip" "side main"; }
  .app-header { grid-area: head; }
  .app-main { grid-area: main; max-width: 1200px; padding: var(--sp-5) var(--sp-6); padding-bottom: var(--sp-6); }
  .app-main.has-savebar { padding-bottom: 104px; }
  .tabbar {
    grid-area: side; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; justify-content: flex-start; gap: var(--sp-1);
    padding: var(--sp-4) var(--sp-3); border-top: 0; border-right: 2px solid var(--border-soft);
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: var(--sp-3); padding: 0 var(--sp-4); font-size: var(--fs-md); border-radius: var(--r-md); flex: none; }
  .tab[aria-current="page"] { background: var(--primary-soft); }
  .tab[aria-current="page"]::before { display: none; }
  .tab .badge-dot { position: static; margin-left: auto; }
  .savebar { left: 224px; bottom: 0; }
  .panic-btn, .app-main.has-savebar ~ .panic-btn { bottom: var(--sp-5); }
  .toast-host { bottom: 100px; left: 224px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
  .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
  .chart-canvas-wrap { height: 320px; }
  .modal-backdrop { padding-left: 224px; }
}
.strip-host { grid-area: strip; }

/* ---------- 16. Yazdırma yok; güneş modu düğmesi ---------- */
.theme-toggle { min-height: var(--tap-min); }

/* ---------- 17. Aşama 3 eklemeleri ---------- */
.tabbar[data-n="2"], .tabbar[data-n="3"] { grid-template-columns: repeat(var(--tabs, 2), 1fr); }
.tabbar[data-n="2"] { --tabs: 2; }
.tabbar[data-n="3"] { --tabs: 3; }
.note-ok { background: var(--ok-soft); color: var(--ok-text); border-color: var(--ok-text); }
.note-ok .cluster { margin-top: var(--sp-2); }
.mask-pin-form { width: 100%; max-width: 320px; }
.mask-overlay .btn-ghost { color: #bdbdbd; border-color: transparent; background: transparent; text-decoration: underline; }
.row-title .icon { width: 18px; height: 18px; vertical-align: -3px; }
@media (min-width: 900px) { .tabbar[data-n] { display: flex; } }

/* ---------- 18. Aşama 4 eklemeleri (owner ekranları) ---------- */
.tabbar[data-n="4"] { grid-template-columns: repeat(4, 1fr); }
.tabbar[data-n="5"] { grid-template-columns: repeat(5, 1fr); }
.modal { max-height: 92vh; max-height: 92dvh; overflow-y: auto; }
.row-wrap { flex-wrap: wrap; }
.row-wrap .row-actions { flex-wrap: wrap; }
a.note { display: block; text-decoration: none; font-weight: 700; min-height: var(--tap-min); }
.note-red { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); font-weight: 700; }
.card-red { border-color: var(--danger); border-width: 3px; }
.row-red { background: var(--danger-soft); }
.row-hl, .tbl tr.row-hl td { background: var(--warn-soft); font-weight: 800; }
.tbl tr.row-hl td { border-top: 2px solid var(--warn-text); border-bottom: 2px solid var(--warn-text); }
.col-hl { background: var(--primary-soft); font-weight: 800; }
.strong { font-weight: 800; }
.tbl-wrap { overflow-x: auto; }
.badge-barter { color: var(--c6); background: var(--surface); border-style: double; }
.badge-check { color: var(--info-text); background: var(--surface); border-style: dashed; }
.kv { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); min-height: 32px; }
.kv-l { color: var(--text-2); font-weight: 600; }
.kv-strong .kv-v { font-size: var(--fs-lg); font-weight: 800; }
.plain { list-style: none; margin: 0; padding: 0; }
.plain li { min-height: 32px; padding: var(--sp-1) 0; border-bottom: 1px solid var(--border-soft); }
.plain li:last-child { border-bottom: 0; }
.panel-grid { display: grid; grid-template-columns: 1fr; gap: var(--sp-3); }
.panel-grid .card + .card { margin-top: 0; }
@media (min-width: 900px) { .panel-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .panel-grid { grid-template-columns: repeat(3, 1fr); } }
.code { display: block; padding: var(--sp-3); background: var(--surface-2); border: 2px solid var(--border-soft); border-radius: var(--r-md); font-family: var(--font-num); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.legend-item { display: inline-flex; align-items: center; min-height: var(--tap-min); }
.field-hint + .field-error:empty { display: none; }
@media (max-width: 899px) { .grid-2 > *, .grid-3 > * { display: block; } }
