/* ============ Bills & Expenses (bills.js) ============
   Property tab, All Bills page, Dashboard reminder and the bill sheets.
   Colours come from theme.css; status colours stay soft (tints, not solid fills). */

/* ---------- Summary: next 30 days + each month ---------- */
.bl-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 22px; }
.bl-sum {
  min-width: 0; padding: 16px 16px 15px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  display: flex; flex-direction: column; gap: 3px;
}
.bl-sum:first-child { background: linear-gradient(160deg, rgba(var(--plum-rgb), 0.06), rgba(var(--plum-rgb), 0) 70%), var(--card); }
.bl-k { font-size: 0.74em; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.bl-v {
  font-size: clamp(1.15em, 5.4vw, 1.55em); font-weight: 800; letter-spacing: -0.02em; color: var(--text-bright);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
}
.bl-s { font-size: 0.8em; color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bl-s em { font-style: normal; color: var(--red-light); font-weight: 600; }

/* ---------- List ---------- */
.bl-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 10px; }
.bl-list-head h2 { margin: 0; font-size: 1.15em; font-weight: 800; letter-spacing: -0.01em; }
.bl-add {
  width: auto; margin: 0; padding: 12px 20px; border-radius: 999px; display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.95em; box-shadow: 0 8px 20px rgba(var(--plum-rgb), 0.2);
}
.bl-add svg { width: 15px; height: 15px; }
.bl-add.sm { padding: 9px 15px; font-size: 0.88em; box-shadow: 0 5px 14px rgba(var(--plum-rgb), 0.18); }
.bl-link { color: var(--plum); font-weight: 700; font-size: 0.9em; }
.bl-link.danger { color: var(--red-light); }

.card.bl-list { padding: 4px 6px; }
.bl-row, .bl-entry, .bl-remind, .bl-pickrow {
  width: 100%; margin: 0; padding: 14px 10px; border-radius: 14px; background: none; color: inherit; font-weight: normal;
  display: flex; align-items: center; gap: 13px; text-align: left;
}
.bl-row + .bl-row { border-top: 1px solid var(--hairline); border-radius: 0; }
.bl-row:hover, .bl-pickrow:hover { filter: none; background: rgba(var(--lavender-rgb), 0.07); }
.bl-row:active, .bl-entry:active, .bl-remind:active, .bl-pickrow:active { transform: none; background: rgba(var(--lavender-rgb), 0.12); }
.bl-row.done { opacity: 0.62; }

.bl-ico {
  width: 42px; height: 42px; border-radius: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--lavender-wash); color: var(--plum);
}
.bl-ico svg { width: 20px; height: 20px; }
.bl-ico.lg { width: 50px; height: 50px; border-radius: 16px; }
.bl-ico.lg svg { width: 24px; height: 24px; }
.bl-ico.utility, .bl-ico.wifi { background: rgba(var(--brand-teal-rgb), 0.11); color: var(--brand-teal-ink); }
.bl-ico.clean, .bl-ico.repair { background: rgba(var(--gold-rgb), 0.1); color: var(--gold); }

.bl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bl-name { font-weight: 700; font-size: 0.97em; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-when { font-size: 0.8em; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-when.alert { color: var(--red-light); font-weight: 600; }
.bl-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.bl-tags span {
  font-size: 0.68em; font-weight: 600; color: var(--text-subtle); padding: 2px 7px; border-radius: 6px;
  background: var(--chip-bg);
}
.bl-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.bl-amt { font-weight: 800; font-size: 0.97em; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bl-amt small { font-weight: 600; color: var(--muted); margin-right: 1px; }
.bl-amt.muted { color: var(--muted); font-weight: 600; }

/* Status: soft tints only */
.bl-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.72em; font-weight: 700; white-space: nowrap; background: var(--chip-bg); color: var(--text-subtle);
}
.bl-pill svg { width: 11px; height: 11px; }
.bl-pill.overdue { background: var(--expense-soft); color: var(--red-light); }
.bl-pill.due { background: var(--warning-soft); color: var(--gold); }
.bl-pill.paid { background: var(--income-soft); color: var(--green); }
.bl-pill.recorded { background: rgba(var(--brand-teal-rgb), 0.11); color: var(--brand-teal-ink); }

/* ---------- Empty state ---------- */
.card.bl-empty { text-align: center; padding: 34px 22px 26px; }
.bl-empty-ico {
  width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 19px; display: flex; align-items: center; justify-content: center;
  background: var(--lavender-wash); color: var(--plum);
}
.bl-empty-ico svg { width: 27px; height: 27px; }
.bl-empty h2 { font-size: 1.15em; font-weight: 800; margin: 0 0 8px; }
.bl-empty p { font-size: 0.9em; color: var(--text-subtle); line-height: 1.5; max-width: 330px; margin: 0 auto 20px; }
.bl-empty .bl-fine { margin: 14px auto 0; }
.bl-fine { font-size: 0.78em; color: var(--muted); line-height: 1.45; margin: 10px 0 0; }
.bl-quiet { font-size: 0.9em; color: var(--muted); padding: 6px 2px; line-height: 1.45; }

/* Notes sit under the bills, with a little more room */
.bl-notes { margin-top: 22px; }

/* ---------- All Bills page ---------- */
.bl-setup { margin: 4px 0 0; }
.bl-head-link { margin: 0; width: auto; font-size: 0.86em; }

/* Properties page entry + Dashboard reminder */
.bl-entry, .bl-remind {
  padding: 13px 14px; margin: 0 0 16px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
}
.bl-entry:hover, .bl-remind:hover { filter: none; border-color: var(--border-hover); }
.bl-entry > svg, .bl-remind > svg { width: 20px; height: 20px; color: var(--text-subtle); flex-shrink: 0; }
.bl-remind-ico {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--warning-soft); color: var(--gold);
}
.bl-remind-ico svg { width: 18px; height: 18px; }
#billsReminder[hidden] { display: none; }
#billsReminder { margin-top: 4px; }
.icon-circle.has-dot::after {
  content: ""; position: absolute; top: 11px; right: 12px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--icon-circle-bg);
}

