:root {
  --navy: #003573;
  --navy-dark: #00224a;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1e21;
  --text-muted: #6b7280;
  --border: #e2e5ea;
  --danger-bg: #fdecea;
  --danger-text: #b3261e;
  --success-bg: #eaf6ec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Optima', 'Candara', 'Calibri', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-shell {
  max-width: 380px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--card);
  box-shadow: 0 0 0 1px var(--border);
}

.dashboard-shell {
  max-width: 720px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.screen { padding: 28px 22px; }
.hidden { display: none !important; }

@media (max-width: 480px) {
  .screen { padding: 22px 16px; }
  .dashboard-shell .topbar { font-size: 15px; padding: 12px 16px; }
}

h1, h2, h3 { margin: 0; font-weight: 600; }

label {
  display: block;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}

input:focus, select:focus { outline: 2px solid var(--navy); outline-offset: 1px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-text { background: transparent; color: var(--text-muted); font-weight: 400; font-size: 14px; }
.btn-small { padding: 8px 12px; font-size: 14px; width: auto; }

.pin-input { text-align: center; font-size: 22px; letter-spacing: 8px; }

.field { margin-bottom: 16px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  padding: 9px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 14px;
  cursor: pointer;
}
.chip.selected { background: var(--navy); color: #fff; border-color: var(--navy); }

.status-card {
  background: var(--bg);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.error-msg { color: var(--danger-text); font-size: 14px; margin: 8px 0 0; }

.metric-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.metric-card { background: var(--bg); border-radius: 10px; padding: 14px 16px; }
.metric-label { font-size: 13px; color: var(--text-muted); margin: 0 0 4px; }
.metric-value { font-size: 26px; font-weight: 600; margin: 0; }
.metric-danger { color: var(--danger-text); }

.tab-row { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn { flex: 1; padding: 10px 6px; border-radius: 8px; border: 1px solid var(--border); background: #fff; font-size: 14px; cursor: pointer; }
.tab-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.entry-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.entry-top { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #e6f1fb; color: var(--navy); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; }
.entry-name { font-size: 16px; font-weight: 600; margin: 0; }
.entry-dest { font-size: 14px; color: var(--text-muted); margin: 2px 0 0; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 6px; white-space: nowrap; }
.badge-overdue { background: var(--danger-bg); color: var(--danger-text); }
.badge-ontime { background: var(--bg); color: var(--text-muted); }
.entry-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; font-size: 14px; color: var(--text-muted); margin-top: 10px; }
.contact-icons a { color: var(--navy); margin-left: 12px; text-decoration: none; font-weight: 600; }

.search-box { margin-bottom: 14px; }

.history-row { display: flex; flex-wrap: wrap; justify-content: space-between; font-size: 15px; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 8px; }
.history-meta { color: var(--text-muted); white-space: nowrap; font-size: 14px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-card { background: #fff; border-radius: 12px; padding: 22px; width: 100%; max-width: 320px; }

.roster-item { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 15px; }
.pin-pill { background: var(--success-bg); color: var(--navy); font-weight: 600; padding: 3px 9px; border-radius: 6px; font-size: 13px; }
