/* ==========================================================================
   Akış — temel katman (AKIS_SPEC 2.x, 4.6, 5, 7.1)
   Renk değişmezi yok (D11): her renk tokens.css'ten gelir.

   ========================================================================== */

/* D14: hidden her zaman gizler (rol menüsü, ayar sekmesi, pager sızıntıları) */
[hidden] { display: none !important; }

/* Sade / Ayrıntılı (5.4) */
html[data-detail="simple"] .d-only,
html[data-detail="detailed"] .s-only { display: none !important; }
html:not([data-detail]) .d-only { display: none !important; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }
b.num, strong.num { white-space: nowrap; }

.ax-skip {
  position: fixed; left: var(--sp-3); top: var(--sp-3); z-index: var(--z-toast);
  padding: 10px 14px; border-radius: var(--r-md); background: var(--surface); color: var(--fg);
  box-shadow: var(--shadow-2); font-weight: 650; transform: translateY(-200%);
}
.ax-skip:focus { transform: none; outline: 2px solid var(--primary); outline-offset: 2px; }


/* Hareket azaltma (2.5) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

/* Salt okunur rozeti (tek kural; index.html ve design.css'teki tekrarlar silindi) */
.ro-badge {
  display: inline-block; margin-left: 10px; padding: 2px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; vertical-align: middle;
  background: var(--warn-soft); color: var(--warn);
}

/* Roller: mali müşavir salt okunur */
/* Asıl kapı sunucuda (advisor-guard, API 403). Yeni her yazma kontrolü
   data-write taşır; aşağıdaki liste yalnız güvenlik ağıdır (4.6). */
body[data-role="advisor"] [data-write],
body[data-role="advisor"] [data-action^="new-"],
body[data-role="advisor"] .button.primary:not([data-read]),
body[data-role="advisor"] [data-action="transfer"], body[data-role="advisor"] [data-action="fx-revalue"], body[data-role="advisor"] [data-action="categories"],
body[data-role="advisor"] [data-receipt-action]:not([data-receipt-action="open"]), body[data-role="advisor"] [data-receipt-action="open"][data-focus="confirm"],
body[data-role="advisor"] [data-doc-set-status], body[data-role="advisor"] [data-nilvera-answer],
body[data-role="advisor"] [data-plan-contract], body[data-role="advisor"] [data-invoice-contract], body[data-role="advisor"] [data-void-expense],
body[data-role="advisor"] [data-send-local], body[data-role="advisor"] [data-send-gib], body[data-role="advisor"] [data-return-invoice],
body[data-role="advisor"] [data-reject-draft], body[data-role="advisor"] [data-approve-draft], body[data-role="advisor"] [data-reconcile-import],
body[data-role="advisor"] [data-reconcile-account], body[data-role="advisor"] [data-realize-plan], body[data-role="advisor"] [data-product-toggle],
body[data-role="advisor"] [data-product-edit], body[data-role="advisor"] [data-product-active], body[data-role="advisor"] [data-official-cancel],
body[data-role="advisor"] [data-new-subscription], body[data-role="advisor"] [data-edit-subscription], body[data-role="advisor"] [data-edit-plan],
body[data-role="advisor"] [data-edit-invoice], body[data-role="advisor"] [data-edit-forecast], body[data-role="advisor"] [data-edit-customer],
body[data-role="advisor"] [data-edit-contract], body[data-role="advisor"] [data-edit-asset], body[data-role="advisor"] [data-delete-plan],
body[data-role="advisor"] [data-delete-invoice], body[data-role="advisor"] [data-deactivate-category], body[data-role="advisor"] [data-complete-task],
body[data-role="advisor"] [data-cancel-task], body[data-role="advisor"] [data-cancel-invoice], body[data-role="advisor"] [data-approve-task],
body[data-role="advisor"] [data-cal-snooze], body[data-role="advisor"] [data-cal-reopen], body[data-role="advisor"] [data-cal-edit],
body[data-role="advisor"] [data-cal-done], body[data-role="advisor"] [data-cal-cancel], body[data-role="advisor"] [data-archive-customer],
body[data-role="advisor"] [data-archive-contract], body[data-role="advisor"] [data-forecast-done], body[data-role="advisor"] [data-forecast-cancel],
body[data-role="advisor"] [data-expense-from-invoice], body[data-role="advisor"] [data-email-invoice], body[data-role="advisor"] [data-ai-draft-reject],
body[data-role="advisor"] [data-ai-draft-approve], body[data-role="advisor"] [data-ak-retry],
body[data-role="advisor"] [data-batch-select], body[data-role="advisor"] #invoiceBatchBar, body[data-role="advisor"] [data-rp-budget],
body[data-role="advisor"] #rpBudgetSaveBtn, body[data-role="advisor"] [data-sugg-act], body[data-role="advisor"] [data-ai-open],
body[data-role="advisor"] .ax-rowmenu [data-write], body[data-role="advisor"] [data-scope="personal"], body[data-role="advisor"] [data-rp-scope="personal"],
body[data-role="advisor"] [data-cal-scope="personal"] { display: none !important; }