/* ---------- Sheets ---------- */
.bl-sheet .sheet-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 10px; }
.bl-form [hidden], .bl-detail [hidden], .bl-sheet [hidden] { display: none !important; }
.bl-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.bl-two > div { min-width: 0; }
.bl-seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; margin-top: 10px;
  border-radius: 14px; background: rgba(var(--lavender-rgb), 0.12);
}
label + .bl-seg { margin-top: 0; }
.bl-seg button {
  margin: 0; padding: 9px 6px; border-radius: 10px; background: none; color: var(--text-subtle);
  font-size: 0.86em; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bl-seg button:hover { filter: none; color: var(--text); }
.bl-seg button.on { background: var(--card-solid); color: var(--text); box-shadow: 0 2px 8px var(--shadow-card), 0 0 0 1px var(--border); }

.bl-modes { display: flex; flex-direction: column; gap: 8px; }
.bl-modes button {
  margin: 0; padding: 12px 14px 12px 40px; border-radius: 14px; text-align: left; position: relative;
  background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text); font-weight: normal;
  display: flex; flex-direction: column; gap: 2px;
}
.bl-modes button::before {
  content: ""; position: absolute; left: 14px; top: 15px; width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--input-border); background: var(--card-solid); box-sizing: border-box;
}
.bl-modes button.on { border-color: rgba(var(--plum-rgb), 0.5); background: rgba(var(--plum-rgb), 0.035); box-shadow: 0 0 0 3px var(--focus-ring); }
.bl-modes button.on::before { border: 5px solid var(--plum); }
.bl-modes button:hover { filter: none; }
.bl-modes button:active { transform: none; }
.bl-modes button:disabled { opacity: 0.45; }
.bl-modes b { font-size: 0.93em; }
.bl-modes span { font-size: 0.8em; color: var(--text-subtle); line-height: 1.4; }

.bl-checkline {
  display: flex; align-items: center; gap: 10px; margin: 12px 0 0; font-size: 0.9em; font-weight: 500; color: var(--text); cursor: pointer;
}
.bl-checkline input { width: 18px; height: 18px; padding: 0; margin: 0; flex-shrink: 0; accent-color: var(--plum); }
.bl-owner-note { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--lavender-wash); font-size: 0.84em; color: var(--text-soft); line-height: 1.45; }
.bl-remind-row { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--divider); }
.bl-error { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--expense-soft); color: var(--red); font-size: 0.86em; line-height: 1.4; }
.bl-save { margin-top: 18px; }
.bl-save.ghost { background: var(--btn-edit-bg); color: var(--btn-edit-text); margin-top: 10px; padding: 11px; font-size: 0.92em; }
.bl-more { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }
.bl-intro { font-size: 0.9em; color: var(--text-subtle); line-height: 1.5; margin: 6px 0 12px; }

/* One bill */
.bl-detail-top { display: flex; align-items: center; gap: 13px; margin-top: 10px; }
.bl-place-name { font-size: 0.82em; font-weight: 700; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-big {
  margin: 18px 0 4px; font-size: 2.1em; font-weight: 800; letter-spacing: -0.03em; color: var(--text-bright);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.bl-big small { display: block; font-size: 0.36em; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.bl-mode-line { font-size: 0.84em; color: var(--text-subtle); line-height: 1.45; margin: 0 0 4px; }
.bl-note, .bl-found {
  margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(var(--brand-teal-rgb), 0.08);
  font-size: 0.87em; color: var(--text); line-height: 1.45; display: flex; flex-direction: column; gap: 3px;
}
.bl-found { background: var(--lavender-wash); }
.bl-found span { color: var(--text-subtle); font-size: 0.95em; overflow-wrap: anywhere; }
.bl-pay { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--divider); }
.bl-pay-title { font-weight: 700; font-size: 0.92em; color: var(--text); }
.bl-pay .bl-two label { margin-top: 10px; }
.bl-pay .bl-link { margin: 12px auto 0; display: flex; }

.bl-hist { margin-top: 22px; }
.bl-hist-title, .bl-pay-title + label { font-size: 0.74em; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.bl-hist-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--hairline); }
.bl-hist-row:last-child { border-bottom: none; }
.bl-hist-row .bl-name { font-size: 0.9em; font-weight: 600; }
.bl-hist-amt { font-weight: 700; font-size: 0.9em; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); flex-shrink: 0; }

