/* =========================================================================
   Apartment Manager – design system
   Self-contained (CSP: same-origin only, no web fonts / inline styles).
   Light + automatic dark theme via tokens below.
   ========================================================================= */
[hidden] { display: none !important; } /* the hidden attribute always wins over display rules */

:root {
  color-scheme: light;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;

  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --primary-ring: rgba(79, 70, 229, .22);
  --grad: linear-gradient(135deg, #6366f1 0%, #7c3aed 100%);

  --bg: #f4f5fb;
  --card: #ffffff;
  --surface: #f7f8fc;
  --hover: #f1f3f9;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e6e8f0;
  --border-strong: #cfd4e0;
  --glass: rgba(255, 255, 255, .72);

  --good: #047857;  --good-bg: #e7f8f0;
  --warn: #b45309;  --warn-bg: #fff6e5;
  --error: #dc2626; --error-bg: #fef1f1;
  --info: #4338ca;  --info-bg: #eef2ff;
  --neutral: #64748b; --neutral-bg: #f1f4f8;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -14px rgba(15, 23, 42, .14);
  --shadow-lg: 0 30px 60px -24px rgba(30, 27, 75, .35);
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar: 268px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --primary: #818cf8;
    --primary-2: #a78bfa;
    --primary-dark: #a5b4fc;
    --primary-soft: rgba(129, 140, 248, .14);
    --primary-ring: rgba(129, 140, 248, .32);
    --bg: #0a0d17;
    --card: #111625;
    --surface: #161c2d;
    --hover: #1a2135;
    --text: #e8eaf2;
    --text-2: #c3c8d6;
    --muted: #8f99b0;
    --border: #232b40;
    --border-strong: #323c56;
    --glass: rgba(17, 22, 37, .75);
    --good: #34d399;  --good-bg: rgba(52, 211, 153, .12);
    --warn: #fbbf24;  --warn-bg: rgba(251, 191, 36, .12);
    --error: #f87171; --error-bg: rgba(248, 113, 113, .12);
    --info: #a5b4fc;  --info-bg: rgba(129, 140, 248, .14);
    --neutral: #a3acc0; --neutral-bg: rgba(148, 163, 184, .12);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 12px 32px -16px rgba(0, 0, 0, .7);
    --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .8);
  }
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 100% -10%, rgba(124, 58, 237, .07), transparent 60%),
    radial-gradient(900px 420px at -10% 0%, rgba(79, 70, 229, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }
::selection { background: var(--primary-ring); }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; color: var(--text); }
h1 { font-size: 1.5rem; margin: 12px 0 4px; font-weight: 750; }
.muted { color: var(--muted); margin: 0 0 20px; }
code { font-size: .85rem; overflow-wrap: anywhere; padding: 1px 6px; border-radius: 6px; background: var(--neutral-bg); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---- Auth (sign in, set password, offline, access denied) ---- */
body.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background:
    radial-gradient(700px 500px at 15% 10%, rgba(99, 102, 241, .35), transparent 60%),
    radial-gradient(600px 500px at 90% 20%, rgba(168, 85, 247, .28), transparent 60%),
    radial-gradient(700px 600px at 60% 110%, rgba(56, 189, 248, .22), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}
body.auth::before {
  /* faint grid texture */
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at center, #000 10%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 10%, transparent 70%);
  opacity: .55;
}

.card {
  position: relative;
  width: 100%;
  max-width: 410px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 24px;
  padding: 36px 30px 30px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rise .5s var(--ease) both;
}
@media (prefers-color-scheme: dark) { .card { border-color: rgba(255, 255, 255, .08); } }
.card h1 { font-size: 1.55rem; margin-top: 18px; }
.card .muted { margin-bottom: 24px; }
.logo {
  border-radius: 18px;
  box-shadow: 0 0 0 6px var(--primary-soft), 0 12px 30px -8px rgba(79, 70, 229, .55);
}

@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---- Forms ---- */
form { text-align: left; }
label { display: block; font-weight: 600; font-size: .86rem; color: var(--text-2); margin: 16px 0 6px; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
input[type="email"], input[type="tel"], input[type="date"], input[type="month"],
input[type="datetime-local"], input[type="time"], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-ring);
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}
input[type="search"] {
  padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px center;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 17px; height: 17px; }
textarea { resize: vertical; min-height: 110px; }
[aria-invalid="true"], input[aria-invalid="true"] { border-color: var(--error) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--error-bg) !important; }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 76px; }
.toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  border: 0; background: none; color: var(--primary); font: inherit; font-weight: 650;
  font-size: .85rem; padding: 7px 11px; cursor: pointer; border-radius: 8px;
}
.toggle:hover { background: var(--primary-soft); }

.field-error { display: block; min-height: 1.2em; color: var(--error); font-size: .82rem; margin-top: 5px; }
.hint { display: block; color: var(--muted); font-size: .8rem; margin-top: 5px; }

fieldset { border: 0; padding: 0; margin: 16px 0 0; }
legend { font-weight: 600; font-size: .86rem; color: var(--text-2); margin-bottom: 8px; padding: 0; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 9px; margin: 0; padding: 10px 15px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--card);
  font-weight: 550; color: var(--text); cursor: pointer; transition: all .15s;
}
.choice:hover { border-color: var(--primary); }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); box-shadow: 0 0 0 3px var(--primary-ring); }

