:root {
  --teal: #1D4ED8;
  --teal-dark: #0F2A43;
  --teal-soft: #DBEAFE;
  --gold: #b45309;
  --ink: #0F172A;
  --muted: #475569;
  --line: #E2E8F0;
  --bg: #F5F7FA;
  --card: #ffffff;
  --red: #b91c1c;
  --red-soft: #fdecec;
  --amber: #92400e;
  --amber-soft: #fdf3e3;
  --green: #166534;
  --green-soft: #e9f7ee;
  --blue: #1d4ed8;
  --blue-soft: #e8effe;
  --purple: #6d28d9;
  --purple-soft: #f1eafe;
  --gold-bright: #f4b900;
  --gold-deep: #eab308;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--teal); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red); }
.success { color: var(--green); }

/* top bar (mobile) + sidebar (desktop) */
.topbar { background: linear-gradient(135deg, #0F2A43, #1D4ED8); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1024px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: .6rem; }
.brand { color: #fff; font-weight: 800; font-size: 1.25rem; text-decoration: none; display: inline-flex; align-items: center; gap: .5rem; }
/* brand logo mark — the green £ tile framed in gold so it reads on the deep-green bar */
.brand-logo { width: 2rem; height: 2rem; border-radius: 9px; background: var(--gold-bright); padding: 2px; flex: none; }
/* nav icons — inline SVG, no icon font */
.nav-icon { display: inline-flex; width: 1.15rem; height: 1.15rem; flex: none; }
.nav-icon svg { width: 100%; height: 100%; fill: currentColor; }
.brand-tag { font-size: .8rem; opacity: .85; }
.nav-toggle { margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.6); color: #fff; border-radius: 8px; font-size: 1.1rem; padding: .2rem .6rem; cursor: pointer; }
.sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 248px; background: linear-gradient(180deg, #0F2A43, #14365E); color: #fff; z-index: 30; transform: translateX(-105%); transition: transform .2s ease; display: flex; flex-direction: column; padding: 1rem; gap: 1rem; }
.sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.35); }
.sidebar-brand { display: flex; flex-direction: column; }
.sidebar-brand .brand { font-size: 1.35rem; }
.sidebar-cta { text-align: center; }
.main-nav { display: flex; flex-direction: column; gap: .15rem; }
.main-nav a { color: #DBEAFE; text-decoration: none; padding: .55rem .7rem; border-radius: 8px; font-size: .95rem; display: flex; align-items: center; gap: .6rem; }
.main-nav a.active, .main-nav a:hover { background: rgba(255,255,255,.18); color: #fff; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.sidebar-user { font-size: .85rem; opacity: .85; word-break: break-all; }
.sidebar-foot .btn { border-color: rgba(255,255,255,.6); color: #fff; background: transparent; }
.sidebar-foot .btn:hover { background: rgba(255,255,255,.15); }
@media (min-width: 900px) {
  .topbar { display: none; }
  .nav-toggle { display: none; }
  .sidebar { transform: none; }
  .app-main { margin-left: 248px; }
}

/* layout */
.view { max-width: 1024px; margin: 0 auto; padding: 1rem 1rem 5.5rem; }
@media (min-width: 900px) { .view { padding-bottom: 3rem; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: 0 1px 4px rgba(26,46,44,.06); }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.row-between { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 720px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }

/* stat tiles — each card has its own colour identity */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; position: relative; box-shadow: 0 1px 4px rgba(26,46,44,.06); }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 800; margin: .1rem 0; }
.stat .sub { font-size: .85rem; color: var(--muted); }
.stat.alert .value { color: var(--red); }
.stat.ok .value { color: var(--green); }
.stat-top { display: flex; align-items: center; gap: .5rem; }
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.7rem; height: 1.7rem; border-radius: 9px; font-weight: 800; font-size: 1rem; flex: none; }
.stat-icon svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.progress { height: 6px; background: #efe9d8; border-radius: 999px; margin: .45rem 0 .35rem; overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 999px; }
.stat-green { background: var(--green-soft); border-color: #cdeeda; }
.stat-green .value { color: var(--green); }
.stat-green .stat-icon { background: var(--green); color: #fff; }
.stat-green .progress span { background: var(--green); }
.stat-red { background: var(--red-soft); border-color: #f6cdcd; }
.stat-red .value { color: var(--red); }
.stat-red .stat-icon { background: var(--red); color: #fff; }
.stat-red .progress span { background: var(--red); }
.stat-blue { background: var(--blue-soft); border-color: #c9d8f8; }
.stat-blue .value { color: var(--blue); }
.stat-blue .stat-icon { background: var(--blue); color: #fff; }
.stat-blue .progress span { background: var(--blue); }
.stat-teal { background: var(--teal-soft); border-color: #BFDBFE; }
.stat-teal .value { color: var(--teal-dark); }
.stat-teal .stat-icon { background: var(--teal); color: #fff; }
.stat-teal .progress span { background: var(--teal); }

/* clickable stat cards + alert rows */
a.stat { display: block; text-decoration: none; color: inherit; cursor: pointer; }
a.stat:active { transform: scale(.99); }
.stat-chev { position: absolute; top: .5rem; right: .8rem; font-size: 1.4rem; line-height: 1; color: var(--muted); }
.alert-row { display: block; text-decoration: none; color: inherit; margin: .35rem 0; padding: .4rem .5rem; border-radius: 8px; }
.alert-row:hover { background: rgba(220,38,38,.06); }
.alert-row:active { background: rgba(220,38,38,.10); }
.alert-row .alert-link { color: var(--teal); font-weight: 700; text-decoration: underline; }

/* buttons */
.btn { display: inline-block; border: 1px solid var(--teal); background: #fff; color: var(--teal); border-radius: 10px; padding: .65rem 1.1rem; font-size: 1rem; cursor: pointer; text-decoration: none; font-weight: 600; }
.btn:hover { background: var(--teal-soft); }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .7rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* forms */
label { display: block; font-weight: 600; margin: .7rem 0 .25rem; }
input, select, textarea { width: 100%; padding: .65rem .7rem; font-size: 1rem; border: 1px solid #b9c6c3; border-radius: 8px; background: #fff; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
.form-grid { display: grid; gap: 0 .9rem; }
@media (min-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.checkbox-row { display: flex; gap: .5rem; align-items: center; margin: .7rem 0; }
.checkbox-row input { width: auto; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .02em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.overdue td { background: var(--red-soft); }
tr.partial td { background: var(--amber-soft); }
tr.paid td { background: var(--green-soft); }

/* badges */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-grey { background: #efe9d8; color: var(--muted); }
.badge-teal { background: var(--teal-soft); color: var(--teal-dark); }
.badge-type { background: rgba(0,0,0,.35); color: #fff; }
.demo-tag { background: var(--amber-soft); color: var(--amber); font-size: .75rem; font-weight: 700; border-radius: 6px; padding: .1rem .4rem; }

/* lists */
.list-item { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .75rem; background: var(--card); box-shadow: 0 1px 4px rgba(26,46,44,.06); }
.list-item h3 { margin: 0 0 .2rem; }
.list-item h3 a { color: var(--ink); text-decoration: none; }
.list-item h3 a:hover { color: var(--teal); }

/* property cards — illustrated gradient header, never a fake photo */
.prop-card { padding: 0; overflow: hidden; }
.prop-head { height: 84px; display: flex; align-items: flex-end; justify-content: space-between; padding: .7rem .9rem; }
.prop-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.6rem; height: 2.6rem; border-radius: 12px; background: rgba(255,255,255,.22); color: #fff; }
.prop-icon svg { width: 1.6rem; height: 1.6rem; fill: currentColor; }
.prop-body { padding: .9rem 1rem 1rem; }
.grad-house { background: linear-gradient(135deg, #166534, #22c55e); }
.grad-flat { background: linear-gradient(135deg, #1d4ed8, #60a5fa); }
.grad-hmo { background: linear-gradient(135deg, #6d28d9, #a78bfa); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--bg); }
.login-card { background: #fff; border-radius: 16px; border-top: 4px solid var(--gold-bright); padding: 2rem 1.5rem; max-width: 380px; width: 100%; box-shadow: 0 8px 30px rgba(0,0,0,.12); }
.logo { font-size: 1.8rem; font-weight: 800; color: var(--teal); display: flex; align-items: center; gap: .6rem; }
.login-sub { color: var(--muted); }
.login-note { font-size: .85rem; color: var(--muted); margin-top: 1rem; }

/* toast — sits above the gold bottom nav on mobile */
.toast { position: fixed; left: 50%; bottom: 4.6rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 50; max-width: 90vw; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
@media (min-width: 1024px) { .toast { bottom: 1.2rem; } }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* footer */
.footer { max-width: 1024px; margin: 0 auto; padding: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.footer-note { width: 100%; }

details { margin: .5rem 0; }
details summary { cursor: pointer; font-weight: 600; color: var(--teal); }
pre.code { background: #f5f0df; padding: .8rem; border-radius: 8px; overflow-x: auto; font-size: .85rem; }

/* dashboard — greeting, alerts, checklist, quick actions, charts */
.greeting h1 { font-size: 1.7rem; margin-bottom: .1rem; }
.alert-card { background: #fdf0f0; border: 1px solid #f6cdcd; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: 0 1px 4px rgba(26,46,44,.06); }
.alert-card h2 { margin: 0; font-size: 1.15rem; }
.alert-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .3rem; }
.alert-bell { display: inline-flex; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--red); color: #fff; flex: none; }
.alert-bell svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }
.alert-card p { margin: .35rem 0; }
.steps-card .step { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.steps-card .step:first-of-type { border-top: 0; }
.step-dot { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid #b9c6c3; color: #fff; font-weight: 800; font-size: .9rem; flex: none; }
.step.done .step-dot { background: var(--green); border-color: var(--green); }
.step.done .step-label { color: var(--muted); }
.step-label { flex: 1; font-weight: 600; }
.step-chevron { color: var(--teal); font-size: 1.3rem; }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.qa-tile { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1.1rem .5rem; border-radius: 20px; text-decoration: none; color: var(--ink); font-weight: 700; text-align: center; }
.qa-icon { display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem; border-radius: 12px; background: rgba(0,0,0,.08); font-size: 1.3rem; font-weight: 800; }
.qa-icon svg { width: 1.4rem; height: 1.4rem; fill: currentColor; }
.qa-green { background: #dcfce7; }
.qa-blue { background: #dbeafe; }
.qa-teal { background: #dcfce7; }
.qa-amber { background: #fef3c7; }
.bars { display: flex; gap: .35rem; align-items: stretch; height: 120px; margin-top: .5rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .25rem; min-width: 0; }
.bar-pair { flex: 1; display: flex; gap: 2px; align-items: flex-end; width: 100%; justify-content: center; }
.bar { width: 9px; border-radius: 3px 3px 0 0; display: block; }
.bar-income { background: var(--teal); }
.bar-expense { background: #d97757; }
.bar-label { font-size: .7rem; color: var(--muted); }
.legend-dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; vertical-align: middle; }
.legend-income { background: var(--teal); }
.legend-expense { background: #d97757; }
.range-pill { display: inline-block; background: var(--green-soft); color: var(--green); font-weight: 700; font-size: .85rem; padding: .3rem .8rem; border-radius: 999px; border: 1px solid #cdeeda; }
select.range-pill { width: auto; padding: .45rem .8rem; }
.cat-row { display: flex; align-items: center; gap: .7rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.cat-row:first-of-type { border-top: 0; }
.cat-label { flex: 0 0 45%; font-size: .9rem; }
.cat-bar { flex: 1; height: 8px; background: #efe9d8; border-radius: 999px; overflow: hidden; }
.cat-bar span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.insight-row { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.insight-row:first-of-type { border-top: 0; }
.insight-icon { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); flex: none; }
.insight-icon svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.insight-label { flex: 1; }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.month-summary { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin: .7rem 0 .4rem; }
.month-summary .label { color: var(--muted); font-size: .85rem; }
.month-summary .value { font-size: 1.25rem; font-weight: 800; }
.change-badge { background: var(--purple-soft); color: var(--purple); font-weight: 700; font-size: .8rem; padding: .25rem .7rem; border-radius: 999px; }
.mini-bars { display: flex; flex-direction: column; gap: 4px; margin: .5rem 0 .8rem; }
.mini-bar { display: block; height: 8px; border-radius: 999px; }
.mini-income { background: var(--teal); }
.mini-expense { background: #d97757; }
.txn-list { border-top: 1px solid var(--line); }
.txn-row { display: flex; align-items: center; gap: .7rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.txn-row:last-child { border-bottom: 0; }
.txn-icon { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 10px; font-weight: 800; flex: none; }
.txn-in { background: var(--green-soft); color: var(--green); }
.txn-out { background: var(--red-soft); color: var(--red); }
.txn-label { flex: 1; min-width: 0; }
.txn-date { display: block; font-size: .8rem; color: var(--muted); }
.txn-amount-in { color: var(--green); }
.txn-amount-out { color: var(--red); }

/* Pro card — gold accent */
.pro-card { background: #fdf6d8; border: 1px solid #ecd34a; }
.pro-card h2 { color: #7c5e00; }

/* bottom nav — mobile only, warm gold (QuranlyHub gold family).
   Labels are dark ink on gold for contrast — never white on gold.
   The active tab is a dark teal pill on the gold. */
.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; background: #fff; border-top: 1px solid #E2E8F0; padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(26,46,44,.10); }
.bottom-nav a { flex: 1; text-align: center; text-decoration: none; color: #475569; font-size: .78rem; font-weight: 700; padding: .4rem .1rem; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; }
.bottom-nav a .nav-icon { width: 1.35rem; height: 1.35rem; }
.bottom-nav a.active { background: #DBEAFE; color: #1D4ED8; }
@media (min-width: 900px) { .bottom-nav { display: none; } }

/* floating action button — green, so it stands apart from the gold nav */
.fab { position: fixed; right: 1rem; bottom: 4.6rem; z-index: 26; background: #15803d; color: #fff; font-weight: 800; text-decoration: none; padding: .85rem 1.3rem; border-radius: 999px; box-shadow: 0 6px 20px rgba(21,128,61,.45); }
.fab:hover { background: #166534; color: #fff; }
@media (min-width: 900px) { .fab { display: none; } }

@media print {
  .topbar, .footer, .btn, .nav-toggle, #toast, .sidebar, .bottom-nav, .fab { display: none !important; }
  body { background: #fff; }
  .card { border: 1px solid #999; break-inside: avoid; }
  .app-main { margin-left: 0; }
}

/* [hidden] must win over display rules (e.g. .login-wrap is display:flex),
   or the login screen never hides after a successful login. */
[hidden] { display: none !important; }
