:root {
  --primary: #0f766e;
  --primary-light: #ccfbf1;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background: var(--bg); color: var(--text); padding-bottom: 76px; }

.view { display: none; }
.view.active { display: block; }

/* Auth */
#auth-view.active { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: var(--card); padding: 28px; border-radius: 16px; width: 100%; max-width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.06); text-align: center; }
.auth-logo { width: 64px; height: 64px; margin-bottom: 12px; }
.subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 20px; }
.auth-switch { margin-top: 16px; font-size: 0.88rem; color: var(--muted); }
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }

/* Header */
.topbar { background: var(--card); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 34px; height: 34px; }
.topbar h2 { font-size: 1.05rem; }
.sync-badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.sync-badge.synced { background: #dcfce7; color: var(--success); }
.sync-badge.syncing { background: #fef3c7; color: var(--warning); }
.sync-badge.offline { background: #f1f5f9; color: var(--muted); }
.icon-btn { background: #f1f5f9; border: none; width: 36px; height: 36px; border-radius: 10px; font-size: 1.1rem; cursor: pointer; margin-left: 6px; }

/* Layout & Tabs */
.tab-content { display: none; padding: 16px; max-width: 680px; margin: 0 auto; }
.tab-content.active { display: block; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 10px; }

/* Member Avatar Strip */
.member-strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 0 12px; scrollbar-width: none; }
.member-pill { display: flex; flex-direction: column; align-items: center; min-width: 68px; cursor: pointer; opacity: 0.65; transition: 0.2s; }
.member-pill.active { opacity: 1; transform: scale(1.04); }
.member-pill img, .avatar-placeholder { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 2px solid transparent; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; }
.member-pill.active img, .member-pill.active .avatar-placeholder { border-color: var(--primary); }
.member-pill span { font-size: 0.78rem; margin-top: 4px; font-weight: 600; text-align: center; }

/* Cards & Logs */
.card, .log-card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 6px rgba(0,0,0,0.02); }
.log-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.badge { font-size: 0.72rem; padding: 3px 8px; border-radius: 6px; font-weight: 600; color: #fff; }
.status-pill { font-size: 0.72rem; padding: 3px 8px; border-radius: 99px; font-weight: 600; }
.status-ongoing { background: #fee2e2; color: var(--danger); }
.status-recovered { background: #dcfce7; color: var(--success); }
.log-title { font-size: 1rem; font-weight: 700; margin: 6px 0 4px; }
.log-meta { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.log-desc { font-size: 0.88rem; color: #334155; line-height: 1.4; }
.thumb-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumb-row img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }
.log-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }

/* Reports */
.filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px; text-align: center; }
.stat-box strong { display: block; font-size: 1.35rem; color: var(--primary); }
.stat-box span { font-size: 0.75rem; color: var(--muted); }
.bar-row { margin-top: 10px; }
.bar-label { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 4px; }
.bar-track { background: #f1f5f9; height: 8px; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; }

/* Forms & Buttons */
.form-group { margin-bottom: 12px; text-align: left; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 0.92rem; background: #fff; }
.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input[type="color"] { width: 46px; padding: 4px; height: 40px; }

.btn { border: none; border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; font-size: 0.9rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.camera-panel { margin-top: 10px; }
.camera-panel[hidden] { display: none; }
.camera-panel video { display: block; width: 100%; max-height: 320px; background: #0f172a; border-radius: 10px; object-fit: cover; }
.camera-actions { display: flex; gap: 8px; margin-top: 8px; }

.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-chip { padding: 5px 10px; border-radius: 99px; color: #fff; font-size: 0.8rem; font-weight: 600; }

/* Bottom Nav & Modals */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); display: flex; justify-content: space-around; padding: 8px 0; z-index: 30; }
.nav-item { background: none; border: none; display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 1.2rem; cursor: pointer; }
.nav-item small { font-size: 0.72rem; margin-top: 2px; font-weight: 600; }
.nav-item.active { color: var(--primary); }

.modal { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.55); z-index: 50; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal-content { background: var(--card); border-radius: 16px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; padding: 18px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.close-modal { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--muted); }

@media print {
  .topbar, .bottom-nav, .filter-bar, button { display: none !important; }
  body { background: #fff; padding: 0; }
}