/* ============================================================
   BiFatura — Modern SaaS tasarım katmanı (Linear/Stripe tarzı)
   styles.css üzerine biner; mevcut yapıyı bozmaz.
   ============================================================ */

:root {
  /* Renk paleti */
  --bg: #f6f8fa;
  --bg-soft: #eef2f5;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6eaf0;
  --line-strong: #d3dae3;
  --teal: #0d9488;
  --teal-dark: #0f766e;
  --teal-soft: #ccfbf1;
  --amber: #f59e0b;
  --amber-soft: #fef3c7;
  --rose: #e11d48;
  --rose-soft: #ffe4e6;
  --blue: #3b82f6;
  --blue-soft: #dbeafe;
  --violet: #8b5cf6;
  --violet-soft: #ede9fe;

  /* Gölge ve yüzey */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .10);
  --ring: 0 0 0 3px rgba(13, 148, 136, .18);

  /* Ölçek */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-display: "Space Grotesk", "Inter", sans-serif;

  /* --- Faz 0: birleştirilmiş palet ---
     styles.css kendi `:root` bloğunu tanımlıyor ve AYNI isimlere FARKLI
     değerler veriyordu (--teal #087f78 vs #0d9488 gibi); ekranda iki ayrı
     yeşil ve iki ayrı gri oluşuyordu. O blok kaldırıldı, yalnızca burada
     tanımlı olmayan isimler buraya taşındı. */
  --paper: var(--bg);
  --white: #ffffff;
  --mint: var(--teal-soft);
  --shadow: var(--shadow-md);

  /* Kenar çubuğu yüzeyleri. Daha önce sabit renklerdi (#102a33, #183b43,
     #278f87, #8da7aa…) ve tek yerden değiştirilemiyordu. */
  --sidebar-bg: #0f2b31;
  --sidebar-surface: #173b42;
  --sidebar-line: #245058;
  --sidebar-ink: #e6f2f1;
  --sidebar-muted: #8fabad;
  --sidebar-active: var(--teal);

  /* Tipografi ölçeği. Önce 31/24/17/16/15/13/12.5/12/11.5/11/10 gibi
     düzensiz adımlar vardı; aynı görevdeki metinler farklı boyuttaydı. */
  --fs-display: 30px;
  --fs-title: 22px;
  --fs-section: 16px;
  --fs-body: 13px;
  --fs-small: 12px;
  --fs-micro: 10.5px;
}

/* ---------- Temel zemin ---------- */
body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(13, 148, 136, .07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(59, 130, 246, .05), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -.01em;
}

