:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #667085;
  --line: #dfe5ef;
  --primary: #2563eb;
  --primary-dark: #163b8f;
  --navy: #0f172a;
  --navy-2: #111c35;
  --green: #0f9f6e;
  --red: #dc2626;
  --amber: #d97706;
  --cyan: #0284c7;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 26rem),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

a {
  text-decoration: none;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  width: 280px;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff;
  padding: 22px 16px;
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.18);
}

.brand,
.mobile-brand {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0;
}

.brand {
  margin-bottom: 24px;
}

.brand span,
.mobile-brand span {
  color: #93c5fd;
}

.app-nav {
  gap: 4px;
}

.app-nav .nav-link,
.logout-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
}

.app-nav .nav-link i,
.logout-link i {
  width: 20px;
  text-align: center;
  font-size: 1.05rem;
}

.app-nav .nav-link:hover,
.logout-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.app-nav .nav-link.active {
  background: #ffffff;
  color: var(--primary-dark);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.logout-link {
  color: #fecaca;
}

.mobile-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 10px 14px;
  background: var(--navy);
  color: #fff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.2);
}

.menu-btn,
.mobile-quick {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.menu-btn i,
.mobile-quick i {
  font-size: 1.35rem;
}

.mobile-offcanvas {
  width: min(84vw, 330px);
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff;
}

.mobile-offcanvas .app-nav .nav-link {
  min-height: 52px;
  font-size: 1rem;
}

.mobile-offcanvas .app-nav .nav-link i {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.15rem;
}

.mobile-bottom-nav {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 1040;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  gap: 4px;
  min-height: 68px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.28);
}

.bottom-nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 0;
  min-height: 54px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbeafe;
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1;
}

.bottom-nav-item i {
  font-size: 1.25rem;
}

.bottom-nav-item span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.bottom-add {
  transform: translateY(-14px);
  min-height: 62px;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.42);
}

.bottom-add i {
  font-size: 1.45rem;
}

.bottom-nav-button {
  appearance: none;
}

.content {
  min-width: 0;
  padding: 30px;
}

@media (min-width: 992px) {
  .content {
    margin-left: 280px;
  }
}

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

.page-head h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2rem);
  font-weight: 800;
}

.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.btn {
  border-radius: 8px;
  min-height: 40px;
  font-weight: 650;
}

.btn-action {
  min-height: 46px;
  padding-inline: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric,
.panel,
.login-card,
.receipt,
.filter-card {
  background: var(--surface);
  border: 1px solid rgba(223, 229, 239, 0.86);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  position: relative;
  overflow: hidden;
  min-height: 138px;
  padding: 18px;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--primary);
}

.metric-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 8px;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.95rem;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 1.45rem;
  line-height: 1.2;
}

.metric-income::before {
  background: var(--green);
}

.metric-income .metric-icon {
  color: var(--green);
  background: rgba(15, 159, 110, 0.11);
}

.metric-expense::before,
.metric-danger::before {
  background: var(--red);
}

.metric-expense .metric-icon,
.metric-danger .metric-icon {
  color: var(--red);
  background: rgba(220, 38, 38, 0.1);
}

.metric-warning::before {
  background: var(--amber);
}

.metric-warning .metric-icon {
  color: var(--amber);
  background: rgba(217, 119, 6, 0.11);
}

.metric-info::before,
.metric-settlement::before {
  background: var(--cyan);
}

.metric-info .metric-icon,
.metric-settlement .metric-icon {
  color: var(--cyan);
  background: rgba(2, 132, 199, 0.1);
}

