:root {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-elevated: #2c2c2e;
  --text: #ffffff;
  --text-muted: #98989f;
  --border: #2c2c2e;
  --accent: #ff073a;
  --accent-dark: #d1042f;
  --sidebar-width: 240px;
  --bottom-nav-height: 76px;
  --topbar-bg: rgba(0, 0, 0, 0.72);
  --bottomnav-bg: rgba(20, 20, 22, 0.85);
  --hero-gradient: linear-gradient(155deg, #1c1c1e 0%, #0a0a0a 100%);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-elevated: #f0f0f3;
  --text: #1c1c1e;
  --text-muted: #6e6e73;
  --border: #e2e2e6;
  --accent: #ff073a;
  --accent-dark: #d1042f;
  --topbar-bg: rgba(255, 255, 255, 0.78);
  --bottomnav-bg: rgba(255, 255, 255, 0.88);
  --hero-gradient: linear-gradient(155deg, #ffffff 0%, #f0f0f3 100%);
}

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 15px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

@media (min-width: 992px) {
  body {
    padding-bottom: 0;
  }
}

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

.app-main {
  flex: 1;
  min-width: 0;
}

/* ---- Sidebar (desktop) ---- */
.app-sidebar {
  display: none;
}

@media (min-width: 992px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
  }
}

.app-sidebar .brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--accent);
  margin-bottom: 2rem;
  padding: 0 0.5rem;
  text-decoration: none;
  display: block;
  letter-spacing: -0.02em;
}

.app-sidebar .nav-link {
  color: var(--text-muted);
  border-radius: 0.7rem;
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.app-sidebar .nav-link.active,
.app-sidebar .nav-link:hover {
  background: rgba(255, 7, 58, 0.14);
  color: var(--accent);
}

/* ---- Top bar ---- */
.app-topbar {
  background: var(--topbar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.25rem;
  padding-top: calc(0.9rem + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-topbar .brand-mobile {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

@media (min-width: 992px) {
  .app-topbar .brand-mobile {
    display: none;
  }
}

.app-content {
  padding: 1.25rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Bottom nav (mobile) — iOS tab bar style ---- */
.app-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bottomnav-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 30;
}

@media (min-width: 992px) {
  .app-bottom-nav {
    display: none;
  }
}

.app-bottom-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
  padding: 0.4rem 0;
  transition: color 0.15s ease;
}

.app-bottom-nav a.active {
  color: var(--accent);
}

.app-bottom-nav .icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.app-bottom-nav a.active .icon {
  transform: translateY(-1px) scale(1.08);
}

/* ---- Cards ---- */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 0.75rem;
  height: 100%;
}

@media (min-width: 576px) {
  .stat-card {
    padding: 1.1rem;
  }
}

.stat-card .stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

@media (min-width: 576px) {
  .stat-card .stat-value {
    font-size: 1.7rem;
  }
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  padding: 1.25rem;
}

.chart-holder {
  position: relative;
  height: 220px;
  width: 100%;
}

@media (min-width: 768px) {
  .chart-holder {
    height: 280px;
  }
}

/* ---- Hero card (dashboard net kazanç) ---- */
.hero-card {
  background: var(--hero-gradient);
  border: 1px solid var(--border);
  border-radius: 1.5rem;
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -20%;
  width: 60%;
  height: 160%;
  background: radial-gradient(circle, rgba(255, 7, 58, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.hero-card .hero-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.hero-card .hero-value {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0.2rem 0 0.6rem;
}

.hero-card .hero-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.hero-card .hero-sub .positive { color: #32d74b; }
.hero-card .hero-sub .negative { color: var(--accent); }

/* ---- Quick nav grid ---- */
.quick-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  gap: 0.4rem;
}

.quick-nav a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.9rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  text-align: center;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.quick-nav a:active {
  transform: scale(0.96);
}

.quick-nav a:hover {
  border-color: var(--accent);
}

.quick-nav .icon {
  font-size: 1.5rem;
}

/* ---- Mobile list cards (replace tables on small screens) ---- */
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
}

/* Flex öğeleri varsayılan olarak içeriğin altına küçülmez; uzun isim/e-posta gibi
   metinlerin yan taraftaki butonu dışarı itip yatay taşmaya sebep olmasını engeller. */
.list-card.d-flex > div:first-child {
  min-width: 0;
}

.list-card .list-card-title {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: break-word;
}

.list-card .list-card-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow-wrap: break-word;
}

/* ---- Bootstrap overrides for dark theme ---- */
.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-outline-primary:hover {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border);
}

.btn-outline-secondary:hover {
  background-color: var(--surface-elevated);
  border-color: var(--text-muted);
  color: var(--text);
}

.btn-secondary {
  background-color: var(--surface-elevated);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background-color: #3a3a3c;
  border-color: var(--border);
  color: var(--text);
}

.btn-link.nav-link {
  color: var(--text-muted);
}

.badge.bg-primary {
  background-color: var(--accent) !important;
}

.form-control, .form-select {
  background-color: var(--surface-elevated);
  border-color: var(--border);
  color: var(--text);
}

.form-control:focus, .form-select:focus {
  background-color: var(--surface-elevated);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(255, 7, 58, 0.25);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.table {
  --bs-table-color: var(--text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
}

.text-muted {
  color: var(--text-muted) !important;
}

hr {
  border-color: var(--border);
  opacity: 1;
}

/* ---- Uygulama hissi (iOS ana ekran) ------------------------------------- */
html { -webkit-tap-highlight-color: transparent; }

/* Menüler ve butonlar uzun basınca metin seçimi / önizleme açmasın. */
.app-sidebar, .app-bottom-nav, .app-topbar, .btn, .nav-link {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

@media (display-mode: standalone) {
  /* Sayfanın lastik gibi esneyip arkasını göstermesini kapat. */
  html, body { overscroll-behavior-y: none; }

  /* black-translucent durum çubuğu yazısı hep beyaz: açık temada beyaz üstüne
     beyaz kalmasın diye saat/pil alanının arkasını koyu boya. */
  [data-theme="light"] .app-topbar {
    box-shadow: inset 0 env(safe-area-inset-top) 0 #1c1c1e;
  }
}

/* ---- "Ana ekrana ekle" rehberi (kuafor.js) -------------------------------- */
.kurulum-rehberi {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 1080;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: kurulum-gir 0.3s ease-out;
}
.kurulum-rehberi.alt-menu-ustunde {
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
}
.kurulum-rehberi img { border-radius: 10px; flex-shrink: 0; }
.kurulum-rehberi-metin { display: flex; flex-direction: column; gap: 2px; font-size: 0.875rem; line-height: 1.35; }
.kurulum-rehberi-metin span { color: var(--text-muted); }
.kurulum-rehberi-metin b { color: var(--text); font-weight: 600; }
.kurulum-rehberi-kapat {
  margin-left: auto;
  align-self: flex-start;
  background: none;
  border: 0;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px 4px;
}
@keyframes kurulum-gir { from { transform: translateY(20px); opacity: 0; } }
@media (min-width: 992px) {
  .kurulum-rehberi { left: auto; width: 380px; } /* iPad: köşede */
}
