:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1f2421;
  --muted: #6b716c;
  --line: #e3e1d9;
  --brand: #1d6e56;
  --brand-ink: #0f4f3d;
  --danger: #a3322a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 8px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a { color: var(--brand-ink); }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.1rem; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--ink); }
.nav { display: flex; gap: .3rem; margin-left: .5rem; }
.nav a {
  padding: .35rem .7rem; border-radius: 8px; text-decoration: none;
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--brand); color: #fff; }
.nav summary.navtab { padding: .35rem .7rem; border-radius: 8px; color: var(--muted); font-weight: 500; cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .25rem; }
.nav summary.navtab::-webkit-details-marker { display: none; }
.nav summary.navtab::after { content: "▾"; font-size: .65rem; opacity: .7; }
.nav summary.navtab:hover { background: var(--bg); color: var(--ink); }
.nav summary.navtab.active { background: var(--brand); color: #fff; }
.crumb { font-weight: 600; color: var(--ink); white-space: nowrap; }
.crumb::before { content: "›"; color: var(--muted); margin: 0 .45rem 0 .15rem; }
.usermenu { margin-left: auto; display: flex; align-items: center; gap: .9rem; font-size: .92rem; }
.usermenu .who { font-weight: 600; }
.usermenu a { text-decoration: none; color: var(--muted); }
.usermenu a:hover { color: var(--ink); }

/* Layout */
.content { max-width: 940px; margin: 1.4rem auto; padding: 0 1.1rem; }
.page-title { font-size: 1.5rem; margin: .2rem 0 1rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head .page-title { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
  margin-bottom: 1.1rem;
}
.card h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.card h3 { margin: 1.3rem 0 .6rem; font-size: 1rem; }
.card.narrow { max-width: 460px; }
.card.note { background: #fbfaf6; }
.card.empty { text-align: center; padding: 2.4rem 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; }

/* Property cards */
.prop-card { text-decoration: none; color: inherit; display: block; transition: border-color .15s; }
.prop-card:hover { border-color: var(--brand); }
.prop-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.prop-top h2 { margin: 0; font-size: 1.15rem; }
.prop-meta { margin-top: .6rem; color: var(--muted); font-size: .9rem; display: flex; gap: .35rem; flex-wrap: wrap; }

/* Auth */
.auth-card {
  max-width: 380px; margin: 8vh auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem 1.8rem; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 .2rem; font-size: 1.4rem; }
.auth-card .muted { margin-top: 0; }

/* Forms */
.field { display: block; margin-bottom: .9rem; }
.field .lbl { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; }
.input, input[type=text], input[type=password], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
.input:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.input.small { padding: .35rem .5rem; width: auto; }
textarea { min-height: 4.5rem; resize: vertical; }
.row { display: flex; gap: .9rem; flex-wrap: wrap; }
.row .field { flex: 1 1 180px; }
.check { display: flex; align-items: center; gap: .5rem; margin-bottom: .9rem; font-size: .92rem; }
.check input { width: auto; }
.err { display: block; color: var(--danger); font-size: .82rem; margin-top: .25rem; }
.actions { display: flex; gap: .6rem; align-items: center; margin-top: .4rem; }
.inline-add { display: flex; gap: .7rem; align-items: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.inline-add.wrap .field { flex: 1 1 150px; }
.inline-add .field { margin-bottom: 0; }
.reset-row { display: flex; gap: .4rem; align-items: center; }

/* Buttons */
.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0;
  padding: .55rem 1rem; border-radius: 8px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-ink); }
.btn.block { width: 100%; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg); }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }
.scroll-x { overflow-x: auto; }
.subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem 1rem; align-items: end; }
.row-muted td { color: var(--muted); }
.row-dup td { background: #fdf6ec; }
.link { background: none; border: 0; color: var(--brand-ink); cursor: pointer; font: inherit; padding: 0; }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; padding: 0; }

/* Tables */
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; font-size: .82rem; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.data td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data .num { text-align: right; }
.muted-row td { color: var(--muted); }

/* Key-value */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem .9rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; }

