/* PSC One iPhone. Colours from the PSC One desktop design system (logo red
   #E31E24, charcoal #2B2A29, warm greys), laid out the way iPhone apps are:
   large titles, inset lists, a tab bar at the bottom. */
:root {
  --bg: #F6F5F3; --surface: #FFFFFF; --surface2: #F1EFEC; --border: #E3E0DC; --border2: #D3CFCA;
  --text: #2B2A29; --text2: #5F5C58; --text3: #8C8884;
  --brand: #E31E24; --primary: #2B2A29; --on-primary: #FFFFFF;
  --green: #1E7F46; --green-bg: #E5F3EA; --amber: #9A5B00; --amber-bg: #FFF1DC;
  --red: #C4161C; --red-bg: #FDECEC; --blue: #245FA0; --blue-bg: #E7EFF9;
  --bar-bg: rgba(246, 245, 243, .86); --tab-bg: rgba(255, 255, 255, .9);
  --cal-abs: #EDE9E4; --cal-sun: #F6F5F3;
  --r: 14px; --tabs-h: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110; --surface: #1E1D1C; --surface2: #292827; --border: #33312F; --border2: #45423F;
    --text: #F2F0ED; --text2: #BDB8B2; --text3: #8E8984;
    --primary: #F2F0ED; --on-primary: #1E1D1C;
    --green: #5BC98A; --green-bg: #15301F; --amber: #E9AB4E; --amber-bg: #33260F;
    --red: #FF7070; --red-bg: #3A1818; --blue: #86B4F0; --blue-bg: #16263A;
    --bar-bg: rgba(18, 17, 16, .86); --tab-bg: rgba(30, 29, 28, .9);
    --cal-abs: #2E2C2A; --cal-sun: #1A1918;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  min-height: 100vh; min-height: 100dvh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--text2); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Frame ─────────────────────────────────────────────────────────── */
.view { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 24px); }
.bar {
  position: sticky; top: 0; z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: var(--bar-bg); -webkit-backdrop-filter: saturate(1.8) blur(18px); backdrop-filter: saturate(1.8) blur(18px);
  border-bottom: .5px solid transparent;
}
.bar-in {
  height: 48px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left));
}
.bar-title { font-weight: 600; font-size: 17px; opacity: 0; transition: opacity .15s; max-width: 58vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title.show { opacity: 1; }
.bar .icon-btn { justify-self: end; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--brand); font-size: 17px; min-height: 44px; padding-right: 8px; justify-self: start; }
.back .ic { width: 24px; height: 24px; stroke-width: 2.2; }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border: 0; background: none; border-radius: 22px;
  color: var(--brand); cursor: pointer;
}
.icon-btn:disabled { color: var(--text3); opacity: .45; }
.icon-btn:active { background: var(--surface2); }
.big { padding: 4px 20px 12px; }
.big h1 { font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -.02em; }
.big .sub { color: var(--text2); margin-top: 4px; font-size: 15px; }
.content { padding: 0 16px; }

/* ── Tab bar ───────────────────────────────────────────────────────── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 4px max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
  background: var(--tab-bg); -webkit-backdrop-filter: saturate(1.8) blur(18px); backdrop-filter: saturate(1.8) blur(18px);
  border-top: .5px solid var(--border2);
}
.tab {
  flex: 1; max-width: 120px; height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text3); font-size: 11px; font-weight: 500;
}
.tab .ic { width: 25px; height: 25px; }
.tab.on { color: var(--brand); }

/* ── Lists ─────────────────────────────────────────────────────────── */
.list { background: var(--surface); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; box-shadow: 0 0 0 .5px var(--border); }
.list.inset { margin-top: 4px; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 9px 12px 9px 14px; position: relative;
  width: 100%; border: 0; background: none; text-align: left; cursor: default;
}
a.row, button.row { cursor: pointer; }
a.row:active, button.row:active { background: var(--surface2); }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 62px; border-top: .5px solid var(--border); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row-title { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-sub { font-size: 13.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.row-meta { font-size: 14px; color: var(--text2); white-space: nowrap; text-align: right; flex: none; }
.row-meta.mono { color: var(--text3); }
.row-meta.qty { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.row-meta.qty.low { color: var(--amber); }
.row-meta.qty.out { color: var(--red); }
.row.past { opacity: .5; }
.row.danger .row-title, .row.danger .lead-ic { color: var(--red); }
.chev { color: var(--text3); margin-left: -6px; display: grid; }
.chev .ic { width: 18px; height: 18px; stroke-width: 2.2; }
.lead-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface2); color: var(--text); flex: none; }
.count { color: var(--text3); font-size: 13px; margin: 4px 4px 8px; }
.sec { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); margin: 18px 4px 8px; }
.sec .muted { color: var(--text3); font-weight: 500; }
.info { display: flex; justify-content: space-between; gap: 16px; padding: 13px 14px; position: relative; }
.info + .info::before { content: ""; position: absolute; top: 0; right: 0; left: 14px; border-top: .5px solid var(--border); }
.info-k { color: var(--text2); flex: none; }
.info-v { text-align: right; overflow-wrap: anywhere; }

