:root {
  --green: #1f6f43;
  --green-dark: #16532f;
  --green-light: #e8f5ee;
  --red: #c0392b;
  --gray-bg: #f4f6f5;
  --text: #1c2321;
  --text-muted: #667370;
  --border: #dde3e0;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 40, 30, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select {
  font-family: inherit;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.loading-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */

.login-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--green-dark), var(--green) 60%);
  color: white;
  min-height: 100vh;
}
.login-logo {
  font-size: 44px;
  margin-bottom: 4px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 32px 0;
  letter-spacing: 0.3px;
}
.pin-dots {
  display: flex;
  gap: 14px;
  margin-bottom: 28px;
  min-height: 18px;
}
.pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.8);
  background: transparent;
  transition: background 0.1s;
}
.pin-dot.filled { background: white; }

.pin-error {
  color: #ffd7d0;
  background: rgba(192,57,43,0.35);
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  min-height: 18px;
  text-align: center;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 14px;
}
.key {
  width: 76px; height: 76px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.12);
  color: white;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.key:active { background: rgba(255,255,255,0.3); }
.key.empty { visibility: hidden; }
.key.wide-text { font-size: 15px; }

.login-submit {
  margin-top: 24px;
  background: white;
  color: var(--green-dark);
  border: none;
  border-radius: 999px;
  padding: 14px 40px;
  font-size: 16px;
  font-weight: 700;
}
.login-submit:disabled { opacity: 0.5; }

/* ---------- App shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--green);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar-user { font-size: 13px; opacity: 0.9; }
.icon-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  padding: 6px;
}

.content {
  flex: 1;
  padding: 16px 16px 90px 16px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)) 4px;
  z-index: 10;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  color: var(--text-muted);
  font-size: 11px;
  border-radius: 10px;
}
.nav-btn .nav-icon { font-size: 20px; }
.nav-btn.active { color: var(--green); background: var(--green-light); }

/* ---------- Cards / forms ---------- */

.card {
  background: white;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

h2.section-title {
  font-size: 18px;
  margin: 4px 0 16px 0;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px 0;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: white;
  color: var(--text);
}
textarea { resize: vertical; min-height: 60px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--green);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
  margin-top: 18px;
}
.btn:disabled { opacity: 0.5; }
.btn.secondary {
  background: var(--green-light);
  color: var(--green-dark);
}
.btn.danger {
  background: #fbeceb;
  color: var(--red);
}
.btn.small {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
  margin-top: 0;
}
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { margin-top: 0; }

.msg { font-size: 14px; margin-top: 10px; min-height: 18px; }
.msg.error { color: var(--red); }
.msg.success { color: var(--green-dark); }

/* ---------- Lists ---------- */

.report-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.report-item:last-child { border-bottom: none; }
.report-main { flex: 1; min-width: 0; }
.report-area { font-weight: 700; font-size: 15px; }
.report-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.report-note { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-style: italic; }
.report-hours {
  font-weight: 700;
  font-size: 16px;
  color: var(--green-dark);
  white-space: nowrap;
}
.report-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  padding: 0 0 0 8px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 30px 10px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.summary-row:last-child { border-bottom: none; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.pill.admin { background: var(--green-light); color: var(--green-dark); }
.pill.inactive { background: #f1f1f1; color: var(--text-muted); }

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.list-row:last-child { border-bottom: none; }
.list-row-main { min-width: 0; }
.list-row-title { font-weight: 700; font-size: 15px; }
.list-row-sub { font-size: 12px; color: var(--text-muted); }

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20,30,25,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal {
  background: white;
  border-radius: 18px 18px 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; }
}

.link-btn {
  background: none;
  border: none;
  color: var(--green-dark);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 0;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-size: 14px; color: var(--text); }
