:root {
  --mf-bg: #f3f6fa;
  --mf-sidebar: #101828;
  --mf-sidebar-soft: #182230;
  --mf-primary: #2563eb;
  --mf-primary-dark: #1d4ed8;
  --mf-text: #182230;
  --mf-muted: #667085;
  --mf-border: #d7deea;
  --mf-border-soft: #e7ecf4;
  --mf-surface: #ffffff;
  --mf-surface-alt: #f8fafc;
  --mf-success: #16803c;
  --mf-danger: #c83232;
  --mf-warning: #a15c07;
  --mf-shadow: 0 14px 34px rgba(16, 24, 40, .08);
}

* {
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  color: var(--mf-text);
  background: var(--mf-bg);
  font-size: .94rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  color: #d0d5dd;
  background: var(--mf-sidebar);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 22px;
  color: #ffffff;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--mf-primary);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .32);
}

.brand-name {
  display: block;
  font-weight: 700;
  line-height: 1.1;
}

.brand-caption {
  display: block;
  color: #98a2b3;
  font-size: .78rem;
  margin-top: 2px;
}

.sidebar-section {
  margin: 10px 8px 8px;
  color: #98a2b3;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #d0d5dd;
  text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.active {
  color: #ffffff;
  background: var(--mf-sidebar-soft);
}

.sidebar-link.active {
  box-shadow: inset 3px 0 0 var(--mf-primary);
}

.sidebar-link i {
  font-size: 1.05rem;
}

.sidebar-user {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 16px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
}

.user-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: #ffffff;
  background: #344054;
  font-weight: 700;
}

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

.min-w-0 {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding: 14px 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--mf-border-soft);
  backdrop-filter: blur(12px);
}

.topbar-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar-subtitle {
  color: var(--mf-muted);
  font-size: .85rem;
}

.content-wrap {
  padding: 24px 28px 34px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-title {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
}

.page-kicker {
  margin-top: 4px;
  color: var(--mf-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel {
  background: var(--mf-surface);
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.panel-pad {
  padding: 18px;
}

.metric {
  display: grid;
  gap: 12px;
  min-height: 128px;
  padding: 18px;
  background: var(--mf-surface);
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.metric-label {
  color: var(--mf-muted);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--mf-primary);
  background: #eaf1ff;
}

.metric strong {
  display: block;
  font-size: clamp(1.5rem, 2vw, 2rem);
  line-height: 1.1;
}

.metric small {
  color: var(--mf-muted);
}

.metric.income strong,
.text-income {
  color: var(--mf-success);
}

.metric.expense strong,
.text-expense {
  color: var(--mf-danger);
}

.table-shell {
  background: var(--mf-surface);
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.table-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--mf-border-soft);
  background: var(--mf-surface);
}

.table-titlebar h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.table {
  --bs-table-hover-bg: #f7fbff;
}

.table thead th {
  height: 42px;
  color: #475467;
  font-size: .74rem;
  font-weight: 750;
  text-transform: uppercase;
  background: var(--mf-surface-alt);
  border-bottom: 1px solid var(--mf-border);
}

.table thead th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table thead th.sortable::after {
  content: "\F282";
  display: inline-block;
  margin-left: 8px;
  color: #98a2b3;
  font-family: "bootstrap-icons";
  font-size: .72rem;
  vertical-align: middle;
}

.table thead th.sortable.sort-asc::after {
  content: "\F286";
  color: var(--mf-primary);
}

.table thead th.sortable.sort-desc::after {
  content: "\F282";
  color: var(--mf-primary);
}

.table td {
  vertical-align: middle;
  border-color: var(--mf-border-soft);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  color: var(--mf-muted);
  text-align: center;
}

.empty-state i {
  font-size: 2rem;
  color: #98a2b3;
}

.form-control,
.form-select {
  min-height: 42px;
  border-color: #cfd7e6;
  border-radius: 8px;
}

.input-group-text {
  border-color: #cfd7e6;
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--mf-primary);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  font-weight: 650;
}

.btn-primary {
  background: var(--mf-primary);
  border-color: var(--mf-primary);
}

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

.btn-icon {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.badge {
  border-radius: 999px;
  padding: .42rem .62rem;
  font-weight: 700;
}

.modal-content {
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  box-shadow: var(--mf-shadow);
}

.confirm-modal {
  overflow: hidden;
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--mf-primary);
  background: #eaf1ff;
}

.modal-header,
.modal-footer {
  background: var(--mf-surface-alt);
}

.alert {
  border-radius: 8px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
  background: var(--mf-bg);
}

.login-visual {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  color: #ffffff;
  background:
    linear-gradient(140deg, rgba(16,24,40,.94), rgba(29,78,216,.84)),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.18), transparent 26%);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--mf-surface);
  border: 1px solid var(--mf-border);
  border-radius: 8px;
  box-shadow: var(--mf-shadow);
}

.login-stat {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.login-stat div {
  padding: 14px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
}

@media (max-width: 991.98px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: relative;
    height: auto;
    padding: 12px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-user {
    position: static;
    margin-top: 12px;
  }

  .topbar {
    padding: 14px 16px;
  }

  .content-wrap {
    padding: 18px 14px 28px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .login-page {
    display: block;
  }

  .login-visual {
    min-height: 260px;
    padding: 28px;
  }
}

@media (max-width: 575.98px) {
  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar > * {
    width: 100%;
  }
}
