/* Water Billing — warm, friendly, clerk-first styling.
   Big tap targets, plain words, high contrast. */

:root {
  --ink: #20303a;
  --muted: #5b7180;
  --bg: #fdf8f1;
  --card: #ffffff;
  --line: #e8ddcb;
  --brand: #0e7c86;        /* warm teal */
  --brand-dark: #0a5c64;
  --accent: #f2a03d;       /* warm amber */
  --accent-soft: #fdeeda;
  --good: #1d8a4e;
  --red: #c81e1e;          /* after-15th amounts */
  --red-soft: #fdecec;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: var(--ink);
  background: linear-gradient(180deg, #fdf8f1 0%, #f6efe2 100%);
  min-height: 100vh;
}

/* ---------- header ---------- */
.app-header {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(90deg, var(--brand) 0%, #12919e 60%, #1aa3a8 100%);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-drop {
  font-size: 34px; background: rgba(255,255,255,.18);
  width: 58px; height: 58px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex: 0 0 auto;
}
.brand-drop img {
  width: 100%; height: 100%; object-fit: contain;
  background: #fff; padding: 4px;
}
.logo-preview {
  max-width: 200px; max-height: 100px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px; background: #fff; display: block; margin: 8px 0;
}
.brand h1 { margin: 0; font-size: 28px; letter-spacing: .3px; }
.tagline { margin: 2px 0 0; opacity: .92; font-size: 15px; }
.header-date label { display: block; font-size: 13px; opacity: .9; margin-bottom: 4px; }
.header-date input {
  font-size: 16px; padding: 8px 10px; border: none; border-radius: 8px;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 16px 0;
  max-width: 1100px; margin: 0 auto;
}
.tab {
  font-size: 17px; font-weight: 600;
  padding: 12px 18px; min-height: 48px;
  border: 2px solid var(--line); border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: #f3ead9; color: var(--ink);
  cursor: pointer;
}
.tab.active { background: var(--card); border-color: var(--brand); color: var(--brand-dark); }

/* ---------- layout ---------- */
.view {
  max-width: 1100px; margin: 0 auto;
  padding: 20px 16px 40px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(90, 70, 30, .06);
}
.card h2 { margin-top: 0; font-size: 22px; }
.card h3 { margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat {
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat .num { font-size: 30px; font-weight: 700; color: var(--brand-dark); }
.stat .lbl { color: var(--muted); font-size: 15px; }
.stat.warn { background: var(--red-soft); }
.stat.warn .num { color: var(--red); }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-block;
  font-size: 17px; font-weight: 600;
  padding: 13px 22px; min-height: 50px;
  border-radius: 10px; border: 2px solid transparent;
  background: var(--brand); color: #fff;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn-accent { background: var(--accent); color: #3a2703; }
.btn-accent:hover { background: #e08f24; }
.btn-ghost { background: transparent; color: var(--brand-dark); border-color: var(--brand); }
.btn-ghost:hover { background: #e7f4f4; }
.btn-small { padding: 8px 14px; min-height: 40px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

label.fld { display: block; font-weight: 600; margin: 12px 0 4px; }
input[type="text"], input[type="number"], input[type="date"], select, textarea {
  font-size: 17px; padding: 11px 12px; width: 100%;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, select:focus { outline: 3px solid #bfe6e9; border-color: var(--brand); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
input[type="file"] { font-size: 16px; padding: 10px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #f7f1e3; font-size: 15px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.inactive { opacity: .55; }

/* Amount display rule: by-15th BLACK, after-15th RED */
.amt-by { color: #111; font-weight: 600; }
.amt-after { color: var(--red); font-weight: 700; }
.amt-owed-late { color: var(--red); font-weight: 700; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700;
}
.badge-paid { background: #e2f4e8; color: var(--good); }
.badge-due { background: var(--accent-soft); color: #8a5a00; }
.badge-late { background: var(--red-soft); color: var(--red); }
.badge-cutoff { background: var(--red); color: #fff; }
.badge-info { background: #e7f4f4; color: var(--brand-dark); }

/* ---------- warnings / notices ---------- */
.warnbox {
  background: #fff8e6; border: 1px solid #f0d48a; border-left: 6px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}
.warnbox ul { margin: 6px 0 0; padding-left: 20px; }
.okbox {
  background: #e9f7ee; border: 1px solid #a9dcbb; border-left: 6px solid var(--good);
  border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}
.errbox {
  background: var(--red-soft); border: 1px solid #f0b3b3; border-left: 6px solid var(--red);
  border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}

.app-footer {
  max-width: 1100px; margin: 0 auto; padding: 0 16px 30px;
  color: var(--muted); font-size: 14px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}

.big-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px 0; }
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.searchbar input { flex: 1 1 220px; }

/* ---------- print bills (postcards) ---------- */
#printArea { display: none; }

/* On-screen postcard preview */
.screen-postcards .postcard {
  background: #fff;
  border: 1.5px solid #cbbf9f;
  border-radius: 8px;
  max-width: 620px;
  margin: 0 0 16px;
  padding: 16px 20px;
  font-size: 14.5px;
  box-shadow: 0 2px 6px rgba(90, 70, 30, .10);
}
.screen-postcards .postcard h4 { margin: 0 0 2px; font-size: 18px; }
.screen-postcards .postcard .pc-sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.screen-postcards .postcard table { margin: 4px 0; }
.screen-postcards .postcard td, .screen-postcards .postcard th { padding: 3px 6px; border-bottom: none; }
.screen-postcards .postcard .stub { border-top: 2px dashed #999; margin-top: 10px; padding-top: 8px; }
.screen-postcards .postcard .pc-back { line-height: 1.55; }
.screen-postcards .pc-amt-by { color: #000; font-weight: 700; }
.screen-postcards .pc-amt-after { color: var(--red); font-weight: 700; }
.screen-postcards .pc-logo { height: 40px; float: right; margin: 0 0 6px 10px; }
.screen-postcards .pc-message { font-style: italic; margin-top: 8px; }
.screen-postcards .pc-powered { margin-top: 10px; font-size: 11px; color: #777; text-align: right; }

@media print {
  body { background: #fff; }
  .app-header, .tabs, .view, .app-footer { display: none !important; }
  #printArea { display: block; }
  .postcard {
    width: 6in; height: 4.25in;
    border: 1px solid #999;
    margin: 0 auto 0.25in;
    padding: 0.22in 0.28in;
    page-break-inside: avoid;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 10.5pt; color: #000;
    position: relative;
    box-shadow: none; border-radius: 0; max-width: none;
  }
  .postcard h4 { margin: 0 0 2px; font-size: 13pt; }
  .postcard .pc-sub { font-size: 9pt; margin-bottom: 8px; }
  .postcard table { width: 100%; border-collapse: collapse; margin: 4px 0; }
  .postcard td, .postcard th { border: none; padding: 1.5px 4px; font-size: 10pt; text-align: left; }
  .postcard .stub {
    border-top: 2px dashed #000; margin-top: 10px; padding-top: 8px;
  }
  .postcard .pc-back { font-size: 9.5pt; line-height: 1.5; }
  .postcard .pc-amt-by { color: #000; font-weight: 700; }
  .postcard .pc-amt-after { color: #c81e1e; font-weight: 700; }
  .postcard .pc-logo { height: 0.42in; float: right; margin: 0 0 4px 8px; }
  .postcard .pc-message { font-style: italic; margin-top: 6px; }
  .postcard .pc-powered { margin-top: 8px; font-size: 7.5pt; color: #666; text-align: right; }
}

@media (max-width: 640px) {
  .brand h1 { font-size: 23px; }
  .tab { flex: 1 1 44%; border-bottom: 2px solid var(--line); border-radius: 10px; }
  .view { padding: 14px 10px 32px; }
}
