:root {
  --bg: #f5f6f2;
  --surface: #fff;
  --surface-2: #eef1ec;
  --ink: #18201d;
  --muted: #748079;
  --line: #e1e6e1;
  --line-strong: #cbd3cd;
  --green: #176b55;
  --green-dark: #0d4537;
  --green-soft: #e4f0eb;
  --gold: #b88a3b;
  --gold-soft: #f7efdf;
  --red: #b95445;
  --red-soft: #fae9e5;
  --shadow: 0 18px 50px rgba(25,38,32,.07);
  --shadow-sm: 0 8px 24px rgba(25,38,32,.06);
  --radius: 18px;
  --font: "DM Sans", sans-serif;
  --display: "Playfair Display", serif;
}

[data-theme="dark"] {
  --bg: #0e1311;
  --surface: #171d1a;
  --surface-2: #202823;
  --ink: #edf2ee;
  --muted: #9ca9a2;
  --line: #29322d;
  --line-strong: #3b4841;
  --green: #55b494;
  --green-dark: #d9f1e8;
  --green-soft: #17332b;
  --gold: #d6ad61;
  --gold-soft: #362c1d;
  --red: #df8272;
  --red-soft: #38221e;
  --shadow: 0 20px 60px rgba(0,0,0,.22);
  --shadow-sm: 0 10px 28px rgba(0,0,0,.18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 var(--font);
}
button, input, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--green) 28%, transparent);
  outline-offset: 2px;
}
.hidden { display: none !important; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--green);
  color: white;
  display: grid;
  place-items: center;
  font: 600 19px var(--display);
  box-shadow: 0 8px 18px rgba(23,107,85,.22);
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.02em;
}

.brand-name small {
  display:block;
  color: var(--muted);
  font-size:10px;
  font-weight:500;
  letter-spacing:.08em;
  text-transform: uppercase;
}

.nav-title {
  padding: 0 10px 9px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

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

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  transition: .2s;
}

.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active {
  background: var(--green-soft);
  color: var(--green-dark);
  font-weight: 600;
}

.badge {
  margin-left: auto;
  background: var(--red-soft);
  color: var(--red);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 20px;
}

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.profile {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d8c4a2, #8eaa9c);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
}

.profile strong { font-size: 12px; }
.profile span { display:block; color: var(--muted); font-size: 10px; }

.main {
  min-width: 0;
  padding: 30px 38px 70px;
  max-width: 1450px;
  width: 100%;
  margin: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.breadcrumb { font-size: 12px; color: var(--muted); }
.breadcrumb b { color: var(--ink); }

.top-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  display: grid;
  place-items: center;
  transition: .2s;
}

.icon-btn:hover { border-color: var(--green); color: var(--green); }

.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.hero {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: end;
  margin-bottom: 28px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
}

h1 {
  font: 600 clamp(30px,4vw,44px)/1.1 var(--display);
  letter-spacing: -.035em;
  margin: 0;
}

.hero p { color: var(--muted); margin: 10px 0 0; max-width: 620px; }

.primary {
  background: var(--green);
  color: white;
  border-radius: 12px;
  padding: 11px 16px;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(23,107,85,.16);
  transition: .2s;
}
.primary:hover { transform: translateY(-1px); filter: brightness(.96); }

.secondary {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
}
.secondary:hover { border-color: var(--green); }

.logout-btn {
  display: block;
  width: 100%;
}

.wide { width: 100%; }
.small { padding: 8px 10px; font-size: 12px; }

.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 15px; margin-bottom: 18px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 19px;
  box-shadow: var(--shadow-sm);
}

.stat-top { display:flex; justify-content:space-between; align-items:center; color: var(--muted); font-size:11px; font-weight:600; }
.stat-icon {
  width: 32px; height: 32px; border-radius: 10px; display:grid; place-items:center;
  background: var(--green-soft); color: var(--green);
}
.stat-value { font-size:26px; font-weight:700; letter-spacing:-.04em; margin:12px 0 2px; }
.stat-foot { font-size:11px; color: var(--muted); }
.up { color: var(--green); font-weight: 600; }

