/* CAU Site Tracker — styles */
:root {
  --red: #c62828;
  --red-dark: #8e0000;
  --amber: #f59e0b;
  --green: #2e7d32;
  --blue: #1565c0;
  --ink: #1a1d21;
  --muted: #6b7280;
  --bg: #f2f4f8;
  --card: #ffffff;
  --line: #e3e7ee;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ---------- auth screen ---------- */
#authScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(150deg, #1c2947, #2d4a7a 60%, #3563a8);
}
.auth-card {
  background: var(--card); border-radius: 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  padding: 44px 52px; text-align: center; max-width: 400px; width: 100%;
}
.auth-logo { height: 80px; object-fit: contain; max-width: 100%; }
.auth-card h1 { font-size: 1.35rem; margin: 18px 0 6px; color: #18223a; }
.auth-card p { color: var(--muted); margin: 0 0 24px; font-size: .95rem; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border: none; border-radius: 9px; background: #2E75B6; color: #fff;
  padding: 12px 22px; font-weight: 600; font-size: 1rem;
}
.google-btn:hover { background: #266199; }
.g-badge {
  background: #fff; color: #2E75B6; border-radius: 50%; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .85rem;
}
.auth-error { color: var(--red); margin-top: 16px; font-size: .9rem; }
.auth-request h2 { margin: 18px 0 6px; font-size: 1.1rem; color: #18223a; }
.auth-request p { margin: 0 0 10px; }
.auth-request .btn { margin-top: 8px; }

/* ---------- header ---------- */
header.app-header {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 10px 22px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 900;
}
header.app-header .title { font-weight: 800; font-size: 1.05rem; }
.header-logo { height: 34px; object-fit: contain; }
header .spacer { flex: 1; }
header .user-chip { color: var(--muted); font-size: .85rem; }
.mode-banner {
  background: #fff7e6; border: 1px solid #ffd591; color: #ad6800;
  border-radius: 8px; padding: 6px 12px; font-size: .82rem;
}
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 14px; font-weight: 600; color: var(--ink);
}
.btn:hover { background: #f5f6f8; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.subtle { border: none; background: transparent; color: var(--muted); }
.btn.small { padding: 4px 10px; font-size: .82rem; }
.btn.danger { color: var(--red); }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 20px 22px 80px; }
section.panel {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.panel h2 .toggle { margin-left: auto; }

/* ---------- summary strip ---------- */
.summary-strip { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  flex: 1; min-width: 150px; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; border-left: 5px solid var(--line);
}
.stat .num { font-size: 1.7rem; font-weight: 800; }
.stat .lbl { color: var(--muted); font-size: .82rem; }
.stat.clickable { cursor: pointer; transition: box-shadow .12s, transform .12s; }
.stat.clickable:hover { box-shadow: 0 4px 12px rgba(16, 24, 40, .14); transform: translateY(-1px); }
.stat.overdue { border-left-color: var(--red); }
.stat.duesoon { border-left-color: var(--amber); }
.stat.current { border-left-color: var(--green); }
.stat.sites   { border-left-color: var(--blue); }

/* ---------- map ---------- */
#overviewMap { height: 380px; border-radius: 8px; }
#groundRiskMap { height: 560px; border-radius: 8px; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: .82rem; color: var(--muted); }
.map-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filters label { display: block; font-size: .78rem; color: var(--muted); margin-bottom: 3px; font-weight: 600; }
.filters select, .filters input {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 160px; background: #fff;
}

/* ---------- site cards ---------- */
.site-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 14px; overflow: hidden;
}
.site-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px; cursor: pointer;
  border-left: 5px solid var(--line);
}
.site-head.status-overdue { border-left-color: var(--red); }
.site-head.status-duesoon { border-left-color: var(--amber); }
.site-head.status-current { border-left-color: var(--green); }
.site-head .chev { color: var(--muted); transition: transform .15s; }
.site-card.open .chev { transform: rotate(90deg); }
.site-head .s-name { font-weight: 700; }
.site-head .s-addr { color: var(--muted); font-size: .84rem; }
.site-head .spacer { flex: 1; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}
.badge.overdue { background: #fdecea; color: var(--red); }
.badge.duesoon { background: #fff4e0; color: #b45309; }
.badge.current { background: #e8f5e9; color: var(--green); }
.badge.neutral { background: #eef1f5; color: var(--muted); }
.site-body { border-top: 1px solid var(--line); padding: 14px 18px; display: none; }
.site-card.open .site-body { display: block; }
.site-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------- tasks table ---------- */
table.tasks { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.tasks th {
  text-align: left; color: var(--muted); font-size: .74rem; text-transform: uppercase;
  letter-spacing: .04em; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
table.tasks td { padding: 8px; border-bottom: 1px solid #f0f2f6; vertical-align: top; }
table.tasks tr:last-child td { border-bottom: none; }
.t-name { font-weight: 600; }
.t-meta { color: var(--muted); font-size: .78rem; }
.t-ref { color: var(--blue); font-size: .76rem; }
.pill { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; display: inline-block; }
.pill.overdue { background: #fdecea; color: var(--red); }
.pill.duesoon { background: #fff4e0; color: #b45309; }
.pill.current { background: #e8f5e9; color: var(--green); }
.pill.none { background: #eef1f5; color: var(--muted); }
.faa { color: var(--green); font-size: .78rem; font-weight: 600; }
td .btn { margin: 1px 2px 1px 0; }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 12px; padding: 22px 24px; width: 100%; max-width: 560px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal.wide { max-width: 1080px; }
.modal h3 { margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.hint { font-size: .78rem; color: var(--muted); }

/* ---------- history list ---------- */
.hist-list { max-height: 260px; overflow: auto; margin: 0; padding-left: 18px; }
.hist-list li { margin-bottom: 6px; font-size: .86rem; }

/* ---------- ground risk ---------- */
.gr-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.gr-layers {
  columns: 2; font-size: .84rem; margin-top: 10px;
}
.gr-layers label { display: flex; gap: 6px; align-items: center; break-inside: avoid; padding: 2px 0; }
.gr-info { font-size: .84rem; color: var(--muted); margin-bottom: 8px; }
.gr-measure-out { font-weight: 700; color: var(--blue); font-size: .88rem; margin-left: 6px; }

/* ---------- emails ---------- */
.email-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.email-chips .chip {
  background: #eef1f5; border-radius: 16px; padding: 3px 10px; font-size: .78rem;
}
.email-chips .chip button { border: none; background: none; color: var(--muted); padding: 0 0 0 4px; }

/* ---------- admin ---------- */
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f0f2f6; }
.user-row .em { flex: 1; }

.empty-note { color: var(--muted); font-style: italic; padding: 8px 0; }

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .gr-layers { columns: 1; }
  header.app-header { flex-wrap: wrap; }
}
