:root {
  --navy: #012970;
  --accent: #4154f1;
  --accent-2: #2d3fd1;
  --bg: #f3f6ff;
  --surface: rgba(255, 255, 255, 0.86);
  --text: #243556;
  --muted: #6b7a99;
  --ok: #0f9d6e;
  --warn: #d97706;
  --danger: #dc3545;
  --shadow: 0 18px 50px rgba(1, 41, 112, 0.12);
  --radius: 18px;
  --sidebar: 260px;
  --font-h: "Nunito", system-ui, sans-serif;
  --font-b: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-b);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at -10% -20%, rgba(65, 84, 241, 0.18), transparent 55%),
    radial-gradient(900px 500px at 110% 0%, rgba(1, 41, 112, 0.16), transparent 50%),
    linear-gradient(180deg, #eef2ff 0%, var(--bg) 40%, #f7f9ff 100%);
  min-height: 100vh;
}

h1, h2, h3, .brand-title { font-family: var(--font-h); color: var(--navy); letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, #041b4d 0%, #012970 55%, #1a2f8f 100%);
  color: #fff;
  padding: 1.25rem 1rem 5rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.06);
}
.sidebar .brand {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .6rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 1rem;
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #6b7cff, #4154f1);
  display: grid; place-items: center; font-weight: 800; font-family: var(--font-h);
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.brand strong { display: block; font-size: 1rem; }
.brand small { opacity: .75; font-size: .75rem; }
.nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: rgba(255,255,255,.82);
  padding: .72rem .85rem;
  border-radius: 12px;
  margin-bottom: .25rem;
  transition: .2s ease;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  transform: translateX(3px);
}
.nav-link.active { box-shadow: inset 3px 0 0 #8ea2ff; }

.content {
  flex: 1;
  padding: 1.25rem 1.5rem 5.5rem;
  width: calc(100% - var(--sidebar));
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 1.25rem;
}
.page-title { margin: 0; font-size: 1.65rem; }
.page-sub { margin: .2rem 0 0; color: var(--muted); font-size: .92rem; }

.card, .kpi, .panel {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.1rem;
}
.kpi { padding: 1rem 1.1rem; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(65,84,241,.18), transparent 70%);
}
.kpi .label { color: var(--muted); font-size: .82rem; margin-bottom: .35rem; }
.kpi .value { font-size: 1.45rem; font-weight: 800; color: var(--navy); font-family: var(--font-h); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; border-radius: 12px; padding: .65rem 1rem;
  font-weight: 650; cursor: pointer; transition: .18s ease;
  font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); color: #fff; }
