:root {
  color-scheme: light;
  --ink: #13212e;
  --muted: #53616d;
  --navy: #0d3b66;
  --blue: #1468a8;
  --pale: #f3f7fa;
  --line: #c7d4dd;
  --green: #176b45;
  --green-pale: #e2f4e9;
  --red: #a9272e;
  --red-pale: #fdecef;
  --amber: #7a4c00;
  --radius: 16px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--pale); font-size: 17px; line-height: 1.5; }
a { color: var(--navy); font-weight: 700; }
button, input, select, textarea { font: inherit; }
button, .button { min-height: 48px; border-radius: 10px; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 4px solid #f5b700; outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 0; background: #fff; padding: .75rem; z-index: 10; }
.skip-link:focus { left: 1rem; }
.site-header { min-height: 64px; padding: .7rem max(1rem, calc((100vw - 1100px) / 2)); background: var(--navy); display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: #fff; }
.site-header a, .site-header .link-button { color: #fff; text-decoration: none; }
.brand { font-size: 1.2rem; font-weight: 800; white-space: nowrap; }
.site-header nav { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.site-header nav > a, .site-header .inline-form { min-height: 48px; display: inline-flex; align-items: center; padding: .55rem .7rem; border-radius: 8px; }
.site-header nav > a:hover, .site-header .inline-form:hover { background: rgba(255,255,255,.14); }
.container { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.75rem); box-shadow: 0 1px 2px rgba(16, 42, 67, .06); margin-block: 1rem; }
.panel h1, .panel h2 { margin-top: 0; }
.narrow, .login-panel { width: min(100%, 520px); margin: 3rem auto; }
.login-panel h1 { font-size: 2rem; }
.lead { color: var(--muted); }
.eyebrow { margin: 0 0 .25rem; color: var(--navy); font-size: .82rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.owner-intro { text-align: center; margin: 2.5rem 0 1.5rem; }
.owner-intro h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.2rem); }
.owner-intro p:last-child { color: var(--muted); margin-bottom: 0; }
.tenant-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.tenant-card { min-height: 148px; padding: 1.25rem; border-radius: var(--radius); display: flex; flex-direction: column; justify-content: space-between; text-decoration: none; border: 3px solid transparent; box-shadow: 0 2px 5px rgba(10, 35, 55, .12); }
.tenant-card .tenant-name { color: var(--ink); font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 800; overflow-wrap: anywhere; }
.tenant-card strong { font-size: 1.35rem; }
.tenant-card.paid { color: var(--green); border-color: var(--green); background: var(--green-pale); }
.tenant-card.unpaid { color: var(--red); border-color: var(--red); background: var(--red-pale); }
.tenant-card.unpaid:hover { background: #fad9df; transform: translateY(-1px); }
.undo-form { margin-top: 1.5rem; text-align: center; }
.confirmation { max-width: 680px; margin: 3rem auto; text-align: center; }
.confirmation h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); }
.confirmation-actions { display: grid; gap: .75rem; margin-top: 1.5rem; }
.primary, .secondary, .button { display: inline-flex; align-items: center; justify-content: center; padding: .65rem 1rem; border: 2px solid transparent; font-weight: 800; text-decoration: none; }
.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.primary:hover { background: #082b4a; }
.secondary { background: #fff; color: var(--navy); border-color: var(--navy); }
.secondary:hover { background: #e8f2f9; }
.large { min-height: 62px; font-size: 1.2rem; }
.notice { padding: 1rem; border-left: 6px solid; border-radius: 8px; background: #fff; margin-bottom: 1rem; font-weight: 650; }
.notice.success { border-color: var(--green); color: #0b4a2e; }
.notice.error { border-color: var(--red); color: #761b22; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin: 1.5rem 0; }
.section-heading h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.tabs { display: flex; gap: .35rem; overflow-x: auto; padding-block: .5rem; border-bottom: 2px solid var(--line); scrollbar-color: var(--blue) transparent; }
.tabs a { flex: 0 0 auto; min-height: 48px; display: inline-flex; align-items: center; padding: .65rem .85rem; text-decoration: none; border-radius: 8px 8px 0 0; }
.tabs a.active { background: var(--navy); color: #fff; }
.month-picker { display: flex; align-items: flex-end; gap: .5rem; }
.month-picker label { margin: 0; }
.month-picker input { min-height: 44px; }
.stacked-form, .form-grid { display: grid; gap: 1rem; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.form-grid .full { grid-column: 1 / -1; }
label, .field { display: grid; gap: .35rem; font-weight: 750; color: #293a47; }
input, select, textarea { width: 100%; min-height: 48px; padding: .55rem .65rem; border: 2px solid #8ca3b3; border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 92px; resize: vertical; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.stat { padding: 1rem; border-radius: 12px; background: #e5f0f8; color: var(--navy); display: grid; gap: .25rem; }
.stat strong { font-size: 2rem; }
.stat.danger { background: var(--red-pale); color: var(--red); }
.inline-action { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.inline-action p { margin-bottom: 0; color: var(--muted); }
.inline-action h2 { margin-bottom: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 600px; }
th, td { padding: .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
td small { display: block; color: var(--muted); }
.actions { min-width: 190px; white-space: normal; }
.action-group { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.action-form { margin: 0; }
.action-button { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; padding: .55rem .85rem; border: 2px solid var(--navy); border-radius: 9px; background: #fff; color: var(--navy); font-weight: 800; text-decoration: none; cursor: pointer; white-space: nowrap; }
.action-button:hover { background: #e8f2f9; }
.action-button.danger { border-color: var(--red); color: #8e2028; background: #fff8f8; }
.action-button.danger:hover { background: var(--red-pale); }
.link-button { min-height: 36px; padding: .25rem; border: 0; background: transparent; color: var(--navy); font-weight: 800; text-decoration: underline; }
.status { display: inline-block; padding: .25rem .5rem; border-radius: 999px; font-weight: 800; font-size: .9rem; }
.status.paid, .status.cash { color: var(--green); background: var(--green-pale); }
.status.partial, .status.late, .status.unpaid, .status.reversed { color: var(--red); background: var(--red-pale); }
.history-list { display: grid; gap: .75rem; }
.history-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.muted { opacity: .6; }
.report-actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.helper-text { margin: -.3rem 0 0; color: var(--muted); font-size: .92rem; }
.modal { width: min(100% - 2rem, 520px); padding: 0; border: 0; border-radius: var(--radius); background: transparent; color: var(--ink); box-shadow: 0 18px 50px rgba(0,0,0,.28); }
.modal::backdrop { background: rgba(8, 30, 49, .62); }
.modal-card { display: grid; gap: 1rem; padding: clamp(1.25rem, 5vw, 2rem); background: #fff; border-radius: var(--radius); }
.modal-card h2, .modal-card p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: .75rem; flex-wrap: wrap; margin-top: .25rem; }

@media (max-width: 700px) {
  body { font-size: 16px; }
  .site-header { align-items: flex-start; flex-direction: column; }
  .container { width: min(100% - 1rem, 1100px); margin-top: 1rem; }
  .section-heading, .inline-action { align-items: stretch; flex-direction: column; }
  .month-picker { width: 100%; }
  .month-picker label { flex: 1; }
  .form-grid, .compact { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .tenant-card { min-height: 128px; }
  .action-group { align-items: stretch; flex-direction: column; }
  .action-form, .action-button { width: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .primary, .modal-actions .secondary { width: 100%; }
  .no-print { display: flex; }
}

@media print {
  body { background: #fff; font-size: 11pt; }
  .site-header, .tabs, .no-print, .notice { display: none !important; }
  .container { width: 100%; margin: 0; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .report-table { margin-top: 1rem; }
  table { min-width: 0; }
}
