/* ===== Base (same palette and look as before) ===== */
:root {
  --ink: #1f2937; --muted: #6b7280; --bg: #f4f6f8; --line: #e5e7eb; --field: #cbd5e1;
  --soft: #f8fafc; --ok: #166534; --bad: #991b1b;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--ink); }
[hidden] { display: none !important; }
h2, h3 { margin-top: 0; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.small { font-size: 13px; margin: 8px 0 0; }
.app { max-width: 1100px; margin: 0 auto; min-height: 100vh; }

/* ===== Form fields ===== */
input, select, textarea { font: inherit; font-size: 15px; background: #fff; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  padding: 11px 12px; border: 1px solid var(--field); border-radius: 7px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(31, 41, 55, .08); }
textarea { line-height: 1.5; resize: vertical; min-height: 160px; }
label { display: block; font-weight: 600; font-size: 14px; color: #374151; margin: 16px 0 7px; }
.full { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; margin: 18px 0; font-weight: normal; color: var(--ink); }

/* ===== Buttons ===== */
.btn { background: var(--ink); color: #fff; border: 0; border-radius: 7px; padding: 12px 20px; font-size: 15px; font-weight: bold; cursor: pointer; }
.btn:hover:not(:disabled) { opacity: .9; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--field); border-radius: 7px; padding: 11px 20px; font-size: 14px; font-weight: bold; cursor: pointer; margin-top: 10px; }
.btn-outline:hover { background: var(--soft); }
.link-btn { border: 0; background: none; color: var(--ink); font-size: 14px; font-weight: bold; cursor: pointer; padding: 8px; margin-top: 8px; }
.link-btn:hover { text-decoration: underline; }
.msg { margin-top: 12px; font-size: 14px; min-height: 20px; color: var(--ok); }
.msg.error { color: var(--bad); }

/* ===== Sign in card ===== */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.auth-card { width: 100%; max-width: 430px; background: #fff; border-radius: 14px; padding: 40px; box-shadow: 0 8px 30px rgba(0, 0, 0, .1); text-align: center; }
.auth-card h1 { margin: 0; font-size: 28px; }
.auth-card h1 + .muted { margin: 7px 0 0; }
.auth-card h2 { margin: 0 0 8px; font-size: 21px; }
.auth-card label { text-align: left; margin-top: 0; }
.auth-card input { width: 100%; margin-bottom: 17px; }
.auth-icon { width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: bold; }
.auth-divider { width: 50px; height: 3px; background: var(--ink); border-radius: 3px; margin: 25px auto; }
.auth-alt { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
/* show only the pieces for the current mode */
.auth[data-mode=signin] [data-for]:not([data-for~=signin]),
.auth[data-mode=signup] [data-for]:not([data-for~=signup]),
.auth[data-mode=reset] [data-for]:not([data-for~=reset]),
.auth[data-mode=newpass] [data-for]:not([data-for~=newpass]) { display: none; }

/* ===== Header and navigation ===== */
.topbar { background: var(--ink); color: #fff; padding: 24px 30px; padding-top: max(24px, env(safe-area-inset-top)); position: relative; }
.topbar h1 { margin: 0; font-size: 28px; }
.topbar p { margin: 5px 0 0; opacity: .75; }
.user-bar { position: absolute; right: 30px; top: 24px; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.logout-btn { border: 1px solid rgba(255, 255, 255, .35); background: none; color: #fff; padding: 7px 12px; border-radius: 6px; cursor: pointer; }
.logout-btn:hover { background: rgba(255, 255, 255, .1); }
.nav { display: flex; gap: 5px; background: #fff; padding: 10px 20px; border-bottom: 1px solid #ddd; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-btn { flex: 0 0 auto; border: 0; background: none; padding: 12px 18px; border-radius: 6px; cursor: pointer; font-size: 15px; color: var(--ink); white-space: nowrap; }
.nav-btn:hover { background: #f0f2f4; }
.nav-btn.active { background: var(--line); font-weight: bold; }
main { padding: 25px; padding-bottom: max(25px, env(safe-area-inset-bottom)); }
.page { display: none; }
.page.active { display: block; }
.narrow { max-width: 850px; margin: 0 auto; }

/* ===== Cards, dashboard, tables ===== */
.card { background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0, 0, 0, .08); padding: 22px; margin-bottom: 20px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 20px; }
.summary { margin: 0; }
.summary span { display: block; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.summary strong { font-size: 28px; }
.chart { position: relative; height: 320px; margin-top: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--soft); }
.underline::after { content: ""; display: block; width: 42px; height: 3px; margin-top: 12px; background: var(--ink); border-radius: 3px; }

/* ===== Check-in ===== */
.date-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.date-row label { margin: 0; }
.note { margin: 10px 0 20px; padding: 12px 15px; border-radius: 6px; font-size: 14px; line-height: 1.5; }
.note:empty { display: none; }
.note.info { background: #eff6ff; color: #1e40af; }
.note.auto { background: #f0fdf4; color: var(--ok); }
.row { border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; gap: 15px; font-weight: 600; }
.yesno { display: flex; gap: 8px; }
.yesno button { width: 64px; height: 45px; border: 1px solid #bbb; background: #fff; border-radius: 6px; cursor: pointer; font-size: 17px; font-weight: bold; color: var(--ink); touch-action: manipulation; }
.yesno button:not(.on):not(:disabled):hover { background: #f0f2f4; }
.yesno button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.yesno button:disabled { cursor: not-allowed; opacity: .55; }
.total-box { margin: 25px 0; padding: 18px; background: #f1f5f9; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.total-box strong { font-size: 24px; }

/* ===== Category setup ===== */
.setup { border: 1px solid #ddd; border-radius: 8px; padding: 18px; margin-bottom: 15px; background: #fff; }
.setup input[type=text] { width: 100%; margin-bottom: 15px; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.score-grid > div { background: var(--soft); padding: 15px; border-radius: 6px; }
.score-grid b { display: block; margin-bottom: 10px; }
.score-grid label { display: inline-flex; gap: 6px; margin: 0 15px 0 0; font-weight: normal; }
.opposite { font-size: 18px; font-weight: bold; }

/* ===== Accountability people ===== */
#people { display: grid; gap: 18px; margin: 20px 0; }
.person { border: 1px solid #d7e0ea; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0, 0, 0, .06); }
.person-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: var(--soft); border-bottom: 1px solid var(--line); font-weight: bold; font-size: 17px; }
.person-head span { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.person-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; padding: 4px 18px 18px; }
.person-grid input, .person-grid select { width: 100%; }
.hint { margin-top: 7px; font-size: 12.5px; line-height: 1.45; color: #64748b; }

/* ===== Contact ===== */
#contactImages { width: 100%; padding: 14px; border: 1px dashed #b8c1cc; border-radius: 8px; background: var(--soft); cursor: pointer; font-size: 14px; }

/* ===== Phones ===== */
@media (max-width: 700px) {
  main { padding: 14px; }
  .topbar { padding: 18px 16px; padding-top: max(18px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 22px; }
  .topbar p { font-size: 13px; }
  .user-bar { position: static; margin-top: 14px; justify-content: space-between; }
  #userEmail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logout-btn { flex-shrink: 0; min-height: 42px; }
  .nav { padding: 7px 8px; gap: 4px; }
  .nav-btn { min-height: 44px; padding: 10px 13px; font-size: 14px; }
  .card { padding: 18px 15px; margin-bottom: 15px; }
  h2 { font-size: 22px; }
  .summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .chart { height: 240px; }
  .date-row, .row { flex-direction: column; align-items: stretch; }
  .yesno button { flex: 1; height: 50px; }
  .score-grid, .person-grid { grid-template-columns: 1fr; }
  .btn-wide { width: 100%; min-height: 48px; }
  input, select, textarea { font-size: 16px; } /* stops iPhone from zooming in */
  table { min-width: 420px; }
  .auth { padding: 18px 14px; }
  .auth-card { padding: 26px 19px; }
}