.btn-soft { background: #e8ecff; color: var(--navy); }
.btn-danger { background: #ffe3e6; color: #b42318; }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid #d5ddf5; }
.btn-sm { padding: .4rem .7rem; font-size: .85rem; border-radius: 10px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; font-weight: 600; }
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  border: 1px solid #d7deef;
  background: #fff;
  border-radius: 12px;
  padding: .7rem .85rem;
  color: var(--text);
  outline: none;
  transition: .15s ease;
}
.form-control:focus {
  border-color: #8ea2ff;
  box-shadow: 0 0 0 4px rgba(65,84,241,.12);
}
.help { font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.total-box {
  background: linear-gradient(135deg, #eef2ff, #e7ecff);
  border-radius: 14px;
  padding: .9rem 1rem;
  font-weight: 700;
  color: var(--navy);
}

.table-wrap { overflow: auto; border-radius: 14px; }
table.data {
  width: 100%; border-collapse: collapse; min-width: 900px;
}
table.data th, table.data td {
  padding: .75rem .7rem; border-bottom: 1px solid #e6ebf8; text-align: left; vertical-align: top;
  font-size: .92rem;
}
table.data th {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: #f7f9ff; position: sticky; top: 0;
}
table.data tr:hover td { background: rgba(65,84,241,.035); }

.badge-status {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700;
}
.badge-pending { background: #fff4e5; color: #b54708; }
.badge-partial { background: #eef2ff; color: #3538cd; }
.badge-settled { background: #e4f7ef; color: #087443; }
.badge-personal { background: #f3e8ff; color: #6b21a8; }
.badge-company { background: #e0f2fe; color: #075985; }

.alert {
  border-radius: 12px; padding: .85rem 1rem; margin-bottom: 1rem;
  animation: fadeUp .35s ease both;
}
.alert-error { background: #ffe8ea; color: #9b1c1c; border: 1px solid #ffc9ce; }
.alert-success { background: #e5f8ef; color: #0f6a45; border: 1px solid #b7ebd0; }
.alert-warn { background: #fff7e8; color: #9a6700; border: 1px solid #ffe0a3; }

.collapse-box {
  border: 1px dashed #c9d4f3;
  border-radius: 14px;
  padding: 1rem;
  background: #fbfcff;
}
.vendor-suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff; border: 1px solid #d7deef; border-radius: 12px;
  box-shadow: var(--shadow); z-index: 20; max-height: 220px; overflow: auto;
}
.vendor-suggest button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: .65rem .8rem; cursor: pointer;
}
.vendor-suggest button:hover { background: #eef2ff; }
.pos-rel { position: relative; }

.mobile-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid #dfe6f8;
  padding: .45rem .4rem calc(.45rem + env(safe-area-inset-bottom));
  z-index: 50;
  grid-template-columns: repeat(5, 1fr);
  gap: .2rem;
}
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  color: var(--muted); font-size: .68rem; font-weight: 700; padding: .35rem;
  border-radius: 12px;
}
.mobile-nav a.active, .mobile-nav a:hover { color: var(--accent); background: #eef2ff; }
.mobile-nav .icon { font-size: 1.1rem; }

.fade-up { animation: fadeUp .45s ease both; }
.stagger > * { animation: fadeUp .45s ease both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .08s; }
.stagger > *:nth-child(3) { animation-delay: .14s; }
.stagger > *:nth-child(4) { animation-delay: .2s; }
.stagger > *:nth-child(5) { animation-delay: .26s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.expense-cards { display: none; }
.expense-card {
  background: var(--surface); border-radius: 16px; padding: 1rem;
  box-shadow: var(--shadow); margin-bottom: .8rem; border: 1px solid rgba(255,255,255,.7);
}
.expense-card .row1 { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .4rem; }
.expense-card .amt { font-weight: 800; color: var(--navy); font-family: var(--font-h); }

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .7rem;
  margin-bottom: 1rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: "";
  position: absolute; inset: -20%;
  background:
    radial-gradient(circle at 20% 20%, rgba(65,84,241,.35), transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(1,41,112,.35), transparent 30%),
    radial-gradient(circle at 60% 80%, rgba(109,140,255,.25), transparent 35%),
    linear-gradient(145deg, #06153a, #0b2a6b 45%, #1b3f9a);
  animation: drift 16s ease-in-out infinite alternate;
  z-index: 0;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1.05); }
  to { transform: translate3d(2%, 1%, 0) scale(1.1); }
}
.login-card {
  position: relative; z-index: 1;
  width: min(440px, 100%);
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 24px;
  padding: 2rem 1.6rem;
  box-shadow: 0 30px 80px rgba(0,0,0,.28);
  animation: cardIn .7s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-brand {
  text-align: center; margin-bottom: 1.4rem;
  animation: fadeUp .6s ease .1s both;
}
.login-brand .mark {
  width: 64px; height: 64px; margin: 0 auto .8rem;
  border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #6b7cff, #4154f1);
  color: #fff; font-size: 1.4rem; font-weight: 800; font-family: var(--font-h);
  box-shadow: 0 12px 30px rgba(65,84,241,.4);
}
.login-brand h1 { margin: 0; font-size: 1.55rem; }
.login-brand p { margin: .35rem 0 0; color: var(--muted); }
.password-wrap { position: relative; }
.password-wrap button {
  position: absolute; right: .55rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.chart-box { padding: 1rem; min-height: 280px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .content { width: 100%; padding: 1rem 1rem 6rem; }
  .mobile-nav { display: grid; }
  .form-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .table-desktop { display: none; }
  .expense-cards { display: block; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-title { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