/* ── Avatars and badges ────────────────────────────────────────────── */
.av {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 14px; font-weight: 600; letter-spacing: .02em;
}
.av.big { width: 96px; height: 96px; font-size: 34px; }
.av0 { background: #F5E1E1; color: #8E1418; } .av1 { background: #E3ECF6; color: #1B4A7E; }
.av2 { background: #E2F0E7; color: #17603A; } .av3 { background: #F7ECD9; color: #7A4A00; }
.av4 { background: #ECE6F5; color: #523C7E; } .av5 { background: #E0EFEE; color: #165F5F; }
@media (prefers-color-scheme: dark) {
  .av0 { background: #3E1F20; color: #FFB4B4; } .av1 { background: #1C2D42; color: #A9C8F2; }
  .av2 { background: #1A3324; color: #9BDDB4; } .av3 { background: #3A2C14; color: #F0C987; }
  .av4 { background: #2D2440; color: #CDB9F0; } .av5 { background: #173332; color: #95D8D6; }
}
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5;
  background: var(--surface2); color: var(--text2); vertical-align: middle; white-space: nowrap;
}
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }

/* ── Controls ──────────────────────────────────────────────────────── */
.search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; margin: 0 0 12px;
  background: var(--surface2); border-radius: 12px; color: var(--text3);
}
.search .ic { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; outline: none; height: 100%; }
.search input::placeholder { color: var(--text3); }
.search.fake { color: var(--text3); }
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: .5px solid var(--border2);
  background: var(--surface); font-size: 14px; cursor: pointer; white-space: nowrap;
}
.chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg { display: flex; background: var(--surface2); border-radius: 10px; padding: 2px; margin: 0 0 12px; }
.seg button { flex: 1; min-height: 34px; border: 0; background: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--text2); }
.seg button b { font-weight: 600; color: var(--text3); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button.on b { color: var(--text2); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 0; background: var(--surface2); color: var(--text); font-weight: 600; font-size: 16px; cursor: pointer;
}
.btn .ic { width: 20px; height: 20px; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.ghost { background: none; color: var(--text2); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; }
.btn:active { filter: brightness(.94); }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text2); min-height: 44px; }
.check.pad { padding: 0 4px; }
.check input { width: 22px; height: 22px; accent-color: var(--brand); margin: 0; }

/* ── Home ──────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  background: var(--surface); border-radius: var(--r); padding: 14px; min-height: 112px; box-shadow: 0 0 0 .5px var(--border);
  display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden;
}
.card:active { background: var(--surface2); }
.card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--border2); }
.card-att::before { background: var(--green); } .card-gp::before { background: var(--blue); }
.card-st::before { background: var(--amber); } .card-tn::before { background: var(--brand); }
.card-label { font-size: 13px; font-weight: 600; color: var(--text2); }
.card-val { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; min-height: 35px; }
.card-val small { font-size: 16px; font-weight: 600; color: var(--text3); }
.card-val .card-text { font-size: 18px; letter-spacing: 0; display: block; line-height: 1.25; }
.card-sub { font-size: 13px; color: var(--text3); margin-top: auto; }
.card-hol { grid-column: 1 / -1; min-height: 0; }

/* ── Person ────────────────────────────────────────────────────────── */
.hero { text-align: center; padding: 8px 0 16px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hero.left { text-align: left; align-items: flex-start; padding-top: 4px; }
.hero h2 { font-size: 24px; font-weight: 700; margin-top: 8px; letter-spacing: -.01em; }
.hero.left h2 { margin-top: 0; font-size: 21px; line-height: 1.3; }
.hero-photo { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; display: grid; place-items: center; }
.hero-photo .photo { width: 100%; height: 100%; object-fit: cover; }
.hero-tags { margin-top: 4px; display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions .btn { min-width: 130px; color: var(--brand); background: var(--surface); box-shadow: 0 0 0 .5px var(--border); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 12px; }
.stat { background: var(--surface); border-radius: 12px; padding: 10px 6px; text-align: center; box-shadow: 0 0 0 .5px var(--border); }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat b small { font-size: 13px; color: var(--text3); font-weight: 600; }
.stat span { font-size: 11.5px; color: var(--text2); }
.stat.good b { color: var(--green); }
.month-head { display: flex; align-items: center; justify-content: space-between; margin: 0 -8px 8px; }
.month-head b { font-size: 17px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; background: var(--surface); border-radius: var(--r); padding: 10px; box-shadow: 0 0 0 .5px var(--border); }
.dow { text-align: center; font-size: 11px; font-weight: 600; color: var(--text3); padding-bottom: 2px; }
.day { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.day.pres { background: var(--green-bg); color: var(--green); }
.day.half { background: var(--amber-bg); color: var(--amber); }
.day.late { background: var(--red-bg); color: var(--red); }
.day.abs { background: var(--cal-abs); color: var(--text2); }
.day.sun, .day.hol { background: var(--cal-sun); color: var(--text3); box-shadow: inset 0 0 0 1px var(--border); }
.day.fut { color: var(--text3); opacity: .5; }
.day.today { outline: 2px solid var(--brand); outline-offset: 1px; }
.start0 { grid-column-start: 1; } .start1 { grid-column-start: 2; } .start2 { grid-column-start: 3; } .start3 { grid-column-start: 4; }
.start4 { grid-column-start: 5; } .start5 { grid-column-start: 6; } .start6 { grid-column-start: 7; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text2); margin: 10px 4px 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .pres { background: var(--green); } .legend .half { background: var(--amber); } .legend .late { background: var(--red); }
.legend .abs { background: var(--cal-abs); box-shadow: inset 0 0 0 1px var(--border2); } .legend .sun { background: var(--cal-sun); box-shadow: inset 0 0 0 1px var(--border2); }

/* ── Attendance date bar, holidays ─────────────────────────────────── */
.datebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 -8px 12px; }
.datepick { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 12px; cursor: pointer; }
.datepick b { font-size: 17px; }
.datepick small { font-size: 13px; color: var(--text2); }
.datepick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; cursor: pointer; }
.datepick:active { background: var(--surface2); }
.dateblock { width: 44px; height: 44px; border-radius: 10px; background: var(--red-bg); color: var(--red); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; line-height: 1.05; }
.dateblock b { font-size: 18px; }
.dateblock span { font-size: 10.5px; font-weight: 600; text-transform: uppercase; }
.note { background: var(--amber-bg); color: var(--amber); border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; font-weight: 500; font-size: 15px; }
.note.pre { white-space: pre-wrap; background: var(--surface); color: var(--text); box-shadow: 0 0 0 .5px var(--border); font-weight: 400; }

/* ── States ────────────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 0; color: var(--text3); font-size: 15px; }
.spin { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border2); border-top-color: var(--brand); animation: spin .8s linear infinite; display: inline-block; }
.spin.sm { width: 18px; height: 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }
.empty { text-align: center; color: var(--text3); padding: 32px 16px; font-size: 15px; }
.msg { background: var(--surface); border-radius: var(--r); padding: 18px; text-align: center; color: var(--text2); box-shadow: 0 0 0 .5px var(--border); margin: 8px 0; }
.msg.err p { color: var(--red); margin-bottom: 12px; }
.foot { text-align: center; color: var(--text3); font-size: 12.5px; margin: 24px 0 8px; line-height: 1.6; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px); z-index: 30;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: 20px; font-size: 14px; font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ── Sign-in and forms ─────────────────────────────────────────────── */
.login, .splash {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 24px) 24px calc(env(safe-area-inset-bottom) + 24px); text-align: center; gap: 4px;
}
.splash { gap: 24px; }
.login-logo, .splash img { border-radius: 20px; box-shadow: 0 4px 16px rgba(0,0,0,.14); }
.login h1 { font-size: 28px; font-weight: 700; margin-top: 14px; letter-spacing: -.01em; }
.login .badge { margin-top: 10px; }
.login .msg { width: 100%; max-width: 360px; margin-top: 16px; }
.form { width: 100%; max-width: 360px; margin-top: 24px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.card-form { max-width: none; margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; font-weight: 600; color: var(--text2); padding-left: 4px; }
.field input {
  height: 48px; border-radius: 12px; border: .5px solid var(--border2); background: var(--surface); color: var(--text);
  padding: 0 14px; font: inherit; font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.field input:focus { border-color: var(--text2); box-shadow: 0 0 0 3px rgba(43,42,41,.12); }
.form-err { color: var(--red); font-size: 14px; min-height: 20px; }

@media (min-width: 640px) {
  .view { max-width: 640px; margin: 0 auto; }
  .tabs { max-width: 640px; margin: 0 auto; border-left: .5px solid var(--border2); border-right: .5px solid var(--border2); }
}
