/* ---------- Theme ---------- */
:root {
  --green: #5A439D;
  --green2: #ECE4FB;
  --ink: #2D2E30;
  --muted: #707080;
  --bg: #FBF9FF;
  --line: #E5E0EF;
  --white: #fff;
  --red: #D94B55;
  --amber: #A96B13;
  --shadow: 0 8px 28px #39265d12;
  --accent: #FFC857;
  --pink: #F5DCEB;
  --mint: #DDF2E8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Roboto, Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }

/* ---------- App shell ---------- */
.app {
  max-width: 520px;
  min-height: 100dvh;
  margin: auto;
  background: var(--bg);
  padding-bottom: 92px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #ffffffef;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 10px; }

.logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #5A439D 0%, #7862B8 65%, #FFC857 100%);
  color: white;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -1px;
}

.brand h1 { font-size: 19px; margin: 0; font-weight: 800; letter-spacing: -.45px; }
.brand small { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }

.avatar {
  border: 0;
  background: var(--green2);
  color: var(--green);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-weight: 800;
}

.content { padding: 18px; }

/* ---------- Headings & stats ---------- */
.greeting {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.greeting h2 {
  font-size: 24px;
  line-height: 1.18;
  margin: 5px 0 0;
  font-weight: 800;
  letter-spacing: -.7px;
}

.month {
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 12px;
  color: #42534c;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px;
  box-shadow: var(--shadow);
}

.stat:nth-child(1) { background: linear-gradient(145deg, #fff 65%, #F0E9FC); }
.stat:nth-child(2) { background: linear-gradient(145deg, #fff 65%, #FFF3E1); }
.stat:nth-child(3) { background: linear-gradient(145deg, #fff 65%, #FCECF2); }
.stat:nth-child(4) { background: linear-gradient(145deg, #fff 65%, #EAF5F0); }

.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat strong { display: block; font-size: 25px; letter-spacing: -.5px; margin: 8px 0 4px; }
.stat small { font-size: 12px; color: var(--muted); }
.stat.alert strong { color: var(--red); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 12px;
}

.section-head h3 { font-size: 18px; margin: 0; font-weight: 800; letter-spacing: -.25px; }

.text-btn {
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 700;
  font-size: 13px;
  padding: 5px;
}

/* ---------- Notices ---------- */
.notice-list { display: grid; gap: 9px; }

.notice {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 13px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.notice-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #FFF2D9, #ECE4FB);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 18px;
}

.notice p { margin: 0; font-size: 13px; line-height: 1.4; flex: 1; }
.notice p b { display: block; font-size: 14px; margin-bottom: 3px; }

.small-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Property cards ---------- */
.property-list { display: grid; gap: 12px; }

.property {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 8px 24px #39265d0b;
}

.property-img { height: 130px; position: relative; background: #EAE5F5; }
.property-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.property-img .tag {
  position: absolute;
  left: 12px;
  top: 12px;
  background: linear-gradient(100deg, #ffffffef, #FFF0C7ef);
  color: #5A439D;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
}

.property-body { padding: 14px; }

.property-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}

.property-title h4 { font-size: 16px; margin: 0; font-weight: 800; }
.property-title p { font-size: 12px; color: var(--muted); margin: 5px 0 0; }

.owned {
  font-size: 10px;
  color: var(--green);
  background: var(--green2);
  padding: 6px 7px;
  border-radius: 7px;
  font-weight: 800;
  white-space: nowrap;
}

.property-meta {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  margin: 13px 0;
}

.property-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.action {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 11px;
  padding: 10px 5px;
  color: #34473f;
  font-size: 12px;
  font-weight: 700;
}

.action.primary { background: var(--green); border-color: var(--green); color: white; }
.action .ico { display: block; font-size: 17px; margin-bottom: 4px; }

/* ---------- Bottom navigation & FAB ---------- */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, 100%);
  z-index: 20;
  background: #fff;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 8px 5px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px #39265d0a;
}

.navitem {
  border: 0;
  background: transparent;
  color: #8b9892;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 0;
}

.navitem span { font-size: 20px; line-height: 1; }
.navitem.active { color: #5A439D; }

.fab {
  position: fixed;
  right: max(18px, calc((100vw - 520px) / 2 + 18px));
  bottom: 92px;
  z-index: 8;
  background: #5A439D;
  color: white;
  border: 0;
  border-radius: 16px;
  padding: 13px 16px;
  font-weight: 800;
  box-shadow: 0 8px 20px #5A439D30;
}

/* ---------- Search, filters, tabs ---------- */
.toolbar { display: flex; gap: 8px; margin-bottom: 13px; }

.search {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  padding: 12px 13px;
  outline: none;
}

.filter {
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  padding: 0 12px;
  color: var(--ink);
}

.tabs {
  display: flex;
  gap: 7px;
  overflow: auto;
  margin-bottom: 14px;
  padding-bottom: 2px;
}

.tab {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 10px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.tab.active { background: var(--green2); border-color: #CFC2EC; color: var(--green); }

/* ---------- Cards ---------- */
.tenant-card, .row-card, .expense-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
}

.row-card:nth-of-type(4n+1) { background: #FBF9FF; }
.row-card:nth-of-type(4n+2) { background: #FFFCF5; }
.row-card:nth-of-type(4n+3) { background: #FFF9FB; }

.tenant-top { display: flex; gap: 10px; align-items: center; }

.tenant-avatar {
  width: 43px;
  height: 43px;
  border-radius: 14px;
  background: #ECE4FB;
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.tenant-name { font-size: 16px; font-weight: 800; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  background: #ECE4FB;
  color: var(--green);
}

.pill.due { background: #fff0ef; color: var(--red); }
.pill.partial { background: #fff4df; color: var(--amber); }

.amount { font-weight: 800; font-size: 19px; }

.tenant-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 12px; }

.flat-expense-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 13px 14px;
  text-align: left;
  background: #F3EFFB;
  border-color: #D7C9F0;
  color: #5A439D;
  font-size: 14px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #D7C9F0;
  background: #fff;
  color: #5A439D;
  border-radius: 11px;
  padding: 10px 13px;
  font-weight: 800;
  font-size: 14px;
  margin: 0 0 14px;
  box-shadow: 0 3px 12px #39265d0a;
}

.link-danger {
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 0 0;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.btn.green { background: var(--green); border-color: var(--green); color: white; }
.btn.lightgreen { background: linear-gradient(110deg, #ECE4FB, #FFF0C7); border-color: #D7C9F0; color: var(--green); }
.btn.red { color: var(--red); background: #FFF3F3; }
.btn.full { width: 100%; padding: 13px; }

.empty {
  padding: 32px 18px;
  text-align: center;
  color: var(--muted);
  background: #fff;
  border: 1px dashed #D8D1E8;
  border-radius: 16px;
}

.empty b { display: block; color: var(--ink); margin: 9px 0; }

/* ---------- Forms ---------- */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 800; color: #5F5C6D; }

.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid #DCD6E8;
  border-radius: 11px;
  background: #fff;
  padding: 12px;
  color: var(--ink);
  outline-color: #BBA9E3;
  min-width: 0;
}

.field textarea { min-height: 75px; resize: vertical; }

/* ---------- Modal sheet ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: #201735c9;
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal.show { display: flex; }

.sheet {
  background: var(--bg);
  width: min(520px, 100%);
  max-height: 92dvh;
  overflow: auto;
  border-radius: 24px 24px 0 0;
  padding: 20px 18px calc(22px + env(safe-area-inset-bottom));
  animation: slide .22s ease;
}

.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 17px; }
.sheet-head h3 { font-size: 19px; margin: 0; }

.close {
  border: 0;
  background: #ECE4FB;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  font-size: 19px;
}

/* ---------- Detail views ---------- */
.detail-head {
  background: var(--green);
  color: white;
  border-radius: 18px;
  padding: 17px;
  margin-bottom: 14px;
}

.detail-head h3 { font-size: 21px; margin: 0 0 6px; }
.detail-head p { margin: 0; color: #E9DFF8; font-size: 13px; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }

.detail-metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.detail-metric small { color: var(--muted); font-size: 11px; }
.detail-metric b { display: block; font-size: 18px; margin-top: 6px; }

.subhead { font-size: 14px; font-weight: 800; margin: 17px 0 10px; }

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.history-item:last-child { border-bottom: 0; }

.proof {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-top: 8px;
  background: #F5F2FA;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  background: #2D2E30;
  color: white;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  z-index: 80;
  transition: .2s;
  max-width: 90%;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Login ---------- */
.login {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, #ECE4FB 0%, #F8F7FC 55%, #FFF0C7 100%);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.login-card {
  width: min(420px, 100%);
  background: white;
  border: 1px solid #E5E0EF;
  border-radius: 26px;
  padding: 25px;
  box-shadow: 0 20px 70px #39265d17;
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 25px; }
.login-brand h2 { font-size: 23px; margin: 0; }
.login-brand p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.login-card h3 { font-size: 20px; margin: 0 0 6px; }
.login-card .intro { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 0 20px; }
.login-card .field { margin-bottom: 13px; }
.login-note { font-size: 11px; line-height: 1.5; color: var(--muted); margin-top: 15px; }

.logout {
  border: 0;
  background: #fff0ef;
  color: var(--red);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 800;
}

/* ---------- Animation & responsive ---------- */
@keyframes slide {
  from { transform: translateY(25px); opacity: .6; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 700px) {
  body { background: #eaf0ec; }
  .app { box-shadow: 0 0 0 1px #dfe8e2; min-height: 100dvh; }
  .content { padding: 20px; }
  .modal { align-items: center; }
  .sheet { border-radius: 24px; max-height: 85dvh; }
  .bottomnav { bottom: 0; }
}

@media (max-width: 360px) {
  .content { padding: 14px; }
  .greeting h2 { font-size: 21px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 22px; }
  .property-actions { gap: 5px; }
  .action { font-size: 11px; }
  .formgrid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
}
