:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e6e8ec;
  --accent: #111827;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 18px;
  --pad: 16px;
  --nav-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-weight: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px var(--pad) calc(var(--nav-h) + 40px);
}

/* ---------- skeleton ---------- */
.skeleton { max-width: 480px; margin: 0 auto; padding: 24px var(--pad); }
.skel-block { background: #e8eaee; border-radius: var(--radius); animation: pulse 1.4s ease-in-out infinite; }
.skel-title { height: 22px; width: 55%; margin-bottom: 18px; border-radius: 8px; }
.skel-hero { height: 150px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ---------- auth ---------- */
.auth {
  max-width: 380px;
  margin: 0 auto;
  padding: 18vh var(--pad) 40px;
}
.auth h1 { font-size: 26px; font-weight: 700; margin: 0 0 6px; }
.auth p { color: var(--muted); font-size: 14px; margin: 0 0 26px; line-height: 1.5; }
.auth .field { margin-bottom: 12px; }

/* ---------- headers ---------- */
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.top h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -0.3px; }
.top .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center; background: var(--card); color: var(--muted);
  border: 1px solid var(--line);
}

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 14px;
}
.card-title { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }

.hero { background: var(--accent); color: #fff; padding: 20px var(--pad); }
.hero .label { font-size: 12px; opacity: 0.65; letter-spacing: 0.4px; text-transform: uppercase; }
.hero .amount { font-size: 34px; font-weight: 700; margin: 6px 0 14px; letter-spacing: -1px; }
.hero .split { display: flex; gap: 10px; }
.hero .split > div { flex: 1; background: rgba(255,255,255,0.09); border-radius: 12px; padding: 10px 12px; }
.hero .split .k { font-size: 11px; opacity: 0.65; }
.hero .split .v { font-size: 15px; font-weight: 700; margin-top: 3px; }

.stat-row { display: flex; gap: 10px; margin-bottom: 14px; }
.stat-row .card { flex: 1; margin: 0; padding: 14px; }
.stat-row .k { font-size: 11px; color: var(--muted); }
.stat-row .v { font-size: 17px; font-weight: 700; margin-top: 4px; letter-spacing: -0.4px; }

/* ---------- budget bars ---------- */
.budget-item { margin-bottom: 14px; }
.budget-item:last-child { margin-bottom: 0; }
.budget-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.budget-head .name { font-size: 14px; font-weight: 600; }
.budget-head .nums { font-size: 12px; color: var(--muted); }
.bar { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; transition: width 0.3s ease; }
.budget-item.over .bar > span { background: var(--bad) !important; }
.budget-item.over .nums { color: var(--bad); }

/* ---------- transactions ---------- */
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 16px 4px 8px; font-size: 12px; color: var(--muted); font-weight: 600;
}
.txn { display: flex; align-items: center; gap: 4px; padding: 11px var(--pad); background: var(--card); }
/* The row itself opens the edit sheet; the trash button stays a separate target. */
.txn-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.txn-open:active { opacity: 0.6; }
.txn:first-of-type { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.txn:last-of-type { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.txn + .txn { border-top: 1px solid var(--line); }
.dot { width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.dot svg { width: 19px; height: 19px; }
.dot.sm { width: 28px; height: 28px; border-radius: 9px; }
.dot.sm svg { width: 16px; height: 16px; }
.txn .t2 .pay { display: inline-grid; place-items: center; vertical-align: -2px; margin-right: 5px; color: var(--faint); }
.txn .t2 .pay svg { width: 13px; height: 13px; }

/* ---------- spend breakdown ---------- */
.brk { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; }
.brk:last-child { margin-bottom: 0; }
.brk-body { flex: 1; min-width: 0; display: block; }
.brk .budget-head { display: flex; }
.brk .bar { display: block; }

/* ---------- funds ---------- */
.week-row { display: flex; gap: 10px; }
.week-row > div { flex: 1; }
.week-row .k { font-size: 11px; color: var(--muted); }
.week-row .v { font-size: 16px; font-weight: 700; margin-top: 3px; letter-spacing: -0.3px; }

.fund-tag {
  display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 99px;
  font-size: 10px; font-weight: 700; color: #fff; vertical-align: 1px;
}

/* ---------- campus ---------- */
.mode-switch { margin-bottom: 16px; }

/* Schedule month grid: dots are the classes that day, a red pip means a task
   is due, a ring means something was moved or canceled. */
.cal-cell.sched { display: grid; grid-template-rows: auto auto; align-content: center; gap: 3px; }
.cal-cell.sched.changed { border-color: var(--accent); border-style: dashed; }
.cal-dots { display: flex; gap: 2px; justify-content: center; min-height: 5px; }
.cal-dots i { width: 4px; height: 4px; border-radius: 50%; display: block; }
.cal-dots i.due { background: var(--bad); border-radius: 1px; width: 5px; height: 5px; }
.cal-foot .scale i.ring { background: transparent; border: 1.5px dashed var(--accent); }
.cal-foot .scale i.due { background: var(--bad); border-radius: 2px; }

.txn.is-off .t1 { text-decoration: line-through; color: var(--faint); }
.txn.is-off .dot { opacity: 0.45; }
.due-bad { color: var(--bad); font-weight: 700; }

.check {
  width: 26px; height: 26px; border-radius: 9px; flex: none;
  border: 1.6px solid var(--line); background: var(--card); color: #fff;
  display: grid; place-items: center; margin-right: 8px;
}
.check.on { background: var(--good); border-color: var(--good); }
.check svg { width: 15px; height: 15px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 45%; }

.slot-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.slot-row select, .slot-row input {
  min-width: 0; padding: 9px 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 13px; outline: none;
}
.slot-row select { flex: 0 0 66px; }
.slot-row input[type="time"] { flex: 1 1 0; }
.slot-row input[type="text"] { flex: 1 1 60px; }

.cat-sub { display: block; font-size: 11.5px; color: var(--faint); font-weight: 500; margin-top: 2px; }

.preview {
  background: #eef1f4; border-radius: 12px; padding: 11px 13px;
  font-size: 12.5px; line-height: 1.5; color: var(--muted); margin-bottom: 14px;
}

/* ---------- category management ---------- */
.cat-row { display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 0; text-align: left; }
.cat-row + .cat-row { border-top: 1px solid var(--line); }
.cat-row:active { opacity: 0.6; }
.cat-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.cat-id { font-size: 11px; color: var(--faint); font-family: ui-monospace, monospace; }
.dimmed { opacity: 0.5; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sw-btn { width: 32px; height: 32px; border-radius: 10px; border: 2px solid transparent; }
.sw-btn.on { border-color: var(--ink); outline: 2px solid var(--card); outline-offset: -5px; }

.icon-pick { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ic-btn {
  aspect-ratio: 1; border-radius: 11px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); display: grid; place-items: center;
}
.ic-btn svg { width: 19px; height: 19px; }
.ic-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- segmented control ---------- */
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600;
}
.seg button svg { width: 17px; height: 17px; }
.seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

.pace { font-size: 12px; font-weight: 600; margin-top: 12px; }
.pace.good { color: var(--good); }
.pace.bad { color: var(--bad); }
.txn .body { flex: 1; min-width: 0; display: block; }
.txn .t1 { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.txn .t2 { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }
.txn .t3 { display: block; font-size: 11.5px; color: var(--faint); margin-top: 2px; opacity: 0.85; }
.hero .hero-sub { font-size: 12.5px; opacity: 0.7; margin: -8px 0 14px; }
.txn .amt { font-size: 14px; font-weight: 700; white-space: nowrap; }
.txn .amt.in { color: var(--good); }
.txn .del { color: var(--faint); padding: 6px; margin: -6px -6px -6px 2px; }

.empty { text-align: center; color: var(--faint); font-size: 13px; padding: 34px 10px; line-height: 1.6; }

/* ---------- calendar heatmap ---------- */
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { margin-bottom: 6px; }
.cal-dow span { text-align: center; font-size: 10.5px; font-weight: 700; color: var(--faint); }

.cal-pad { aspect-ratio: 1; }
.cal-cell {
  aspect-ratio: 1; border-radius: 9px; background: #f1f3f5;
  display: grid; place-items: center; position: relative;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  border: 1.5px solid transparent;
}
/* Four spend levels, darkest = heaviest day of the month. */
.cal-cell.lvl-1 { background: #d6dbe2; }
.cal-cell.lvl-2 { background: #a9b2bf; }
.cal-cell.lvl-3 { background: #6b7686; color: #fff; }
.cal-cell.lvl-4 { background: #2c3646; color: #fff; }
.cal-cell.future { background: transparent; color: #cbd2da; }
.cal-cell.today { border-color: var(--ink); }
.cal-cell.sel { outline: 2px solid var(--ink); outline-offset: 1px; }

/* A day with no spending gets a green pip; a day with income gets a green edge. */
.cal-cell.zero::after {
  content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--good);
}
.cal-cell.earned { box-shadow: inset 0 -3px 0 var(--good); }

.cal-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; font-size: 11.5px; color: var(--muted);
}
.cal-foot b { color: var(--ink); }
.cal-foot .scale { display: flex; align-items: center; gap: 3px; }
.cal-foot .scale i { width: 10px; height: 10px; border-radius: 3px; background: #f1f3f5; }
.cal-foot .scale i.lvl-1 { background: #d6dbe2; }
.cal-foot .scale i.lvl-2 { background: #a9b2bf; }
.cal-foot .scale i.lvl-3 { background: #6b7686; }
.cal-foot .scale i.lvl-4 { background: #2c3646; }

/* ---------- tabs / chips ---------- */
.tabs { display: flex; gap: 6px; background: #e9ebef; padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tabs button { flex: 1; padding: 8px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--card); color: var(--ink); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 99px; font-size: 13px; font-weight: 600;
  background: var(--card); color: var(--muted); border: 1px solid var(--line);
}
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- month picker ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.month-nav .m { font-size: 15px; font-weight: 700; }
.month-nav button { width: 32px; height: 32px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--muted); font-size: 16px; }
.month-nav button:disabled { opacity: 0.35; }

/* ---------- charts ---------- */
.donut-row { display: flex; align-items: center; gap: 18px; }
.donut { width: 116px; height: 116px; border-radius: 50%; flex: none; position: relative; }
.donut::after {
  content: ''; position: absolute; inset: 22px; border-radius: 50%; background: var(--card);
}
.legend { flex: 1; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin-bottom: 7px; }
.legend-row .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row .lb { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-row .vl { font-weight: 700; }

.trend svg { width: 100%; height: auto; display: block; }

/* ---------- form ---------- */
.field { display: block; margin-bottom: 14px; }
.field .lbl { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: block; }
.field input, .field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); font-size: 15px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.amount-input {
  width: 100%; border: 0; background: none; font-size: 34px; font-weight: 700;
  letter-spacing: -1px; outline: none; padding: 4px 0;
}
.btn {
  width: 100%; padding: 14px; border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 15px; font-weight: 700;
}
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.55; }
.err { color: var(--bad); font-size: 13px; margin-bottom: 10px; min-height: 18px; }

/* ---------- sheet ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 8px var(--pad) calc(20px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto; max-height: 92vh; overflow-y: auto;
  animation: rise 0.22s ease;
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
.grabber { width: 38px; height: 4px; border-radius: 99px; background: #d3d7dd; margin: 6px auto 14px; }
.sheet h2 { font-size: 17px; font-weight: 700; margin: 0 0 16px; }

/* ---------- fab + nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,0.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 480px; margin: 0 auto; height: var(--nav-h); display: flex; }
.nav button { flex: 1; display: grid; place-items: center; gap: 3px; color: var(--faint); font-size: 10.5px; font-weight: 600; }
.nav button.on { color: var(--ink); }
.nav svg { width: 21px; height: 21px; }

/* Centre add button, lifted out of the bar. */
.nav-add { flex: 1; display: grid; place-items: center; position: relative; }
.add-btn {
  position: absolute; bottom: 10px;
  width: 56px; height: 42px; border-radius: 21px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  border: 4px solid var(--bg);
  box-shadow: 0 6px 16px rgba(15,23,42,0.28);
}
.add-btn svg { width: 22px; height: 22px; }
.add-btn:active { transform: translateY(1px); }

/* ---------- toast ---------- */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 22px); z-index: 60; pointer-events: none; display: grid; place-items: center; }
.toast { background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 99px; font-size: 13px; font-weight: 600; animation: rise 0.2s ease; }

/* ---------- attendance ---------- */
/* Three tones, reused by the pill, the bar and the meeting cells, so a course
   that is close to the limit reads the same everywhere. */
.att-pill {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px;
  white-space: nowrap; flex: none;
}
.att-pill.ok   { background: #dcfce7; color: #15803d; }
.att-pill.warn { background: #fef3c7; color: #a16207; }
.att-pill.bad  { background: #fee2e2; color: var(--bad); }

.att-bar { display: block; height: 4px; border-radius: 99px; background: var(--line); margin-top: 6px; }
.att-bar i { display: block; height: 100%; border-radius: 99px; }
.att-bar i.ok   { background: var(--good); }
.att-bar i.warn { background: #d97706; }
.att-bar i.bad  { background: var(--bad); }

.att-today { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.att-mark-row { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.att-mark-name { flex: 1; min-width: 120px; font-size: 14px; font-weight: 600; }
.att-marks { display: flex; gap: 6px; }
.att-btn {
  font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.att-btn:active { transform: translateY(1px); }
.att-btn.hadir.on { background: #dcfce7; border-color: #86efac; color: #15803d; }
.att-btn.izin.on  { background: #fef3c7; border-color: #fcd34d; color: #a16207; }
.att-btn.alfa.on  { background: #fee2e2; border-color: #fca5a5; color: var(--bad); }

.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 7px; }
.att-slot {
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  padding: 8px 9px; border-radius: 11px; background: var(--bg);
  border: 1.5px solid transparent;
}
.att-slot:active { transform: translateY(1px); }
.att-slot .n { font-size: 10px; font-weight: 700; color: var(--faint); letter-spacing: 0.04em; }
.att-slot .d { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.att-slot .s { font-size: 12.5px; font-weight: 700; color: var(--faint); }
.att-slot .f { font-size: 10px; color: var(--accent); font-weight: 600; }
.att-slot.hadir { background: #dcfce7; } .att-slot.hadir .s { color: #15803d; }
.att-slot.izin  { background: #fef3c7; } .att-slot.izin  .s { color: #a16207; }
.att-slot.alfa  { background: #fee2e2; } .att-slot.alfa  .s { color: var(--bad); }
.att-slot.now   { border-color: var(--accent); }
.att-slot.off   { opacity: 0.45; }

.att-help { font-size: 12px; color: var(--faint); line-height: 1.5; margin: 12px 0 0; }
