/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  background: #f4f6f8;
  color: #1a1a1a;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Login ────────────────────────────────────────────────────────────────── */
#login-screen, #newpassword-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #1a2a3a;
}

.login-card {
  background: white;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  text-align: center;
}

.login-card .logo { font-size: 40px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; font-weight: 700; color: #1a2a3a; }
.login-card .subtitle { color: #666; margin-bottom: 24px; font-size: 14px; }
.login-card .field { text-align: left; margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; margin-top: 8px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
header {
  background: #1a2a3a;
  color: white;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.logo-sm { font-size: 20px; }
.site-title { font-size: 16px; font-weight: 600; }

#main-nav { display: flex; gap: 4px; }
#main-nav button {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
#main-nav button:hover { background: rgba(255,255,255,0.1); color: white; }
#main-nav button.active { background: rgba(255,255,255,0.15); color: white; }

.header-right { display: flex; align-items: center; gap: 10px; }
#user-label { font-size: 13px; color: rgba(255,255,255,0.6); }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: white;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
}

.count-label { font-size: 13px; color: #666; margin-left: auto; }

/* ── Household list ───────────────────────────────────────────────────────── */
#household-list {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.household-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.household-card:hover { border-color: #2563eb; box-shadow: 0 2px 8px rgba(37,99,235,0.1); }

.card-name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.card-address { font-size: 13px; color: #555; }
.card-meter { font-size: 12px; color: #888; margin-top: 4px; }
.card-flags { font-size: 12px; color: #d97706; margin-top: 4px; }

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 8px;
}
.status-pending    { background: #fef3c7; color: #92400e; }
.status-clean      { background: #d1fae5; color: #065f46; }
.status-flagged    { background: #fee2e2; color: #991b1b; }
.status-no_reading { background: #f3f4f6; color: #374151; }
.status-stale      { background: #dbeafe; color: #1e40af; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  font-size: 15px;
  font-family: inherit;
  color: #1a1a1a;
  background: white;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: #2563eb; }

.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist label {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.checklist input[type="checkbox"] { width: auto; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 7px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }

.btn-secondary {
  background: white;
  color: #374151;
  border: 1px solid #d1d5db;
  border-radius: 7px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.btn-secondary:hover { background: #f9fafb; }

.btn-danger {
  background: #dc2626;
  color: white;
  border: none;
  border-radius: 7px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }

.btn-sm {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
.btn-sm:hover { background: rgba(255,255,255,0.25); }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  border-radius: 7px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.warn-msg {
  background: #fef3c7;
  color: #92400e;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  margin-top: 6px;
}
.result-box {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 7px;
  padding: 12px 16px;
  font-size: 14px;
  margin-top: 12px;
}
.result-box.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 200;
  overflow-y: auto;
  padding: 40px 16px;
}

.modal {
  background: white;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  position: relative;
}

.modal h2 { font-size: 18px; margin-bottom: 12px; }
.modal h3 { font-size: 15px; margin-bottom: 12px; color: #374151; }
.modal hr { border: none; border-top: 1px solid #e5e7eb; margin: 20px 0; }

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
  line-height: 1;
}

.modal-info {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.6;
}
.modal-info strong { display: block; font-size: 14px; margin-bottom: 4px; }

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Admin panel ──────────────────────────────────────────────────────────── */
.admin-panel {
  max-width: 600px;
  margin: 24px auto;
  padding: 0 20px;
}
.admin-panel h2 { font-size: 18px; margin-bottom: 6px; }
.admin-panel p { color: #555; font-size: 14px; margin-bottom: 14px; }
.admin-panel hr { border: none; border-top: 1px solid #e5e7eb; margin: 28px 0; }
.admin-row { display: flex; gap: 10px; align-items: center; }
.admin-row select { max-width: 160px; }
