:root {
  --navy-950: #08111f;
  --navy-900: #0f172a;
  --navy-800: #172554;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --success: #059669;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --bg: #eef3f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dbe3ee;
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 18px 45px rgba(15, 23, 42, .08);
  --shadow-sm: 0 8px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, .08), rgba(37, 99, 235, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 286px;
  background: linear-gradient(180deg, #0f172a 0%, #08111f 100%);
  color: #eaf2ff;
  padding: 20px 16px;
  z-index: 20;
  box-shadow: 20px 0 50px rgba(8, 17, 31, .22);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 78px;
  padding: 8px 8px 22px;
  border-bottom: 1px solid rgba(203, 213, 225, .14);
  margin-bottom: 18px;
}
.brand strong { display: block; line-height: 1; color: #fff; }
.brand small { display: block; color: #93c5fd; letter-spacing: .16em; margin-top: 5px; font-size: 11px; }
.brand-mark,
.brand-logo {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  font-weight: 900;
  font-size: 23px;
  overflow: hidden;
  box-shadow: 0 14px 28px rgba(37, 99, 235, .28);
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 5px; background: #fff; }
.brand-mark.large { width: 64px; height: 64px; font-size: 33px; margin: 0 auto; }
.login-logo { width: 74px; height: 74px; margin: 0 auto; border: 1px solid var(--line); box-shadow: none; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar a:not(.brand) {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 11px 13px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 700;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}
.sidebar a.active,
.sidebar a:not(.brand):hover {
  background: rgba(37, 99, 235, .18);
  color: #fff;
}
.sidebar a.active { box-shadow: inset 3px 0 0 #60a5fa; }
.sidebar a:not(.brand):hover { transform: translateX(2px); }

.main { margin-left: 286px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  min-height: 92px;
  padding: 20px 34px;
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}
.topbar h1 { margin: 4px 0 0; font-size: 28px; line-height: 1.15; color: var(--slate-900); }
.eyebrow {
  margin: 0;
  color: var(--blue-700);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 900;
}
.userbox {
  text-align: right;
  color: var(--slate-700);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
}
.userbox span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.menu-toggle { display: none; }
.content { padding: 30px 34px; flex: 1; }
.footer { padding: 18px 34px 24px; color: var(--muted); font-size: 13px; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card,
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  inset: auto 18px 0 auto;
  width: 58px;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: var(--blue-600);
}
.stat.dark {
  background: linear-gradient(135deg, var(--blue-700), var(--navy-900));
  color: #fff;
  border-color: transparent;
}
.stat.dark::after { background: #93c5fd; }
.stat.success { background: linear-gradient(135deg, #f0fdf4, #ffffff); border-color: #bbf7d0; }
.stat.success::after { background: var(--success); }
.stat.warning { background: linear-gradient(135deg, #fffbeb, #ffffff); border-color: #fde68a; }
.stat.warning::after { background: var(--warning); }
.stat.danger { background: linear-gradient(135deg, #fef2f2, #ffffff); border-color: #fecaca; }
.stat.danger::after { background: var(--danger); }
.stat span { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .07em; }
.stat.dark span { color: #bfdbfe; }
.stat strong { display: block; font-size: 27px; line-height: 1.15; margin-top: 8px; overflow-wrap: anywhere; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-title h2,
.card h2 { margin: 0; font-size: 18px; line-height: 1.25; color: var(--slate-900); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--slate-700);
  cursor: pointer;
  font-weight: 900;
  white-space: nowrap;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(15, 23, 42, .10); border-color: #bfd0e5; }
.btn.primary,
.btn.gold {
  background: var(--blue-600);
  color: #fff;
  border-color: var(--blue-600);
}
.btn.primary:hover,
.btn.gold:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }

.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th {
  color: var(--slate-600);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  background: #f8fafc;
}
tbody tr:hover { background: #f8fbff; }
tbody tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 900; }
.badge.income { background: var(--success-soft); color: #047857; }
.badge.expense { background: var(--danger-soft); color: #b91c1c; }
.badge.neutral { background: var(--slate-100); color: var(--slate-700); }
.badge.warning { background: var(--warning-soft); color: #92400e; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field.full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 7px; font-weight: 900; color: var(--slate-700); }
.input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--slate-900);
  outline: none;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, .16);
}
textarea { min-height: 106px; resize: vertical; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(120px, 1fr)); gap: 12px; margin-bottom: 16px; }
.permissions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.check-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  color: var(--slate-700);
  font-weight: 800;
}
.check-row input { width: 17px; height: 17px; accent-color: var(--blue-600); }
.logo-preview {
  width: 130px;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  margin-bottom: 10px;
}
.logo-preview img { max-width: 118px; max-height: 70px; object-fit: contain; }
.danger-zone { border-color: #fecaca; background: #fffafa; }

.alert {
  padding: 13px 15px;
  border-radius: 8px;
  margin-bottom: 18px;
  background: var(--warning-soft);
  color: #92400e;
  border: 1px solid #fde68a;
}
.alert.success { background: var(--success-soft); color: #047857; border-color: #bbf7d0; }
.alert.danger { background: var(--danger-soft); color: #b91c1c; border-color: #fecaca; }
.note-box {
  padding: 13px 15px;
  border-radius: 8px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: var(--blue-700);
  font-weight: 800;
}
.muted { color: var(--muted); }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 6px; vertical-align: middle; border: 1px solid rgba(15, 23, 42, .16); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, .24), transparent 34%),
    linear-gradient(135deg, #0f172a 0%, #172554 52%, #0b1220 100%);
}
.login-card {
  width: min(460px, calc(100vw - 32px));
  background: rgba(255, 255, 255, .98);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 28px 100px rgba(8, 17, 31, .46);
}
.login-card h1 { text-align: center; margin: 10px 0; font-size: 31px; line-height: 1.1; color: var(--slate-900); }
.login-card .eyebrow, .login-card .muted { text-align: center; }
.login-card .muted { margin-bottom: 18px; }
.login-card .btn { width: 100%; margin-top: 12px; }
.login-card small { display: block; margin-top: 16px; color: var(--muted); text-align: center; }

@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
}

@media (max-width: 980px) {
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(8, 17, 31, .52);
    z-index: 15;
  }
  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 56px;
    min-height: 42px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--blue-700);
    font-weight: 900;
  }
  .topbar { align-items: flex-start; padding: 18px; gap: 12px; }
  .topbar h1 { font-size: 23px; }
  .content { padding: 18px; }
  .footer { padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
  .userbox { display: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid, .filters, .permissions-grid { grid-template-columns: 1fr; }
  .section-title { align-items: flex-start; flex-direction: column; }
  .section-title .btn { width: 100%; }
  .btn { width: 100%; white-space: normal; text-align: center; }
  .actions .btn, .actions form { flex: 1 1 130px; }
  .actions form .btn { width: 100%; }
  .card, .stat { padding: 16px; }
  .stat { min-height: 100px; }
  .stat strong { font-size: 24px; }
  th, td { padding: 11px 9px; }
  .login-card { padding: 26px 22px; }
  .login-card h1 { font-size: 28px; }
}
