:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --accent: #2563eb;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

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

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding-bottom: 76px;
}

#app.wide { max-width: 1100px; padding-bottom: 24px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: 0.85; }
.topbar button.link { background: none; border: none; color: white; font-size: 13px; text-decoration: underline; padding: 0; }

.screen { padding: 16px; display: none; flex: 1; }
.screen.active { display: block; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--primary-dark); }
.card h3 { font-size: 13px; margin: 0 0 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-tile { background: var(--primary-light); border-radius: 10px; padding: 10px; text-align: center; }
.stat-tile .num { font-size: 20px; font-weight: 700; color: var(--primary-dark); }
.stat-tile .label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; color: var(--text); }
label .opt { font-weight: 400; color: var(--text-muted); }
input[type=text], input[type=date], input[type=time], input[type=number], input[type=email],
input[type=password], select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 13px 16px; border-radius: 10px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 14px;
  background: var(--primary); color: white;
}
.btn:active { background: var(--primary-dark); }
.btn.secondary { background: var(--surface); color: var(--primary-dark); border: 1px solid var(--primary); }
.btn.ghost { background: transparent; color: var(--accent); border: 1px dashed var(--border); }
.btn.small { width: auto; padding: 8px 14px; font-size: 13px; margin-top: 0; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; }

.chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); font-size: 13px; cursor: pointer; user-select: none;
}
.chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.tri-toggle { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); margin-top: 6px; }
.tri-toggle .opt { flex: 1; text-align: center; padding: 10px; font-size: 13px; cursor: pointer; background: var(--surface); }
.tri-toggle .opt.active-yes { background: var(--success); color: white; }
.tri-toggle .opt.active-neutral { background: var(--warning); color: white; }
.tri-toggle .opt.active-no { background: var(--danger); color: white; }

.photo-capture {
  border: 2px dashed var(--border); border-radius: 12px; padding: 14px; text-align: center;
  margin-top: 6px; background: #fafafa;
}
.photo-capture img { max-width: 100%; border-radius: 8px; margin-top: 8px; }
.photo-capture .geo { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.photo-capture input[type=file] { display: none; }

.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--surface); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; padding: 8px 4px 10px;
}
.bottom-nav button {
  background: none; border: none; font-size: 11px; color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; flex: 1;
}
.bottom-nav button.active { color: var(--primary); font-weight: 700; }
.bottom-nav .icon { font-size: 19px; }

.list-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .name { font-weight: 600; font-size: 14px; }
.list-item .meta { font-size: 12px; color: var(--text-muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.yes { background: #dcfce7; color: var(--success); }
.badge.neutral { background: #fef3c7; color: var(--warning); }
.badge.no { background: #fee2e2; color: var(--danger); }

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

.toast {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 100; box-shadow: var(--shadow); max-width: 90%; text-align: center;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.hidden { display: none !important; }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); }
table.data-table th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .stat-grid { grid-template-columns: repeat(2, 1fr) !important; } }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { max-width: 380px; width: 100%; }
.login-card .logo { text-align: center; font-size: 30px; margin-bottom: 4px; }
.login-card h1 { text-align: center; font-size: 19px; margin: 0 0 4px; }
.login-card p.sub { text-align: center; color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

a.plain { color: var(--accent); text-decoration: none; }
.mr-select-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.mr-select-row select { flex: 1; }