.grid { display: grid; grid-template-columns: 1.35fr .85fr; gap: 18px; }
.grid.two-col { grid-template-columns: 1fr 1.2fr; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 21px 15px;
}
.card-head h2 { font-size: 15px; margin:0; font-weight:700; }
.card-head p { margin:3px 0 0; color: var(--muted); font-size: 11px; }
.link { background: none; color: var(--green); font-size: 11px; font-weight: 700; }

.activity { padding: 0 21px 16px; }
.activity-row { display:flex; align-items:center; gap:12px; padding:14px 0; border-top:1px solid var(--line); }
.activity-dot {
  width:34px; height:34px; border-radius:11px; display:grid; place-items:center;
  background: var(--green-soft); color: var(--green); flex: none;
}
.activity-main { min-width:0; flex:1; }
.activity-main strong { display:block; font-size:12px; }
.activity-main span { color: var(--muted); font-size:11px; }
.activity-amt { text-align:right; font-weight:700; font-size:12px; }
.activity-amt small { display:block; color: var(--muted); font-weight:400; font-size:10px; }

.chart { height: 205px; padding: 0 21px 20px; display:flex; align-items:end; gap:12px; }
.bar-wrap { height:100%; flex:1; display:flex; flex-direction:column; justify-content:end; align-items:center; gap:7px; }
.bar {
  width:100%; max-width:34px;
  border-radius:7px 7px 3px 3px;
  background: linear-gradient(180deg, var(--green), color-mix(in srgb, var(--green) 62%, var(--surface)));
  min-height:12px;
}
.bar-label { font-size:9px; color: var(--muted); }

