:root {
  --navy: #16324f; --navy-2: #1f4468; --ink: #1d2433; --muted: #5f6b7a; --line: #dde2e8; --soft: #f3f6fa; --bg: #f7f8fa;
  --accent: #2478a0; --red: #b42318; --green: #137a4b; --amber: #8a5a00; --radius: 10px;
  --focus: 0 0 0 3px rgba(36, 120, 160, .35);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Calibri, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: 400; }
.small-print { font-size: .85rem; margin: .2rem 0 .6rem; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* brand */
.brand { display: flex; align-items: center; gap: .6rem; color: var(--navy); }
.brand-logo { height: 34px; width: auto; display: block; }
.auth-card .brand-logo { height: 64px; margin: 0 auto; }

/* demo banner (QA preview host only) */
.demo-banner { margin: 0; padding: .45rem 1rem; background: #fff4d6; color: var(--amber); text-align: center; font-weight: 600; font-size: .85rem; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1.2rem; padding: .55rem 1.25rem; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-brand { text-decoration: none; }
.topbar nav { display: flex; gap: .3rem; }
.topbar nav a { padding: .45rem .75rem; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600; }
.topbar nav a.on { background: var(--soft); color: var(--navy); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.save-state { font-size: .8rem; color: var(--green); }
.save-state.busy { color: var(--muted); }
.save-state.bad { color: var(--red); font-weight: 600; }

.page { max-width: 1440px; margin: 0 auto; padding: 1.25rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.crumbs { margin: 0 0 .6rem; font-size: .85rem; color: var(--muted); }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .6rem; }
.card-head h2 { margin: 0; }
.count { display: inline-block; min-width: 1.6em; padding: 0 .4em; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: .8rem; text-align: center; }
.actions { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 40px; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #b9c2cd; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .88rem; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-size: .82rem; text-decoration: underline; cursor: pointer; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: #fde8e6; color: var(--red); }

/* forms */
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 600; min-width: 0; }
.field small { font-weight: 400; }
input, select, textarea { font: inherit; color: var(--ink); border: 1px solid #cdd4dc; border-radius: 7px; padding: .5rem .6rem; background: #fff; min-height: 40px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: var(--focus); }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; min-height: 40px; }
.check input { width: 18px; height: 18px; min-height: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.form-grid.four { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form-grid.charges { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid h2 { margin: .6rem 0 0; }
.span2 { grid-column: 1 / -1; }
.row-actions { display: flex; gap: .6rem; justify-content: space-between; margin-top: .4rem; }
.form-error { color: var(--red); min-height: 1.2em; margin: .2rem 0; font-size: .9rem; }
.warn-text { color: var(--amber); font-weight: 600; }

/* property grid */
.toolbar { margin-bottom: .9rem; max-width: 420px; }
.pgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: .9rem; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; }
.pcard-main { display: block; padding: 1rem 1.1rem .4rem; text-decoration: none; color: inherit; flex: 1; }
.pcard-main:hover h3 { color: var(--accent); }
.pcard h3 { margin: 0 0 .2rem; font-size: 1.05rem; }
.pcard p { margin: .15rem 0; font-size: .88rem; }
.pcard-last { color: var(--ink); }
.pcard-actions { padding: .5rem 1.1rem 1rem; }
.pill { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; vertical-align: middle; letter-spacing: .02em; }
.pill.draft { background: #fff4d6; color: var(--amber); }
.pill.final { background: #dcf3e8; color: var(--green); }
.empty { text-align: center; padding: 2rem 1.2rem; }
.empty p { max-width: 560px; margin: .6rem auto; }
.archived { margin-top: 1.2rem; }
.prop-summary { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.prop-summary p { margin: .2rem 0; }

/* tables */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .45rem .4rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: .35rem .4rem; border-bottom: 1px solid #eef1f4; vertical-align: middle; }
table.data .r { text-align: right; }
table.data .c { text-align: center; }
table.data .nowrap { white-space: nowrap; }
table.edit input { min-height: 36px; padding: .35rem .45rem; }

table.edit input.num { text-align: right; min-width: 80px; width: 92px; }
table.edit input.short { min-width: 60px; width: 64px; }
table.edit input.wide { min-width: 220px; }
table.edit input[data-bf=guest] { min-width: 160px; }
table.edit input[type=date] { width: 140px; min-width: 132px; }
table.edit input[type=checkbox] { width: 18px; height: 18px; min-height: 0; }
td.calc { color: var(--muted); white-space: nowrap; }
.empty-row { text-align: center; padding: 1rem !important; }
table.map th { padding: .3rem; }
table.map select { min-width: 120px; font-size: .82rem; min-height: 34px; padding: .25rem; }
table.map td { font-size: .82rem; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
table.map td.ignored { color: #aab3bd; text-decoration: line-through; }

/* paste */
.paste-panel { border: 1px dashed #9fb3c8; background: #f8fbfe; border-radius: 8px; padding: .8rem; margin: 0 0 .9rem; }
.paste-area { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.paste-foot { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin-top: .6rem; }
.paste-foot p { margin: 0; }

/* editor layout */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.summary { position: sticky; top: 72px; }
.summary h2 { margin-bottom: .6rem; }
.due { background: var(--navy); color: #fff; border-radius: 8px; padding: .8rem 1rem; margin-bottom: .8rem; }
.due span { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.due strong { font-size: 1.7rem; letter-spacing: -.01em; }
.due.neg { background: var(--red); }
.srows { font-size: .88rem; }
.srow { display: flex; justify-content: space-between; gap: .8rem; padding: .28rem 0; border-bottom: 1px solid #eef1f4; }
.srow span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.srow.strong { font-weight: 700; }
.srow .neg { color: var(--red); }
.warnings { margin-top: .8rem; background: #fff8e6; border: 1px solid #f1d58a; border-radius: 8px; padding: .6rem .8rem; font-size: .84rem; }
.warnings ul { margin: .3rem 0 0; padding-left: 1.1rem; }
.summary-actions { display: grid; gap: .5rem; margin-top: 1rem; }

/* auth */
body.is-auth { background: linear-gradient(160deg, #eaf1f8, #f7f8fa 60%); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.8rem 1.6rem; box-shadow: 0 10px 30px rgba(22, 50, 79, .08); }
.auth-card h1 { margin: 1.1rem 0 .4rem; font-size: 1.4rem; }
.auth-card form { display: grid; gap: .8rem; margin-top: .8rem; }
.fine { font-size: .78rem; color: var(--muted); margin: 1rem 0 0; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }

/* settings */
.logo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo-row .label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.logo-preview { max-height: 48px; max-width: 180px; border: 1px solid var(--line); border-radius: 6px; padding: 4px; background: #fff; }
.tpl { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .9rem; }
.tpl .btn { margin-top: .5rem; }

/* dialog */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 25, 40, .45); }
.send-form { padding: 1.3rem; display: grid; gap: .8rem; }
.send-form h2 { margin: 0; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; opacity: 0; transition: .25s; z-index: 50; max-width: calc(100vw - 32px); font-size: .9rem; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); }

@media (max-width: 1100px) {
  .form-grid.four { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; order: -1; }
}

/* combined units, imported history, per-flat periods (12 Nov 2026) */
.pill.combined { background: #e6f0f7; color: var(--navy); }
.pill.imported { background: var(--soft); color: var(--muted); }
.small { font-size: .82rem; }
.import-note { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; border-color: #b9d6e6; background: #f2f8fc; }
.import-note h2 { margin: 0 0 .25rem; font-size: 1rem; }
.import-note p { margin: 0; }
.sent-check { margin: .4rem 0 .6rem; padding: .4rem .6rem; border-radius: 8px; font-size: .82rem; }
.sent-check.ok { background: #e8f5ee; color: var(--green); }
.sent-check.bad { background: #fff4d6; color: var(--amber); font-weight: 600; }
.flat-period { margin: .2rem 0 .6rem; }
/* vendor rules (12 Nov 2026) */
.bank-note { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .8rem; margin-top: .2rem; font-size: .75rem; color: #6b7280; }
.bank-note .bank-text { overflow-wrap: anywhere; }
.bank-note .tick { display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap; cursor: pointer; }
.bank-note .tick input { width: 14px; height: 14px; min-height: 0; margin: 0; }
.ok-text { color: #15803d; }
table.rules td { vertical-align: middle; }
table.rules select { min-width: 10rem; }

@media (max-width: 640px) {
  body { font-size: 15px; }
  .page { padding: .8rem; }
  .topbar { padding: .5rem .8rem; gap: .6rem; flex-wrap: wrap; }
  .topbar .brand span { display: none; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav a { flex: 1; text-align: center; }
  .save-state { display: none; }
  .form-grid, .form-grid.four, .form-grid.charges { grid-template-columns: 1fr 1fr; }
  .form-grid > .field:only-child { grid-column: 1 / -1; }
  .card { padding: .9rem; }
  h1 { font-size: 1.35rem; }
  .pgrid { grid-template-columns: 1fr; }
  .due strong { font-size: 1.5rem; }
}
@media (max-width: 420px) {
  .form-grid, .form-grid.charges { grid-template-columns: 1fr; }
  .form-grid.four { grid-template-columns: 1fr 1fr; }
}

.adv-fee{border:1px solid #ddd;border-radius:8px;padding:.6rem .8rem;margin:.4rem 0}
.adv-fee summary{cursor:pointer;padding:.2rem 0}
.adv-fee[open] summary{margin-bottom:.6rem}

.calc-note{background:#f4f7fb;border-radius:6px;padding:.5rem .7rem;margin:.3rem 0}
