:root {
  --navy-950: #061530;
  --navy-900: #0b2447;
  --navy-800: #123267;
  --navy-700: #19376d;
  --navy-600: #22488c;
  --blue-accent: #2f7bd6;
  --sky-100: #eaf2fc;
  --sky-50: #f5f9fe;
  --white: #ffffff;
  --gray-500: #6b7789;
  --gray-200: #e4e9f0;
  --green: #1f9d55;
  --red: #d64545;
  --amber: #d69a1f;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(11, 36, 71, 0.08);
  --sidebar-w: 250px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Roboto, -apple-system, Arial, sans-serif;
  background: var(--sky-50);
  color: var(--navy-950);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .page-title, .section-title, .stat-card .value {
  font-family: "Poppins", "Inter", "Segoe UI", sans-serif;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-900), var(--navy-950));
  color: var(--white);
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 3px;
}

.logo-circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}

.sidebar-brand .logo-fallback {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--white);
  flex-shrink: 0;
  font-family: "Poppins", sans-serif;
}

.sidebar-brand h1 {
  font-size: 15.5px;
  margin: 0;
  font-weight: 700;
  line-height: 1.25;
}

.sidebar nav { padding: 10px 0 90px; }

.sidebar .nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,0.45);
  padding: 14px 20px 6px;
}

.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.85);
  font-size: 14.5px;
  border-left: 3px solid transparent;
}

.sidebar a.nav-link:hover {
  background: rgba(255,255,255,0.06);
}

.sidebar a.nav-link.active {
  background: rgba(47,123,214,0.18);
  border-left-color: var(--blue-accent);
  color: var(--white);
  font-weight: 600;
}

.nav-icon { width: 18px; text-align: center; }

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
  gap: 14px;
}

.topbar-left { display: flex; align-items: center; gap: 14px; }

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--navy-900);
  cursor: pointer;
}

.page-title { font-size: 18px; font-weight: 700; color: var(--navy-900); }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.lang-switch {
  display: flex;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  overflow: hidden;
}

.lang-switch a {
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-500);
}

.lang-switch a.active {
  background: var(--navy-900);
  color: var(--white);
}

.profile-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 22px;
  background: var(--sky-100);
}

.profile-chip img, .profile-chip .avatar-fallback {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.profile-chip .avatar-fallback {
  background: var(--navy-700);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.profile-chip .name { font-size: 13px; font-weight: 600; color: var(--navy-900); }
.profile-chip .role-badge {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--gray-500);
  display: block;
}

.content {
  padding: 24px;
  flex: 1;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6,21,48,0.5);
  z-index: 35;
}

/* ---------- Cards / Grid ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--gray-200);
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--blue-accent);
}
.stat-card.deposit { border-left-color: var(--green); }
.stat-card.withdrawal { border-left-color: var(--amber); }
.stat-card.expense { border-left-color: var(--red); }
.stat-card.balance { border-left-color: var(--navy-700); }

.stat-card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-500);
  font-weight: 600;
}
.stat-card .value {
  font-size: 24px;
  font-weight: 800;
  color: var(--navy-950);
  margin-top: 6px;
}

h2.section-title {
  color: var(--navy-900);
  font-size: 18px;
  margin: 0 0 14px;
  font-weight: 700;
}

/* ---------- Forms ---------- */
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  background: var(--white);
  color: var(--navy-950);
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(47,123,214,0.15);
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy-800);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.errorlist { color: var(--red); font-size: 12.5px; margin: 4px 0 0; padding: 0; list-style: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.btn-primary { background: var(--navy-900); color: var(--white); }
.btn-primary:hover { background: var(--navy-800); }
.btn-outline { background: var(--white); color: var(--navy-900); border: 1px solid var(--navy-900); }
.btn-outline:hover { background: var(--sky-100); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-success { background: var(--green); color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--gray-200); }
table.table { width: 100%; border-collapse: collapse; min-width: 700px; }
table.table th {
  background: var(--navy-900);
  color: var(--white);
  text-align: left;
  padding: 12px 14px;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
table.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13.5px;
  white-space: nowrap;
}
table.table tbody tr:hover { background: var(--sky-50); }
table.table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-deposit { background: #e3f7e9; color: var(--green); }
.badge-withdrawal { background: #fdf2df; color: var(--amber); }
.badge-expense { background: #fbe6e6; color: var(--red); }
.badge-active { background: #e3f7e9; color: var(--green); }
.badge-inactive { background: #f1f1f1; color: var(--gray-500); }
.badge-role { background: var(--sky-100); color: var(--navy-800); }

/* ---------- Filters bar ---------- */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  padding: 16px;
  margin-bottom: 18px;
}
.filter-bar form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filter-bar .form-group { margin: 0; min-width: 150px; flex: 1; }

.period-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.period-tabs a {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--gray-200);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-800);
  background: var(--white);
}
.period-tabs a.active { background: var(--navy-900); color: var(--white); border-color: var(--navy-900); }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-950), var(--navy-700));
  padding: 20px;
}
.login-card {
  background: var(--white);
  width: 100%;
  max-width: 380px;
  border-radius: 16px;
  padding: 36px 30px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.25);
  text-align: center;
}
.logo-circle-lg {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--sky-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  overflow: hidden;
  padding: 6px;
  border: 1px solid var(--gray-200);
}
.logo-circle-lg img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}
.login-card .logo-fallback {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: var(--navy-900);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 28px;
  margin: 0 auto 14px;
  font-family: "Poppins", sans-serif;
}
.login-card h1 { font-size: 20px; color: var(--navy-950); margin: 0 0 4px; }
.login-card p.subtitle { color: var(--gray-500); font-size: 13px; margin: 0 0 22px; }
.login-card .form-group { text-align: left; }

/* ---------- Messages ---------- */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
.messages .success { background: #e3f7e9; color: var(--green); }
.messages .error { background: #fbe6e6; color: var(--red); }
.messages .info, .messages .warning { background: var(--sky-100); color: var(--navy-800); }

/* ---------- Calculator ---------- */
.calculator {
  max-width: 340px;
  background: var(--navy-950);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.calc-display {
  background: rgba(255,255,255,0.06);
  color: var(--white);
  border-radius: 10px;
  padding: 18px 14px;
  text-align: right;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 14px;
  min-height: 46px;
  word-break: break-all;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.calc-btn {
  padding: 16px 0;
  border-radius: 10px;
  border: none;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255,255,255,0.08);
  color: var(--white);
}
.calc-btn:hover { background: rgba(255,255,255,0.16); }
.calc-btn.op { background: var(--blue-accent); }
.calc-btn.equal { background: var(--green); grid-column: span 2; }
.calc-btn.clear { background: var(--red); }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-800);
  background: var(--white);
}
.pagination .current { background: var(--navy-900); color: var(--white); border-color: var(--navy-900); }

/* ---------- Avatar upload preview ---------- */
.avatar-preview {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--sky-100);
}

.text-muted { color: var(--gray-500); font-size: 13px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .hamburger { display: block; }
  .overlay.show { display: block; }
  .page-title { font-size: 15px; }
  .profile-chip .name-wrap { display: none; }
  .content { padding: 16px; }
}

@media (max-width: 520px) {
  table.table { min-width: 560px; }
  .login-card { padding: 28px 20px; }
}
