/* Large, high-contrast and simple: easy to read and click. */
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1d2733;
  --muted: #5d6b7a;
  --border: #d5dbe1;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok: #1a7f37;
}

* { box-sizing: border-box; }

/* Make sure hidden things stay hidden, even when a style sets "display". */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 "Segoe UI", system-ui, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.5rem; }
.version { font-size: 0.8rem; font-weight: normal; color: var(--muted); }
h2 { margin-top: 0; }
h3 { margin: 24px 0 8px; }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

button {
  font: inherit;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.big { padding: 14px 24px; font-size: 1.1rem; }
button.small, button.delete { font-size: 0.9rem; padding: 4px 10px; }
button.delete { color: var(--danger); }

.button-row { display: flex; flex-wrap: wrap; gap: 12px; }

label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }

input, select {
  font: inherit;
  font-weight: normal;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.inline-form label { flex: 1 1 260px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 16px;
  margin-bottom: 8px;
}

/* Property tabs along the top of the bills card. */
.card.tabbed { padding: 0; overflow: hidden; }
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 12px 16px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.tabs button {
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 20px;
  font-weight: 600;
  margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  border-top: 3px solid var(--accent);
}
.tab-body { padding: 20px 24px; overflow-x: auto; }  /* wide tables scroll instead of being cut off */
#monthly-total { margin-top: -8px; }
#show-bill-form { margin-top: 16px; }

details.card summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.card[open] summary { margin-bottom: 12px; color: var(--text); }
.item-actions { display: flex; gap: 8px; }

.item-list { list-style: none; padding: 0; margin: 0 0 16px; }
.item-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 0.9rem; }
td.amount { white-space: nowrap; }

.muted, .hint { color: var(--muted); }
.hint { font-size: 0.9rem; }

#save-status { font-size: 0.95rem; color: var(--ok); }
#save-status.error { color: var(--danger); font-weight: 600; }

@media (max-width: 640px) {
  header { padding: 12px 16px; }
  .card { padding: 16px; }
  .tab-body { padding: 16px; }
  table { font-size: 0.9rem; }
}

/* Bills table: row being edited, and the Edit / Remove buttons. */
tr.editing td { background: #eef4ff; }
td.row-actions { white-space: nowrap; text-align: right; }
td.row-actions button + button { margin-left: 6px; }
#backup-button { margin-bottom: 8px; }

/* Screen switch: Bills / Monthly. */
.view-switch { display: flex; gap: 12px; margin-bottom: 16px; }
.view-button {
  flex: 1 1 0;
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
}
.view-button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: #fff4e5;
  color: #8a4b00;
  font-size: 0.9rem;
}

/* Monthly screen. */
.month-nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.month-nav h2 { margin: 0; min-width: 10ch; text-align: center; }
.month-nav button { font-size: 1.1rem; }
.month-nav button.small { font-size: 0.9rem; }
.month-summary { font-weight: 600; margin: 0 0 12px; }
.overdue-elsewhere { background: #fff4e5; color: #8a4b00; padding: 8px 12px; border-radius: 8px; }
.overdue-elsewhere button { margin: 2px 0; }

td.status { white-space: nowrap; }
tr.status-cleared td.status { color: var(--ok); }
tr.status-scheduled td.status { color: var(--accent); }
tr.status-overdue td { background: #fff4e5; }
tr.status-overdue td.status { color: #8a4b00; font-weight: 600; }
tr.status-open td.status { color: var(--muted); }

tr.payment-form-row td { background: #eef4ff; }
.payment-form-row .inline-form label { flex: 0 1 200px; }
.payment-form-title { flex-basis: 100%; }
button.small.primary { color: var(--accent-text); }

/* Keep short values on one line so rows stay compact. */
#month-table td:first-child, td.amount { white-space: nowrap; }

/* View by: Property / Pay method (Monthly screen). */
.group-switch { display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; flex-wrap: wrap; }
.group-switch span { color: var(--muted); font-weight: 600; }
.group-switch button[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--card); }

/* Bill notes: small grey line under the bill's name. */
.notes { font-size: 0.85rem; color: var(--muted); }
label.wide { grid-column: 1 / -1; }

/* "All pay methods" totals table. */
#method-summary-table tbody tr.clickable { cursor: pointer; }
#method-summary-table tbody tr.clickable:hover td { background: #eef4ff; }
#method-summary-table tbody tr td:first-child { color: var(--accent); font-weight: 600; }
#method-summary-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
td.unpaid-count { color: #8a4b00; font-weight: 600; }
tr.status-auto td.status { color: var(--accent); }

/* One-off expense form and stopped bills. */
#show-expense-form { margin-top: 16px; }
label.checkbox { flex-direction: row; align-items: center; gap: 8px; font-weight: normal; align-self: end; padding-bottom: 10px; }
label.checkbox input { width: 20px; height: 20px; }
.stopped-bills { margin-top: 24px; }
.stopped-bills summary { cursor: pointer; font-weight: 600; color: var(--muted); }
#exp-delete { margin-left: auto; }