.spotlight {
  padding:21px; min-height:100%; background: linear-gradient(145deg, var(--green-dark), var(--green));
  color:white; position:relative; overflow:hidden;
}
.spotlight:after {
  content:""; position:absolute; width:190px; height:190px; border:1px solid rgba(255,255,255,.12);
  border-radius:50%; right:-70px; top:-65px; box-shadow:0 0 0 28px rgba(255,255,255,.03),0 0 0 52px rgba(255,255,255,.015);
}
.spotlight .eyebrow { color:#bfe6d9; }
.spotlight h2 { font:600 27px/1.15 var(--display); max-width:270px; margin:5px 0 11px; }
.spotlight p { color:#c9ded7; font-size:12px; max-width:310px; }
.spot-value { font-size:34px; font-weight:700; margin:24px 0 3px; }
.spot-meta { color:#c9ded7; font-size:11px; }
.mini-actions { display:flex; gap:8px; margin-top:25px; }
.mini-actions button {
  background: rgba(255,255,255,.11); color:#fff; border:1px solid rgba(255,255,255,.15); border-radius:10px; padding:8px 11px; font-weight:600;
}

.toolbar { display:flex; gap:9px; align-items:center; flex-wrap:wrap; margin-bottom:18px; }
.search {
  height:42px; background:var(--surface); border:1px solid var(--line); border-radius:12px; display:flex; align-items:center;
  gap:9px; padding:0 13px; flex:1; min-width:220px;
}
.search svg { color:var(--muted); flex:none; }
.search input { border:0; outline:0; background:transparent; width:100%; }
.select {
  height:42px; border:1px solid var(--line); background:var(--surface); border-radius:12px; padding:0 12px; min-width:130px;
}

.chips { display:flex; gap:7px; flex-wrap:wrap; margin-bottom:18px; }
.chip {
  padding:8px 12px; border-radius:20px; border:1px solid var(--line); background:var(--surface); color:var(--muted); font-size:11px; font-weight:600;
}
.chip.active {
  background: var(--green-soft); color: var(--green-dark); border-color: transparent;
}

.gallery-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:15px; }
.photo { overflow:hidden; }
.photo-image {
  aspect-ratio:1/1; background: linear-gradient(135deg,#dbe6df,#9db8aa); position:relative; display:flex; align-items:end; padding:12px; overflow:hidden;
}
.photo-image:before {
  content:""; position:absolute; inset:0;
  background: radial-gradient(circle at 70% 25%, rgba(255,255,255,.6), transparent 27%), linear-gradient(145deg, transparent 45%, rgba(16,67,53,.25), rgba(10,31,26,.32));
}
.photo:nth-child(2) .photo-image { background: linear-gradient(135deg,#ded4c1,#8c9b91); }
.photo:nth-child(3) .photo-image { background: linear-gradient(135deg,#d7d9e2,#9ca8bc); }
.photo:nth-child(4) .photo-image { background: linear-gradient(135deg,#d3d2c9,#899885); }
.photo:nth-child(5) .photo-image { background: linear-gradient(135deg,#dfe7e0,#8aa59d); }
.photo:nth-child(6) .photo-image { background: linear-gradient(135deg,#e7e2d8,#b9a98e); }
.photo:nth-child(7) .photo-image { background: linear-gradient(135deg,#d4dce6,#8a9d9c); }
.photo:nth-child(8) .photo-image { background: linear-gradient(135deg,#e0d7c8,#af9a86); }
.photo-badge {
  position:relative; z-index:1; background:rgba(255,255,255,.88); backdrop-filter:blur(8px); padding:5px 8px; border-radius:8px; font-size:9px; font-weight:700;
}
.photo-info { padding:11px 2px 2px; }
.photo-info strong { font-size:12px; }
.photo-info span { display:block; color: var(--muted); font-size:10px; margin-top:2px; }

.upload {
  border:1.5px dashed var(--line-strong); min-height:190px; display:grid; place-items:center; text-align:center; padding:25px; background:var(--surface-2); border-radius:var(--radius); margin-bottom:18px;
}
.upload-icon { width:46px; height:46px; border-radius:14px; background:var(--surface); display:grid; place-items:center; margin:auto; color:var(--green); }
.upload strong { display:block; margin-top:9px; }
.upload p { font-size:11px; color: var(--muted); margin:3px 0 12px; }

.table-card { overflow:hidden; }
.table-scroll { overflow:auto; }
table { width:100%; border-collapse:collapse; min-width:700px; }
th { text-align:left; padding:13px 16px; color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.08em; border-bottom:1px solid var(--line); }
td { padding:13px 16px; border-bottom:1px solid var(--line); font-size:12px; }
.money { text-align:right; }
.source { display:inline-block; border-radius:999px; padding:4px 6px; font-size:10px; font-weight:700; }
.mpesa { background:#e4f0eb; color:#176b55; }
.bank { background:#f7efdf; color:#7f5a18; }
.card-pill { background:#eef1ec; color:#45514d; }

.status { padding:5px 9px; border-radius:8px; font-size:9px; font-weight:700; }
.pending { background:var(--gold-soft); color:#765318; }
.approved { background:var(--green-soft); color:var(--green-dark); }

.receipt-layout { display:grid; grid-template-columns: 1fr .8fr; gap:18px; }
.receipt-list { padding:0 20px; }
.receipt {
  display:grid; grid-template-columns:70px 1fr auto; gap:14px; align-items:center; padding:15px 0; border-bottom:1px solid var(--line);
}
.receipt-thumb {
  width:60px; height:60px; border-radius:12px; background:linear-gradient(145deg,#f2eee5,#d7ccba); display:grid; place-items:center; font-size:10px; color:var(--muted); font-weight:700; text-transform:uppercase;
}
.receipt strong { display:block; }
.receipt-meta { font-size:11px; color: var(--muted); margin-top:4px; }
.receipt-actions { display:flex; }

.form-card { padding:22px; }
.form-grid { display:grid; grid-template-columns: repeat(2,1fr); gap:16px; }
.form-grid.stacked { grid-template-columns:1fr; }
.field label {
  display:block; font-size:10px; color:var(--muted); font-weight:700; margin:0 0 6px; text-transform:uppercase; letter-spacing:.08em;
}
.field input, .field select {
  width:100%; height:42px; border-radius:12px; border:1px solid var(--line); background:var(--surface); padding:0 12px;
}
.form-actions { margin-top: 18px; }

.tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:20px; overflow:auto; }
.tab { padding:11px 14px; background:none; color:var(--muted); font-size:12px; font-weight:600; white-space:nowrap; }
.tab.active { color: var(--green-dark); border-bottom:2px solid var(--green); }
.subpage { display:none; }
.subpage.active { display:block; }

.report-cards { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:18px; }
.report-card { padding:18px; }
.report-card span { color: var(--muted); font-size:10px; }
.report-card strong { display:block; margin-top:10px; font-size:24px; }
.progress { margin-top:12px; height:8px; border-radius:999px; background:var(--surface-2); overflow:hidden; }
.progress i { display:block; height:100%; border-radius:inherit; background: linear-gradient(90deg, var(--green), #8ec7ad); }

.toast {
  position:fixed; right:24px; bottom:24px; background:var(--ink); color:var(--surface); padding:12px 15px; border-radius:12px; box-shadow:var(--shadow); font-size:12px; opacity:0; transform:translateY(8px); transition:.2s; pointer-events:none;
}
.toast.show { opacity:1; transform:none; }

.modal { position:fixed; inset:0; background:rgba(8,14,11,.5); backdrop-filter:blur(5px); display:none; place-items:center; padding:20px; z-index:80; }
.modal.open { display:grid; }
.modal-box { background:var(--surface); border-radius:18px; border:1px solid var(--line); width:min(480px,100%); box-shadow:var(--shadow); padding:20px; }
.modal-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:15px; }
.close { background:none; font-size:22px; color:var(--muted); }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(23,107,85,.08), rgba(255,255,255,.28));
  padding: 30px;
}

.auth-card {
  width: min(460px, 100%);
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
}

.auth-brand {
  display:flex; align-items:center; gap:12px; margin-bottom: 22px;
}
.auth-brand .brand-mark { width:44px; height:44px; }
.brand-subtitle { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.auth-header { margin-bottom: 18px; }
.auth-header h1 { font-size: clamp(28px, 3vw, 38px); }
.auth-form { display:grid; gap:18px; }
.field span { display:block; font-size:10px; color:var(--muted); font-weight:700; margin:0 0 6px; text-transform:uppercase; letter-spacing:.08em; }
.field input { display:block; width:100%; height:46px; border:1px solid var(--line); border-radius:12px; background:var(--surface); padding:0 12px; }
.auth-error {
  margin-top: 14px; background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 23%, transparent);
  border-radius: 10px; padding: 10px 12px; font-size: 12px;
}
.demo-accounts { margin-top: 26px; border-top:1px solid var(--line); padding-top: 18px; }
.demo-accounts h3 { margin:0 0 10px; font-size:12px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); }
.demo-row { display:flex; justify-content:space-between; gap: 16px; font-size:12px; padding:8px 0; border-bottom:1px solid var(--line); }
.demo-row:last-child { border-bottom:0; }

@media (max-width: 1050px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
  .grid, .grid.two-col, .receipt-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { display:block; }
  .sidebar {
    position: sticky; height:auto; top:0; padding:10px 12px; border-right:0; border-bottom:1px solid var(--line); flex-direction:row; align-items:center; gap:12px;
  }
  .nav { display:flex; overflow:auto; }
  .brand { padding:0; }
  .sidebar-bottom { margin-top:0; margin-left:auto; }
  .main { padding: 20px 16px 50px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .stats { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