.bl-picklist { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; padding: 2px 6px; }
.bl-pickrow + .bl-pickrow { border-top: 1px solid var(--hairline); border-radius: 0; }
.bl-pick { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow-y: auto; padding: 2px 2px 6px; }
.bl-pick .bl-checkline { margin: 0; padding: 10px 4px; border-bottom: 1px solid var(--hairline); }

@media (max-width: 380px) {
  .bl-summary { gap: 10px; }
  .bl-sum { padding: 14px 13px; }
  .bl-row { gap: 11px; padding: 13px 6px; }
  .bl-ico { width: 38px; height: 38px; border-radius: 12px; }
  .bl-seg.four button { font-size: 0.8em; padding: 9px 3px; }
}
@media (min-width: 700px) {
  .bl-summary { gap: 16px; }
  .bl-row { padding: 15px 14px; }
}

/* The property tabs' middle label is long: a touch smaller on the narrowest phones */
@media (max-width: 360px) {
  .prop-tabs button { font-size: 0.84em; }
}

/* Amount / Date: same each time or varies */
.bl-seg-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: center; gap: 8px; margin-top: 10px; }
.bl-seg-row .bl-seg { margin-top: 0; }
.bl-seg-k { font-size: 0.8em; font-weight: 700; color: var(--text-soft); }
.bl-due-hint { margin-top: 6px; }
.bl-remind-row + .bl-fine { margin-top: 6px; }

/* Variable dates */
.bl-pill.check { background: rgba(var(--brand-teal-rgb), 0.11); color: var(--brand-teal-ink); }
.bl-arrive { margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--lavender-wash); font-size: 0.87em; line-height: 1.45; }
.bl-arrive b { display: block; color: var(--text); }
.bl-arrive > span { color: var(--text-subtle); }
.bl-arrive-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 10px; align-items: center; }
.bl-arrive-row input { margin: 0; }
.bl-arrive-btn { margin: 0; padding: 11px 16px; width: auto; background: var(--btn-edit-bg); color: var(--btn-edit-text); font-size: 0.92em; }

/* Set up your bills: each bill with the properties it's on */
.bl-types-link { margin: 12px auto 0; display: flex; }
.bl-types { display: flex; flex-direction: column; gap: 10px; }
.bl-type { padding: 10px 10px 12px; border: 1px solid var(--border); border-radius: 16px; }
.bl-type-top { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.bl-type input { margin: 0; }
.bl-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0 44px; }
.bl-chip {
  width: auto; margin: 0; padding: 6px 11px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px;
  background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text-subtle);
  font-size: 0.8em; font-weight: 500; line-height: 1.2; max-width: 100%;
}
.bl-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-chip svg { width: 12px; height: 12px; flex-shrink: 0; display: none; }
.bl-chip[aria-pressed="true"] { background: rgba(var(--plum-rgb), 0.09); border-color: rgba(var(--plum-rgb), 0.45); color: var(--plum); font-weight: 600; }
.bl-chip[aria-pressed="true"] svg { display: block; }
.bl-chip:hover { filter: none; }
.bl-chip:active { transform: none; }
.bl-type-note { margin: 8px 0 0 44px; font-size: 0.78em; color: var(--text-subtle); line-height: 1.45; }

.bl-type .bl-ico { width: 34px; height: 34px; border-radius: 11px; }
.bl-type .bl-ico svg { width: 18px; height: 18px; }
.bl-type-del { width: 30px; height: 30px; }
.bl-type-del svg { width: 14px; height: 14px; }
.bl-types + .bl-link { margin: 12px 0 0; display: inline-flex; align-items: center; gap: 6px; }
.bl-types + .bl-link svg { width: 14px; height: 14px; }
.bl-big.muted { color: var(--muted); }
.bl-note .bl-save { margin-top: 10px; }

/* Reordering: press and hold a bill, then drag it */
.bl-list .bl-row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.bl-list .bl-row.pressing { transition: background-color 0.2s 0.12s; background: rgba(var(--lavender-rgb), 0.1); }
.bl-list.bl-dragging { cursor: grabbing; }
.bl-list.bl-dragging .bl-row:not(.dragging) { pointer-events: none; }
.bl-row.dragging {
  position: relative; z-index: 3; border-radius: 14px; background: var(--card-solid);
  box-shadow: 0 14px 34px var(--shadow-strong), 0 0 0 1px var(--border); transition: box-shadow 0.15s;
}
.bl-row.dragging + .bl-row { border-top-color: transparent; }
.bl-drag-hint { margin: 10px 4px 0; text-align: center; }

/* All Bills: one row per bill, with the properties it's on */
.bl-type-row > svg { width: 18px; height: 18px; color: var(--text-subtle); flex-shrink: 0; }
.bl-type-row .bl-tags { margin-top: 4px; }
