:root {
  --navy-1: #020b3a;
  --navy-2: #01052a;
  --navy-3: #06114f;
  --purple: #4318ff;
  --purple-2: #601cff;
  --text: #09114a;
  --text-soft: #5c689a;
  --line: #e8ebf4;
  --panel: #ffffff;
  --bg: #fbfcff;
  --green: #16a34a;
  --green-soft: #ebf8ef;
  --orange: #ff6900;
  --orange-soft: #fff1e8;
  --pink: #ff2f67;
  --pink-soft: #ffeef4;
  --blue: #2367f7;
  --blue-soft: #ebf2ff;
  --shadow: 0 12px 28px rgba(13, 19, 64, 0.04);
  --sidebar-w: 224px;
  --sidebar-collapsed: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: transparent; }
svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

.expenses-app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
body.sidebar-collapsed .expenses-app { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.expenses-sidebar {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; padding: 16px 14px 18px;
  background: radial-gradient(circle at 22px 22px, rgba(96, 32, 255, 0.3), transparent 84px), linear-gradient(180deg, var(--navy-3) 0%, var(--navy-2) 54%, #000b33 100%);
  box-shadow: 18px 0 44px rgba(4, 11, 51, 0.16);
}
.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px 18px; }
.sidebar-brand-icon { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #3200ef 0%, #651dff 100%); box-shadow: 0 12px 24px rgba(68, 24, 255, 0.32); flex: 0 0 44px; }
.sidebar-brand-icon svg { width: 24px; height: 24px; stroke-width: 2; }
.brand-copy strong { display: block; color: #fff; font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.brand-copy small { display: block; margin-top: 2px; color: rgba(255,255,255,0.92); font-size: 10px; font-weight: 700; letter-spacing: 0.06em; }
.sidebar-toggle { width: 34px; height: 34px; flex: 0 0 34px; display: grid; place-items: center; color: rgba(255,255,255,0.86); border-radius: 10px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.06); }
.sidebar-toggle svg { width: 18px; height: 18px; stroke-width: 2.2; transition: transform .2s ease; }
.expenses-nav { padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-item, .logout-link {
  height: 46px; display: flex; align-items: center; gap: 14px; padding: 0 12px; margin-bottom: 5px; border-radius: 10px;
  color: rgba(255,255,255,0.96); font-size: 14px; font-weight: 600; transition: background .2s ease, color .2s ease;
}
.nav-item:hover, .logout-link:hover { background: rgba(255,255,255,0.05); }
.nav-item.active { color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5e1cff 100%); box-shadow: 0 14px 26px rgba(67, 14, 255, 0.26); }
.nav-icon { width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 28px; }
.nav-icon svg { width: 21px; height: 21px; stroke-width: 1.9; }
.nav-text { white-space: nowrap; }
.assist-card {
  margin: 18px 4px 18px; padding: 18px 16px 16px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(81, 20, 255, 0.28) 0%, rgba(63, 18, 180, 0.66) 100%);
  border: 1px solid rgba(255,255,255,0.08); color: #fff;
}
.assist-card h3 { margin: 0 0 8px; font-size: 18px; font-weight: 800; line-height: 1.35; }
.assist-card p { margin: 0 0 18px; color: rgba(255,255,255,0.96); font-size: 14px; line-height: 1.45; }
.assist-bottom-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.assist-bottom-row button { min-width: 114px; height: 38px; padding: 0 14px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); font-size: 13px; font-weight: 700; }
.assist-bot { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,0.12); }
.assist-bot svg { width: 22px; height: 22px; stroke-width: 1.8; }
.logout-link { margin-top: 8px; }

