:root {
  /* Brand colours come from the logo: blue #001cd8 and pink #fc0088. */
  --bg: #f4f5fa;
  --surface: #ffffff;
  --border: #e4e7ef;
  --text: #151b2c;
  --muted: #667085;
  --accent: #001cd8;
  --accent-text: #ffffff;
  --accent-soft: #eceeff;
  --brand-pink: #fc0088;
  --danger: #c62f3b;
  --sidebar: #0a0f2c;
  --sidebar-text: #b9c0d9;
  --radius: 14px;
  /* Figures use their own typeface so amounts never read like words. */
  --font-num: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .04);
  /* The one bold surface on each page: brand blue with a pink glow. */
  --hero: radial-gradient(120% 150% at 100% 0%, rgba(252, 0, 136, .5) 0%, transparent 44%),
          linear-gradient(135deg, #001cd8 0%, #2b40f3 100%);
  --i-grid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3h7v7H3zM14 3h7v7h-7zM14 14h7v7h-7zM3 14h7v7H3z'/%3E%3C/svg%3E");
  --i-trend: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 17l6-6 4 4 8-8M14 7h7v7'/%3E%3C/svg%3E");
  --i-in: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM15 9l-6 6M9 9v6h6'/%3E%3C/svg%3E");
  --i-out: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM9 15l6-6M9 9h6v6'/%3E%3C/svg%3E");
  --i-brief: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7h18v13H3zM8 7V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2M3 13h18'/%3E%3C/svg%3E");
  --i-user: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2M12 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8z'/%3E%3C/svg%3E");
  --i-wallet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12V7H5a2 2 0 0 1 0-4h14v4M3 5v14a2 2 0 0 0 2 2h16v-5M18 12a2 2 0 0 0 0 4h4v-4z'/%3E%3C/svg%3E");
  --i-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3v18h18M7 14l4-4 3 3 5-6'/%3E%3C/svg%3E");
  --i-top: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M5 12l7-7 7 7'/%3E%3C/svg%3E");
  --i-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20zM12 6v6l4 2'/%3E%3C/svg%3E");
  --i-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E");
  --i-pencil: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z'/%3E%3C/svg%3E");
  --i-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6M10 11v6M14 11v6'/%3E%3C/svg%3E");
  --i-key: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 7a4 4 0 1 1-3.9 5H8v3H5v3H2v-3l7.2-7.2A4 4 0 0 1 15 7zM16 9h.01'/%3E%3C/svg%3E");
  --i-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 9v4M12 17h.01M10.3 3.9L2 18a2 2 0 0 0 1.7 3h16.6a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3C/svg%3E");
  --i-average: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12h16M4 6h10M4 18h7'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

/* App shell: the window itself never scrolls, so the sidebar cannot move.
   Only the entries table scrolls (and the content area, if the window is short). */
html { overscroll-behavior: none; }

body {
  margin: 0;
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Amounts: fixed-width digits that line up in columns, with lighter decimals
   so the rupees are what the eye lands on. */
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt .dec { font-size: .8em; font-weight: 500; opacity: .5; }
td.amt, .bar-value .amt, .split-row .amt, .due .amt, .tip-row strong, .collect-of .amt {
  font-family: var(--font-num);
  letter-spacing: -.03em;
}
:is(.card-total, .kpi-hero, .collect-due) .amt .dec { opacity: .7; }

/* Sidebar */
.sidebar {
  display: flex; flex-direction: column;
  overflow-y: auto;
  width: 240px;
  flex-shrink: 0;
  padding: 22px 14px;
  background: radial-gradient(140% 60% at 0% 0%, rgba(0, 28, 216, .45) 0%, transparent 60%), var(--sidebar);
  color: var(--sidebar-text);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 26px; }
/* The logo sits on a white tile: its dark blue would vanish on the sidebar. */
.brand-mark {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}
.brand-name { color: #fff; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; opacity: .7; }
.sidebar nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: 10px;
  color: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background-color .12s, color .12s;
}
/* Each link's icon is drawn from its address, so the page markup stays plain. */
.sidebar nav a::before {
  content: '';
  flex-shrink: 0;
  width: 17px; height: 17px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  opacity: .85;
}
.sidebar nav a[href="/"], .sidebar nav a[href^="/?"] { --icon: var(--i-grid); }
.sidebar nav a[href^="/investments"] { --icon: var(--i-trend); }
.sidebar nav a[href^="/income"] { --icon: var(--i-in); }
.sidebar nav a[href^="/expenses"] { --icon: var(--i-out); }
.sidebar nav a[href^="/projects"] { --icon: var(--i-brief); }
.sidebar nav a[href^="/activity"] { --icon: var(--i-clock); }
.sidebar nav a + a { margin-top: 3px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav a.active { background: rgba(255, 255, 255, .13); color: #fff; }
.sidebar nav a.active::after {
  content: '';
  position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand-pink), #6a7bff);
}

.sidebar nav { flex: 1; }

/* Signed-in user and Log out, at the foot of the sidebar. */
.account {
  display: flex; align-items: center; gap: 10px;
  margin-top: 16px; padding: 14px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
}
.account-avatar {
  display: grid; place-items: center; flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-pink), #6a7bff);
  color: #fff; font-size: 13px; font-weight: 700;
}
.account-name { flex: 1; min-width: 0; overflow: hidden; color: #fff; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.logout {
  height: 30px; padding: 0 10px;
  border-color: rgba(255, 255, 255, .18);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 12px;
}
.logout:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.logout:focus-visible { outline-color: #fff; }

/* Login page */
body.login-page {
  align-items: center; justify-content: center;
  height: auto; min-height: 100vh; min-height: 100dvh;
  overflow: auto;
  padding: 24px 16px;
  background:
    radial-gradient(70% 60% at 100% 0%, rgba(252, 0, 136, .38) 0%, transparent 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(0, 28, 216, .7) 0%, transparent 65%),
    var(--sidebar);
}
main.login-card {
  flex: none;
  display: block;
  width: min(400px, 100%);
  overflow: visible;
  padding: 34px 30px 30px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  text-align: center;
}
.login-logo { border-radius: 16px; box-shadow: 0 6px 18px rgba(16, 24, 40, .16); }
.login-card h1 { margin: 16px 0 0; font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.login-sub { margin: 4px 0 24px; color: var(--muted); }
#login-form { display: grid; gap: 16px; text-align: left; }
#login-form input { width: 100%; height: 46px; font-size: 16px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 68px; }
.password-field button {
  position: absolute; top: 6px; right: 6px;
  height: 34px; padding: 0 10px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
}
.password-field button:hover { background: var(--bg); color: var(--text); }
#login-btn { height: 46px; margin-top: 4px; font-size: 15px; }

/* Page */
main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
  padding: 30px 34px;
  background:
    radial-gradient(900px 260px at 12% -90px, rgba(0, 28, 216, .07), transparent 70%),
    radial-gradient(700px 220px at 96% -70px, rgba(252, 0, 136, .05), transparent 70%);
}
main > * { flex-shrink: 0; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 22px;
}
.page-header h1 { margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.page-header p { margin: 2px 0 0; color: var(--muted); }
.page-header button { flex-shrink: 0; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  position: relative;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-label { padding-right: 44px; color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.card-value { margin-top: 6px; font-size: 25px; font-weight: 650; letter-spacing: -.01em; }
.card-note { margin-top: 3px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

/* Icon tile in a card's corner; --icon picks the glyph, a tone-* class the colour. */
.card-icon {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--tone-soft, var(--accent-soft));
}
.card-icon::before {
  content: '';
  position: absolute; inset: 9px;
  background: var(--tone, var(--accent));
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.tone-blue { --tone: #1f6cc9; --tone-soft: #e2eefc; }
.tone-orange { --tone: #d4521d; --tone-soft: #fdeadf; }
.tone-green { --tone: #108058; --tone-soft: #dbf3e9; }
.tone-amber { --tone: #a86f00; --tone-soft: #fcefcf; }
.tone-ink { --tone: #3d4759; --tone-soft: #eceef3; }
.tone-red { --tone: #c62f3b; --tone-soft: #fde8ea; }

/* Hero surfaces: the headline figure on each page. */
.card-total, .kpi.kpi-hero, .collect-due {
  border-color: transparent;
  background: var(--hero);
  color: #fff;
  box-shadow: 0 10px 26px rgba(0, 28, 216, .22);
}
:is(.card-total, .kpi-hero, .collect-due) :is(.card-label, .card-note, .kpi-note, .all-time) { color: rgba(255, 255, 255, .8); }
:is(.card-total, .kpi-hero, .collect-due) .card-icon { background: rgba(255, 255, 255, .18); }
:is(.card-total, .kpi-hero, .collect-due) .card-icon::before { background: #fff; }

.panel {
  margin-bottom: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }

/* Form */
dialog {
  width: min(480px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 70px rgba(10, 15, 44, .35);
}
dialog[open] { animation: dialog-in .16s ease-out; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(10, 15, 44, .55); backdrop-filter: blur(3px); }
dialog h2 { margin: 0; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 22px 22px; }
.fields .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--muted); }
input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d5d9e4;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}
.fields input { width: 100%; }
/* iPhones centre the text of date boxes and size them differently from other
   fields; these keep every field the same height and left-aligned. */
input[type="date"] { -webkit-appearance: none; appearance: none; min-width: 0; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Item suggestions, listed under the field while typing. */
.suggest {
  margin: 0; padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(16, 24, 40, .1);
  list-style: none;
}
.suggest li {
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.suggest li:hover, .suggest li.active { background: var(--accent-soft); }
input { transition: border-color .12s, box-shadow .12s; }
input:hover { border-color: #b9bfd0; }
input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 28, 216, .16); }

.form-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: #f8f9fc;
}
button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid #d5d9e4;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background-color .12s, border-color .12s, box-shadow .12s, transform .06s;
}
button:hover { background: var(--bg); }
button:active { transform: translateY(1px); }
button.primary {
  border-color: transparent;
  background: linear-gradient(180deg, #2238ee 0%, var(--accent) 100%);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 28, 216, .35), 0 6px 16px rgba(0, 28, 216, .22), inset 0 1px 0 rgba(255, 255, 255, .18);
}
button.primary:hover { background: linear-gradient(180deg, #2f45f5 0%, #0a27e6 100%); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: .6; cursor: default; }
.form-error { margin: 0; color: var(--danger); }

/* Table */
.table-panel { padding: 0; overflow: hidden; }
.table-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.table-head h2 { margin: 0; }
.filter-note { margin-left: auto; color: var(--muted); font-size: 12px; text-align: right; }
.count {
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* The panel takes whatever height is left and its rows scroll inside it, so
   the header and totals row stay in view. */
main > .table-panel {
  display: flex; flex-direction: column;
  flex-shrink: 1;
  min-height: 260px;
  margin-bottom: 0;
}
.table-head { flex-shrink: 0; }
.table-scroll { flex: 1; min-height: 0; overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px 20px; text-align: left; white-space: nowrap; }
td { border-bottom: 1px solid #eef0f3; }

thead th {
  position: sticky; top: 0; z-index: 1;
  padding-block: 10px;
  background: #f8f9fb;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Few-column tables: Item takes the spare width so Amount stays near it. */
table.simple .item { width: 100%; }

td.wrap { white-space: normal; min-width: 160px; }
/* Three clear levels in a row: the name (dark, bold), the amounts (bold
   figures), and supporting detail such as dates and remarks (small, grey). */
td.date { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
td.item { color: #0e1424; font-weight: 600; }
td.remarks { color: var(--muted); font-size: 13px; }
td.num { color: #0e1424; font-size: 14.5px; font-weight: 600; }
td.blank, td.zero { color: #b6bdc9; font-weight: 400; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Total Amount is the figure people scan for, so it gets its own band. */
td.total-amount { font-weight: 700; background: rgba(31, 94, 255, .045); }
thead th.total-amount { background: #eef2fd; color: #3c5bb5; }
td.running { color: var(--muted); font-weight: 500; }

tbody tr { transition: background-color .12s; }
tbody tr:nth-child(even) { background: #fbfcfd; }
tbody tr:hover { background: #f3f6fc; }
tbody tr.editing { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
tbody tr:last-child td { border-bottom: 0; }

tfoot td {
  position: sticky; bottom: 0;
  padding-block: 14px;
  background: #f8f9fb;
  border-top: 1px solid var(--border);
  border-bottom: 0;
  font-weight: 700;
}
tfoot td:first-child {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
tfoot td.total-amount { background: #e4ebfd; color: #1a3f9e; }

th.actions, td.actions { width: 1%; padding-left: 0; text-align: right; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  opacity: 0;
  transition: opacity .12s, background-color .12s, color .12s;
}
.icon-btn svg { width: 16px; height: 16px; }
tr:hover .icon-btn, tr.editing .icon-btn, .icon-btn:focus-visible { opacity: 1; }
.icon-btn:hover { background: #e6ebf5; color: var(--accent); }
.icon-btn.danger:hover { background: #fdecee; color: var(--danger); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); }
@media (hover: none) { .icon-btn { opacity: 1; } }

.empty { margin: 0; padding: 40px 28px; text-align: center; color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Project payments */
.form-hint { margin: 0; color: var(--muted); font-size: 12px; }

table.projects .item { width: 34%; }

/* Collection overview: one headline share with its meter, and what is left. */
.collect { display: flex; align-items: stretch; gap: 28px; padding: 22px 24px; }
.collect-main { flex: 1; min-width: 0; }
.collect-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; margin: 2px 0 12px; }
.collect-percent { font-size: 44px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.collect-of { color: var(--muted); font-size: 15px; }
.collect-of strong { color: var(--text); }
.collect-due {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  min-width: 290px;
  padding: 18px 22px;
  border-radius: var(--radius);
}
.collect-due-value { margin-top: 4px; font-size: 26px; font-weight: 600; }

/* Meters: the unfilled track is a lighter step of the fill's own colour. */
.meter { height: 12px; border-radius: 6px; background: #d7e6fb; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 6px; background: #2a78d6; transition: width .3s; }
.meter.small { flex: 1; height: 6px; min-width: 70px; border-radius: 3px; }
.meter.small .meter-fill { border-radius: 3px; }
.meter.done { background: #d5efd5; }
.meter.done .meter-fill { background: #0ca30c; }
.meter.partial { background: #fbe7ba; }
.meter.partial .meter-fill { background: #d98e00; }
.meter.pending { background: #e9ecf1; }

td.progress { min-width: 170px; }
td.progress > .meter { display: inline-block; width: calc(100% - 48px); vertical-align: middle; }
.progress-percent {
  display: inline-block; width: 40px; margin-left: 8px;
  color: var(--muted); font-size: 12px; text-align: right; vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

.chips { margin-left: auto; }
.chips button { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; font-size: 12px; }
.chip-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.chips button[aria-pressed="true"] .chip-count { color: rgba(255, 255, 255, .7); }
tbody tr { animation: row-in .18s ease-out; }
@keyframes row-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { tbody tr { animation: none; } .meter-fill { transition: none; } }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.done { background: #e3f4e3; color: #0a5c0a; }
.badge.partial { background: #fdf0d2; color: #7a5200; }
.badge.pending { background: #fde8e8; color: #a32424; }
td.status .due { margin-left: 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* Activity log */
main > .activity-panel { display: flex; flex-direction: column; flex-shrink: 1; min-height: 260px; margin-bottom: 0; padding: 0; overflow: hidden; }
.activity-scroll { flex: 1; min-height: 0; overflow: auto; }
.activity-day {
  position: sticky; top: 0; z-index: 1;
  margin: 0; padding: 10px 22px;
  border-bottom: 1px solid var(--border);
  background: #f8f9fc;
  color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
}
.activity { display: flex; align-items: flex-start; gap: 14px; padding: 16px 22px; border-bottom: 1px solid #eef0f3; }
.activity:last-child { border-bottom: 0; }
.activity-icon {
  position: relative; flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--tone-soft);
}
.activity-icon::before {
  content: '';
  position: absolute; inset: 9px;
  background: var(--tone);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.activity-body { flex: 1; min-width: 0; }
.activity-title { font-weight: 600; }
.activity-entry { margin-top: 1px; color: var(--text); overflow-wrap: anywhere; }
.activity-change { margin-top: 2px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.activity-side { display: flex; align-items: center; gap: 12px; flex-shrink: 0; color: var(--muted); font-size: 13px; white-space: nowrap; }
.activity.is-reverted .activity-entry, .activity.is-reverted .activity-change { text-decoration: line-through; color: var(--muted); }
.tag {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  border-radius: 999px;
  background: #fcefcf; color: #7a5200;
  font-size: 11px; font-weight: 600; vertical-align: 1px;
}
.tag.muted { background: #eceef3; color: var(--muted); }
.revert { height: 32px; padding: 0 12px; font-size: 13px; }

/* Dashboard */
:root {
  /* Chart colours follow the thing they stand for, on every chart. */
  --series-income: #2a78d6;
  --series-expenses: #eb6834;
  --series-ajmal: #1baf7a;
  --series-yaser: #eda100;
  --series-net: #3d4759;
  --chart-grid: #eceef2;
  --chart-axis: #c5cad3;
}

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 16px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button { height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; }
.presets button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(0, 28, 216, .25); }
.custom-range { display: flex; gap: 10px; }
.range-menu { display: none; }
.delete-entry { margin-right: auto; border-color: #efc4c8; color: var(--danger); }
.delete-entry:hover { background: #fdecee; }
.custom-range label { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; }
.custom-range input { height: 32px; font-size: 13px; }
.all-time { text-transform: none; letter-spacing: 0; }
main.loading .kpis, main.loading .chart-card { opacity: .55; transition: opacity .15s; }

.kpis {
  display: grid;
  grid-template-columns: 1.5fr repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  position: relative;
  display: block;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
a.kpi { transition: border-color .12s, box-shadow .12s, transform .12s; }
a.kpi:hover { border-color: #c3c9e6; box-shadow: 0 6px 18px rgba(16, 24, 40, .09); transform: translateY(-1px); }
a.kpi:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kpi-value { margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.kpi-note { margin-top: 2px; color: var(--muted); font-size: 12px; }
.kpi-hero {
  grid-row: span 2;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 26px;
}
.kpi-hero .kpi-value { font-size: 50px; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; }
.kpi-hero .card-icon { top: 20px; right: 20px; width: 42px; height: 42px; border-radius: 12px; }
.kpi-hero .card-icon::before { inset: 11px; }
.kpi-hero .kpi-note { margin-top: 6px; font-size: 13px; }
.trend { font-weight: 600; }
.trend.up { color: #006300; }
.trend.down { color: #c62f3b; }
.kpi .card-label { padding-right: 44px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.chart-card { padding: 18px 20px 20px; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.chart-head h2 { margin: 0; }
.chart-sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.chart-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }
.chart-empty { margin: 0; padding: 24px 0; color: var(--muted); text-align: center; }

.legend { display: flex; gap: 14px; margin: 2px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: 12px; white-space: nowrap; }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { flex-shrink: 0; width: 10px; height: 10px; border-radius: 3px; }

.chart { position: relative; }
.chart svg { display: block; touch-action: pan-y; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.grid-line { stroke: var(--chart-grid); }
.axis-line { stroke: var(--chart-axis); }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tick-year { fill: #9aa3b0; }
.band-wash { fill: rgba(31, 94, 255, .06); }
.crosshair { stroke: var(--chart-axis); }
.running-line { fill: none; stroke: var(--series-net); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.running-area { fill: var(--series-net); opacity: .08; }
.running-dot { fill: var(--series-net); stroke: var(--surface); stroke-width: 2; }
.end-label { fill: var(--text); font-size: 12px; font-weight: 600; }

.chart-tip {
  position: absolute;
  z-index: 2;
  min-width: 150px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(16, 24, 40, .12);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.tip-title { margin-bottom: 4px; color: var(--muted); }
.tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.tip-key { width: 10px; height: 2px; border-radius: 1px; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-label { color: var(--muted); }

.table-view { margin-top: 12px; font-size: 13px; }
.table-view summary { width: fit-content; color: var(--muted); cursor: pointer; }
.table-view summary:hover { color: var(--text); }
.table-view-scroll { margin-top: 10px; overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.table-view th, .table-view td { padding: 8px 14px; }
.table-view thead th { position: static; }

.split-bar { display: flex; gap: 2px; height: 14px; }
.split-segment { flex-basis: 0; min-width: 4px; }
.split-segment:first-child { border-radius: 4px 0 0 4px; }
.split-segment:last-child { border-radius: 0 4px 4px 0; }
.split-segment:only-child { border-radius: 4px; }
.split-rows { margin-top: 16px; }
.split-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #eef0f3; }
.split-row:last-child { border-bottom: 0; }
.split-name { flex: 1; }
.split-row strong { font-variant-numeric: tabular-nums; }
.split-share { width: 40px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 11fr) minmax(0, 10fr) 150px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}
.bar-label { min-width: 0; line-height: 1.3; }
.bar-name { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-count { color: var(--muted); font-size: 11px; }
.bar-track { height: 10px; }
.bar-fill { height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; }
.bar-value { display: flex; align-items: baseline; justify-content: flex-end; gap: 8px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-share { width: 32px; color: var(--muted); font-size: 12px; text-align: right; }

@media (max-width: 800px) {
  /* Phones scroll the page normally, with the top bar pinned. */
  body { flex-direction: column; height: auto; overflow: visible; }
  .sidebar {
    position: sticky; top: 0; z-index: 5;
    overflow: visible;
    width: auto;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    flex-direction: row; align-items: center; justify-content: space-between; gap: 12px;
  }
  .brand { padding: 0; min-width: 0; }
  .account { margin: 0; padding: 0; border: 0; }
  .account-name { display: none; }
  .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
  .sidebar nav a.active::after { display: none; }

  /* Page links become a floating bar at the bottom of the screen: icon
     buttons, with the current page's button widened to show its name. */
  .sidebar nav {
    position: fixed; z-index: 20;
    left: 50%; bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 4px;
    max-width: calc(100% - 20px);
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 999px;
    background: rgba(10, 15, 44, .9);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    box-shadow: 0 14px 34px rgba(10, 15, 44, .4);
  }
  .sidebar nav a {
    flex-shrink: 0;
    justify-content: center; gap: 0;
    min-width: 46px; height: 46px;
    padding: 0 13px;
    border-radius: 999px;
    color: #c3c9e2;
    font-size: 0; /* hides the label; the link keeps its name for screen readers */
    white-space: nowrap;
  }
  .sidebar nav a::before { width: 20px; height: 20px; opacity: 1; }
  .sidebar nav a + a { margin-top: 0; }
  .sidebar nav a.active {
    gap: 8px;
    padding: 0 16px;
    background: linear-gradient(135deg, #1a31ea 0%, var(--accent) 100%);
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 28, 216, .5), inset 0 1px 0 rgba(255, 255, 255, .2);
  }

  /* Bottom padding keeps the last rows clear of the floating bar. */
  main { display: block; overflow: visible; padding: 22px 16px calc(104px + env(safe-area-inset-bottom)); }
  main > .table-panel { display: block; min-height: 0; }
  .page-header h1 { font-size: 21px; }
  .page-header { margin-bottom: 16px; }
  .page-header p { display: none; }

  .cards { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
  .card { padding: 14px; }
  .card-value { font-size: 18px; }
  .card-icon { top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 9px; }
  .card-icon::before { inset: 7px; }
  .card-label, .kpi .card-label { padding-right: 34px; }
  .card:not(.card-total) .card-icon, .kpi:not(.kpi-hero) .card-icon { display: none; }
  .card:not(.card-total) .card-label, .kpi:not(.kpi-hero) .card-label { padding-right: 0; white-space: nowrap; }
  .card-total { grid-column: 1 / -1; }
  .card-total .card-value { font-size: 22px; }

  .panel { margin-bottom: 20px; padding: 18px; }
  /* 16px stops iOS zooming the page when a field is focused. */
  input { width: 100%; height: 44px; font-size: 16px; }
  button { height: 44px; }
  .form-actions button { flex: 1; }

  /* Each entry becomes a card: seven columns can't fit a phone screen. */
  .table-panel { padding: 0; }
  .table-head { padding: 12px 16px; }
  .table-scroll { overflow: visible; }
  .table-panel table, .table-panel tbody, .table-panel tfoot { display: block; }
  .table-panel thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%);
  }
  .table-panel tbody tr, .table-panel tfoot tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 12px;
    padding: 16px 18px;
  }
  .table-panel tbody tr {
    grid-template-areas:
      "item    item    amount"
      "date    date    actions"
      "ajmal   yaser   running"
      "remarks remarks remarks";
    align-items: start;
    border-bottom: 1px solid #eef0f3;
  }
  .table-panel tbody tr:last-child { border-bottom: 0; }
  .table-panel td, .table-panel td.wrap { display: block; min-width: 0; padding: 0; border: 0; white-space: normal; }

  .table-panel tbody td.item { grid-area: item; font-size: 15px; font-weight: 600; }
  .table-panel tbody td.item.blank { font-weight: 400; }
  .table-panel tbody td.total-amount { grid-area: amount; background: none; font-size: 16px; }
  .table-panel tbody td.date { grid-area: date; align-self: center; font-size: 12px; }
  .table-panel tbody td.actions { grid-area: actions; align-self: center; width: auto; }
  .table-panel tbody td.total-amount { text-align: right; }
  .suggest li { padding: 12px 10px; font-size: 16px; }
  .table-panel tbody td.ajmal { grid-area: ajmal; }
  .table-panel tbody td.yaser { grid-area: yaser; }
  .table-panel tbody td.running { grid-area: running; }
  .table-panel tbody td.remarks { grid-area: remarks; margin-top: 10px; font-size: 13px; }
  .table-panel tbody td.date.blank, .table-panel tbody td.remarks.blank { display: none; }
  .table-panel td.ajmal, .table-panel td.yaser { text-align: left; }
  .table-panel tbody td.ajmal, .table-panel tbody td.yaser, .table-panel tbody td.running { margin-top: 8px; }

  /* Project cards: progress bar and paid amount under the name, status last. */
  .table-panel tbody td.paid { grid-area: running; margin-top: 8px; }
  .table-panel table.projects tbody tr {
    grid-template-areas:
      "item     item     amount"
      "progress progress paid"
      "status   status   status";
  }
  .table-panel table.projects tbody td.progress { grid-area: progress; align-self: end; min-width: 0; margin-top: 8px; padding-bottom: 4px; }
  .table-panel table.projects tbody td.paid { grid-area: paid; }
  .table-panel table.projects tbody td.status { grid-area: status; align-self: center; margin-top: 12px; }
  .table-panel table.projects tbody td.actions { grid-area: actions; margin-top: 12px; }
  .collect { flex-direction: column; gap: 16px; padding: 16px; }
  .collect-percent { font-size: 36px; }
  .collect-due { min-width: 0; padding: 14px 16px; }
  .table-head { flex-wrap: wrap; }
  .table-panel .chips { width: calc(100% + 32px); margin: 4px -16px 0; padding: 0 16px; }
  .table-panel tbody td.status { grid-area: remarks; margin-top: 10px; }
  .table-panel tfoot td.paid { text-align: right; }
  .table-panel table.projects .item { width: auto; }

  .table-panel td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
  }

  .icon-btn { opacity: 1; width: 34px; height: 34px; margin-right: -8px; }
  .icon-btn + .icon-btn { margin-left: 8px; }

  .table-panel tfoot tr { background: #f8f9fb; border-top: 1px solid var(--border); }
  .table-panel tfoot td { position: static; padding: 0; border: 0; background: none; }
  .table-panel tfoot td:first-child, .table-panel tfoot td:last-child { display: none; }
  .table-panel tfoot td.total-amount { background: none; }
  .table-panel table.simple tfoot td.total-amount { grid-column: 1 / -1; }

  /* ---- Phone layout: fewer things per screen, more room around each ---- */

  /* One menu instead of a row of range buttons; dates only for a custom range. */
  .filters { gap: 10px; margin-bottom: 18px; }
  .filters .presets { display: none; }
  .range-menu {
    display: block;
    width: 100%; height: 44px;
    padding: 0 40px 0 14px;
    border: 1px solid #d5d9e4;
    border-radius: 12px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 12px center / 18px no-repeat;
    color: var(--text);
    font: inherit; font-size: 16px; font-weight: 500;
    -webkit-appearance: none; appearance: none;
  }
  .filters:not(.custom-open) .custom-range { display: none; }

  /* Activity: time and Revert drop under the text. */
  main > .activity-panel { display: block; min-height: 0; }
  .activity-scroll { overflow: visible; }
  .activity-day { position: static; padding: 10px 18px; }
  .activity { flex-wrap: wrap; gap: 12px; padding: 16px 18px; }
  .activity-body { flex-basis: calc(100% - 46px); }
  .activity-side { width: 100%; justify-content: space-between; padding-left: 46px; }
  .revert { height: 36px; }

  /* Summary: the headline card first, on its own; secondary cards dropped. */
  .cards .card-total { order: -1; }
  .card-extra { display: none; }
  .kpi:not(.kpi-hero) .kpi-note:not(:has(.trend)) { display: none; }

  /* Entries: name and amount, with the date beneath. Tap a row to edit it. */
  .table-panel tbody td.actions { display: none; }
  .table-panel tbody td.running { display: none; }
  .table-panel tbody tr { cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .table-panel tbody tr:nth-child(even) { background: none; }
  .table-panel tbody tr:active { background: #f1f3fa; }
  .table-panel tbody td.date { margin-top: 2px; }
  .table-panel td.num:not(.total-amount) { font-weight: 500; }
  .page-header button { height: 40px; padding: 0 14px; }
  /* Presets scroll sideways in one row rather than stacking. */
  .presets { flex-wrap: nowrap; margin: 0 -16px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
  .presets::-webkit-scrollbar { display: none; }
  .presets button { flex-shrink: 0; height: 34px; }
  .custom-range { width: 100%; }
  .custom-range label { flex: 1; min-width: 0; flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; }
  .custom-range input { width: 100%; min-width: 0; height: 40px; padding: 0 8px; font-size: 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 17px; }
  .kpi-hero { grid-column: 1 / -1; grid-row: auto; padding: 16px; }
  .kpi-hero .kpi-value { font-size: 34px; }
  .kpi-hero .card-icon { top: 14px; right: 14px; width: 34px; height: 34px; }
  .kpi-hero .card-icon::before { inset: 8px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .chart-card { padding: 16px; }
  .chart-head { flex-direction: column; gap: 8px; }
  .bar-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

/* Narrow phones: tighten the floating bar so the longest page name still fits. */
@media (max-width: 400px) {
  .sidebar nav { gap: 2px; }
  .sidebar nav a { min-width: 40px; padding: 0 10px; }
  .sidebar nav a.active { gap: 7px; padding: 0 13px; font-size: 12.5px; }
}
/* Very small screens: icons only; the current page is shown by its highlight. */
@media (max-width: 380px) {
  .sidebar nav a.active { gap: 0; font-size: 0; }
}