/* Forms use the full width: fields (.field from app.js, .row > div) flow into as many ~240px columns as fit. */
.form { margin-top: 18px; }
.form, .form fieldset { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); column-gap: 16px; align-items: start; }
.form > *, .form fieldset > * { grid-column: 1 / -1; min-width: 0; }
.form > .field, .form fieldset > .field, .form .row > div { grid-column: auto; }
.form .field.wide { grid-column: 1 / -1; }
.form .row { display: contents; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
.form-actions form { margin: 0; }
.form-actions .btn-outline { padding: 11px 18px; font-size: .95rem; }

/* ---- Buttons ---- */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; margin-top: 20px; padding: 13px 18px;
  border: 0; border-radius: var(--radius);
  background: var(--grad); color: #fff;
  font: inherit; font-size: .98rem; font-weight: 650; letter-spacing: .005em;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 8px 20px -8px rgba(79, 70, 229, .7);
  transition: transform .15s var(--ease), box-shadow .2s, filter .2s;
}
.btn:hover { color: #fff; filter: brightness(1.07); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 12px 26px -10px rgba(79, 70, 229, .8); }
.btn:active { transform: translateY(0) scale(.985); }
a.btn { text-align: center; }
.btn:disabled { opacity: .7; cursor: wait; transform: none; }
.btn.auto { display: inline-flex; width: auto; margin: 0; padding: 10px 18px; font-size: .92rem; }

.btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--card); color: var(--text);
  font: inherit; font-size: .88rem; font-weight: 600; line-height: 1.3;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, color .15s, background .15s, transform .15s;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-outline:active { transform: scale(.98); }
.btn-outline.danger { color: var(--error); }
.btn-outline.danger:hover { border-color: var(--error); background: var(--error-bg); color: var(--error); }
.small-btn { padding: 5px 10px; font-size: .78rem; }
a.strong { font-weight: 700; color: var(--primary); text-decoration: none; }
a.strong:hover { text-decoration: underline; }

/* ---- Alerts ---- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin: 14px 0; border-radius: var(--radius);
  font-size: .9rem; text-align: left; border: 1px solid transparent;
  animation: rise .35s var(--ease) both;
}
.alert::before { content: ""; flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent); }
.alert.error { background: var(--error-bg); color: var(--error); border-color: color-mix(in srgb, var(--error) 22%, transparent); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 18%, transparent); }

/* =========================================================================
   App shell: top bar (mobile / residents) + sidebar (admins, desktop)
   ========================================================================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(170%);
  backdrop-filter: blur(16px) saturate(170%);
  border-bottom: 1px solid var(--border);
}
.topbar.with-nav { padding-bottom: 0; }
.brand {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  color: var(--text); font-family: var(--font-display); font-weight: 750; font-size: 1.02rem; letter-spacing: -.015em; text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand img { border-radius: 9px; flex-shrink: 0; box-shadow: 0 4px 12px -4px rgba(79, 70, 229, .6); }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user { display: flex; align-items: center; gap: 8px; }
.user form { margin: 0; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--grad); color: #fff; font-weight: 700; font-size: .8rem; letter-spacing: .02em;
  box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--primary-ring);
}
.user-name { display: flex; flex-direction: column; min-width: 0; font-size: .86rem; font-weight: 650; line-height: 1.25; }
.user-name small { color: var(--muted); font-weight: 500; font-size: .76rem; }

.icon-btn, .bell {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 11px;
  border: 1px solid transparent; background: none; color: var(--muted);
  font: inherit; font-size: .86rem; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover, .bell:hover, .bell.active { background: var(--hover); color: var(--text); }
.bell.active { color: var(--primary); background: var(--primary-soft); }
.icon-btn .label { display: none; }
.bell .count {
  position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: linear-gradient(135deg, #f43f5e, #e11d48); color: #fff;
  font-size: .66rem; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px var(--card);
  animation: pop .4s var(--ease) both;
}
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }

.nav { order: 3; width: 100%; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  position: relative; flex-shrink: 0; display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 11px 12px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: .86rem;
  transition: color .15s;
}
.nav a .icon { width: 17px; height: 17px; }
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--primary); }
.nav a[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--grad); }

/* Phones/tablets: the menu is a slide-in drawer opened by the hamburger (.nav-toggle). app.js toggles html.nav-open,
   without JS the #main-nav anchor opens it via :target. Desktop (>= 1024px) keeps the fixed sidebar below. */