.expenses-main { min-width: 0; padding: 22px 20px 18px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.page-head p { margin: 6px 0 0; color: var(--text-soft); font-size: 14px; }
.head-actions { display: flex; align-items: center; gap: 20px; }
.date-btn, .add-btn, .filter-btn, .export-btn, .per-page-btn {
  height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 12px; border-radius: 12px; font-size: 15px; font-weight: 650;
}
.date-btn { min-width: 280px; padding: 0 18px; color: #172359; border: 1px solid #dde2f0; background: #fff; }
.add-btn { min-width: 150px; color: #fff; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); box-shadow: 0 14px 30px rgba(67, 14, 255, 0.18); }
.date-btn svg, .add-btn svg, .filter-btn svg, .export-btn svg, .search-box svg, .desc-icon svg, .pay-badge svg, .action-btn svg, .per-page-btn svg, .stat-icon svg { width: 20px; height: 20px; stroke-width: 1.9; }
.caret { width: 18px !important; height: 18px !important; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card { min-height: 158px; display: flex; gap: 18px; align-items: flex-start; padding: 22px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stat-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; flex: 0 0 54px; }
.stat-icon.purple { color: #fff; background: linear-gradient(135deg, #4318ff 0%, #6621ff 100%); }
.stat-icon.green { color: #fff; background: linear-gradient(135deg, #18a44c 0%, #2fc86b 100%); }
.stat-icon.orange { color: #fff; background: linear-gradient(135deg, #ff6900 0%, #ff8a2a 100%); }
.stat-icon.blue { color: #fff; background: linear-gradient(135deg, #2468f7 0%, #4d84ff 100%); }
.stat-label { display: block; color: #29346f; font-size: 14px; font-weight: 600; }
.stat-card h2 { margin: 6px 0 6px; font-size: 19px; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em; }
.stat-card p { margin: 0; color: var(--text-soft); font-size: 14px; }
.trend { display: inline-flex; align-items: center; gap: 8px; min-height: 26px; margin-top: 18px; color: #10863e; font-size: 13px; font-weight: 700; }
.trend::before { content: attr(data-tag); }
.trend em { font-style: normal; font-weight: 500; color: #53608f; }
.trend.up { padding: 0 0; }
.trend.up::before { content: none; }
.trend.up { background: none; }
.trend.up::after { content: ''; }
.trend.up { position: relative; }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { }
.trend.up { color: #138a3e; }
.trend.up::before {
  content: attr(data-text);
}
/* fallback chip rendering with inner span simulation using background on text itself */
.trend.up {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.trend.up::before {
  content: attr(data-chip);
}
/* explicit content for provided markup */
.trend.up { padding-left: 0; }
.trend.up { }
.stat-card .trend.up { }
.stat-card .trend.up::before { content: none; }
.stat-card .trend.up {
  background: transparent;
}
.stat-card .trend.up {
  gap: 0;
}
.stat-card .trend.up::after { content: none; }
.stat-card .trend.up {
  position: static;
}
.stat-card .trend.up {
  display: inline-flex;
  gap: 8px;
}
.stat-card .trend.up::first-line { }
.stat-card .trend.up {
  color: #4d5b8b;
}
.stat-card .trend.up::before {
  content: '';
}
.stat-card .trend.up {
  color: inherit;
}
.stat-card .trend.up {
  font-weight: 600;
}
.stat-card .trend.up span,
.stat-card .trend.up { }
/* chip styling via nested em not possible, use strong visual on first text part */
.stat-card .trend.up {
  color: #53608f;
}
.stat-card .trend.up::before {
  content: none;
}
.stat-card .trend.up {
  white-space: nowrap;
}
.stat-card .trend.up {
  background: none;
}
.stat-card .trend.up {
  position: relative;
}
.stat-card .trend.up {
  padding-left: 0;
}
.stat-card .trend.up {
  display: inline-flex;
  align-items: center;
}
.stat-card .trend.up {
  gap: 8px;
}
.stat-card .trend.up {
  font-size: 13px;
}
.stat-card .trend.up {
  font-weight: 600;
}
.stat-card .trend.up::after { content: none; }
.stat-card .trend.up {
  color: #5a6695;
}
.stat-card .trend.up::before {
  content: attr(data-label);
}
/* actual visible pill from the literal text start */
.stat-card .trend.up {
  background-image: linear-gradient(#e7f7ec, #e7f7ec);
  background-repeat: no-repeat;
  background-size: 58px 26px;
  background-position: left center;
  padding-left: 12px;
  min-height: 26px;
  border-radius: 999px;
}
.stat-card .trend.up em { margin-left: 10px; }

.table-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.table-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.search-box { min-width: 0; flex: 1 1 auto; max-width: 420px; height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border: 1px solid #dde2f0; border-radius: 12px; background: #fff; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; }
.search-box input::placeholder { color: #6672a5; }
.tool-actions { display: flex; align-items: center; gap: 14px; }
.filter-btn, .export-btn { padding: 0 16px; color: #172359; border: 1px solid #dde2f0; background: #fff; }
.export-btn { min-width: 108px; color: #391fff; }

.table-wrap { overflow-x: auto; }
.expense-table { min-width: 1180px; display: grid; grid-template-columns: 1.05fr 2.35fr 1.3fr 1fr 1.2fr 1fr .8fr; align-items: center; }
.expense-header { min-height: 46px; padding: 0 18px; color: #141f5a; font-size: 13px; font-weight: 800; border-bottom: 1px solid var(--line); }
.expense-row { min-height: 68px; padding: 0 18px; color: #1d255f; font-size: 14px; border-bottom: 1px solid #edf0f7; }
.sort { color: #7380b2; font-size: 12px; }
.date-col strong { display: block; font-size: 15px; font-weight: 600; }
.date-col span { display: block; margin-top: 5px; color: #576293; font-size: 13px; }
.desc-col { display: flex; align-items: center; gap: 14px; }
.desc-icon { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 34px; }
.desc-icon.purple { color: #481fff; background: #f2edff; }
.desc-icon.green { color: #16a34a; background: #eaf8ee; }
.desc-icon.orange { color: #ff6900; background: #fff2e8; }
.desc-icon.pink { color: #ff2f67; background: #ffeef4; }
.desc-icon.blue { color: #2367f7; background: #ebf2ff; }
.desc-icon.teal { color: #0e8aa2; background: #eaf8fb; }
.desc-icon.indigo { color: #4d37ff; background: #f0eeff; }
.desc-icon.amber { color: #e59a00; background: #fbf4e2; }
.desc-col strong { display: block; font-size: 15px; font-weight: 700; }
.desc-col span { display: block; margin-top: 4px; color: #5a6695; font-size: 13px; }
.cat-badge, .pay-badge {
  min-height: 28px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.cat-badge.stock { color: #4d25ff; background: #f2edff; }
.cat-badge.transport { color: #178e43; background: #eaf8ee; }
.cat-badge.utilities { color: #ff6900; background: #fff1e8; }
.cat-badge.rent { color: #ff2f67; background: #ffeef4; }
.cat-badge.supplies { color: #2367f7; background: #ebf2ff; }
.cat-badge.marketing { color: #0f7b89; background: #e9f7f9; }
.cat-badge.maintenance { color: #4d37ff; background: #f0eeff; }
.cat-badge.staff { color: #c98000; background: #fbf4e2; }
.amount-col { font-size: 16px; font-weight: 800; }
.amount-col.red { color: #ef1d33; }
.pay-badge.mpesa { color: #178f43; background: #eaf8ee; }
.pay-badge.cash { color: #2c57db; background: #ebf0fd; }
.pay-badge svg { width: 16px; height: 16px; }
.action-group { display: flex; align-items: center; gap: 8px; }
.action-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; border: 1px solid #dfe4f1; background: #fff; color: #3923ff; }
.action-btn.danger { color: #ff2a45; }
.action-btn svg { width: 16px; height: 16px; }

.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 14px 16px; }
.table-footer p { margin: 0; color: #223066; font-size: 14px; font-weight: 550; }
.pagination { display: flex; align-items: center; gap: 12px; }
.page-btn { width: 40px; height: 40px; border-radius: 10px; color: #202a62; background: #fff; border: 1px solid #dfe4f1; font-size: 15px; font-weight: 700; }
.page-btn.active { color: #fff; border-color: transparent; background: linear-gradient(135deg, #3500ee 0%, #5d1cff 100%); box-shadow: 0 14px 26px rgba(67, 14, 255, 0.22); }
.page-btn.muted { color: #8d96bc; }
.per-page-btn { min-width: 138px; padding: 0 18px; color: #202a62; border: 1px solid #dfe4f1; background: #fff; }

body.sidebar-collapsed .expenses-sidebar { padding-left: 10px; padding-right: 10px; }
body.sidebar-collapsed .brand-copy, body.sidebar-collapsed .nav-text, body.sidebar-collapsed .assist-copy, body.sidebar-collapsed .assist-bottom-row button, body.sidebar-collapsed .logout-link .nav-text { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-right: 0; padding-left: 0; }
body.sidebar-collapsed .sidebar-brand-row { flex-direction: column; align-items: center; gap: 12px; }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .nav-item, body.sidebar-collapsed .logout-link { justify-content: center; padding: 0; }
body.sidebar-collapsed .assist-card { padding: 12px; display: grid; place-items: center; }
body.sidebar-collapsed .assist-bottom-row { justify-content: center; }

@media (max-width: 1450px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .head-actions { justify-content: flex-end; }
  .table-tools { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .tool-actions { justify-content: flex-end; }
}
@media (max-width: 980px) {
  .expenses-app, body.sidebar-collapsed .expenses-app { grid-template-columns: 1fr; }
  .expenses-sidebar { min-height: auto; }
  .expenses-main { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .head-actions, .tool-actions { flex-direction: column; align-items: stretch; }
  .date-btn, .add-btn, .filter-btn, .export-btn, .per-page-btn { width: 100%; }
  .table-footer { flex-direction: column; align-items: flex-start; }
}
