:root,
html[data-theme="light"] {
  --bg: #eef2f6;
  --bg-elev: #ffffff;
  --bg-soft: #f7f9fc;
  --text: #1a2332;
  --muted: #5b6b7c;
  --line: #d7e0ea;
  --brand: #0f4c5c;
  --brand-2: #1b6b7a;
  --accent: #c45c26;
  --sidebar: #0d3b47;
  --sidebar-text: #e8f1f4;
  --ok: #1f7a4d;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(15, 40, 60, .08);
}

html[data-theme="dark"] {
  --bg: #0f141a;
  --bg-elev: #171e27;
  --bg-soft: #1d2631;
  --text: #e8eef5;
  --muted: #9aabbc;
  --line: #2a3644;
  --brand: #4db8c9;
  --brand-2: #2f8f9d;
  --accent: #e0874f;
  --sidebar: #0a1218;
  --sidebar-text: #d7e6ee;
  --ok: #3dbe7a;
  --danger: #f04438;
  --shadow: 0 12px 36px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", "Candara", "Gill Sans", sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(27,107,122,.16), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(196,92,38,.12), transparent 50%),
    var(--bg);
  color: var(--text);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background: linear-gradient(180deg, var(--sidebar), #0a2c35 80%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: margin-left .25s ease, transform .25s ease;
  z-index: 30;
  box-shadow: var(--shadow);
}

.app-shell.sidebar-collapsed .sidebar {
  margin-left: -270px;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 22px 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #8f3d16);
  color: #fff; font-weight: 800; letter-spacing: .5px;
}
.sidebar-brand strong { display: block; font-size: 1rem; }
.sidebar-brand small { opacity: .75; }

.sidebar-nav {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px; flex: 1; overflow: auto;
}
.sidebar-nav a {
  color: var(--sidebar-text);
  padding: 11px 14px;
  border-radius: 10px;
  opacity: .88;
  transition: .15s ease;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  opacity: 1;
}

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { margin-bottom: 10px; }
.user-chip span { display: block; font-weight: 600; }
.user-chip small { opacity: .7; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px;
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.icon-btn {
  width: 42px; height: 42px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg-elev); display: grid; gap: 4px;
  place-content: center; cursor: pointer;
}
.icon-btn span {
  display: block; width: 16px; height: 2px; background: var(--text); border-radius: 2px;
}
.theme-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 12px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.theme-btn svg { display: block; }
html[data-theme="light"] .theme-moon { display: none; }
html[data-theme="dark"] .theme-sun { display: none; }

.content { padding: 22px 18px 24px; display: flex; flex-direction: column; min-height: calc(100vh - 64px); }
.site-footer {
  margin-top: auto;
  padding: 18px 0 6px;
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.site-footer a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.site-footer a:hover { text-decoration: underline; }
.site-footer-auth {
  margin-top: 18px;
  border-top: none;
  padding-top: 0;
}

.card-panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat-card {
  background: linear-gradient(160deg, var(--bg-elev), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.stat-card span { color: var(--muted); font-size: .85rem; }
.stat-card strong { display: block; margin-top: 8px; font-size: 1.35rem; }

.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--line); }
.table { margin: 0; color: var(--text); }
.table thead th {
  background: var(--bg-soft);
  border-bottom-color: var(--line);
  white-space: nowrap;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table td, .table th { border-color: var(--line); vertical-align: middle; }
.table-hover tbody tr:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }

.badge-soft {
  display: inline-block;
  padding: .25rem .55rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--brand);
  font-size: .78rem;
}
.amount-pos { color: #1b5e20; font-weight: 600; }
.amount-neg { color: #c62828 !important; font-weight: 700; }

html[data-theme="dark"] .amount-pos { color: #69f0ae; }
html[data-theme="dark"] .amount-neg { color: #ff8a80 !important; }

/* Bootstrap tablo/form gece teması düzeltmeleri */
.table {
  --bs-table-bg: var(--bg-elev);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
  --bs-table-striped-bg: var(--bg-soft);
  --bs-table-striped-color: var(--text);
  --bs-table-hover-bg: color-mix(in srgb, var(--brand) 12%, var(--bg-elev));
  --bs-table-hover-color: var(--text);
  background-color: var(--bg-elev) !important;
  color: var(--text) !important;
}
.table > :not(caption) > * > * {
  background-color: transparent !important;
  color: inherit !important;
  border-bottom-color: var(--line) !important;
}
.table thead th {
  background: var(--bg-soft) !important;
  color: var(--text) !important;
  border-bottom-color: var(--line) !important;
}
.table tbody td,
.table tbody th {
  background-color: var(--bg-elev) !important;
  color: var(--text) !important;
}
.table-hover > tbody > tr:hover > * {
  background-color: color-mix(in srgb, var(--brand) 14%, var(--bg-elev)) !important;
  color: var(--text) !important;
}

.form-control,
.form-select {
  background-color: var(--bg-elev);
  color: var(--text);
  border-color: var(--line);
}
.form-control:focus,
.form-select:focus {
  background-color: var(--bg-elev);
  color: var(--text);
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 25%, transparent);
}
.form-control::placeholder { color: var(--muted); opacity: .85; }
.form-control:disabled,
.form-select:disabled,
.form-control[readonly] {
  background-color: var(--bg-soft);
  color: var(--muted);
  opacity: 1;
}
.form-text { color: var(--muted); }
.form-label { color: var(--text); }

.text-muted { color: var(--muted) !important; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: var(--text); }

.btn-outline-secondary {
  color: var(--text);
  border-color: var(--line);
}
.btn-outline-secondary:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--brand);
}
.btn-outline-light {
  border-color: rgba(255,255,255,.35);
}

.alert {
  border-color: var(--line);
}
.card-panel,
.stat-card,
.auth-card {
  color: var(--text);
}

html[data-theme="dark"] .table thead th,
html[data-theme="dark"] .sort-link {
  color: #e8eef5 !important;
}
html[data-theme="dark"] .sort-icons {
  opacity: 0.55;
}
html[data-theme="dark"] .sort-icons .sort-up,
html[data-theme="dark"] .sort-icons .sort-down {
  color: #9aabbc;
}
html[data-theme="dark"] .sort-icons .on,
html[data-theme="dark"] .sort-link.is-sorted {
  color: #7ad7e6 !important;
}
html[data-theme="dark"] .badge-soft {
  background: rgba(77, 184, 201, 0.18);
  color: #9be7f2;
}

.no-print {}

@media print {
  .no-print { display: none !important; }
  .sidebar, .topbar { display: none !important; }
  .amount-neg {
    color: #c62828 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px;
  align-items: center;
  justify-content: flex-start;
}
.filters-left {
  justify-content: flex-start;
  width: 100%;
}
.filters-bar {
  width: 100%;
  justify-content: flex-start;
}
.filters-bar .ms-auto {
  margin-left: auto !important;
}
.sort-link {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.sort-link:hover {
  color: var(--brand);
}
.sort-link.is-sorted {
  color: var(--brand);
}
.sort-icons {
  display: inline-flex;
  flex-direction: column;
  line-height: 0.75;
  font-size: 0.55rem;
  opacity: 0.35;
  vertical-align: middle;
}
.sort-icons.active {
  opacity: 1;
}
.sort-icons .sort-up,
.sort-icons .sort-down {
  color: var(--muted);
}
.sort-icons .on {
  color: var(--brand);
  opacity: 1;
}
.sort-link:hover .sort-icons {
  opacity: 0.7;
}
.sort-link:hover .sort-icons.active {
  opacity: 1;
}
.filters .form-control, .filters .form-select {
  min-width: 160px;
  background: var(--bg-elev);
  color: var(--text);
  border-color: var(--line);
}

.btn-brand {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: 0; color: #fff;
}
.btn-brand:hover { filter: brightness(1.05); color: #fff; }

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-wrap { width: min(420px, 100%); }
.auth-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}
.auth-card h1 {
  font-size: 1.45rem;
  margin-bottom: .35rem;
}
.auth-card p { color: var(--muted); }

.pager { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

@media (max-width: 992px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(0);
  }
  .app-shell.sidebar-collapsed .sidebar {
    margin-left: 0;
    transform: translateX(-110%);
  }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 12px 30px; }
}
