/* Classic Homes Billing - dark navy blue #0a2a5e, lime green #b8d935, white.
   Day mode: white background, dark navy text. Night mode: dark navy
   background, white text. Lime green accents in both modes. */
:root {
  --navy: #0a2a5e; --navy2: #063461; --lime: #b8d935; --lime-d: #8fb51f;
  --bg: #ffffff; --surface: #f4f6fa; --card: #ffffff; --text: #0a2a5e;
  --muted: #5a6b8a; --border: #dbe2ef; --accent: #8fb51f; --danger: #c0392b;
  --shadow: 0 2px 10px rgba(10,42,94,.10);
}
html[data-theme="night"] {
  --bg: #0a2a5e; --surface: #0d3570; --card: #103a78; --text: #ffffff;
  --muted: #c3d2ea; --border: #24497f; --accent: #b8d935; --shadow: 0 2px 10px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--navy2); } html[data-theme="night"] a { color: var(--lime); }
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; background: var(--navy); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar.collapsed { width: 64px; flex-basis: 64px; }
.sidebar.collapsed .nav-item { font-size: 0; } .sidebar.collapsed .nav-ico { font-size: 18px; }
.sidebar.collapsed .brand span, .sidebar.collapsed .side-foot { display: none; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.15); font-size: 18px; }
.brand small { color: var(--lime); font-size: 11px; letter-spacing: 1px; }
.brand-house { color: var(--lime); font-size: 30px; line-height: 1; }
nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.menu-opt { color: var(--lime); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; padding: 14px 10px 4px; }
.nav-item { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; padding: 10px 12px; border-radius: 8px; margin: 2px 0; }
.nav-item:hover { background: rgba(255,255,255,.12); }
.nav-item.active { background: var(--lime); color: var(--navy); font-weight: 700; }
.side-foot { padding: 14px 16px; font-size: 12px; color: #c3d2ea; border-top: 1px solid rgba(255,255,255,.15); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.crumbs { font-weight: 600; flex: 1; min-width: 140px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--lime); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.user-chip { display: flex; flex-direction: column; line-height: 1.2; } .user-chip small { color: var(--muted); font-size: 11px; }
.content { padding: 18px; max-width: 1280px; width: 100%; margin: 0 auto; }
h1 { font-size: 22px; margin: 4px 0 14px; } h2 { font-size: 17px; margin: 0 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .k-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.kpi .k-value { font-size: 24px; font-weight: 800; overflow-wrap: anywhere; }
.kpi .k-sub { color: var(--muted); font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
tbody tr:hover { background: var(--surface); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn { display: inline-block; background: var(--navy); color: #fff; border: 1px solid var(--navy); border-radius: 8px; padding: 8px 14px; cursor: pointer; text-decoration: none; font-size: 14px; }
.btn:hover { filter: brightness(1.15); }
.btn-lime { background: var(--lime); color: var(--navy); border-color: var(--lime); font-weight: 700; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 9px; font-size: 13px; }
.icon-btn { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px; }
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; }
.tab.active { background: var(--lime); color: var(--navy); font-weight: 700; border-color: var(--lime); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; font-size: 13px; }
.chip.active { background: var(--navy); color: #fff; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface); border: 1px solid var(--border); }
.badge-Paid { background: #e6f4d7; color: #2f6b1f; } .badge-Overdue { background: #fde8e8; color: #9b1c1c; }
.badge-Partially { background: #fff3cd; color: #7a5b00; } .badge-Written { background: #e8e8e8; color: #555; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash-ok { background: #e6f4d7; color: #2f6b1f; } .flash-err { background: #fde8e8; color: #9b1c1c; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.pw-wrap { position: relative; } .pw-wrap input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 16px; }
/* Side drawer, slides in from the right */
.drawer-overlay { position: fixed; inset: 0; background: rgba(10,42,94,.45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 40; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 100vw); background: var(--bg); color: var(--text); z-index: 50; transform: translateX(100%); transition: transform .3s ease; display: flex; flex-direction: column; box-shadow: -4px 0 20px rgba(0,0,0,.25); }
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px; border-bottom: 1px solid var(--border); }
.drawer-body { padding: 16px; overflow-y: auto; flex: 1; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card, .kpi { animation: fadeIn .3s ease; }
.bar-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.bar-row .bar-label { width: 90px; flex: 0 0 90px; } .bar-track { flex: 1; background: var(--surface); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--lime); } .bar-fill.billed { background: var(--navy2); }
.login-wrap { max-width: 420px; margin: 8vh auto; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-logo { text-align: center; font-size: 26px; color: var(--navy); } html[data-theme="night"] .login-logo { color: #fff; }
.login-logo .brand-house { font-size: 44px; }
@media (max-width: 1024px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .sidebar { position: fixed; z-index: 30; transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .kpis { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .user-chip { display: none; }
}
/* Print: A4, one bill per sheet, paper white in both modes */
@media print {
  body { background: #fff; color: #000; } .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; } .content { max-width: none; padding: 0; }
  .print-sheet { page-break-after: always; }
}
.print-sheet { background: #fff; color: #000; padding: 18px; border: 1px solid #ccc; margin-bottom: 20px; font-size: 13px; }
.print-head { display: flex; gap: 14px; border-bottom: 3px solid #0a2a5e; padding-bottom: 8px; }
.print-logo { font-size: 44px; color: #b8d935; line-height: 1; }
.print-society { font-size: 24px; font-weight: 800; color: #0a2a5e; }
.print-office { font-weight: 700; letter-spacing: 2px; font-size: 12px; }
.print-addr, .print-contact { font-size: 11px; color: #333; } .print-contact { margin-left: auto; text-align: right; }
.print-title { display: flex; gap: 12px; align-items: center; margin: 10px 0; font-size: 16px; font-weight: 800; }
.print-badge { font-size: 11px; border: 1px solid #0a2a5e; padding: 2px 8px; border-radius: 4px; }
.print-status { margin-left: auto; color: #c0392b; }
.print-meta, .print-grid, .print-table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.print-meta th, .print-meta td, .print-grid th, .print-grid td, .print-table th, .print-table td { border: 1px solid #999; padding: 5px 8px; font-size: 12px; color: #000; }
.print-section { background: #0a2a5e; color: #fff; padding: 5px 8px; font-weight: 700; font-size: 12px; margin-top: 10px; }
.print-table .subtotal td { font-weight: 700; background: #eef2f8; }
.print-how { display: flex; gap: 20px; font-size: 11px; margin-top: 10px; } .print-how > div { flex: 1; }
.print-sign td { text-align: center; padding-top: 18px; font-size: 11px; }
.print-cut { text-align: center; border-top: 2px dashed #000; margin-top: 16px; padding-top: 6px; font-size: 11px; font-weight: 700; }
.print-stub { border: 1px solid #999; padding: 10px; margin-top: 8px; }
.print-note { font-size: 11px; color: #444; }
