:root {
  --bg: #eef3f5; --card: #ffffff; --ink: #14212b; --muted: #66788a;
  --line: #dfe8ec; --brand: #0f766e; --brand-2: #0d9488; --brand-dk: #0b5f59;
  --brand-soft: #e6f6f4;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --info: #1d4ed8;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 18px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .10);
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1100px 500px at 8% -8%, #ddf0ed 0%, rgba(221, 240, 237, 0) 60%),
    radial-gradient(900px 500px at 100% 0%, #e3eef5 0%, rgba(227, 238, 245, 0) 55%),
    linear-gradient(180deg, #f5f9fa 0%, #eef3f5 100%);
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 23px; margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font-size: 15px; margin: 4px 0 10px; }
h4 { font-size: 12px; margin: 16px 0 6px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.due { color: var(--bad); font-weight: 600; }
.paid { color: var(--ok); }

/* ---------- top bar ---------- */
.topbar {
  background: linear-gradient(135deg, #0f766e 0%, var(--brand-2) 60%, #14b8a6 140%);
  color: #fff; padding: 0 18px; display: flex; align-items: center;
  flex-wrap: wrap; position: sticky; top: 0; z-index: 5;
  box-shadow: 0 2px 16px rgba(15, 118, 110, .28);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff;
  padding: 10px 18px 10px 0; font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  background: none; border: 0; padding: 0;
  filter: drop-shadow(0 2px 5px rgba(2, 44, 40, .35));
}
.brand-mark svg { width: 100%; height: 100%; display: block; }
.brand-name em { font-style: normal; color: #b8f5ec; }
.brand-mark.big {
  width: 64px; height: 64px; background: none; border: 0;
  box-shadow: 0 12px 26px rgba(13, 148, 136, .38);
}
.brand-mark .tp-window { animation: tp-lights 1.2s steps(1, end) infinite; }
@keyframes tp-lights {
  0%, 49.9% { opacity: 1; }
  50%, 100% { opacity: .6; }
}
.brand-mark .tp-pulse { animation: tp-pulse 1.2s steps(1, end) infinite; }
@keyframes tp-pulse {
  0%, 49.9% { opacity: .45; }
  50%, 100% { opacity: .8; }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark .tp-window, .brand-mark .tp-pulse { animation: none; }
}
.topbar nav { display: flex; flex-wrap: wrap; padding: 6px 0; }
.topbar nav a {
  color: #d9f8f3; padding: 7px 11px; margin: 2px; font-size: 13.5px;
  border-radius: 9px; transition: background .12s ease, color .12s ease;
}
.topbar nav a:hover { color: #fff; background: rgba(255, 255, 255, .16); text-decoration: none; }

/* ---------- landlord PIN dialog ---------- */
dialog {
  border: 0; border-radius: var(--radius); padding: 20px 22px;
  width: min(92vw, 360px); background: var(--card); color: var(--ink);
  box-shadow: 0 24px 60px rgba(6, 30, 28, .35);
}
dialog::backdrop { background: rgba(6, 30, 28, .45); }
dialog h3 { margin: 0 0 6px; font-size: 17px; }
dialog input {
  width: 100%; margin: 12px 0 6px; padding: 10px 12px;
  font-size: 18px; letter-spacing: .28em; text-align: center;
}
.dialog-error { color: var(--bad); font-size: 12px; margin: 0 0 10px; min-height: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions .btn + .btn { margin-left: 0; }

/* ---------- layout ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 22px 16px 64px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.cols { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 900px) {
  .cols { grid-template-columns: 1fr 1fr; gap: 16px; }
  .cols .card { margin-bottom: 0; }
  .cols { margin-bottom: 16px; }
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px; margin-bottom: 16px; }
.stat { position: relative; overflow: hidden; padding-left: 20px;
  transition: transform .15s ease, box-shadow .15s ease; }
.stat::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0;
  width: 4px; background: linear-gradient(180deg, #14b8a6, var(--brand)); }
.stat:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.stat .lbl { font-size: 11.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600; }
.stat .num { font-size: 24px; font-weight: 800; margin: 4px 0; letter-spacing: -.02em; }
.stat .num.big, .big { font-size: 20px; font-weight: 800; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .05em; border-bottom: 2px solid var(--line); padding: 8px 9px;
  font-weight: 700; white-space: nowrap; }
td { padding: 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:nth-child(even) td { background: #fbfdfd; }
tbody tr:hover td { background: #f1faf8; }
tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: #f6fbfa; }
.vacant-row td, .muted-row td { color: var(--muted); }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px;
  font-weight: 700; color: #fff; letter-spacing: .01em; }
.badge.occupied, .badge.done, .badge.settled { background: var(--ok); }
.badge.vacant, .badge.none { background: var(--muted); }
.badge.held { background: var(--warn); }
.badge.open { background: var(--bad); }
.badge.in-progress { background: var(--warn); }
.badge.high { background: var(--bad); }
.badge.medium { background: var(--warn); }
.badge.low { background: var(--info); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-block; color: #fff; border: 0; border-radius: 9px;
  padding: 9px 15px; font-size: 14px; font-weight: 600; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 2px 8px rgba(15, 118, 110, .25);
  transition: background .12s ease, transform .12s ease, box-shadow .12s ease;
}
.btn:hover { background: linear-gradient(135deg, var(--brand-dk), var(--brand));
  text-decoration: none; transform: translateY(-1px); color: #fff; }
.btn:active { transform: none; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line);
  box-shadow: none; }
.btn.ghost:hover { background: var(--brand-soft); border-color: #b9e5df;
  color: var(--brand-dk); }
.btn.warn { background: linear-gradient(135deg, #b45309, #d97706);
  box-shadow: 0 2px 8px rgba(180, 83, 9, .25); }
.btn.danger { background: linear-gradient(135deg, #b91c1c, #dc2626);
  box-shadow: 0 2px 8px rgba(185, 28, 28, .22); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn + .btn { margin-left: 6px; }

form.inline, form.inline-row { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
form.inline-row { margin: 8px 0; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; color: var(--ink); text-transform: uppercase;
  transition: border-color .12s ease, box-shadow .12s ease; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .16); }
input.num-in { width: 110px; text-align: right; }
input.cap { text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; align-items: end; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px;
  font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; }
.filter { align-items: end; margin-bottom: 12px; }
.filter label { display: inline-flex; flex-direction: column; font-size: 12px; color: var(--muted); }

/* ---------- flashes ---------- */
.flash { padding: 11px 15px; border-radius: 10px; margin-bottom: 12px; font-size: 14px;
  border-left: 4px solid transparent; box-shadow: var(--shadow); }
.flash.ok { background: #e9fbf0; color: var(--ok); border: 1px solid #b7efc9;
  border-left-color: var(--ok); }
.flash.error { background: #fef1f1; color: var(--bad); border: 1px solid #f7c6c6;
  border-left-color: var(--bad); }

/* ---------- misc ---------- */
.actions .btn { margin: 0 8px 8px 0; }
.month-nav { display: flex; gap: 8px; align-items: center; margin: 0 0 14px; }
.month-nav .btn { padding: 5px 11px; }

.receipt { max-width: 480px; margin: 0 auto; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.receipt .kv td { padding: 7px 8px; border-bottom: 1px dashed var(--line); }
.receipt .kv td:first-child { color: var(--muted); }
.danger-zone { border-color: #f3b4b4; background: linear-gradient(180deg, #fff 0%, #fff7f7 100%); }

/* ---------- login ---------- */
.login-wrap { max-width: 380px; margin: 6vh auto 0; }
.login-hero { text-align: center; margin-bottom: 18px;
  animation: rise .45s ease both; }
.login-hero .brand-mark.big { margin-bottom: 12px; }
.login-hero h1 { font-size: 34px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-hero h1 em { font-style: normal;
  background: linear-gradient(135deg, var(--brand) 10%, #14b8a6 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-hero .tagline { color: var(--muted); margin: 0; font-size: 14px; }
.pulse-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #2dd4bf; margin-left: 5px; vertical-align: 7px;
  animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(45, 212, 191, .55); }
  70% { box-shadow: 0 0 0 11px rgba(45, 212, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.login { max-width: 380px; margin: 0 auto; text-align: center; padding: 24px; }
.login input { width: 100%; margin: 6px 0 14px; text-align: center;
  letter-spacing: 6px; font-size: 19px; padding: 12px; }
.login .btn { width: 100%; padding: 12px; font-size: 15px; }

@media (max-width: 560px) {
  main { padding: 16px 12px 56px; }
  .brand { padding-right: 10px; }
  .topbar { padding: 0 12px; }
  .login-hero h1 { font-size: 30px; }
}

@media print {
  .topbar, .foot, .btn, .actions, footer { display: none !important; }
  body { background: #fff; }
  .receipt { border: 0; box-shadow: none; }
}

/* ---------- payment tree ---------- */
.ptree-row td { background: #f7fbfa; border-bottom: 1px solid var(--line); }
.ptree { font-size: 12.5px; color: var(--ink); padding: 2px 0 6px 14px; }
.ptree-root { font-weight: 700; color: var(--brand-dk); margin-bottom: 2px; }
.ptree-list { list-style: none; margin: 0; padding-left: 16px;
  border-left: 2px solid #cfe9e4; }
.ptree-list li { padding: 1px 0; }
.ptree-list li .r { float: right; font-weight: 600; }

/* ---------- ECG underline under the wordmark ---------- */
.brand-text { position: relative; display: inline-block; padding-bottom: 1px; }
.brand-ecg {
  position: absolute; left: -2px; right: -2px; bottom: 4px;
  width: calc(100% + 4px); height: 22px; overflow: visible;
  pointer-events: none;
}
.brand-ecg .brand-ecg-dot {
  fill: #ccfbf1; opacity: 0;
  filter: drop-shadow(0 0 4px rgba(94, 234, 212, .95));
  offset-path: path("M0 17.5 H68 L72 17.5 L76 8 L80 22.5 L84 13 L88 17.5 H148 L152 17.5 L156 8 L160 22.5 L164 13 L168 17.5 H240");
  offset-distance: 0%; offset-rotate: 0deg;
  animation: ecg-travel 2.8s linear 1.2s infinite;
}
@keyframes ecg-travel {
  0%   { offset-distance: 0%;   opacity: 0; }
  8%   { opacity: 1; }
  88%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}
.login-hero h1 { position: relative; padding-bottom: 14px; }
.login-hero h1 .brand-ecg {
  left: 50%; right: auto; transform: translateX(-50%);
  width: min(100%, 300px); height: 24px; bottom: 21px;
}
.brand:focus-visible { outline: 2px solid #99f6e4; outline-offset: 3px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) {
  .brand-ecg .brand-ecg-dot { animation: none; opacity: 0; }
}

/* ---------- logout ---------- */
.topbar .logout-link {
  align-self: center; margin-left: 10px; padding: 6px 12px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
  color: #eafffb; background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28); box-shadow: none;
}
.topbar .logout-link:hover { background: rgba(255, 255, 255, .22); color: #fff; }
@media (max-width: 560px) {
  .topbar .logout-link { padding: 5px 10px; font-size: 12px; margin-left: 6px; }
}