/* ---------- Kenar çubuğu ---------- */
.sidebar {
  width: 264px;
  background: linear-gradient(180deg, #0b1f2a 0%, #0d2430 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  padding: 24px 16px 18px;
  gap: 20px;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #14b8a6, #0d9488);
  box-shadow: 0 6px 18px rgba(13, 148, 136, .35);
}
.brand strong { font-family: var(--font-display); letter-spacing: -.02em; }
.workspace {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}
.nav-item {
  position: relative;
  border-radius: 9px;
  padding: 9px 12px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-item::before {
  content: "";
  position: absolute; left: -16px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #2dd4bf, #0d9488);
  opacity: 0; transform: scaleY(.4);
  transition: opacity .18s ease, transform .18s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #f0fdfa; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(13, 148, 136, .22), rgba(13, 148, 136, .08));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, .18);
}
.nav-item.active::before { opacity: 1; transform: scaleY(1); }
.nav-item em { background: rgba(255, 255, 255, .1); color: #a7f3d0; }

/* ---------- Üst çubuk ---------- */
.topbar {
  height: 76px;
  margin-bottom: 30px;
  background: rgba(246, 248, 250, .8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 15;
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.03em; }
.icon-btn {
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: all .15s ease;
}
.icon-btn:hover { border-color: var(--teal); color: var(--teal); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ---------- Görünüm başlığı ---------- */
.view-head h2 { font-family: var(--font-display); letter-spacing: -.03em; }
.eyebrow { letter-spacing: .12em; }

/* ---------- Metrik kartları ---------- */
.metric-grid { gap: 16px; }
.metric {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.metric::after {
  content: "";
  position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 148, 136, .10), transparent 70%);
}
.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.metric strong { font-family: var(--font-display); font-size: 28px; letter-spacing: -.02em; }
.metric.accent {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  border-color: transparent;
  box-shadow: 0 12px 30px rgba(13, 148, 136, .28);
}
.metric.accent::after { background: radial-gradient(circle, rgba(255, 255, 255, .18), transparent 70%); }

/* ---------- Paneller ---------- */
.panel, .table-panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.panel { padding: 22px 24px; }
.panel h3 { font-family: var(--font-display); letter-spacing: -.02em; }

/* ---------- Butonlar ---------- */
.button { border-radius: 10px; font-weight: 600; transition: all .15s ease; }
.button.primary {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  box-shadow: 0 6px 16px rgba(13, 148, 136, .28);
}
.button.primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(13, 148, 136, .34); }
.button.ghost { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.button.ghost:hover { border-color: var(--teal); color: var(--teal); }

/* ---------- Rozetler (semantik) ---------- */
.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .02em;
  background: var(--bg-soft); color: var(--ink-2);
  border: 1px solid transparent;
}
.badge.success { background: var(--teal-soft); color: var(--teal-dark); }
.badge.warning { background: var(--amber-soft); color: #b45309; }
.badge.danger { background: var(--rose-soft); color: var(--rose); }
.badge.info { background: var(--blue-soft); color: #1d4ed8; }

/* ---------- Tablolar ---------- */
.table-panel { overflow: hidden; }
.table-scroll { overflow: auto; }
table { font-size: 12.5px; }
th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px; letter-spacing: .08em;
  padding: 13px 18px;
  position: sticky; top: 0; z-index: 1;
}
td { padding: 14px 18px; border-bottom: 1px solid #f1f4f7; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td, th { font-variant-numeric: tabular-nums; }

/* ---------- Cari / hesap kartları ---------- */
.customer-card, .account-card {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.customer-card:hover, .account-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-strong);
}
.customer-avatar, .account-icon {
  background: linear-gradient(135deg, var(--teal-soft), #e0f2fe);
  color: var(--teal-dark);
}

/* ---------- Kapsam anahtarı ---------- */
.scope-switch { background: var(--bg-soft); border-radius: 10px; padding: 4px; }
.scope-switch button { border-radius: 7px; font-weight: 600; }
.scope-switch button.active {
  background: var(--surface);
  color: var(--teal-dark);
  box-shadow: var(--shadow-sm);
}

/* ---------- Formlar ---------- */
.form-grid input, .form-grid select, .form-grid textarea,
.stack-form input, .stack-form select, .stack-form textarea,
.connection-settings input, .connection-settings select,
.invoice-filters input, .invoice-filters select {
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.stack-form input:focus, .stack-form select:focus, .stack-form textarea:focus,
.connection-settings input:focus, .connection-settings select:focus,
.invoice-filters input:focus, .invoice-filters select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: var(--ring);
}
.search { border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.search:focus-within { border-color: var(--teal); box-shadow: var(--ring); }

/* ---------- Boş durum ---------- */
.empty-state {
  border-radius: var(--r-lg);
  border: 1px dashed var(--line-strong);
  background: var(--surface);
}
.empty-illustration {
  background: linear-gradient(135deg, var(--teal-soft), #e0f2fe);
  box-shadow: 0 8px 20px rgba(13, 148, 136, .15);
}

/* ---------- Modal ---------- */
.modal-card {
  border-radius: var(--r-xl);
  box-shadow: 0 30px 90px rgba(15, 23, 42, .28);
  border: 1px solid var(--line);
}
.modal-backdrop { background: rgba(11, 31, 42, .55); backdrop-filter: blur(6px); }

/* ---------- Bildirim ---------- */
.notice {
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, .1);
}

/* ---------- Ayarlar bölümleri ---------- */
.settings-section { max-width: 920px; }
.section-heading h3 { font-family: var(--font-display); letter-spacing: -.02em; }
.settings-form { max-width: 920px; }
.settings-form .full { grid-column: 1 / -1; }
.settings-toggles { display: grid; gap: 9px; margin-top: 14px; }
.settings-toggles label, .toggle-field {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2);
}
.settings-toggles input, .toggle-field input { accent-color: var(--teal); }

/* ---------- Duyarlı ---------- */
@media (max-width: 720px) {
  .settings-grid { grid-template-columns: 1fr; }
  .settings-form { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .customer-grid, .account-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Ayarlar — modern SaaS düzeni (Linear/Stripe)
   ============================================================ */
.settings-layout { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 24px; align-items: start; }
.settings-main, .settings-side { display: flex; flex-direction: column; gap: 24px; }
.settings-group { display: flex; flex-direction: column; gap: 12px; }
.settings-group-head { display: flex; align-items: center; gap: 12px; padding: 2px 4px; }
.settings-group-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--teal-soft), #e0f2fe); color: var(--teal-dark); flex: none; }
.settings-group-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: var(--ink); }
.settings-group-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.settings-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.provider { display: flex; align-items: center; gap: 12px; }
.provider-mark { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: linear-gradient(135deg, var(--teal), #0ea5e9); color: #fff; flex: none; box-shadow: var(--shadow-sm); }
.provider-mark.alt { background: linear-gradient(135deg, var(--violet), var(--blue)); }
.provider h4 { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.provider p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.settings-status { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-fields { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.settings-fields label, .settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.settings-fields label.full, .settings-form label.full { grid-column: 1 / -1; }
.settings-fields input, .settings-fields select, .settings-fields textarea, .settings-form input, .settings-form select, .settings-form textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font-size: 13.5px; font-family: inherit; transition: border-color .15s, box-shadow .15s, background .15s; }
.settings-fields input:focus, .settings-fields select:focus, .settings-fields textarea:focus, .settings-form input:focus, .settings-form select:focus, .settings-form textarea:focus { outline: none; border-color: var(--teal); background: var(--surface); box-shadow: var(--ring); }
.settings-fields textarea, .settings-form textarea { resize: vertical; min-height: 72px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.settings-toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); transition: border-color .15s, background .15s; }
.settings-toggle:hover { border-color: var(--line-strong); background: var(--surface); }
.settings-toggle input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--teal); flex: none; }
.settings-toggle span { display: flex; flex-direction: column; gap: 2px; }
.settings-toggle b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.settings-toggle small { font-size: 12px; color: var(--muted); }
.settings-toggles { display: flex; flex-direction: column; gap: 10px; }
.settings-security { display: flex; flex-direction: column; gap: 12px; }
.security-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.security-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal-dark); flex: none; }
.security-row > div { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.security-row b { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.security-row small { font-size: 12px; color: var(--muted); }
.button.danger { color: var(--rose); border-color: var(--rose-soft); background: var(--rose-soft); }
.button.danger:hover { background: var(--rose); color: #fff; }

.settings-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 960px) {
  .settings-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .settings-fields { grid-template-columns: 1fr; }
  .settings-card { padding: 16px; }
}

/* Planning dashboard */
.planning-hero { align-items: flex-end; }
.planning-hero p { max-width: 680px; }
.planning-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.planning-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 20px 0 16px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.toolbar-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.planning-period { color: var(--ink-2); font-size: 13px; font-weight: 600; }
.planning-dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.planning-panel-wide { grid-column: 1 / -1; }
.planning-panel { min-width: 0; }
.planning-panel .panel-head { align-items: center; }
.panel-heading-icon { width: 18px; height: 18px; color: var(--muted-2); flex: none; }
.planning-dashboard .compact-list { min-height: 42px; }
.planning-dashboard .compact-row { min-height: 52px; }
.list-more { display: block; width: 100%; margin-top: 8px; padding: 9px 12px; border: 1px dashed var(--line); border-radius: var(--r-sm); background: transparent; color: var(--teal-dark); font-size: 12.5px; font-weight: 600; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.list-more:hover { background: var(--teal-soft); border-color: var(--teal); }

/* Akıllı kutu · AI asistan komut merkezi */
.ai-command-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.ai-quick-panel { min-width: 0; }
.ai-quick-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ai-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; transition: border-color .15s ease, background .15s ease, transform .1s ease; }
.ai-tile:hover { border-color: var(--teal); background: var(--teal-soft); transform: translateY(-1px); }
.ai-tile i { width: 20px; height: 20px; color: var(--teal-dark); margin-bottom: 6px; }
.ai-tile span { font-size: 13.5px; font-weight: 700; }
.ai-tile small { font-size: 11.5px; color: var(--muted-2); }
.ai-chat-panel { min-width: 0; display: flex; flex-direction: column; }
.ai-chat-messages { flex: 1; min-height: 120px; max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.ai-msg { max-width: 88%; padding: 9px 12px; border-radius: var(--r-md); font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ai-msg.ai.error { border-color: var(--danger); color: var(--danger); }
.ai-chat-form { display: flex; gap: 8px; margin-top: 10px; }
.ai-chat-form textarea { flex: 1; resize: none; }
.ai-chat-form .button { flex: none; align-self: flex-end; }

@media (max-width: 900px) {
  .ai-command-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .planning-hero { align-items: flex-start; }
  .planning-actions { width: 100%; }
  .planning-actions .button { flex: 1 1 190px; justify-content: center; }
  .planning-toolbar { align-items: flex-start; flex-direction: column; }
  .planning-period { align-self: flex-start; }
  .planning-dashboard { grid-template-columns: 1fr; }
  .planning-panel-wide { grid-column: auto; }
}
@media (max-width: 480px) {
  .planning-actions .button { width: 100%; }
  .planning-toolbar { margin-top: 16px; }
  .planning-toolbar .scope-switch { width: 100%; }
  .planning-toolbar .scope-switch button { flex: 1; }
}

/* --- Fişler (ÖKC) --- */
.receipt-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.receipt-summary-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.receipt-summary-cards .stat { flex: 1 1 160px; padding: 12px 14px; border: 1px solid var(--border, #e5e7eb); border-radius: 10px; }
.receipt-summary-cards .stat span { display: block; font-size: 12px; opacity: .7; }
.receipt-summary-cards .stat strong { display: block; font-size: 20px; margin-top: 4px; }
.receipt-list { display: grid; gap: 16px; }
.receipt-card { display: grid; grid-template-columns: 132px 1fr; gap: 16px; padding: 14px; border: 1px solid var(--border, #e5e7eb); border-radius: 12px; }
.receipt-thumb { display: block; overflow: hidden; border-radius: 8px; background: rgba(0,0,0,.04); }
.receipt-thumb img { width: 100%; height: 100%; max-height: 190px; object-fit: cover; display: block; }
.receipt-body > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.receipt-badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.receipt-badge.pending { color: #b45309; }
.receipt-badge.confirmed { color: #047857; }
.receipt-badge.rejected { color: #b91c1c; }
.receipt-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 16px; margin: 0 0 10px; }
.receipt-fields div { margin: 0; }
.receipt-fields dt { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; opacity: .6; }
.receipt-fields dd { margin: 2px 0 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.receipt-breakdown { font-size: 13px; opacity: .8; margin: 0 0 8px; }
.receipt-warning { font-size: 13px; color: #b45309; margin: 0 0 6px; }
.receipt-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

@media (max-width: 720px) {
  .receipt-card { grid-template-columns: 1fr; }
  .receipt-thumb img { max-height: 240px; object-fit: contain; }
}

/* --- Sayfalama ve yükleniyor göstergeleri --- */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; padding: 12px 2px 0; font-size: 13px;
}
.pager:empty { display: none; }
.pager-info { opacity: .75; font-variant-numeric: tabular-nums; }
.pager-info strong { font-weight: 600; opacity: 1; }
.pager-buttons { display: flex; gap: 8px; }
.pager-buttons button[disabled] { opacity: .4; cursor: not-allowed; }

/* Yüklenirken içerik yerine hareketli iskelet: ekran değiştirince eski veya
   boş içeriğin öylece durması uygulamanın donduğu izlenimi veriyordu. */
.skeleton-list { display: grid; gap: 10px; padding: 4px 0; }
.skeleton-row {
  height: 46px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(0,0,0,.05) 25%, rgba(0,0,0,.09) 37%, rgba(0,0,0,.05) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
/* Hareketi azalt tercihi olan kullanıcıda animasyon kapanır. */
@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; }
}

/* --- Yerleşim genişliği ve yoğunluk --- */
/*
   İçerik `max-width:1250px` ile kapatılıp ortalanıyordu; 1920px ekranda
   kenarlarda 203'er piksel boşluk kalıyor, panel dar ve dengesiz görünüyordu.
   Sınır tamamen kaldırılmıyor: çok geniş ekranda satır uzunluğu okunaksız
   olur. 1500px, 1920'de boşluğu 34 piksele indirirken 2560px'te okunabilir
   bir genişlik bırakır.
*/
.view { max-width: 1500px; }

/* Dikey ritim: başlık altı boşluğu ve kart iç dolgusu fazlaydı; ekranda
   gereğinden az bilgi görünüyordu. */
.topbar { margin-bottom: 26px; }
.metric { padding: 16px 18px; }
.metric strong { margin: 8px 0 6px; }
.panel, .table-panel { padding: 18px 20px; }
.table-panel { padding: 0; }

/* Boş ve hata durumları ekranın yarısını kaplıyordu. */
.empty, .error { padding: 30px 24px; }
.empty-state { padding: 44px 24px; }
.empty-state h3 { margin: 12px 0 6px; }

@media (max-width: 1400px) {
  .view { max-width: 1250px; }
}

/* Durum filtresi çipleri (Fişler). Projede `.chip` diye bir bileşen yoktu;
   `.scope-switch` kullanılabilirdi ama ona bağlı genel kapsam değiştirme
   işleyicisi var, bu yüzden ayrı ve bağımsız bir bileşen tanımlandı. */
.chip {
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface, #fff);
  color: var(--muted); font-size: 12px; font-weight: 600;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover { border-color: #91c7bf; color: var(--ink); }
.chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }

/* --- Mobil: kenar çubuğu tüm ekranlarda açılır panel --- */
/*
   Kenar çubuğu 258px sabit genişlikteydi ve YALNIZCA Faturalar ekranı için
   mobil kuralı vardı (`body:has(#view-invoices.active)`). Diğer tüm
   ekranlarda telefonda içerik ~100 piksele sıkışıyor, panel kullanılamaz
   hâle geliyordu. `#menuBtn` ve `#sidebar.open` mantığı app.js'te zaten
   mevcuttu; eksik olan yalnızca bu CSS'ti.
*/
@media (max-width: 860px) {
  .mobile-only { display: grid; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(16, 42, 51, .35);
  }
  .sidebar.open { transform: none; }
  .main { padding: 0 16px 40px; }
  .topbar { height: auto; padding: 14px 0; gap: 12px; }
  .view-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .split-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .search { max-width: none; }
  /* Geniş tablolar taşmak yerine kendi içinde kaydırılır. */
  .table-panel { overflow-x: auto; }
}
@media (max-width: 860px) {
  /* Açık menünün arkasındaki içeriğe tıklanınca kapanması için örtü. */
  .sidebar.open::after {
    content: ''; position: fixed; inset: 0 0 0 258px;
    background: rgba(16, 42, 51, .45); z-index: -1;
  }
}


/* ============================================================
   FAZ 1 — Kabuk ve tipografi ölçeği
   Bu blok mevcut tasarım katmanını EZMEZ: yalnızca styles.css'te
   sabit renk olarak kalmış nötrleri tokenlara bağlar ve tipografi
   ölçeğini uygular. Kenar çubuğu gradyanı, aktif menü halkası ve
   buton/metrik hover davranışları olduğu gibi korunur.
   ============================================================ */

/* styles.css'te sabit kalmış nötr yüzeyler. #fbfcfc ve #eef1f2 gibi
   değerler palete bağlı olmadığı için tema tek yerden değiştirilemiyordu. */
.quick-actions button { background: var(--surface-2); border-color: var(--line); }
.compact-row { background: var(--surface-2); border-color: var(--line); }
.stack-form input, .stack-form select, .stack-form textarea,
.form-grid input, .form-grid select, .form-grid textarea { background: var(--surface-2); border-color: var(--line); }
.health-row { border-bottom-color: var(--line); }
td { border-bottom-color: var(--line); }
.card-actions { border-top-color: var(--line); }
.empty-state { border-color: var(--line-strong); }
.quick-actions button > svg:last-child { color: var(--muted-2); }
.search { color: var(--muted-2); }
.search input { color: var(--ink); }

/* Tipografi ölçeği. Önce 31/24/17/16/15/13/12.5/12/11.5/11/10 gibi
   düzensiz adımlar vardı; aynı görevdeki metinler farklı boyuttaydı. */
.topbar h1 { font-size: var(--fs-title); }
.view-head h2 { font-size: var(--fs-display); }
.view-head p { font-size: var(--fs-body); }
.panel h3, .customer-card h3, .account-card h3 { font-size: var(--fs-section); }
.eyebrow { font-size: var(--fs-micro); }
.nav-item { font-size: var(--fs-small); }
.button { font-size: var(--fs-small); }
.quick-actions b, .compact-row b { font-size: var(--fs-small); }
.quick-actions small, .compact-row small, .health-row small { font-size: var(--fs-micro); color: var(--muted); }
.identifier, .customer-meta { font-size: var(--fs-small); color: var(--muted); }

/* Odak görünürlüğü: klavyeyle gezerken hangi öğede olunduğu belli olmuyordu. */
:where(button, a, input, select, textarea):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
}

/* ============================================================
   FAZ 3 — Giriş ekranı
   login.html yalnızca tailwind.css + styles.css yüklüyordu; design.css
   hiç yüklenmiyordu. Artık yükleniyor, ancak `.auth-page` kuralları
   rengi SABİT yazdığı için (#087f78 eski yeşil) uygulama paletiyle
   uyuşmuyordu. Bu blok giriş ekranını tek palete bağlar.
   ============================================================ */
.auth-page { background: var(--surface); }
.auth-page .auth-intro {
  background: linear-gradient(160deg, var(--teal-soft) 0%, #e8f3f1 55%, var(--surface-2) 100%);
  border-right: 1px solid var(--line);
}
.auth-page h1 { font-family: var(--font-display); letter-spacing: -.03em; color: var(--ink); }
.auth-page .intro-lead { color: var(--ink-2); }
.auth-page .brand-name { font-family: var(--font-display); letter-spacing: -.02em; }

/* Sol paneldeki örnek defter kartı */
.auth-page .ledger-card {
  border-color: var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.auth-page .ledger-head, .auth-page .ledger-foot { background: var(--surface-2); }
.auth-page .ledger-row { border-top-color: var(--line); }
.auth-page .ledger-date { color: var(--muted); }
.auth-page .ledger-amount.in { color: var(--teal); }
.auth-page .ledger-amount.out { color: var(--rose); }
.auth-page .ledger-foot { border-top-color: var(--line); }
.auth-page .intro-footer { color: var(--muted); }
.auth-page .status-dot { background: var(--teal); }
.auth-page .footer-rule { background: var(--line-strong); }

/* Sağ panel: form */
.auth-page .auth-panel { background: var(--surface); }
.auth-page .eyebrow { color: var(--teal); font-size: var(--fs-micro); letter-spacing: .12em; }
.auth-page h2 { font-family: var(--font-display); letter-spacing: -.025em; color: var(--ink); }
.auth-page #authSubtitle { color: var(--muted); }
.auth-page .field-group label { color: var(--ink-2); }
.auth-page input {
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.auth-page input:focus { outline: none; border-color: var(--teal); background: var(--surface); box-shadow: var(--ring); }
/* Giriş butonu uygulamadaki birincil butonla aynı dili konuşur. */
.auth-page button[type="submit"] {
  background: linear-gradient(135deg, var(--teal), var(--teal-dark));
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(13, 148, 136, .28);
  transition: transform .15s ease, box-shadow .15s ease;
}
.auth-page button[type="submit"]:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(13, 148, 136, .34); }

/* ============================================================
   FAZ 4 — Genel bakış
   Eski hâlde "Çalışma alanı durumu" paneli SABİT metindi ve gerçek
   durumu kontrol etmeden her zaman "Aktif/Bağlı" yazıyordu. Yerine
   gerçek veriye dayanan "Dikkat gerektirenler" ve "Son hareketler"
   panelleri geldi.
   ============================================================ */

/* Tıklanabilir iş satırı: buton olduğu için tarayıcı varsayılanları sıfırlanır. */
.overview-todo-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.overview-todo-row:hover {
  border-color: var(--teal);
  background: var(--surface);
  transform: translateX(2px);
}
.overview-todo-row strong {
  min-width: 28px;
  text-align: right;
  color: var(--teal-dark);
  font-size: var(--fs-section);
}

/* "Bekleyen iş yok" — boşluk değil, olumlu bir durum olarak gösterilir. */
.overview-clear {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px;
  border: 1px solid var(--teal-soft);
  border-radius: var(--r-md);
  background: var(--teal-soft);
  color: var(--teal-dark);
}
.overview-clear svg { width: 22px; flex: none; }
.overview-clear b { display: block; font-size: var(--fs-small); }
.overview-clear small { color: var(--teal-dark); opacity: .8; font-size: var(--fs-micro); }

.overview-recent { margin-top: 18px; }
.overview-recent .compact-row strong { font-variant-numeric: tabular-nums; }

/* `.compact-row > span:first-child` genel kuralı `flex:1` veriyor; bu satırda
   ilk eleman ikon kutusu olduğu için ikon bant gibi uzuyordu. İkon sabit
   kalmalı, metin esnemeli. */
/* Özgüllük notu: rakip kural `.compact-row > span:first-child` (0,2,1)
   olduğu için seçicinin en az o kadar spesifik olması gerekiyor. */
.compact-row.overview-todo-row > span.health-icon:first-child { flex: none; width: 34px; }
.compact-row.overview-todo-row > span:nth-child(2) { min-width: 0; display: grid; gap: 3px; flex: 1; }

/* ============================================================
   FAZ 4 — Cariler
   Kart alt satırındaki "Ekstre" butonunda ikon ve metin aynı hizada
   değildi: `.text-button` flex olmadığı için lucide'ın ürettiği SVG
   satır içinde kalıyor ve metni alt satıra itiyordu.
   ============================================================ */
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-small);
  border-radius: var(--r-sm);
  padding: 4px 6px;
  margin: -4px -6px;           /* hizayı bozmadan tıklama alanını büyüt */
  transition: background .15s ease, color .15s ease;
}
.text-button svg { width: 15px; height: 15px; flex: none; }
.text-button:hover { background: var(--teal-soft); color: var(--teal-dark); }

.card-actions { border-top-color: var(--line); gap: 10px; }
.card-actions .icon-btn.small svg { width: 15px; height: 15px; }

/* Cari kartı: başlık uzun ünvanlarda kesiliyordu; iki satıra kadar
   gösterilip sonrası kısaltılıyor (tam ünvan title özniteliğinde). */
.customer-card { display: flex; flex-direction: column; }
.customer-card h3 {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  min-height: calc(2 * 1.35em);
  margin: 14px 0 6px;
}
.customer-card .customer-meta { margin: 12px 0 14px; }
.customer-card .card-actions { margin-top: auto; }

/* Az sayıda cari varken kartlar ekranı boydan boya gerip garip
   görünmesin diye sütun genişliği sınırlandırıldı. */
.customer-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* ============================================================
   FAZ 4 — Cari ekstresi (tam sürüm)
   ============================================================ */
.statement-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.statement-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.statement-identity { margin-bottom: 18px; }
.statement-identity h3 { font-size: var(--fs-title); margin: 0 0 4px; letter-spacing: -.02em; }
.statement-contact { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; color: var(--muted); font-size: var(--fs-small); }
.statement-contact span { display: inline-flex; align-items: center; gap: 6px; }
.statement-contact svg { width: 14px; height: 14px; }

.statement-filter { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-sm); }
.statement-filter label { display: grid; gap: 6px; font-size: var(--fs-micro); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.statement-filter input { height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); font: inherit; }

.statement-balances { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.statement-balance { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.statement-balance span { display: block; font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.statement-balance strong { display: block; margin: 8px 0 4px; font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.statement-balance small { color: var(--muted); font-size: var(--fs-small); }

.statement-period { margin-bottom: 18px; }
.statement-count { color: var(--muted); font-size: var(--fs-small); margin: 0 0 12px; }

/* Fatura mı tahsilat mı olduğu bir bakışta ayrılsın. */
.statement-kind { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-micro); font-weight: 700; }
.statement-kind.invoice { background: var(--blue-soft); color: #1d4ed8; }
.statement-kind.payment { background: var(--teal-soft); color: var(--teal-dark); }

@media (max-width: 720px) {
  .statement-filter { flex-direction: column; align-items: stretch; }
  .statement-filter label, .statement-filter .button { width: 100%; }
}

/* Yazdırma: ekran kabuğu ve etkileşimli kontroller kâğıda basılmaz. */
@media print {
  .sidebar, .topbar, .statement-head, .statement-filter, .toolbar, .view-head > button, .notice { display: none !important; }
  .main { padding: 0; }
  .view { max-width: none; }
  #customersGrid, #customerPager { display: none !important; }
  .panel, .table-panel, .statement-balance { box-shadow: none; border-color: #ccc; }
  body { background: #fff; }
  table { font-size: 11px; }
}

/* ============================================================
   Yapışkan AI asistanı (ai-dock)
   Telegram botuyla aynı /api/ai/assistant ucunu kullanır.
   ============================================================ */
.ai-dock-toggle {
  position: fixed; right: 22px; bottom: 22px; z-index: 45;
  display: inline-flex; align-items: center; gap: 9px;
  height: 52px; padding: 0 20px 0 17px;
  border: 0; border-radius: 999px;
  background: linear-gradient(135deg, #14b8a6, var(--teal-dark));
  color: #fff; font: 600 13.5px var(--font); letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(13, 148, 136, .38);
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.ai-dock-toggle:hover { transform: translateY(-2px); box-shadow: 0 18px 42px rgba(13, 148, 136, .46); }
.ai-dock-toggle svg { width: 19px; height: 19px; }
.ai-dock-toggle[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: scale(.9); }

/* Panel */
.ai-dock {
  position: fixed; right: 22px; bottom: 22px; z-index: 46;
  width: 392px; max-height: min(620px, calc(100dvh - 44px));
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 26px 70px rgba(15, 23, 42, .22);
  overflow: hidden;
  animation: ai-dock-in .26s cubic-bezier(.2, .8, .3, 1) both;
}
.ai-dock[hidden] { display: none; }
@keyframes ai-dock-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.ai-dock-head {
  display: flex; align-items: center; gap: 11px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(20, 184, 166, .10), rgba(13, 148, 136, .04));
}
.ai-dock-avatar {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center; border-radius: 11px;
  background: linear-gradient(140deg, #5eead4, #14b8a6); color: #04312f;
}
.ai-dock-avatar svg { width: 17px; height: 17px; }
.ai-dock-id { flex: 1; min-width: 0; }
.ai-dock-id b { display: block; font-size: var(--fs-body); letter-spacing: -.01em; }
.ai-dock-id small { display: block; margin-top: 2px; font-size: var(--fs-micro); color: var(--muted); }

.ai-dock-log {
  flex: 1; min-height: 180px;
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.ai-dock-empty { margin: auto 0; text-align: center; color: var(--muted); font-size: var(--fs-small); line-height: 1.6; }

.ai-bubble { max-width: 86%; padding: 10px 13px; border-radius: 14px; font-size: var(--fs-body); line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-bubble.user { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 5px; }
.ai-bubble.bot { align-self: flex-start; background: var(--bg-soft); color: var(--ink); border-bottom-left-radius: 5px; }
.ai-bubble.error { background: var(--rose-soft); color: #9f1239; }
.ai-bubble b { font-weight: 650; }

/* Taslak kartı: Telegram'daki onay akışının panel karşılığı. */
.ai-draft-card {
  align-self: flex-start; max-width: 92%;
  border: 1px solid var(--teal-soft); border-radius: 14px;
  background: var(--surface); overflow: hidden;
}
.ai-draft-card header { padding: 10px 13px; background: var(--teal-soft); color: var(--teal-dark); font-size: var(--fs-small); font-weight: 650; }
.ai-draft-card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; padding: 11px 13px; font-size: var(--fs-small); }
.ai-draft-card dt { color: var(--muted); }
.ai-draft-card dd { margin: 0; font-variant-numeric: tabular-nums; }
.ai-draft-actions { display: flex; gap: 8px; padding: 0 13px 12px; }
.ai-draft-actions .button { flex: 1; justify-content: center; padding: 8px 10px; }
.ai-draft-note { padding: 0 13px 12px; margin: 0; font-size: var(--fs-micro); color: var(--muted); line-height: 1.5; }

/* Yazıyor göstergesi */
.ai-typing { display: inline-flex; gap: 4px; align-items: center; }
.ai-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); animation: ai-typing 1.1s ease-in-out infinite; }
.ai-typing span:nth-child(2) { animation-delay: .18s; }
.ai-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes ai-typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.ai-dock-chips { display: flex; gap: 7px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
.ai-dock-chips::-webkit-scrollbar { display: none; }
.ai-dock-chips .chip { white-space: nowrap; font-size: var(--fs-micro); padding: 6px 12px; }

.ai-dock-form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.ai-dock-form textarea {
  flex: 1; min-width: 0;
  max-height: 120px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--fs-body); line-height: 1.5;
  resize: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ai-dock-form textarea:focus { outline: none; border-color: var(--teal); box-shadow: var(--ring); }
.ai-dock-send {
  flex: none; width: 40px; height: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r-md);
  background: linear-gradient(135deg, #14b8a6, var(--teal-dark)); color: #fff;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease;
}
.ai-dock-send:hover { transform: translateY(-1px); }
.ai-dock-send:disabled { opacity: .5; cursor: progress; transform: none; }
.ai-dock-send svg { width: 18px; height: 18px; }

/* Mobil: tam ekran sayfa. Küçük ekranda köşe paneli kullanışsız. */
@media (max-width: 560px) {
  .ai-dock {
    right: 0; bottom: 0; left: 0;
    width: auto; max-height: 100dvh; height: 100dvh;
    border-radius: 0; border: 0;
  }
  .ai-dock-toggle { right: 16px; bottom: 16px; }
  .ai-dock-label { display: none; }
  .ai-dock-toggle { padding: 0; width: 52px; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-dock { animation: none; }
  .ai-typing span { animation: none; opacity: .5; }
  .ai-dock-toggle, .ai-dock-send, .ai-dock-form textarea { transition: none; }
  .ai-dock-log { scroll-behavior: auto; }
}

/* ============================================================
   Faturalar ekranı (#view-invoices) — yeniden kurulan sayfa yapısı
   ------------------------------------------------------------
   Eski hâlinde ekran üç ayrı araç çubuğuyla başlıyor, gelişmiş filtreler
   her zaman açık duruyor ve asıl içerik (liste) çok aşağıda kalıyordu.
   Ayrıca fatura satırları genel `table` stilini kullandığı için tarih,
   numara, tutar ve durum aynı görsel ağırlıktaydı; gözün tutarı ve durumu
   ayırt etmesi zordu.
   Bu blok yalnızca `#view-invoices` ve `inv-` önekli sınıfları hedefler;
   genel bileşenleri (`.button`, `.badge`, `.icon-btn`) EZMEZ.
   ============================================================ */

#view-invoices { max-width: 1320px; }

/* --- Başlık --- */
.inv-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.inv-head-text h2 {
  margin: 6px 0 6px;
  font: 600 var(--fs-display) / 1.1 var(--font-display), var(--font);
  letter-spacing: -.03em;
  color: var(--ink);
}
.inv-head-text p { margin: 0; max-width: 62ch; color: var(--muted); font-size: var(--fs-small); line-height: 1.6; }
.inv-head-actions { display: flex; gap: var(--sp-2); flex: none; }

/* Yıl seçici: fatura çekimi takvim yılı bazlıdır, varsayılan içinde
   bulunulan yıl. Geçmiş yıl gerektiğinde açıkça seçilir. */
.inv-year {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 10px 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted);
}
.inv-year:focus-within { border-color: var(--teal); box-shadow: var(--ring); }
.inv-year svg { width: 15px; flex: none; }
.inv-year select {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: var(--fs-small);
  font-weight: 700;
  padding-right: 2px;
}

/* --- Canlı özet kartları ---
   Rakamlar EKRANDA GÖRÜNEN filtrelenmiş listeden hesaplanır; filtre
   değişince birlikte değişirler. Tahmini veya sabit hiçbir değer yoktur. */
.inv-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.inv-stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px 17px;
  box-shadow: var(--shadow-sm);
}
.inv-stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent, var(--line-strong));
}
.inv-stat span { display: block; font-size: var(--fs-micro); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.inv-stat strong { display: block; margin: 9px 0 5px; font: 600 21px/1.15 var(--font-display), var(--font); letter-spacing: -.02em; color: var(--ink); }
.inv-stat small { display: block; font-size: var(--fs-micro); color: var(--muted-2); }
.inv-stat.is-sales { --accent: var(--teal); }
.inv-stat.is-purchase { --accent: var(--blue); }
.inv-stat.is-pending { --accent: var(--amber); }
/* İşlem bekleyen kartı tıklanabilir (taslak sekmesine geçer); düğme olduğu
   için hizalama ve imleç ayrıca verilir. */
button.inv-stat { display: block; width: 100%; text-align: left; cursor: pointer; font: inherit; }
button.inv-stat:hover { border-color: var(--amber); box-shadow: var(--shadow-md); }
.inv-stat.is-pending strong { color: #92400e; }

/* --- Sekme ve komuta çubuğu --- */
.inv-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-4);
}
.inv-tabs { display: flex; gap: var(--sp-5); }
.inv-tabs button {
  position: relative;
  padding: 11px 2px 13px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-body);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: color .16s ease, border-color .16s ease;
}
.inv-tabs button:hover { color: var(--ink-2); }
.inv-tabs button.active { color: var(--teal-dark); border-bottom-color: var(--teal); }
.inv-bar-tools { display: flex; align-items: center; gap: var(--sp-2); padding-bottom: 9px; flex-wrap: wrap; }

.inv-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-width: 230px;
  padding: 0 11px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--muted-2);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.inv-search:focus-within { border-color: var(--teal); box-shadow: var(--ring); }
.inv-search svg { width: 15px; flex: none; }
.inv-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: var(--fs-small); color: var(--ink); }

/* Yön seçimi kendi bileşeni: aynı satırda arama ve filtre düğmesiyle
   hizalanması gerekiyor, `.scope-switch` alt boşluk taşıdığı için satırı
   bozuyordu. */
.inv-seg { display: flex; gap: 2px; padding: 3px; background: var(--bg-soft); border-radius: var(--r-sm); }
.inv-seg button {
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-micro);
  font-weight: 700;
  transition: background .16s ease, color .16s ease;
}
.inv-seg button:hover { color: var(--ink-2); }
.inv-seg button.active { background: var(--surface); color: var(--teal-dark); box-shadow: var(--shadow-sm); }

.inv-filter-toggle { height: 36px; padding: 0 12px; font-size: var(--fs-small); }
.inv-filter-toggle[aria-expanded="true"] { border-color: var(--teal); color: var(--teal-dark); }
.inv-filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 9px;
  background: var(--teal);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.inv-filter-count[hidden] { display: none; }

/* --- Gelişmiş filtreler: varsayılan KAPALI --- */
.inv-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-3);
  align-items: end;
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.inv-filters[hidden] { display: none; }
.inv-filters label { display: grid; gap: 6px; font-size: var(--fs-micro); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.inv-filters input, .inv-filters select {
  height: 36px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-small);
}
.inv-filters input:focus, .inv-filters select:focus { outline: 0; border-color: var(--teal); box-shadow: var(--ring); }
.inv-filters .button { height: 36px; justify-content: center; }

/* --- Aktif filtre çipleri: neyin açık olduğu görünür olsun --- */
.inv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-3); }
.inv-chips[hidden] { display: none; }
.inv-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px 5px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-micro);
  font-weight: 600;
}
.inv-chip b { font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.inv-chip button {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}
.inv-chip button:hover { background: var(--rose-soft); color: var(--rose); }

/* --- Durum satırı --- */
.inv-statusline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-small);
  color: var(--muted);
}
.inv-statusline-spacer { flex: 1; }
.inv-conn { font-size: var(--fs-micro); color: var(--muted-2); }
.inv-statusline .icon-btn { width: 30px; height: 30px; }

/* --- Sağlayıcı detayı --- */
.inv-sources { margin-bottom: var(--sp-4); }
.inv-sources summary {
  cursor: pointer;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-small);
  font-weight: 600;
  list-style: none;
}
.inv-sources summary::-webkit-details-marker { display: none; }
.inv-sources summary::before { content: "\25B8  "; color: var(--muted-2); }
.inv-sources[open] summary { border-radius: var(--r-sm) var(--r-sm) 0 0; border-bottom-color: transparent; }
.inv-sources[open] summary::before { content: "\25BE  "; }
.inv-sources > div {
  padding: var(--sp-4);
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: var(--surface);
}

/* --- Liste --- */
.inv-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.inv-table-scroll { overflow-x: auto; }
.inv-list table { width: 100%; border-collapse: collapse; font-size: var(--fs-small); }
.inv-list thead th {
  padding: 11px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--fs-micro);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  text-align: left;
  white-space: nowrap;
}
.inv-list tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.inv-list tbody tr:last-child td { border-bottom: 0; }
.inv-list tbody tr { transition: background .14s ease; }
.inv-list tbody tr:hover { background: var(--surface-2); }

/* Tarih: gün büyük, ay ve yıl küçük. Liste tarih sırasında tarandığı için
   gözün güne kilitlenmesi gerekiyor. */
.inv-date { display: grid; gap: 1px; line-height: 1.25; }
.inv-date b { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.inv-date small { font-size: var(--fs-micro); color: var(--muted-2); }

.inv-no { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: var(--fs-micro); color: var(--ink-2); letter-spacing: -.01em; }
.inv-no.is-empty { color: var(--muted-2); font-style: italic; font-family: var(--font); }

.inv-party { display: grid; gap: 2px; max-width: 320px; }
.inv-party b { font-size: var(--fs-body); font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-source { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-micro); color: var(--muted); }
.inv-source::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--muted-2)); }
.inv-source.is-local { --dot: var(--violet); }
.inv-source.is-bimasraf { --dot: var(--blue); }
.inv-source.is-nilvera { --dot: var(--teal); }

.inv-dir { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-micro); font-weight: 700; }
.inv-dir svg { width: 13px; }
.inv-dir.is-sales { color: var(--teal-dark); }
.inv-dir.is-purchase { color: var(--blue); }

/* Başlık hücresi de sağa hizalanmalı: `.inv-list thead th` özgüllüğü
   `.inv-amount` kuralını yeniyordu, TUTAR başlığı solda kalıyordu. */
.inv-amount, .inv-list thead th.inv-amount { text-align: right; }
.inv-amount b { font-size: var(--fs-body); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-amount small { display: block; margin-top: 2px; font-size: var(--fs-micro); color: var(--muted-2); }

.inv-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 20px;
  background: var(--tone-soft, var(--bg-soft));
  color: var(--tone, var(--muted));
  font-size: var(--fs-micro);
  font-weight: 700;
  white-space: nowrap;
}
.inv-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.inv-state.is-ok { --tone: #0f766e; --tone-soft: var(--teal-soft); }
.inv-state.is-wait { --tone: #92400e; --tone-soft: var(--amber-soft); }
.inv-state.is-bad { --tone: #9f1239; --tone-soft: var(--rose-soft); }
.inv-state.is-idle { --tone: var(--muted); --tone-soft: var(--bg-soft); }

/* İşlem düğmeleri: her satırda dört dolu renkli düğme listeyi okunmaz hâle
   getiriyordu. Sessiz dururlar, üzerine gelince belirginleşirler; yalnızca
   asıl eylem (faturayı kes) her zaman dolu. */
.inv-actions { display: flex; justify-content: flex-end; gap: 5px; }
.inv-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 29px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--fs-micro);
  font-weight: 700;
  transition: color .14s ease, border-color .14s ease, background .14s ease;
}
.inv-act svg { width: 14px; }
.inv-act:hover { color: var(--teal-dark); border-color: var(--teal); background: var(--teal-soft); }
.inv-act.is-icon { width: 29px; padding: 0; justify-content: center; }
.inv-act.is-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.inv-act.is-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.inv-act.is-danger:hover { color: var(--rose); border-color: var(--rose); background: var(--rose-soft); }

.inv-list .empty, .inv-list .empty-state { border: 0; background: transparent; box-shadow: none; }
.inv-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--amber-soft);
  color: #7c4a03;
  font-size: var(--fs-small);
}
.inv-warning svg { width: 16px; flex: none; margin-top: 1px; }

/* --- Dar ekran: tablo satırları karta dönüşür --- */
@media (max-width: 900px) {
  .inv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .inv-head { align-items: flex-start; }
  .inv-head-actions { width: 100%; }
  .inv-head-actions .button { flex: 1; justify-content: center; }
  .inv-bar { align-items: stretch; }
  .inv-bar-tools { width: 100%; }
  .inv-search { flex: 1 1 100%; min-width: 0; }
  .inv-list { border-radius: var(--r-md); }
  .inv-list thead { display: none; }
  .inv-list table, .inv-list tbody, .inv-list tr, .inv-list td { display: block; width: auto; }
  /* Kart düzeni ızgarayla kurulur: alt alta yığılmış yedi alan satırı
     358px yüksekliğe çıkarıyordu, telefonda ekranda tek fatura kalıyordu.
     Sütun sırası sabittir: 1 tarih, 2 no, 3 cari, 4 yön, 5 tutar, 6 durum,
     7 işlemler. */
  .inv-list tbody tr {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 4px 10px;
    padding: 13px 15px;
    border-bottom: 1px solid var(--line);
  }
  .inv-list tbody td { padding: 0; border: 0; white-space: normal; min-width: 0; }
  .inv-list tbody td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .inv-list tbody td:nth-child(4) { grid-column: 2; grid-row: 1; align-self: center; }
  .inv-list tbody td:nth-child(6) { grid-column: 3; grid-row: 1; justify-self: end; }
  .inv-list tbody td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; margin-top: 2px; }
  .inv-list tbody td:nth-child(2) { grid-column: 1 / 3; grid-row: 3; align-self: center; }
  .inv-list tbody td:nth-child(5) { grid-column: 3; grid-row: 3; justify-self: end; }
  .inv-list tbody td:nth-child(7) { grid-column: 1 / -1; grid-row: 4; margin-top: 4px; }
  /* Kart düzeninde tarih yan yana okunur; dikey iki satır yer kaybı. */
  .inv-list tbody .inv-date { display: flex; align-items: baseline; gap: 5px; }
  .inv-list tbody .inv-party b { white-space: normal; }
  .inv-amount b { font-size: var(--fs-section); }
  .inv-list td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: var(--fs-micro);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted-2);
  }
  .inv-list td:nth-child(1)::before, .inv-list td:nth-child(3)::before,
  .inv-list td:nth-child(4)::before, .inv-list td:nth-child(6)::before,
  .inv-list td:nth-child(7)::before { content: none; }
  .inv-amount { text-align: left; }
  .inv-actions { justify-content: flex-start; margin-top: 8px; flex-wrap: wrap; }
  .inv-party { max-width: none; }
}
@media (max-width: 460px) {
  .inv-stats { grid-template-columns: 1fr; }
}
