:root {
  --ink: #1d2430; --muted: #5d6676; --line: #e3e6eb; --bg: #f6f7f9; --card: #fff;
  --accent: #2f5d8a; --accent-ink: #fff; --ok: #1f7a4d; --ok-bg: #e7f5ee;
  --warn: #8a5a00; --warn-bg: #fff4dc; --err: #a32b2b; --err-bg: #fdeaea;
  --rent: #2f5d8a; --elec: #b9770e; --water: #1f7f8c;
  --field-bg: #fff; --field-line: #c9ced6; --pill-bg: #eef0f3; --info-bg: #eef3f8; --info: #2b4764;
  --purple-bg: #efe9fb; --purple: #5b3c9b; --code-bg: #f1f3f6; --err-line: #e0b4b4;
  --company-bg: #e8f1ee; --company: #2f6b55; --header: #fff;
  color-scheme: light;
}
/* Dark theme: chosen with the switch in the top bar, or following the device when set to Auto */
:root[data-theme="dark"] {
  --ink: #e6e9ef; --muted: #9aa4b2; --line: #2c3340; --bg: #12161c; --card: #1a1f27;
  --accent: #7fb0e0; --accent-ink: #0d1520; --ok: #6fd3a0; --ok-bg: #173327;
  --warn: #f0c060; --warn-bg: #3a2e12; --err: #f28b8b; --err-bg: #3a1c1c;
  --rent: #7fb0e0; --elec: #e0a646; --water: #4fc1cf;
  --field-bg: #11151b; --field-line: #3a4352; --pill-bg: #262d38; --info-bg: #1c2a3a; --info: #a9c8ea;
  --purple-bg: #2a2340; --purple: #c4b0f2; --code-bg: #232a35; --err-line: #6b3434;
  --company-bg: #1b3029; --company: #8fd6b8; --header: #161b22;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6e9ef; --muted: #9aa4b2; --line: #2c3340; --bg: #12161c; --card: #1a1f27;
    --accent: #7fb0e0; --accent-ink: #0d1520; --ok: #6fd3a0; --ok-bg: #173327;
    --warn: #f0c060; --warn-bg: #3a2e12; --err: #f28b8b; --err-bg: #3a1c1c;
    --rent: #7fb0e0; --elec: #e0a646; --water: #4fc1cf;
    --field-bg: #11151b; --field-line: #3a4352; --pill-bg: #262d38; --info-bg: #1c2a3a; --info: #a9c8ea;
    --purple-bg: #2a2340; --purple: #c4b0f2; --code-bg: #232a35; --err-line: #6b3434;
    --company-bg: #1b3029; --company: #8fd6b8; --header: #161b22;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
header.top { background: var(--header); border-bottom: 1px solid var(--line); }
header.top .inner { max-width: 1100px; margin: 0 auto; padding: 10px 20px; display: flex;
                    gap: 18px; align-items: center; flex-wrap: wrap; }
header.top .brand { font-weight: 650; margin-right: auto; color: var(--ink); text-decoration: none; }
header.top nav a { text-decoration: none; color: var(--muted); padding: 4px 2px; }
header.top nav a.on { color: var(--ink); border-bottom: 2px solid var(--accent); }
main { max-width: 1100px; margin: 0 auto; padding: 22px 20px 60px; }
main.narrow { max-width: 720px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px;
        margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { font-size: 26px; font-weight: 650; }
.stat-label { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 650; border-top: 2px solid var(--line); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.tablewrap table { border: 0; }
.tablewrap tr:last-child td { border-bottom: 0; }
form.inline { display: inline; }
label { display: block; font-weight: 550; margin: 10px 0 4px; font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 450; }
input[type=text], input[type=password], input[type=date], input[type=email], input[type=number],
input[type=file], select, textarea {
  width: 100%; max-width: 420px; padding: 8px 10px; border: 1px solid var(--field-line); border-radius: 7px;
  font: inherit; background: var(--field-bg); color: var(--ink); }
textarea { max-width: 100%; min-height: 80px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.row > div { flex: 1 1 180px; }
button, .btn { display: inline-block; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-ink); padding: 7px 14px; border-radius: 7px; font: inherit; font-weight: 550;
  cursor: pointer; text-decoration: none; }
button.secondary, .btn.secondary { background: var(--card); color: var(--accent); }
button.small, .btn.small { padding: 3px 9px; font-size: 13px; }
button.danger { background: var(--card); color: var(--err); border-color: var(--err-line); }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.warn, .note.warn { background: var(--warn-bg); color: var(--warn); }
.note { padding: 10px 14px; border-radius: 8px; background: var(--info-bg); color: var(--info); margin: 10px 0; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px;
        background: var(--pill-bg); color: var(--muted); white-space: nowrap; }
.pill.active, .pill.paid { background: var(--ok-bg); color: var(--ok); }
.pill.upcoming { background: var(--info-bg); color: var(--info); }
.pill.open, .pill.unpaid { background: var(--warn-bg); color: var(--warn); }
.pill.reported { background: var(--purple-bg); color: var(--purple); }
.kind { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.kind.rent { background: var(--rent); } .kind.electric_gas { background: var(--elec); }
.kind.water { background: var(--water); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.link-box { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--code-bg);
            padding: 8px 10px; border-radius: 7px; word-break: break-all; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
details > summary { cursor: pointer; color: var(--accent); }
.pin { font-size: 24px; letter-spacing: .4em; text-align: center; max-width: 160px !important; }
.balance { font-size: 34px; font-weight: 700; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
img.bill { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
@media (max-width: 640px) { th, td { padding: 7px 6px; } main { padding: 16px 12px 50px; }
  .pill.reported { white-space: normal; } .card { padding: 14px 12px; } }

form.paidform input[type=date], form.paidform select { width: auto; max-width: 140px; padding: 3px 6px; font-size: 13px; }
.row.top { align-items: flex-start; }

.pill.waived { background: var(--pill-bg); color: var(--muted); }
details.waive { display: inline-block; margin-left: 6px; vertical-align: middle; }
details.waive summary { cursor: pointer; color: var(--accent); }
details.waive form { margin-top: 6px; white-space: normal; max-width: 260px; }
details.waive input[type=text] { width: 100%; margin-bottom: 4px; }
.pill.company { background: var(--company-bg); color: var(--company); }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  header.top .inner { padding: 8px 12px; gap: 6px 12px; }
  header.top nav { order: 3; width: 100%; display: flex; gap: 16px; overflow-x: auto; white-space: nowrap;
                   -webkit-overflow-scrolling: touch; scrollbar-width: none; padding-bottom: 2px; }
  header.top nav::-webkit-scrollbar { display: none; }
  header.top nav a { padding: 6px 0; }
  h1 { font-size: 20px; }
  .section-title { flex-wrap: wrap; }
  .stat { font-size: 22px; }
  input[type=text], input[type=password], input[type=date], input[type=email], input[type=number],
  select, textarea { max-width: 100%; font-size: 16px; }   /* 16px stops iPhone zooming into fields */
  button, .btn { padding: 9px 14px; }
  button.small, .btn.small { padding: 6px 11px; font-size: 14px; }

  /* tables marked "stack": one card per row, label on the left */
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr:first-child { display: none; }
  table.stack tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 0 3px 38%; position: relative; text-align: left; white-space: normal; min-height: 24px; }
  table.stack td::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 35%;
                           font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
  table.stack td:not([data-label]) { padding-left: 0; }
  table.stack td:not([data-label])::before { content: none; }
  table.stack td:empty { display: none; }
  table.stack td.num { text-align: left; }
  table.stack form.paidform { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
  table.stack form.paidform input[type=date], table.stack form.paidform select { max-width: none; width: auto; font-size: 15px; padding: 5px 6px; }
  details.waive { display: block; margin: 6px 0 0; }
  details.waive form { max-width: 100%; }
  .tablewrap { border-radius: 10px; }
  /* lease charges: the checkbox row is short; description first and bold */
  table.charges td[data-label="Pay"] input { width: 20px; height: 20px; }
  table.charges td[data-label="Description"] { font-weight: 550; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .grid.stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { margin-bottom: 12px; }
}

/* theme switch */
.theme-switch { background: none; border: 1px solid var(--line); color: var(--muted); padding: 3px 9px;
                border-radius: 99px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.theme-switch:hover { color: var(--ink); border-color: var(--muted); }

/* company logo */
header.top .brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-logo { height: 32px; width: auto; max-width: 160px; object-fit: contain; display: inline-block; }
.brand-logo.big { height: 56px; max-width: 240px; margin-bottom: 8px; }
.brand-co { display: block; font-size: 12px; font-weight: 450; color: var(--muted); line-height: 1.2; }
/* optional dark-theme logo: swap when the dark theme is on (chosen, or Auto on a dark device) */
.brand-logo.logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo.has-dark { display: none; }
:root[data-theme="dark"] .brand-logo.logo-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo.has-dark { display: none; }
  :root:not([data-theme="light"]) .brand-logo.logo-dark { display: inline-block; }
}
.logo-preview-dark { background: #12161c; display: inline-block; padding: 8px 12px; border-radius: 8px; }
@media (max-width: 640px) { .brand-logo { height: 26px; max-width: 110px; } }

header.top .signed-in { white-space: nowrap; }
@media (max-width: 640px) { header.top .signed-in { display: none; } }

/* view switch + monthly statements */
.viewswitch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; }
.viewswitch button { background: none; color: var(--muted); border: 0; border-radius: 0; padding: 5px 12px; font-size: 14px; font-weight: 500; }
.viewswitch button.on { background: var(--accent); color: var(--accent-ink); }
.card.month { padding: 12px 14px; }
.month-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.month-total { font-size: 20px; font-weight: 650; text-align: right; }
.card.month .tablewrap { border: 0; }
.card.month td { padding: 6px 4px; }
.month-sum td { border-top: 2px solid var(--line); }
.month-pay { margin-top: 8px; align-items: flex-end; }
/* condo portal: assessment kinds */
.kind.annual { background: var(--rent); } .kind.special { background: var(--elec); }
details > summary { cursor: pointer; color: var(--accent); margin: 8px 0; }
.kind.mail_fee { background: var(--muted); }
fieldset[hidden], [hidden] { display: none !important; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--info-bg); color: var(--info); margin: 10px 0; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dash a.card { display: block; text-decoration: none; color: inherit; margin: 0; }
.dash .big { font-size: 22px; font-weight: 650; }

/* ---------- phones: condo portal additions ---------- */
@media (max-width: 640px) {
  .row { flex-direction: column; gap: 0; }
  .row > div, .row > form { flex: 1 1 auto !important; width: 100%; }
  .row > div[style*="flex:0 0 auto"] { width: auto; }
  input[type=tel], input[type=url], input[type=search], input[type=time], input[type=file] { max-width: 100%; font-size: 16px; }
  form.inline { display: inline-block; }
  .actions { flex-wrap: wrap; }
  label.check { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
  label.check input { margin-top: 3px; flex: 0 0 auto; }
  .section-title > div:last-child { width: 100%; }
  details > summary { padding: 6px 0; }
  .bylaws h2 { font-size: 18px; } .bylaws h3 { font-size: 16px; }
  .bylaws section p { font-size: 15.5px; }
  .dash { grid-template-columns: 1fr 1fr; }
  code { word-break: break-all; }
}

/* ---------- Southport Hangar colors (from the logo: navy, burgundy, parchment) ---------- */
:root {
  --accent: #1d3a5c; --accent-ink: #fff; --rent: #1d3a5c; --elec: #8a2c22;
  --bg: #f7f1e6; --header: #fffdf8; --line: #e6dccb; --pill-bg: #efe6d6;
  --info-bg: #e9eef5; --info: #1d3a5c; --brand-red: #8a2c22; --field-line: #cfc3ad;
}
:root[data-theme="dark"] {
  --accent: #e2c493; --accent-ink: #10243a; --rent: #9cb6d6; --elec: #e08a7d;
  --bg: #0f1a26; --card: #16222f; --header: #10243a; --line: #263749; --pill-bg: #223244;
  --info-bg: #1b2d42; --info: #c9d8ea; --brand-red: #e08a7d; --field-bg: #0d1620; --field-line: #34485e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #e2c493; --accent-ink: #10243a; --rent: #9cb6d6; --elec: #e08a7d;
    --bg: #0f1a26; --card: #16222f; --header: #10243a; --line: #263749; --pill-bg: #223244;
    --info-bg: #1b2d42; --info: #c9d8ea; --brand-red: #e08a7d; --field-bg: #0d1620; --field-line: #34485e;
  }
}
header.top { border-bottom: 3px solid var(--brand-red); }
header.top .brand { color: var(--ink); text-decoration: none; font-weight: 650; }
h1 { color: var(--accent); letter-spacing: -.01em; }
:root[data-theme="dark"] h1 { color: var(--ink); }
header.top .brand-logo { height: 40px; border-radius: 50%; }
.brand-logo.big { height: 120px; max-width: 120px; border-radius: 50%; display: block; margin: 0 auto 10px; }
@media (max-width: 640px) { header.top .brand-logo { height: 34px; } }

/* fields the base styles didn't size */
input[type=search], input[type=tel], input[type=url], input[type=time] { width: 100%; padding: 8px 10px; border: 1px solid var(--field-line);
  border-radius: 8px; background: var(--field-bg); color: var(--ink); font: inherit; }

/* ---------- public home page */
.public { max-width: 520px; margin: 32px auto 24px; text-align: center; }
.public-logo { width: 280px; max-width: 72vw; height: auto; border-radius: 50%; display: block; margin: 0 auto 18px;
  box-shadow: 0 2px 14px rgba(16, 36, 58, .18); }
.public h1 { font-size: 26px; margin: 0 0 6px; line-height: 1.25; }
.public-tagline { color: var(--muted); margin: 0 0 22px; }
.public-notice { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px;
  margin: 0 auto 22px; text-align: left; white-space: pre-line; }
.public-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.public-actions .btn { min-width: 170px; padding: 11px 18px; font-size: 16px; text-decoration: none; }
.public-foot { margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.public-foot p { margin: 4px 0; }
@media (max-width: 640px) { .public { margin-top: 16px; } .public h1 { font-size: 22px; } .public-actions .btn { width: 100%; } }

/* ---------- board members: My unit | Board switch, unit picker */
.areaswitch { display: inline-flex; border: 1px solid var(--line); border-radius: 99px; overflow: hidden; flex: 0 0 auto; }
.areaswitch a { padding: 5px 12px; font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; white-space: nowrap; }
.areaswitch a.on { background: var(--accent); color: var(--accent-ink); }
.unitswitch { width: auto; padding: 4px 8px; font-size: 14px; }
header.top a.signed-in { color: var(--muted); text-decoration: none; }
header.top a.signed-in:hover { text-decoration: underline; }

/* ---------- show / hide password */
.pwwrap { position: relative; display: block; }
.pwwrap input { padding-right: 64px; }
.pwwrap input.pin { padding-right: 12px; }
.pwtoggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0;
  color: var(--accent); font-size: 13px; font-weight: 600; padding: 4px 8px; cursor: pointer; }
.pwtoggle:hover { text-decoration: underline; }

/* ---------- sidebar layout (board and member pages) ---------- */
:root { --side-w: 248px; }
.ico { width: 18px; height: 18px; flex: 0 0 18px; }
.side { position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); z-index: 40; display: flex; flex-direction: column;
  background: var(--header); border-right: 1px solid var(--line); }
.side-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px 10px 18px; }
.side-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650;
  font-size: 14px; line-height: 1.25; min-width: 0; }
.side-brand .brand-logo, .mtop-brand .brand-logo { height: 44px; width: 44px; border-radius: 50%; flex: 0 0 auto; }
.side-x { display: none; margin-left: auto; }
.side-switch { display: flex; margin: 4px 14px 8px 18px; border: 1px solid var(--line); border-radius: 99px; padding: 2px; background: var(--bg); }
.side-switch a { flex: 1; text-align: center; padding: 5px 0; border-radius: 99px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); text-decoration: none; }
.side-switch a.on { background: var(--accent); color: var(--accent-ink); }
.side-units { margin: 0 14px 6px 18px; width: auto; font-size: 14px; padding: 5px 8px; }
.side-nav { flex: 1; overflow-y: auto; padding: 2px 10px 12px 12px; }
.side-group { margin: 12px 8px 3px; padding-bottom: 4px; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin: 1px 0; border-radius: 8px;
  color: var(--ink); text-decoration: none; font-size: 14.5px; }
.side-nav a .ico { color: var(--muted); }
.side-nav a:hover { background: var(--pill-bg); }
.side-nav a.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side-nav a.on .ico { color: var(--accent-ink); }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px 12px; }
.side-me { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side-me span { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.side-me small { font-weight: 400; color: var(--muted); font-size: 12px; }
.side-me:hover, .side-me.on { background: var(--pill-bg); }
.side-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; padding: 0 4px; }
button.linkish { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted);
  padding: 4px 2px; font-size: 13.5px; font-weight: 500; }
button.linkish:hover { color: var(--ink); }
button.linkish .ico { width: 16px; height: 16px; }
.iconbtn { background: none; border: 0; color: var(--ink); padding: 6px; border-radius: 8px; line-height: 0; }
.iconbtn .ico { width: 22px; height: 22px; }
.iconbtn:hover { background: var(--pill-bg); }
.mtop, .side-scrim { display: none; }
body.with-side main { margin: 0 0 0 var(--side-w); max-width: 1180px; padding: 26px 32px 60px; }
body.with-side main.narrow { max-width: 860px; }

@media (max-width: 900px) {
  .mtop { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 30; padding: 8px 12px;
    background: var(--header); border-bottom: 3px solid var(--brand-red); }
  .mtop-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 650; min-width: 0; }
  .mtop-brand .brand-logo { height: 34px; width: 34px; }
  .mtop-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side { transform: translateX(-100%); transition: transform .2s ease; width: min(84vw, 300px); box-shadow: none; }
  .side-x { display: inline-flex; }
  body.side-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  body.side-open .side-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 20, 32, .45); }
  body.with-side main { margin: 0 auto; padding: 18px 16px 50px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
