/* ================= Design tokens ================= */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e5e9f0;
  --text: #1c2433;
  --text-muted: #6b7688;
  --primary: #4f6bfa;
  --primary-hover: #3d57e0;
  --primary-soft: #eef1ff;
  --success: #16a34a;
  --success-soft: #e8f8ee;
  --danger: #dc3545;
  --danger-soft: #fdeeee;
  --warning: #d97706;
  --warning-soft: #fdf3e3;
  --sidebar-bg: #161b2c;
  --sidebar-text: #b7bfd6;
  --sidebar-active: #4f6bfa;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);
}

[data-bs-theme="dark"] {
  --bg: #0f1320;
  --surface: #171c2c;
  --surface-2: #1d2333;
  --border: #2a3149;
  --text: #e7eaf3;
  --text-muted: #929bb5;
  --primary: #6d82ff;
  --primary-hover: #8194ff;
  --primary-soft: #232a47;
  --success: #34d17c;
  --success-soft: #14301f;
  --danger: #f0576c;
  --danger-soft: #3a1620;
  --warning: #f0a84e;
  --warning-soft: #3a2a12;
  --sidebar-bg: #0c0f1a;
  --sidebar-text: #a6adc4;
  --sidebar-active: #6d82ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ================= App shell ================= */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 1040;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.4rem 1.4rem 1.2rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .2px;
}
.sidebar-brand i { font-size: 1.4rem; color: var(--sidebar-active); }

.sidebar-nav {
  flex: 1;
  padding: .5rem .9rem;
  overflow-y: auto;
}

.sidebar-nav .nav-link, .sidebar-footer .nav-link {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: var(--sidebar-text);
  padding: .7rem .9rem;
  border-radius: 10px;
  font-weight: 500;
  font-size: .92rem;
  margin-bottom: .2rem;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav .nav-link i, .sidebar-footer .nav-link i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; }

.sidebar-footer {
  padding: .9rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1035;
}

/* ================= Main area ================= */
.app-main {
  flex: 1;
  margin-left: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-page-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  flex: 1;
}

.app-topbar-actions { display: flex; align-items: center; gap: .6rem; }

.btn-icon {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.btn-icon:hover { background: var(--surface-2); }

.btn-user {
  display: flex; align-items: center; gap: .5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  padding: .35rem .7rem .35rem .35rem;
  color: var(--text);
  font-weight: 500;
}

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}

.app-content { padding: 1.6rem; flex: 1; }

/* ================= Cards ================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  padding: 1rem 1.25rem;
}
.card-body { padding: 1.25rem; }

.stat-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .85rem; margin-top: .15rem; }

.icon-primary { background: var(--primary-soft); color: var(--primary); }
.icon-success { background: var(--success-soft); color: var(--success); }
.icon-warning { background: var(--warning-soft); color: var(--warning); }
.icon-danger  { background: var(--danger-soft); color: var(--danger); }

/* ================= Tables ================= */
.table { color: var(--text); margin-bottom: 0; }
.table > :not(caption) > * > * {
  border-bottom-color: var(--border);
  padding: .85rem .9rem;
  vertical-align: middle;
}
.table thead th {
  color: var(--text-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:hover { background: var(--surface-2); }
.table-responsive { border-radius: var(--radius); }

/* ================= Forms ================= */
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: .55rem .8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem var(--primary-soft);
  background: var(--surface);
  color: var(--text);
}
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .35rem; }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { color-scheme: dark; }

.input-group-text { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

/* ================= Buttons ================= */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn { border-radius: 10px; font-weight: 500; }
.btn-sm { border-radius: 8px; }

.badge { font-weight: 600; padding: .4em .7em; border-radius: 7px; }
.badge-diye { background: var(--danger-soft); color: var(--danger); }
.badge-liye { background: var(--success-soft); color: var(--success); }

/* ================= Login page ================= */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f6bfa 0%, #6a3bf0 100%);
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 2.2rem 2rem;
}
.auth-brand { text-align: center; margin-bottom: 1.6rem; }
.auth-brand i { font-size: 2.4rem; color: var(--primary); }
.auth-brand h1 { font-size: 1.3rem; font-weight: 700; margin-top: .5rem; }

/* ================= Misc ================= */
.password-mask { letter-spacing: 2px; font-family: monospace; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.6rem; margin-bottom: .8rem; display: block; }
.section-toolbar {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; justify-content: space-between;
  margin-bottom: 1.1rem;
}
.balance-positive { color: var(--danger); font-weight: 700; }
.balance-negative { color: var(--success); font-weight: 700; }
.balance-zero { color: var(--text-muted); font-weight: 700; }

/* Toasts */
.toast { border-radius: 12px; }

/* ================= Responsive ================= */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .sidebar-backdrop.show { display: block; }
}

@media (max-width: 575.98px) {
  .app-content { padding: 1rem; }
  .app-topbar { padding: .8rem 1rem; }
  .stat-value { font-size: 1.3rem; }
}