/* Badges & tags */
.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); }
.status-owned { background: #e1f1ea; border-color: #bfe0d0; color: var(--brand-ink); }
.status-prospect, .status-under_contract { background: #fdf3e2; border-color: #f0dcb4; color: #8a5a12; }
.status-sold, .status-archived { background: #eee; border-color: #ddd; color: #555; }
.tag { font-size: .72rem; background: var(--bg); border: 1px solid var(--line); padding: 0 .4rem; border-radius: 6px; color: var(--muted); }
.tag-red { color: var(--danger); font-weight: 600; font-size: .8rem; }
.tag-amber { color: #8a5a12; font-weight: 600; font-size: .8rem; }
.tag-green { color: var(--brand-ink); font-weight: 600; font-size: .8rem; }
.prewrap { white-space: pre-line; }
.badge.good { background: #e1f1ea; border-color: #bfe0d0; color: var(--brand-ink); }

/* Flash */
.flash { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .9rem; font-size: .92rem; border: 1px solid; }
.flash.success { background: #e6f3ec; border-color: #bfe0cd; color: var(--brand-ink); }
.flash.error { background: #fbeae8; border-color: #eecac5; color: var(--danger); }
.flash.message, .flash.info { background: #eef1f4; border-color: #d6dce2; color: #33485c; }

/* Sub-navigation on property pages — clean tab bar with dropdown groups */
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.3rem; padding-bottom: .55rem; border-bottom: 1px solid var(--line); }
.subnav .tab { padding: .4rem .8rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; }
.subnav .tab:hover { background: var(--bg); color: var(--ink); }
.subnav .tab.active { background: var(--brand); color: #fff; }
.subnav summary.tab { list-style: none; user-select: none; }
.subnav summary.tab::-webkit-details-marker { display: none; }
.subnav summary.tab::after { content: "▾"; font-size: .7rem; opacity: .65; }
.subnav .navdrop[open] summary.tab::after { opacity: 1; }
.navdrop { position: relative; }
.navdrop-panel { position: absolute; top: calc(100% + 5px); left: 0; z-index: 30; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: .35rem; display: flex; flex-direction: column; gap: .1rem; }
.navdrop-panel a { padding: .45rem .65rem; border-radius: 7px; text-decoration: none; color: var(--ink); font-size: .92rem; white-space: nowrap; }
.navdrop-panel a:hover { background: var(--bg); }
.navdrop-panel a.active { background: #e1f1ea; color: var(--brand-ink); font-weight: 600; }

/* Card spanning two grid columns */
.card.span2 { grid-column: span 2; }
.span2 { grid-column: span 2; }
@media (max-width: 620px) { .card.span2, .span2 { grid-column: auto; } }

/* Big number */
.bignum { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }

/* Ownership split bar */
.split-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--line); margin: .3rem 0 .9rem; }
.split-bar .seg { height: 100%; }
.seg1, .dot1 { background: #1d6e56; }
.seg2, .dot2 { background: #2f6fb3; }
.seg3, .dot3 { background: #c98a1b; }
.seg4, .dot4 { background: #7a5bd0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .45rem; vertical-align: middle; }

/* Contact cards */
.contact-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.contact-head h2 { margin: 0; }

/* Scroll wrapper for wide tables on narrow screens */
.table-wrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.nowrap form { display: inline; margin-left: .6rem; }
.section-title { font-size: 1.2rem; margin: 0; }
details summary { cursor: pointer; font-weight: 500; }
details[open] summary { margin-bottom: .9rem; }
.doc-list { list-style: none; padding: 0; margin: .6rem 0 0; }
.doc-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.check-btn { background: none; border: 0; font-size: 1.2rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 0; }
.check-btn:hover { color: var(--brand); }
.check-btn.done { color: var(--brand); }
table.data tr.overdue td { background: #fdf1ef; }
table.data tr.done td { color: var(--muted); }

/* Compact tables */
table.mini { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.mini td { padding: .28rem .2rem; border-bottom: 1px solid var(--line); }
table.mini .num { text-align: right; }
table.mini .strong { font-weight: 700; }
table.mini tr.total td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: 600; padding-top: .45rem; }
table.data tr.total td { font-weight: 600; }

/* Two-column form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .9rem; }
.form-grid .field { margin-bottom: .6rem; }
.form-grid .span2 { grid-column: span 2; }
.form-grid h3.form-section { margin: .8rem 0 .1rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: .25rem; }
.form-grid h3.form-section:first-of-type { margin-top: .3rem; }
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span2 { grid-column: auto; } }

/* Amount direction + activity type badges */
.num.pos { color: var(--brand-ink); }
.num.neg { color: var(--danger); }
.badge.type-contribution { background: #e1f1ea; border-color: #bfe0d0; color: var(--brand-ink); }
.badge.type-expense { background: #fdeee2; border-color: #f0d6b4; color: #8a5a12; }

/* Hamburger nav on small screens */
.navtoggle {
  display: none; margin-left: auto; background: none; border: 0;
  font-size: 1.35rem; line-height: 1; color: var(--ink); cursor: pointer;
  padding: .15rem .45rem; border-radius: 8px;
}
.navtoggle::before { content: "\2630"; }                   /* hamburger */
.topbar.nav-open .navtoggle::before { content: "\2715"; }  /* close X */
.navtoggle:hover { background: var(--bg); }

@media (max-width: 620px) {
  .navtoggle { display: inline-flex; }
  .nav, .usermenu { display: none; }
  .topbar.nav-open .nav {
    display: flex; flex-direction: column; align-items: stretch;
    order: 3; width: 100%; gap: .15rem; margin: .45rem 0 0;
  }
  .topbar.nav-open .usermenu {
    display: flex; order: 4; width: 100%; margin: .5rem 0 0; gap: 1.1rem;
    justify-content: flex-start; flex-wrap: wrap;
    padding-top: .6rem; border-top: 1px solid var(--line);
  }
  .nav a, .nav summary.navtab { padding: .55rem .7rem; }   /* larger tap targets */
  /* dropdown groups expand inline instead of overlaying the items below */
  .navdrop-panel {
    position: static; box-shadow: none; border: 0; min-width: 0;
    padding: .1rem 0 .3rem 1rem;
  }
}

/* Notifications */
.bell { position: relative; }
.bell-count { display: inline-block; min-width: 1.05rem; padding: 0 .3rem; margin-left: .15rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.45; text-align: center; vertical-align: text-top; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { display: flex; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li.unread .notif-msg { font-weight: 600; }
.notif-list li.unread .notif-msg::before { content: "●"; color: var(--danger); margin-right: .4rem; font-size: .6rem; vertical-align: middle; }
.notif-msg { flex: 1; min-width: 12rem; text-decoration: none; }
.notif-actions { display: flex; gap: .8rem; margin-left: auto; }
