:root {
  --primary: #1A5276; --primary-dark: #154360; --success: #1E6B34; --warning: #F39C12; --danger: #E74C3C;
  --bg: #f0f4f8; --surface: #ffffff; --border: #dde3ea; --text: #1a1a1a; --text-muted: #888888;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px); --safe-right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4;
  padding-left: var(--safe-left); padding-right: var(--safe-right);
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 8px; }
.muted { color: var(--text-muted); font-size: 0.875rem; font-weight: normal; }
.center { text-align: center; }
.error { color: var(--danger); }

.app-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
  background: var(--primary); color: #fff; padding: calc(10px + var(--safe-top)) 16px 10px;
}
.app-header h1 { font-size: 1.15rem; margin: 0; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; }

.sync-banner { position: sticky; top: calc(48px + var(--safe-top)); z-index: 20; width: 100%; padding: 8px 16px; text-align: center; font-weight: 600; color: #fff; }
.sync-banner.pending { background: var(--warning); }
.sync-banner.synced { background: #27AE60; }

.tab-bar { display: flex; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--border); }
.tab { flex: 1 0 auto; background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 14px; font-size: 0.95rem; color: var(--text-muted); cursor: pointer; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-content { padding: 12px 12px calc(24px + var(--safe-bottom)); max-width: 640px; margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

label, .field { display: block; margin-bottom: 14px; font-weight: 600; font-size: 0.9rem; }
.label { display: block; margin-bottom: 6px; }
input, select, textarea {
  display: block; width: 100%; padding: 11px; margin-top: 4px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,82,118,.25); }
input[dir="rtl"], textarea[dir="rtl"] { text-align: right; }

.outcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.outcome-btn { min-height: 60px; border-radius: 10px; border: 2px solid transparent; font: inherit; font-weight: 700; color: #fff; cursor: pointer; opacity: .75; }
.outcome-btn.selected { opacity: 1; border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }
.outcome-home { background: var(--success); }
.outcome-not-home { background: var(--danger); }
.outcome-followup { background: var(--warning); color: #1a1a1a; }
.outcome-declined { background: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 8px 14px; font: inherit; cursor: pointer; }
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.toggle-group { display: flex; gap: 8px; }
.toggle { flex: 1; padding: 10px; border: 1px solid var(--border); background: #fff; border-radius: 8px; font: inherit; cursor: pointer; }
.toggle.selected { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-primary, .btn-secondary { font: inherit; font-weight: 700; border-radius: 8px; padding: 12px 18px; cursor: pointer; }
.btn-primary { width: 100%; background: var(--primary); color: #fff; border: 0; min-height: 48px; }
.btn-primary:active { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); margin: 4px 4px 0 0; }
.form-msg { color: var(--success); font-weight: 600; margin: 10px 0 0; min-height: 1.2em; }

.result-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.map { height: 65vh; border-radius: 12px; border: 1px solid var(--border); }

#signin-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.signin-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; max-width: 380px; width: 100%; text-align: center; }
.signin-card h1 { font-size: 1.3rem; color: var(--primary); }
#g-signin { display: flex; justify-content: center; margin: 16px 0; }

.settings-panel { position: fixed; top: calc(56px + var(--safe-top)); right: 12px; left: 12px; max-width: 360px; margin-left: auto; z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.2); }