.panel {
  padding: 20px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.panel-title i {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

.panel h2,
.panel-title h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.filter-card {
  display: flex;
  align-items: end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px;
  margin-bottom: 18px;
}

.filter-field {
  flex: 1 1 220px;
}

.filter-field .form-label {
  margin-bottom: 6px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-label {
  color: #344054;
  font-weight: 700;
}

.form-control,
.form-select,
.input-group-text {
  min-height: 46px;
  border-color: #d6deea;
  border-radius: 8px;
}

.input-group .form-control {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group-text {
  background: var(--surface-soft);
  color: var(--muted);
}

.form-grid {
  align-items: flex-start;
}

.form-field {
  min-width: 0;
}

.required {
  color: var(--red);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 13px 14px 13px 44px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-actions-sticky {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 34%);
}

.table-responsive {
  border-radius: 8px;
}

.table {
  min-width: 780px;
  margin-bottom: 0;
}

.table thead th {
  background: #f8fafc;
  color: #475467;
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody td {
  vertical-align: middle;
}

.actions {
  white-space: nowrap;
}

.actions form {
  display: inline;
}

.actions .btn {
  margin: 2px;
}

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

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

.fab-add {
  position: fixed;
  right: 18px;
  bottom: 88px;
  z-index: 1035;
  display: none;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.36);
}

.fab-add i {
  font-size: 1.45rem;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  padding: 30px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-weight: 850;
}

.login-card p {
  color: var(--muted);
  margin-bottom: 24px;
}

.receipt {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px;
}

.receipt-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

@media (max-width: 991.98px) {
  body {
    background: var(--bg);
  }

  .sidebar,
  .sidebar.d-lg-flex {
    display: none !important;
  }

  .mobile-topbar,
  .mobile-topbar.d-lg-none {
    display: flex !important;
  }

  .app-shell {
    display: block !important;
    min-height: calc(100vh - 62px);
  }

  .content {
    padding: 18px 18px 96px;
    margin-left: 0 !important;
  }

  .page-head {
    align-items: stretch;
  }
}

@media (max-width: 767.98px) {
  .content {
    padding: 16px 12px 112px;
  }

  .page-head {
    display: block;
  }

  .page-head .btn {
    width: 100%;
    margin-top: 14px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .metric {
    min-height: 118px;
    padding: 16px;
  }

  .metric-icon {
    float: right;
    margin-bottom: 0;
  }

  .metric strong {
    font-size: 1.35rem;
  }

  .panel,
  .filter-card,
  .login-card,
  .receipt {
    padding: 16px;
  }

  .filter-card,
  .filter-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .filter-field {
    width: 100%;
  }

  .filter-actions .btn,
  .form-actions-sticky .btn {
    width: 100%;
    min-height: 48px;
  }

  .form-actions-sticky {
    margin-inline: -16px;
    padding: 14px 16px calc(92px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }

  .table {
    min-width: 860px;
    font-size: 0.95rem;
  }

  .actions .btn {
    min-height: 38px;
  }

  .receipt-head {
    display: block;
  }
}

@media (max-width: 390px) {
  .mobile-brand {
    font-size: 1rem;
  }

  .content {
    padding-inline: 10px;
  }

  .page-head h1 {
    font-size: 1.45rem;
  }
}

@media (max-width: 480px) {
  .mobile-offcanvas {
    width: min(78vw, 292px);
  }

  .mobile-bottom-nav {
    left: 8px;
    right: 8px;
    bottom: 8px;
    min-height: 66px;
    padding: 7px;
  }

  .bottom-nav-item {
    font-size: 0.64rem;
  }

  .mobile-offcanvas .offcanvas-header {
    padding: 18px 16px 10px;
  }

  .mobile-offcanvas .offcanvas-body {
    padding: 8px 12px 16px;
  }

  .mobile-offcanvas .app-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .mobile-offcanvas .app-nav .nav-link {
    justify-content: center;
    min-height: 76px;
    padding: 10px 8px;
    gap: 6px;
    text-align: center;
    flex-direction: column;
    font-size: 0.78rem;
    line-height: 1.15;
  }

  .mobile-offcanvas .app-nav .nav-link span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-offcanvas .app-nav .logout-link {
    grid-column: 1 / -1;
    min-height: 54px;
    flex-direction: row;
  }
}

@media print {
  .sidebar,
  .mobile-topbar,
  .mobile-bottom-nav,
  .mobile-offcanvas,
  .no-print,
  .alert {
    display: none !important;
  }

  .content {
    margin: 0;
    padding: 0;
  }

  .receipt {
    border: 0;
    box-shadow: none;
  }
}