/* Roller: data-roles="owner accountant" (4.3, 4.5). Rol listesinde olmayan gizlenir. */
body[data-role="staff"] [data-roles]:not([data-roles~="staff"]),
body[data-role="accountant"] [data-roles]:not([data-roles~="accountant"]),
body[data-role="advisor"] [data-roles]:not([data-roles~="advisor"]),
body[data-role="owner"] [data-roles]:not([data-roles~="owner"]) { display: none !important; }

/* ---------- Temel öğe varsayılanları ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-padding-top: var(--topbar-h);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: var(--f); font-size: var(--fs-md); line-height: 1.45; font-weight: 400;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  letter-spacing: normal;
}
:is(h1, h2, h3, h4) { margin: 0; color: var(--fg); font-family: var(--f); }
h1 { font-size: var(--fs-h1); line-height: 1.15; font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: var(--fs-h2); line-height: 1.3; font-weight: 700; }
h3 { font-size: var(--fs-lg); line-height: 1.45; font-weight: 600; }
h4 { font-size: var(--fs-md); line-height: 1.45; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary-ink); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
small { font-size: var(--fs-sm); }
code, kbd, samp { font-family: var(--f-mono); font-size: .92em; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: var(--r-xs);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--fg-2);
  font-size: var(--fs-xs); font-weight: 600; text-align: center;
}
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); color: var(--fg); }

/* Form denetimleri (3.2) — eski formlar işaretleme değişmeden dönüşür */
/* :where() → özgüllük 0: bileşen kuralları (.ax-affix, .ax-search …) her zaman ezer. */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]), select, textarea) {
  min-height: var(--h-md); width: 100%;
  padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--fg);
  font-family: var(--f); font-size: var(--fs-md); line-height: 1.4;
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease);
}
textarea { padding: 10px 12px; min-height: 88px; resize: vertical; }
select { padding-right: 32px; }
:where(input, select, textarea):focus-visible {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary);
}
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--bad); }
:where(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
:where(input, select, textarea):disabled { opacity: .5; cursor: not-allowed; }
:where(input[type="checkbox"], input[type="radio"]) {
  width: 18px; height: 18px; margin: 0; accent-color: var(--primary); cursor: pointer;
}
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; font-size: var(--fs-h2); font-weight: 700; color: var(--fg); }

/* Tablo temeli */
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
:is(th, td) { text-align: left; vertical-align: middle; }
:is(th.num, td.num) { text-align: right; }

/* Görünüm bölümleri (switchView .active'i değiştirir) */
.view { display: none; }
.view.active { display: grid; gap: var(--gap-page); align-content: start; min-width: 0; }

/* Telefonda girdiler 16 px (iOS odakta sayfayı büyütmesin, 2.4) */
@media (max-width: 819px) {
  :where(input, select, textarea) { font-size: 16px; }
  html { scroll-padding-bottom: calc(64px + env(safe-area-inset-bottom) + 16px); }
}

/* Baskı temeli */
@media print {
  body { background: var(--surface); color: var(--fg); }
  :is(.ax-side, .ax-tabbar, .ax-topbar, .ax-drawer, .ax-scrim, .notice, .ax-skip, .ai-dock, #demoBanner) { display: none !important; }
}

/* Renk teması değişirken yumuşak geçiş (applyTheme, 260 ms; hareket azaltılınca eklenmez). */
body.theme-switching, body.theme-switching * { transition: background-color var(--dur-2) var(--ease), color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease) !important; }
@media (prefers-reduced-motion: reduce) { body.theme-switching, body.theme-switching * { transition: none !important; } }
