:root {
  --navy: #1B2A4A;
  --navy-light: #24365c;
  --gold: #C9A84C;
  --gold-dark: #a8873a;
  --bg: #F5F5F3;
  --card: #FFFFFF;
  --text: #1C1E22;
  --muted: #6B7280;
  --border: #E4E2DC;
  --danger: #B3403A;
  --radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

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

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, #101a30 100%);
  padding: 24px;
}
.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .brand {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold-dark);
  font-weight: 700;
  margin-bottom: 4px;
}
.login-card h1 {
  font-size: 22px;
  margin: 0 0 24px 0;
  color: var(--navy);
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 16px;
}
input[type="email"], input[type="password"], input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.25);
}
button {
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.btn-primary {
  width: 100%;
  margin-top: 24px;
  background: var(--navy);
  color: #fff;
  padding: 13px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:active { background: var(--navy-light); }
.btn-primary:disabled { opacity: 0.6; }
.error-msg {
  margin-top: 14px;
  font-size: 13px;
  color: var(--danger);
  background: #FBEAE9;
  border-radius: 6px;
  padding: 8px 10px;
}

/* ---------- App shell ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.topbar .title .sub { color: var(--gold); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.app-switcher {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}
.app-switcher option { color: #000; }
.logout-btn {
  background: none;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  padding: 6px;
}

main { flex: 1; padding: 16px; padding-bottom: 90px; max-width: 720px; margin: 0 auto; width: 100%; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 20;
}
.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px 8px;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.bottom-nav a.active { color: var(--navy); }
.bottom-nav a .icon { display: block; font-size: 18px; margin-bottom: 2px; }

/* ---------- Cards / lists ---------- */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 20px 0 10px;
}
.section-title:first-child { margin-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
}
.contact-row:last-child { border-bottom: none; }
.contact-row .name { font-weight: 600; font-size: 14.5px; }
.contact-row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.score-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  background: #EFE7D2;
  border-radius: 20px;
  padding: 3px 10px;
  min-width: 30px;
  text-align: center;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar input { flex: 1; }
.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 2px;
}
.chip {
  flex-shrink: 0;
  padding: 6px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- Contact detail ---------- */
.detail-header {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 18px;
}
.detail-header .name { font-size: 19px; font-weight: 700; color: var(--navy); }
.detail-header .row { font-size: 13px; color: var(--muted); margin-top: 4px; }
.detail-header .score-big {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  background: #EFE7D2;
  border-radius: 20px;
  padding: 4px 12px;
}
.timeline-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item .ev-type { font-weight: 600; font-size: 13.5px; }
.timeline-item .ev-time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-state .big { font-size: 34px; margin-bottom: 8px; }
.empty-state p { font-size: 13.5px; margin: 4px 0; }

.loading { text-align: center; padding: 40px; color: var(--muted); font-size: 13.5px; }

.more-sheet {
  position: fixed;
  bottom: 58px;
  right: 12px;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  z-index: 25;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  overflow: hidden;
}
.more-sheet.hidden { display: none; }
.more-sheet a {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.more-sheet a:last-child { border-bottom: none; }
.more-sheet a:active { background: var(--bg); }

a { color: var(--navy); }
back-link { display: inline-block; margin-bottom: 14px; font-size: 13px; color: var(--muted); text-decoration: none; }