.nav-head, .nav-toggle, .nav-backdrop { display: none; }
@media (max-width: 1023.98px) {
  .topbar.with-nav { padding-bottom: 10px; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  /* Glass effect on a layer behind the bar: backdrop-filter on the bar itself would trap the fixed drawer inside it. */
  .topbar.with-nav::before {
    content: ""; position: absolute; inset: 0; z-index: -1; background: var(--glass);
    -webkit-backdrop-filter: blur(16px) saturate(170%); backdrop-filter: blur(16px) saturate(170%);
  }
  .nav-toggle { display: inline-flex; margin-left: -6px; color: var(--text); }
  .nav-toggle .icon { width: 22px; height: 22px; }
  .topbar.with-nav .nav {
    position: fixed; inset: 0 auto 0 0; z-index: 2;
    width: min(300px, 86vw); flex-direction: column; flex-wrap: nowrap; gap: 2px;
    padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    background: var(--card); border-right: 1px solid var(--border); box-shadow: 0 0 40px -8px rgba(15, 23, 42, .35);
    transform: translateX(-102%); visibility: hidden;
    transition: transform .28s var(--ease), visibility 0s linear .28s;
  }
  .nav-open .topbar.with-nav .nav, .topbar.with-nav .nav:target {
    transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s;
  }
  .nav-head { display: flex; align-items: center; justify-content: space-between; padding: 0 0 8px 12px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
  .nav-title { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
  .topbar.with-nav .nav a:not(.nav-close) { padding: 11px 12px; border-radius: 11px; font-size: .92rem; color: var(--text-2); }
  .topbar.with-nav .nav a .icon { width: 19px; height: 19px; color: var(--muted); }
  .topbar.with-nav .nav a:hover { background: var(--hover); color: var(--text); }
  .topbar.with-nav .nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-dark); }
  .topbar.with-nav .nav a[aria-current="page"] .icon { color: var(--primary); }
  .topbar.with-nav .nav a[aria-current="page"]::after { left: 0; right: auto; top: 9px; bottom: 9px; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1;
    background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .28s var(--ease);
  }
  .nav-open .nav-backdrop, .nav:target ~ .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav-open, .nav-open body { overflow: hidden; } /* the page behind does not scroll while the menu is open */
}
@media (max-width: 1023.98px) and (prefers-reduced-motion: reduce) {
  .topbar.with-nav .nav, .nav-backdrop { transition: none !important; }
}

@media (max-width: 520px) {
  .user-name { display: none; }
  .brand { font-size: .95rem; }
}

/* Sidebar for admins on wide screens */
@media (min-width: 1024px) {
  .topbar.with-nav {
    position: fixed; inset: 0 auto 0 0; z-index: 30;
    width: var(--sidebar);
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0;
    padding: max(18px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border-bottom: 0; border-right: 1px solid var(--border);
    background: var(--card);
    -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  .topbar.with-nav .brand { flex: 0 0 auto; order: 0; padding: 4px 52px 18px 8px; }
  .topbar.with-nav .bell { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 14px; }
  .topbar.with-nav .nav {
    order: 1; flex: 1 1 auto; width: auto; min-height: 0;
    flex-direction: column; gap: 2px; margin: 0; padding: 14px 0; overflow-y: auto;
    border-top: 1px solid var(--border);
  }
  .topbar.with-nav .nav::before {
    content: "Menu"; padding: 0 12px 8px; color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  }
  .topbar.with-nav .nav a { padding: 10px 12px; border-radius: 11px; font-size: .9rem; color: var(--text-2); }
  .topbar.with-nav .nav a .icon { width: 19px; height: 19px; color: var(--muted); transition: color .15s; }
  .topbar.with-nav .nav a:hover { background: var(--hover); color: var(--text); }
  .topbar.with-nav .nav a:hover .icon { color: var(--text); }
  .topbar.with-nav .nav a[aria-current="page"] {
    background: var(--primary-soft); color: var(--primary-dark);
  }
  .topbar.with-nav .nav a[aria-current="page"] .icon { color: var(--primary); }
  .topbar.with-nav .nav a[aria-current="page"]::after { left: 0; right: auto; top: 9px; bottom: 9px; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .topbar.with-nav .user {
    order: 2; flex: 0 0 auto;
    padding: 12px 10px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  }
  .topbar.with-nav .user-name { display: flex; flex: 1; }
  .topbar.with-nav .user-name, .topbar.with-nav .user-name small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar.with-nav ~ .page { margin-left: var(--sidebar); padding: 32px 40px 48px; }
}
@media (min-width: 700px) { .topbar:not(.with-nav) .icon-btn .label { display: inline; } }

/* ---- Page ---- */
.page {
  margin: 0 auto;
  padding: 26px max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.page h1 { margin: 0; font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.9rem); line-height: 1.2; }
.page > h1 + .muted, .page-head + .muted { margin-top: 4px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-head > h1 + * { margin-left: auto; }

.panels { display: grid; gap: 18px; margin-top: 20px; }
.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.page > .panel, .page > section.panel, .page > form.panel { margin-top: 18px; }
.panel h2 {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  margin: 0 0 14px; font-size: 1.05rem; font-weight: 700;
}
.panel h3 { margin: 20px 0 8px; font-size: .95rem; font-weight: 700; }
.panel > .muted:first-child { margin-bottom: 12px; font-size: .85rem; }
h2 small { font-weight: 500; font-size: .82rem; margin-left: auto; }
h2 small a, .panel h2 a {
  display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-dark); font-weight: 650; font-size: .78rem; text-decoration: none;
  transition: filter .15s;
}
h2 small a:hover { filter: brightness(.96); }
h3 small { font-weight: 500; margin-left: 8px; }
.panel .page-head h2 { margin-bottom: 2px; }
.empty { margin: 8px 0 0; color: var(--muted); font-size: .9rem; }
p.empty:only-child, .panel > p.empty { padding: 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); text-align: center; }
p.small, .small { font-size: .85rem; }
.spaced { margin-top: 14px; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; }

@media (min-width: 900px) {
  .panels { grid-template-columns: 1fr 1fr; }
  .panel.wide, .panels > .panel:only-child { grid-column: 1 / -1; }
}

/* ---- Hero (dashboard / home) ---- */
.hero {
  position: relative; overflow: hidden;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding: 26px 24px; border-radius: 22px; color: #fff;
  background:
    radial-gradient(500px 220px at 100% 0%, rgba(255, 255, 255, .22), transparent 60%),
    radial-gradient(400px 260px at 0% 120%, rgba(56, 189, 248, .45), transparent 60%),
    linear-gradient(135deg, #4f46e5 0%, #6d28d9 60%, #7c3aed 100%);
  box-shadow: 0 24px 50px -24px rgba(79, 70, 229, .75);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%;
  border: 40px solid rgba(255, 255, 255, .07); pointer-events: none;
}
.page .hero h1 { color: #fff; font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2rem); }
.hero p { margin: 6px 0 0; color: rgba(255, 255, 255, .82); }
.hero-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-actions a {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 11px;
  background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .25); color: #fff;
  font-weight: 650; font-size: .88rem; text-decoration: none;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background .15s, transform .15s;
}
.hero-actions a .icon { width: 17px; height: 17px; }
.hero-actions a:hover { background: rgba(255, 255, 255, .26); color: #fff; transform: translateY(-1px); }
.hero-actions a.solid { background: #fff; color: #4338ca; border-color: #fff; }
.hero-actions a.solid:hover { background: #eef2ff; color: #3730a3; }

/* ---- Stat tiles ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat {
  position: relative; overflow: hidden;
  padding: 14px 14px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::before { content: ""; position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--border-strong); opacity: .7; }
.stat span { display: block; font-size: .72rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat strong { display: block; margin-top: 4px; font-family: var(--font-display); font-size: 1.35rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.good::before { background: linear-gradient(90deg, #10b981, #34d399); opacity: 1; }
.stat.warn::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); opacity: 1; }
.stat.good strong, .num.in { color: var(--good); }
.stat.warn strong, .num.out { color: var(--warn); }
.panel .stats + table, .panel .stats + .stats, .panel .stats + .table-wrap { margin-top: 16px; }
@media (max-width: 520px) {
  .stats { grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; }
  .stat { padding: 11px 10px 10px; }
  .stat span { font-size: .64rem; letter-spacing: .04em; }
  .stat strong { font-size: 1.05rem; }
  .panel { padding: 16px; }
}

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .89rem; font-variant-numeric: tabular-nums; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
th {
  color: var(--muted); font-weight: 650; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface); border-bottom-color: var(--border);
}
th:first-child { border-top-left-radius: 10px; }
th:last-child { border-top-right-radius: 10px; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; }

.report tr.subtotal td, .report tr.total td, .report tr.heading td { font-weight: 700; }
.report tr.subtotal td { background: var(--surface); }
.report tr.total td { border-top: 2px solid var(--border-strong); background: var(--primary-soft); }
.report tr.heading td { padding-top: 18px; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.report tr.indent td:first-child { padding-left: 26px; }

/* Tables become stacked cards on small screens */
@media (max-width: 640px) {
  .responsive thead { display: none; }
  .responsive, .responsive tbody { display: block; }
  .responsive tr {
    display: block; margin: 0 0 10px; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: 14px; background: var(--card); box-shadow: var(--shadow-sm);
  }
  .responsive tbody tr:hover td { background: none; }
  .responsive td {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
    padding: 7px 0; border: 0; border-bottom: 1px dashed var(--border); white-space: normal; text-align: right;
  }
  .responsive td:last-child { border-bottom: 0; }
  .responsive td::before { content: attr(data-label); margin-right: auto; color: var(--muted); font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; text-align: left; }
  .responsive td > small { flex-basis: 100%; text-align: right; }
}

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: .73rem; font-weight: 650; line-height: 1.5; white-space: nowrap; vertical-align: middle;
  background: var(--neutral-bg); color: var(--neutral);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.verified, .badge.paid, .badge.owner_occupied, .badge.req-resolved, .badge.notice-active { background: var(--good-bg); color: var(--good); }
.badge.pending, .badge.archived, .badge.reversed, .badge.req-in_progress, .badge.prio-high,
.badge.nprio-important, .badge.notice-archived { background: var(--warn-bg); color: var(--warn); }
.badge.rejected, .badge.overdue, .badge.prio-urgent { background: var(--error-bg); color: var(--error); }
.badge.rented, .badge.partial, .badge.req-open, .badge.prio-medium, .badge.notice-scheduled { background: var(--info-bg); color: var(--info); }
.badge.vacant, .badge.unpaid, .badge.req-on_hold, .badge.prio-low, .badge.notice-expired, .badge.notice-draft { background: var(--neutral-bg); color: var(--neutral); }
.badge.nprio-urgent { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.badge.archived { margin-left: 6px; }
.notice-list .badge, .timeline small.badge { display: inline-flex; }
.timeline small.badge { margin-left: 6px; }

/* ---- Filters ---- */
.filters { display: grid; gap: 10px; margin: 18px 0; grid-template-columns: 1fr 1fr; padding: 14px; }
.filters input[type="search"] { grid-column: 1 / -1; }
.filters .btn-outline { padding: 11px 16px; }
@media (min-width: 900px) {
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto auto; align-items: center; }
  .filters input[type="search"] { grid-column: auto; }
}
@media (min-width: 900px) { .history-filters { grid-template-columns: 1fr 1fr 1fr 1.2fr 1fr auto auto; } }
.range { grid-template-columns: 1fr 1fr; }
@media (min-width: 900px) { .range { grid-template-columns: auto auto auto auto 1fr; } }
.date-filter { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; font-size: .82rem; color: var(--muted); }
.date-filter input { flex: 1; }

/* ---- Tabs (segmented) ---- */
.tabs {
  display: inline-flex; max-width: 100%; gap: 4px; margin: 16px 0 0; padding: 4px;
  border-radius: 14px; background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex-shrink: 0; padding: 8px 15px; border-radius: 10px;
  color: var(--muted); font-weight: 650; font-size: .87rem; text-decoration: none;
  transition: background .15s, color .15s;
}
.tabs a:hover { color: var(--text); background: var(--hover); }
.tabs a[aria-current="page"] { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -6px rgba(79, 70, 229, .7); }

/* ---- Details & lists ---- */
.details { display: grid; grid-template-columns: max-content 1fr; gap: 12px 20px; margin: 0; }
.details dt { color: var(--muted); font-size: .84rem; font-weight: 550; }
.details dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.history li:last-child { border-bottom: 0; }
.history small { display: block; margin-top: 2px; }
.group { margin-top: 22px; padding-top: 6px; border-top: 1px solid var(--border); }
.group h3 { margin: 14px 0 0; font-size: .95rem; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.inline-form input[type="date"], .inline-form input[type="month"] { width: auto; padding: 8px 11px; }
.link-panel { margin-top: 18px; border: 1px solid var(--primary); box-shadow: 0 0 0 4px var(--primary-ring), var(--shadow); }
.link-panel input { width: 100%; font-size: .85rem; padding: 10px; background: var(--surface); }
input.plain { width: auto; max-width: 70%; border: 0; background: none; box-shadow: none; font: inherit; color: var(--text); padding: 0; }
input.plain:focus { box-shadow: none; }
.cat-name { flex: 1 1 160px; padding: 8px 11px !important; }
details.panel { margin-top: 18px; }
details.panel > summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 10px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before {
  content: "+"; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; transition: transform .2s;
}
details.panel[open] > summary::before { content: "–"; }
details.panel[open] > summary { margin-bottom: 10px; }

/* ---- Payments ---- */
.qr { display: flex; justify-content: center; margin: 16px 0; }
.qr img { width: 100%; max-width: 260px; height: auto; image-rendering: pixelated; border-radius: 16px; background: #fff; padding: 8px; box-shadow: 0 0 0 1px var(--border), var(--shadow); }
.upi-link { display: flex; width: 100%; text-align: center; }
.steps { padding-left: 22px; margin: 14px 0 6px; font-size: .9rem; }
.steps li { margin-bottom: 7px; }
.steps li::marker { color: var(--primary); font-weight: 700; }
.review { display: flex; flex-wrap: wrap; gap: 6px; min-width: 230px; }
.review input { flex: 1 1 100%; padding: 8px 11px; font-size: .85rem; }

/* ---- Notifications ---- */
.notifications { list-style: none; margin: 0; padding: 0; }
.notifications li { display: flex; align-items: flex-start; gap: 10px; padding: 14px 10px; margin: 0 -10px; border-radius: 12px; border-bottom: 1px solid var(--border); transition: background .12s; }
.notifications li:hover { background: var(--hover); }
.notifications li:last-child { border-bottom: 0; }
.notifications li > a { flex: 1; min-width: 0; color: var(--text); text-decoration: none; }
.notifications li > a > * { display: block; }
.notifications li > a span { color: var(--text-2); font-size: .9rem; margin: 2px 0; overflow-wrap: anywhere; }
.notifications li.unread > a strong::before, .notice-list li.unread > a strong::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); vertical-align: middle;
}
.notifications li.read > a { opacity: .7; }

/* ---- Requests timeline ---- */
.timeline { position: relative; }
.timeline li { position: relative; padding-left: 22px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 19px; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); box-shadow: 0 0 0 3px var(--card); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 32px; bottom: -14px; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.ev-reply {
  margin: 6px 0; padding: 12px 14px 12px 22px; border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: 12px; background: var(--surface);
}
.timeline li.ev-reply::before { background: var(--primary); left: -7px; top: 16px; }
.timeline li.ev-reply::after { display: none; }
.timeline li.ev-status, .timeline li.ev-assigned, .timeline li.ev-created { color: var(--muted); font-size: .88rem; border-bottom: 0; }

/* ---- Notices ---- */
.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.notice-list li { border: 0; }
.notice-list li > a {
  display: block; padding: 14px 16px; color: var(--text); text-decoration: none;
  border: 1px solid var(--border); border-left: 4px solid var(--border-strong); border-radius: 12px; background: var(--surface);
  transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.notice-list li > a:hover { transform: translateX(2px); box-shadow: var(--shadow); color: var(--text); }
.notice-list li > a > span, .notice-list li > a > small { display: block; }
.notice-list li > a > span { font-size: .9rem; color: var(--text-2); margin: 4px 0; overflow-wrap: anywhere; }
.notice-list li.unread > a { border-left-color: var(--primary); background: var(--card); }
.notice-list li.important > a { border-left-color: var(--warn); }
.notice-list li.urgent > a { border-left-color: var(--error); background: var(--error-bg); }
.notice-list li.read > a, .notice-list li.expired > a { opacity: .72; }
.urgent-panel { border-left: 5px solid var(--error); }

/* ---- Page loading indicator ---- */
html.loading::before {
  content: ""; position: fixed; top: 0; left: 0; z-index: 100; height: 3px; width: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7, #38bdf8);
  box-shadow: 0 0 12px rgba(99, 102, 241, .7);
  transform-origin: left; animation: loading 1.2s ease-out forwards;
}
@keyframes loading { from { transform: scaleX(0); } to { transform: scaleX(.85); } }

/* ---- Motion & print ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media print {
  :root { color-scheme: light; --card: #fff; --surface: #fff; --text: #000; --border: #ccc; }
  .topbar, .no-print, .tabs, .hero-actions { display: none !important; }
  body { background: #fff; color: #000; }
  .topbar.with-nav ~ .page { margin-left: 0; padding: 0; }
  .panel { box-shadow: none; border: 0; padding: 0; }
  .responsive thead { display: table-header-group !important; }
}

/* ---- Finance: funds, chart ---- */
:root { --fund-general: #4f46e5; --fund-corpus: #0d9488; --fund-lift: #c2410c; --series-in: #257de0; --series-out: #f47230; }
@media (prefers-color-scheme: dark) { :root { --fund-general: #818cf8; --fund-corpus: #2dd4bf; --fund-lift: #fb923c; --series-in: #338ced; --series-out: #e76624; } }
.badge.fund-general { background: var(--info-bg); color: var(--fund-general); }
.badge.fund-corpus { background: color-mix(in srgb, var(--fund-corpus) 13%, transparent); color: var(--fund-corpus); }
.badge.fund-lift { background: color-mix(in srgb, var(--fund-lift) 13%, transparent); color: var(--fund-lift); }
small.badge { margin: 2px 2px 2px 0; }

.fund-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.fund-cards.five { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.fund-card {
  --accent: var(--fund-general);
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px;
  padding: 18px 20px; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--card);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.fund-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--accent); }
.fund-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: var(--accent); opacity: .07; }
.fund-card:hover { transform: translateY(-2px); color: var(--text); box-shadow: 0 16px 34px -18px color-mix(in srgb, var(--accent) 60%, transparent); }
.fund-card span { font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); }
.fund-card strong { font-family: var(--font-display); font-size: clamp(1.4rem, 1.1rem + 1vw, 1.8rem); font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.fund-card small { color: var(--muted); font-size: .8rem; }
.fund-card.fund-corpus { --accent: var(--fund-corpus); }
.fund-card.fund-lift { --accent: var(--fund-lift); }

.attention { margin-top: 18px; border-left: 4px solid var(--warn); }
.attention h2 { margin-bottom: 4px; }
.page > .filters.range { margin: 18px 0 0; }
table tfoot td, tr.total td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.stat-input { width: 100%; margin-top: 2px; padding: 4px 8px; font-size: 1.05rem; font-weight: 700; }

.chart { position: relative; }
.legend { display: flex; gap: 16px; align-items: center; font-size: .82rem; color: var(--text-2); margin-bottom: 6px; }
.legend .key { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: -10px; }
.key-in { background: var(--series-in); }
.key-out { background: var(--series-out); }
svg.bars { width: 100%; height: auto; display: block; overflow: visible; }
svg.bars .grid { stroke: var(--border); stroke-width: 1; }
svg.bars .axis { stroke: var(--border-strong); stroke-width: 1; }
svg.bars .bar-in { fill: var(--series-in); }
svg.bars .bar-out { fill: var(--series-out); }
svg.bars .hit { fill: transparent; }
svg.bars .bar-group:hover .hit { fill: var(--hover); }
svg.bars .tick { fill: var(--muted); font-size: 12px; text-anchor: middle; font-family: var(--font); }
svg.bars .tick.current { fill: var(--text); font-weight: 700; }
svg.bars .val { fill: var(--text-2); font-size: 11px; font-weight: 600; text-anchor: middle; font-family: var(--font); }
details > summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .88rem; }
td.actions { white-space: normal; }
td.actions > * { margin: 2px 0; }
td.actions, td.wrap { display: table-cell; }
td.wrap { white-space: normal; min-width: 160px; }
.report td:not(.num) { white-space: normal; }
.report td.num { white-space: nowrap; }
.inline-form select { width: auto; }
@media (max-width: 640px) { .responsive td.actions, .responsive td.wrap { display: flex; } }
@media (max-width: 640px) {
  svg.bars .tick { font-size: 24px; }
  svg.bars .val { font-size: 22px; }
}

/* ---- Upcoming bills ---- */
.badge.bill-upcoming { background: var(--info-bg); color: var(--info); }
.badge.bill-due { background: var(--warn-bg); color: var(--warn); }
.badge.bill-overdue { background: var(--error-bg); color: var(--error); }
.badge.bill-partial { background: color-mix(in srgb, var(--fund-corpus) 13%, transparent); color: var(--fund-corpus); }
.badge.bill-paid { background: var(--good-bg); color: var(--good); }
.badge.bill-cancelled { background: var(--neutral-bg); color: var(--neutral); text-decoration: line-through; }
tr.row-overdue td { background: color-mix(in srgb, var(--error) 6%, transparent); }
tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--error); }
.stat .stat-action { margin-top: 10px; }
.stat .stat-action small { display: block; font-weight: 650; }
.stat .stat-action .good-text { color: var(--good); }
tr.row-due td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.bill-widgets { margin-top: 18px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
a.stat { color: var(--text); text-decoration: none; background: var(--card); box-shadow: var(--shadow-sm); }
a.stat:hover { color: var(--text); border-color: var(--primary); }
.stat small { display: block; margin-top: 2px; color: var(--muted); font-size: .78rem; }
.stat.danger::before { background: linear-gradient(90deg, #ef4444, #f87171); opacity: 1; }
.stat.danger strong { color: var(--error); }
.inline-form.no-gap { margin-top: 0; flex-wrap: nowrap; }
.inline-form.no-gap input { width: 90px; }

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.cal-head { padding: 4px 6px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cal-day { min-height: 104px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day.empty { background: none; border-style: dashed; opacity: .5; }
.cal-day.today { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); background: var(--card); }
.cal-num { font-size: .8rem; font-weight: 700; color: var(--muted); }
.cal-day.today .cal-num { color: var(--primary); }
.cal-bill { display: block; padding: 4px 6px; border-radius: 8px; font-size: .74rem; line-height: 1.25; text-decoration: none; border-left: 3px solid currentColor; overflow: hidden; }
.cal-bill span { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.cal-bill small { color: var(--text-2); }
.cal-bill.bill-upcoming { background: var(--info-bg); color: var(--info); }
.cal-bill.bill-due { background: var(--warn-bg); color: var(--warn); }
.cal-bill.bill-overdue { background: var(--error-bg); color: var(--error); }
.cal-bill.bill-partial { background: color-mix(in srgb, var(--fund-corpus) 13%, transparent); color: var(--fund-corpus); }
.cal-bill.bill-paid { background: var(--good-bg); color: var(--good); }
.cal-bill.bill-cancelled { background: var(--neutral-bg); color: var(--neutral); opacity: .7; }
.cal-bill.bill-cancelled span { text-decoration: line-through; }
@media (max-width: 640px) {
  .calendar { gap: 3px; }
  .cal-head { font-size: .6rem; padding: 2px; text-align: center; }
  .cal-day { min-height: 56px; padding: 3px; border-radius: 8px; }
  .cal-bill { padding: 0; height: 6px; border: 0; border-radius: 3px; background: currentColor !important; }
  .cal-bill span, .cal-bill small { display: none; }
}
.legend { flex-wrap: wrap; }
form:has(input[name="kind"][value="once"]:checked) .recurring-only { display: none; }

/* ---- Complaints ---- */
.badge.req-assigned { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-dark); }
.badge.req-closed { background: var(--neutral-bg); color: var(--neutral); }
.choice-emergency:has(input:checked) { border-color: var(--error); background: var(--error-bg); color: var(--error); box-shadow: 0 0 0 3px color-mix(in srgb, var(--error) 20%, transparent); }
.progress-steps { display: flex; gap: 4px; margin: 16px 0 0; padding: 0; list-style: none; counter-reset: step; overflow-x: auto; }
.progress-steps li { flex: 1 1 0; min-width: 92px; position: relative; padding: 10px 8px 8px; border-radius: 10px; background: var(--card); border: 1px solid var(--border);
  font-size: .8rem; font-weight: 650; color: var(--muted); text-align: center; counter-increment: step; }
.progress-steps li::before { content: counter(step); display: block; width: 22px; height: 22px; margin: 0 auto 4px; border-radius: 50%; background: var(--neutral-bg); color: var(--muted); line-height: 22px; font-size: .72rem; }
.progress-steps li.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.progress-steps li.done::before { content: "✓"; background: var(--good-bg); color: var(--good); }
.progress-steps li.current { color: var(--primary-dark); border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.progress-steps li.current::before { background: var(--grad); color: #fff; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.file-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: .8rem; text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip:hover { border-color: var(--primary); }
.timeline li.ev-internal { background: var(--warn-bg); border-radius: 10px; padding-right: 10px; }
.timeline li.ev-feedback { color: var(--text); }
.stars { color: #f59e0b; letter-spacing: 1px; }
.stars .off { color: var(--border-strong); }
.rating { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.rating input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rating label { margin: 0; font-size: 2rem; line-height: 1; color: var(--border-strong); cursor: pointer; transition: color .1s, transform .1s; }
.rating label:hover, .rating label:hover ~ label, .rating input:checked ~ label { color: #f59e0b; }
.rating input:focus-visible + label { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.rating label:active { transform: scale(.9); }

/* ---- Communication ---- */
.emergency-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px max(16px, env(safe-area-inset-left));
  background: linear-gradient(90deg, #dc2626, #b91c1c); color: #fff; text-decoration: none; font-weight: 600; animation: rise .3s var(--ease) both; }
.emergency-banner strong { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .2); text-transform: uppercase; font-size: .72rem; letter-spacing: .06em; }
.emergency-banner span { margin-left: auto; font-size: .85rem; opacity: .9; }
.emergency-banner:hover { color: #fff; filter: brightness(1.08); }
@media (min-width: 1024px) { .topbar.with-nav ~ .emergency-banner { margin-left: var(--sidebar); padding-left: 40px; } }
.notice-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 12px 0; }
.notice-images img { width: 100%; height: 150px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); display: block; }
p.when { padding: 10px 14px; border-radius: 12px; background: var(--info-bg); color: var(--info); }
form:has(input[name="kind"][value="general"]:checked) .meeting-only { display: none; }

/* ---- Community ---- */
.choices.stacked { flex-direction: column; align-items: stretch; }
form:has(input[name="question_type"][value="yes_no"]:checked) .choice-only { display: none; }
.agenda { margin: 0; padding-left: 22px; }
.agenda li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.agenda li:last-child { border-bottom: 0; }
.agenda li::marker { color: var(--primary); font-weight: 700; }
.ballot { margin-top: 14px; padding: 16px; border: 1px solid var(--primary); border-radius: 14px; background: var(--primary-soft); max-width: none; }
.ballot .choice { background: var(--card); }
.poll-results { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 10px; }
.poll-results li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.poll-results .label { font-weight: 600; }
.poll-results .count { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .88rem; }
.poll-results li.lead .label::after { content: " ★"; color: #f59e0b; }
meter { width: 100%; height: 10px; grid-column: 1 / -1; }
.poll-results meter, .history meter { display: block; margin-top: 4px; }
meter::-webkit-meter-bar { background: var(--neutral-bg); border: 0; border-radius: 999px; height: 10px; }
meter::-webkit-meter-optimum-value, meter::-webkit-meter-suboptimum-value, meter::-webkit-meter-even-less-good-value { background: var(--grad); border-radius: 999px; }
meter::-moz-meter-bar { background: #6366f1; border-radius: 999px; }

/* ---- Access control: permission matrix, audit log ---- */
.perm-matrix th.center, .perm-matrix td.center { text-align: center; width: 72px; }
.perm-matrix input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.perm-matrix tr.changed td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .02em; }
td small.mono { word-break: break-all; }
tr.audit-denied td, tr.audit-login_failed td { background: var(--error-bg); }
.history .form-actions .inline-form { margin-top: 6px; }
.history .inline-form input[type="text"] { width: 130px; padding: 8px 11px; }

/* ---- Monthly expense sheet (dashboard) ---- */
/* Dashboard sheets (Monthly expenses, Maintenance collection): theme tables + stat tiles + status badges */
.sheet-stats { margin-bottom: 14px; }
.sheet-stats .stat strong { font-size: 1.15rem; }
table.sheet td.num, table.sheet th.num { text-align: right; }
table.sheet tbody a { color: var(--text); font-weight: 600; text-decoration: none; }
table.sheet tbody a:hover { color: var(--primary); text-decoration: underline; }
table.sheet td > small { display: block; margin: 1px 0 0; font-size: .75rem; }
table.sheet tfoot td { font-weight: 700; background: var(--primary-soft); color: var(--primary-dark); border-bottom: 0; }
table.sheet tfoot td:first-child { border-bottom-left-radius: 10px; }
table.sheet tfoot td:last-child { border-bottom-right-radius: 10px; }
table.sheet .empty-cell { text-align: center; color: var(--muted); padding: 22px; }
.collection-sheet td.flat strong { font-variant-numeric: tabular-nums; }
.collection-sheet td .badge + .badge { margin-left: 4px; }
.collection-sheet td > small { display: inline; margin: 0 0 0 4px; }
.collection-sheet td.update, .collection-sheet th.update { width: 1%; text-align: right; }
.collect-progress { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: .78rem; font-weight: 650; color: var(--muted); }
.collect-progress meter { flex: 1; grid-column: auto; }
.collect-progress span { white-space: nowrap; }
@media (max-width: 640px) { .collection-sheet td.update { width: auto; } }

/* Login: keep me signed in */
.auth .remember { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 500; cursor: pointer; }
.auth .remember input { margin: 0; }
.auth .remember-hint { display: block; margin: 2px 0 4px 25px; font-size: .78rem; }

/* Confirmation dialog (flat delete) */
dialog.modal [hidden] { display: none !important; }
dialog.modal { border: 0; padding: 0; border-radius: 18px; width: min(460px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 30px 80px -20px rgba(15, 23, 42, .45); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog.modal .modal-body { padding: 22px 24px; }
dialog.modal h2 { margin: 0 0 10px; font-size: 1.15rem; }
dialog.modal .blockers { margin: 0 0 12px; padding-left: 20px; }
dialog.modal .blockers li { margin: 3px 0; font-weight: 600; }
dialog.modal .form-actions { justify-content: flex-end; margin-top: 16px; }
.btn.danger { background: var(--error); box-shadow: none; }
.btn.danger:hover { filter: brightness(.95); }
td.row-actions { white-space: nowrap; text-align: right; }
td.row-actions .small-btn { margin-left: 4px; }
@media (max-width: 640px) { .responsive td.row-actions { justify-content: flex-start; gap: 6px; } .responsive td.row-actions .small-btn { margin-left: 0; } }

/* Menu visibility (menus.php) */
.menu-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.menu-list li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.menu-list .menu-icon .icon { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.menu-list .menu-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.menu-list .menu-info small { display: block; margin: 0; font-size: .8rem; line-height: 1.4; }
.menu-list .who { color: var(--muted); font-style: italic; }
.switch { display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; flex-shrink: 0; font-weight: 600; font-size: .85rem; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--border-strong); transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch .state-on, .switch input:checked ~ .state-off { display: none; }
.switch input:checked ~ .state-on { display: inline; color: var(--primary); }
.switch .state-off { color: var(--muted); min-width: 52px; }
.switch .state-on { min-width: 52px; }
@media (max-width: 640px) { .menu-list li { flex-wrap: wrap; align-items: flex-start; } .menu-list .menu-info { flex-basis: calc(100% - 60px); } .switch { margin-left: 48px; } }

dialog.modal .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 480px) { dialog.modal .row { grid-template-columns: 1fr; } }
.raise-bills { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin: 0 0 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--primary-soft); }
.raise-bills p { margin: 0; font-size: .88rem; color: var(--primary-dark); }
/* Category responsibilities (responsibilities.php) */
.resp-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.resp-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.resp-list form { margin: 0; }
.resp-add { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin: 0; }
.resp-add select { flex: 1 1 220px; min-width: 0; }
.resp-table td { vertical-align: top; }

/* ---- Reminders & tasks ---- */
.badge.task-upcoming, .cal-bill.task-upcoming { background: var(--info-bg); color: var(--info); }
.badge.task-today, .cal-bill.task-today { background: var(--warn-bg); color: var(--warn); }
.badge.task-overdue, .cal-bill.task-overdue { background: var(--error-bg); color: var(--error); }
.badge.task-completed, .cal-bill.task-completed { background: var(--good-bg); color: var(--good); }
.badge.task-missed, .cal-bill.task-missed { background: var(--neutral-bg); color: var(--neutral); }
.badge.task-cancelled { background: var(--neutral-bg); color: var(--neutral); text-decoration: line-through; }
.badge.task-planned, .cal-bill.task-planned { background: none; color: var(--muted); border: 1px dashed var(--border-strong); }
.cal-bill.task-planned { border-left: 3px dashed var(--border-strong); opacity: .85; }
.task-current { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: var(--radius); background: var(--surface); }
.task-current.task-today { border-left-color: var(--warn); }
.task-current.task-overdue { border-left-color: var(--error); background: color-mix(in srgb, var(--error) 6%, var(--surface)); }
#current details { margin-top: 14px; }
#current summary { cursor: pointer; font-weight: 650; color: var(--primary); }

/* ---- Important contacts ---- */
.chip-tabs { display: flex; flex-wrap: wrap; overflow: visible; }
.chip-tabs a small { margin-left: 4px; opacity: .7; font-weight: 600; }
.contact-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; margin-top: 16px; }
.contact-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.contact-card.is-fav { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.contact-card.is-emergency { border-left: 4px solid var(--error); }
.contact-card header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.contact-card header form { margin: 0; }
.contact-card h2 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.contact-card header p { margin: 2px 0 0; font-size: .86rem; overflow-wrap: anywhere; }
.contact-card .contact-cat { align-self: flex-start; background: var(--info-bg); color: var(--info); }
.contact-card.is-emergency .contact-cat { background: var(--error-bg); color: var(--error); }
.contact-card dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
.contact-card dt { color: var(--muted); font-size: .8rem; font-weight: 600; padding-top: 1px; }
.contact-card dd { margin: 0; overflow-wrap: anywhere; }
.contact-card dd a { font-weight: 650; font-variant-numeric: tabular-nums; }
.contact-notes { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: var(--surface); font-size: .86rem; color: var(--text-2); }
.contact-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }
.contact-actions a { flex: 1 1 auto; justify-content: center; text-align: center; min-height: 44px; display: inline-flex; align-items: center; }
.contact-actions a.wa { color: #128c4a; border-color: color-mix(in srgb, #25d366 55%, var(--border-strong)); }
.contact-actions a.wa:hover { background: color-mix(in srgb, #25d366 12%, transparent); color: #0c6b38; }
.fav-btn { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.fav-btn[aria-pressed="true"] { color: #f59e0b; border-color: color-mix(in srgb, #f59e0b 50%, var(--border)); background: color-mix(in srgb, #f59e0b 12%, var(--surface)); }
.fav-btn:hover { border-color: #f59e0b; color: #f59e0b; }
.filters.contact-search { grid-template-columns: 1fr auto auto; align-items: center; }
.filters.contact-search input[type="search"] { grid-column: auto; }
@media (max-width: 520px) { .filters.contact-search { grid-template-columns: 1fr auto; } .filters.contact-search input[type="search"] { grid-column: 1 / -1; } }

/* ---- Dashboard: compact layout (main.page.dash) ---- */
.dash { padding-top: 18px; }
.dash .panels { gap: 14px; margin-top: 0; }
.dash .panel { padding: 16px; }
.dash .panel h2 { margin-bottom: 10px; }
.dash .stat { padding: 10px 12px; }
.dash .stat strong { font-size: 1.15rem; }
.dash th, .dash td { padding: 7px 10px; }
.dash table.sheet td > small { font-size: .72rem; }
.dash .collect-progress { margin: 0 0 6px; }
.dash .stats + .table-wrap, .dash .sheet-stats { margin-bottom: 10px; }
@media (min-width: 900px) { .dash .panel.wide > .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.dash td .small-btn { padding: 3px 9px; }
.dash .page-head .form-actions .btn-outline.small-btn { padding: 5px 11px; font-size: .8rem; }

/* ---- Resident home rows: Monthly expenses + My maintenance, then Assigned to me + My complaints + Notices ---- */
.home-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 18px; min-width: 0; }
.home-row > .panel { flex: 1 1 220px; min-width: 0; }
.home-row > .panel.home-half { flex: 1 1 420px; }
.home-row .page-head { gap: 8px; }
.home-row .stats { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
.home-row .stat strong { font-size: 1.1rem; }
.home-row th, .home-row td { padding: 8px 6px; }
.home-row .page-head .form-actions { margin-top: 0; gap: 6px; }
.home-row .page-head .form-actions .btn-outline, .home-row .page-head .form-actions .btn.auto { padding: 5px 11px; font-size: .8rem; }
.home-row .page-head > .btn-outline { padding: 5px 11px; font-size: .8rem; }
