* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f5f7f8;
  color: #1a2327;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.hidden {
  display: none !important;
}

.subtle {
  color: #5b6b70;
  margin: 0.15rem 0 0;
}

.error {
  color: #b3261e;
  background: #fdecea;
  border: 1px solid #f2c1bd;
  padding: 0.75rem 1rem;
  border-radius: 8px;
}

.portal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.portal-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: #38474c;
}

.usage-compare {
  display: flex;
  gap: 2rem;
  margin: 0.75rem 0 1rem;
}

.usage-compare .label {
  display: block;
  font-size: 0.8rem;
  color: #5b6b70;
}

.usage-compare .big {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
}

.btn {
  background: #2f7d6b;
  color: #fff;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn:hover {
  background: #256054;
}

.due-summary {
  display: flex;
  gap: 2rem;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  background: #f2f6f5;
  border-radius: 8px;
}

.due-summary .label {
  display: block;
  font-size: 0.8rem;
  color: #5b6b70;
}

.due-summary .big {
  display: block;
  font-size: 1.3rem;
  font-weight: 600;
}

.due-summary .amount {
  color: #2f7d6b;
}

.breakdown {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 0.5rem;
  margin: 0;
}

.breakdown dt {
  color: #5b6b70;
}

.rate-note {
  display: block;
  font-size: 0.75rem;
  color: #8a9598;
  font-weight: 400;
}

.inline-link {
  background: none;
  border: none;
  color: #2f7d6b;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
}

.breakdown dd {
  margin: 0;
  text-align: right;
}

.breakdown .total {
  font-weight: 700;
  font-size: 1.1rem;
  border-top: 1px solid #e2e6e7;
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-paid {
  background: #e3f5e9;
  color: #1e7b43;
}

.badge-pending {
  background: #fff4de;
  color: #9a6700;
}

.badge-overdue {
  background: #fdecea;
  color: #b3261e;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  text-align: left;
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid #eef1f1;
}

.link-btn {
  background: none;
  border: none;
  color: #2f7d6b;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
}

/* In-page modal — used for both the Manila Water bill PDF and meter photos,
   deliberately never a new tab. */
.mw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 22, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}

.mw-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  position: relative;
  padding: 2.5rem 1rem 1rem;
  display: flex;
}

.mw-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #5b6b70;
}

.mw-modal-body {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mw-modal-pdf {
  width: 100%;
  height: 75vh;
  border: none;
}

.mw-modal-image {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 6px;
}

.mw-modal-html {
  display: block;
  text-align: left;
  max-height: 75vh;
  overflow-y: auto;
}

.pay-instructions h3 {
  margin-top: 0;
}

.pay-instructions .placeholder-note {
  color: #9a6700;
  background: #fff4de;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.pay-instructions ul {
  padding-left: 1.2rem;
}

/* Admin dashboard */
.admin-main {
  max-width: 960px;
}

.btn-secondary {
  background: #e2e6e7;
  color: #38474c;
}

.btn-secondary:hover {
  background: #d0d6d7;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1.5rem;
  align-items: end;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: #38474c;
}

.admin-form input,
.admin-form select {
  padding: 0.45rem 0.5rem;
  border: 1px solid #d0d6d7;
  border-radius: 6px;
  font-size: 0.9rem;
}

.admin-form button {
  grid-column: 1 / -1;
  justify-self: start;
}

.form-status {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: #5b6b70;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#login-form input {
  padding: 0.5rem;
  border: 1px solid #d0d6d7;
  border-radius: 6px;
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.portal-link {
  font-size: 0.75rem;
  color: #5b6b70;
  max-width: 160px;
  overflow-wrap: break-word;
}
