:root {
  --red: #E4010D; --red-dark: #B30009; --ink: #1F2328; --slate: #5B6470; --chalk: #EEF0F2;
  --line: #D8DCE1; --paper: #FFFFFF; --go: #0F7B3E; --go-bg: #E5F4EB; --warn: #8A5A00; --warn-bg: #FFF4D6;
  --bad-bg: #FDE8E9; --display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --body: 'Source Sans 3', system-ui, -apple-system, sans-serif;
  --r: 10px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.5 var(--body); color: var(--ink); background: var(--chalk); min-height: 100dvh; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.1; margin: 0 0 .5rem; letter-spacing: .01em; }
h1 { font-size: 2rem; } h2 { font-size: 1.55rem; } h3 { font-size: 1.2rem; }
p { margin: 0 0 .75rem; }
a { color: var(--red-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #1A73E8; outline-offset: 2px; }
.muted { color: var(--slate); }
.small { font-size: .875rem; }
.hidden { display: none !important; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* top bar */
.bar { background: var(--red); color: #fff; padding: calc(var(--safe-t) + .7rem) 1rem .7rem; display: flex; align-items: center; gap: .75rem; position: sticky; top: 0; z-index: 5; }
.bar .mark { font-family: var(--display); font-weight: 700; font-size: 1.3rem; letter-spacing: .02em; text-decoration: none; color: #fff; line-height: 1; }
.bar .mark small { display: block; font-family: var(--body); font-weight: 600; font-size: .7rem; opacity: .85; letter-spacing: .04em; }
.bar .spacer { flex: 1; }
.bar a.pill, .bar button.pill { color: #fff; background: rgba(0,0,0,.18); border: 0; border-radius: 99px; padding: .35rem .8rem; font-size: .85rem; font-weight: 600; text-decoration: none; cursor: pointer; }

main { max-width: 640px; margin: 0 auto; padding: 1rem 1rem calc(5.5rem + var(--safe-b)); }
main.wide { max-width: 1200px; }

.card { background: var(--paper); border-radius: var(--r); padding: 1.1rem; border: 1px solid var(--line); }
.card + .card { margin-top: 1rem; }
.card h2 { margin-bottom: .75rem; }

/* clock hero */
.clock { text-align: left; padding: 1.25rem 1.1rem 1.1rem; }
.clock .now { font-family: var(--display); font-weight: 600; font-size: clamp(4.2rem, 22vw, 6.5rem); line-height: .9; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.clock .now .ap { font-size: .38em; font-weight: 600; margin-left: .15em; color: var(--slate); }
.clock .date { color: var(--slate); font-weight: 600; margin: .35rem 0 1rem; }
.status { display: flex; align-items: center; gap: .6rem; padding: .75rem .9rem; border-radius: 8px; background: var(--chalk); font-weight: 600; margin-bottom: 1rem; }
.status .dot { width: .7rem; height: .7rem; border-radius: 50%; background: var(--slate); flex: none; }
.status.in { background: var(--go-bg); color: var(--go); }
.status.in .dot { background: var(--go); box-shadow: 0 0 0 4px rgba(15,123,62,.18); }
.status .sub { display: block; font-weight: 400; font-size: .9rem; color: var(--ink); }

.punch { width: 100%; border: 0; border-radius: 12px; min-height: 5rem; font-family: var(--display); font-size: 2rem; font-weight: 700; letter-spacing: .03em; color: #fff; background: var(--red); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: .6rem; touch-action: manipulation; }
.punch:active { transform: translateY(1px); background: var(--red-dark); }
.punch.out { background: var(--ink); }
.punch[disabled] { opacity: .6; cursor: progress; }
.punch .ico { width: 1.6rem; height: 1.6rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: .9rem; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: .7rem .8rem; border: 1px solid #B9C0C8; border-radius: 8px; background: #fff; min-height: 2.9rem; }
textarea { min-height: 5rem; resize: vertical; }
/* iPhone date/time boxes ignore width:100% and run past the card; keep every field the same width, text on the left. */
input, select, textarea { box-sizing: border-box; max-width: 100%; min-width: 0; }
.field, .grid2 > *, .grid3 > *, label { min-width: 0; }
input[type=date], input[type=time], input[type=month], input[type=datetime-local] { -webkit-appearance: none; appearance: none; display: block; text-align: left; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value, input[type=datetime-local]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input.code { font-family: var(--display); font-size: 2rem; letter-spacing: .4em; text-align: center; font-weight: 700; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; flex: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: 8px; padding: .65rem 1.1rem; min-height: 2.9rem; font-weight: 700; cursor: pointer; text-decoration: none; background: var(--red); color: #fff; }
.btn:hover { background: var(--red-dark); }
.btn.ghost { background: #fff; color: var(--ink); border-color: #B9C0C8; }
.btn.ghost:hover { background: var(--chalk); }
.btn.dark { background: var(--ink); }
.btn.go { background: var(--go); }
.btn.sm { min-height: 2.2rem; padding: .35rem .75rem; font-size: .9rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--red-dark); text-decoration: underline; cursor: pointer; padding: 0; font-weight: 600; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line); align-items: center; }
.list li:first-child { border-top: 0; }
.list .what { font-weight: 600; }
.list .meta { font-size: .875rem; color: var(--slate); }
.num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

.badge { display: inline-block; border-radius: 99px; padding: .1rem .6rem; font-size: .8rem; font-weight: 700; background: var(--chalk); color: var(--slate); white-space: nowrap; }
.badge.approved { background: var(--go-bg); color: var(--go); }
.badge.submitted, .badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.rejected, .badge.denied { background: var(--bad-bg); color: var(--red-dark); }
.loc { font-size: .85rem; font-weight: 600; color: var(--go); }
.loc.off { color: var(--red-dark); }

.note { border-left: 4px solid var(--warn); background: var(--warn-bg); padding: .7rem .9rem; border-radius: 0 8px 8px 0; margin-bottom: 1rem; }
.note.bad { border-color: var(--red); background: var(--bad-bg); }
.note.good { border-color: var(--go); background: var(--go-bg); }

/* totals strip */
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr)); gap: .5rem; margin: .5rem 0 1rem; }
.totals div { background: var(--chalk); border-radius: 8px; padding: .55rem .7rem; }
.totals b { display: block; font-family: var(--display); font-size: 1.6rem; line-height: 1.05; font-variant-numeric: tabular-nums; }
.totals span { font-size: .8rem; color: var(--slate); font-weight: 600; }

.day { border-top: 1px solid var(--line); padding: .7rem 0; }
.day:first-of-type { border-top: 0; }
.day h4 { margin: 0 0 .3rem; font-size: 1rem; display: flex; justify-content: space-between; }
.day .ln { display: flex; justify-content: space-between; font-size: .92rem; gap: .5rem; }
.day .pn { font-size: .85rem; color: var(--slate); display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; }

.sig { width: 100%; height: 160px; border: 2px dashed #B9C0C8; border-radius: 8px; background: #fff; touch-action: none; display: block; }
.sigimg { max-width: 260px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }

.period-nav { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.period-nav h2 { flex: 1; text-align: center; margin: 0; font-size: 1.35rem; }
.icon-btn { width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 1px solid #B9C0C8; background: #fff; cursor: pointer; font-size: 1.2rem; flex: none; }

/* bottom tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: var(--safe-b); z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: .5rem 0 .55rem; font-size: .75rem; font-weight: 700; color: var(--slate); text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.tabs a svg { width: 1.5rem; height: 1.5rem; }
.tabs a[aria-current=page] { color: var(--red); }

.banner { display: flex; gap: .75rem; align-items: center; background: var(--ink); color: #fff; border-radius: var(--r); padding: .8rem 1rem; margin-bottom: 1rem; }
.banner p { margin: 0; font-size: .92rem; }
.banner .btn { background: #fff; color: var(--ink); flex: none; }

/* login */
.login { max-width: 420px; margin: 0 auto; padding: calc(var(--safe-t) + 2.5rem) 1.25rem 2rem; }
.login .crest { font-family: var(--display); font-weight: 700; font-size: 2.6rem; line-height: .95; color: var(--red); margin-bottom: .2rem; }
.login .crest span { display: block; color: var(--ink); font-size: 1.3rem; letter-spacing: .02em; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--slate); font-size: .85rem; margin: 1.1rem 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.gbtn { background: #fff; color: var(--ink); border: 1px solid #B9C0C8; width: 100%; }
.gbtn:hover { background: var(--chalk); }

/* tables (HR) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; font-size: .8rem; color: var(--slate); font-weight: 700; padding: .5rem .6rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F7F8F9; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }

/* HR layout */
.hr-shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100dvh - 3.5rem); }
.hr-nav { background: var(--ink); padding: 1rem .6rem; }
.hr-nav a { display: flex; justify-content: space-between; color: #D5D9DE; text-decoration: none; padding: .55rem .75rem; border-radius: 8px; font-weight: 600; }
.hr-nav a[aria-current=page] { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--red); }
.hr-nav .count { background: var(--red); color: #fff; border-radius: 99px; font-size: .75rem; padding: 0 .5rem; line-height: 1.4rem; }
.hr-main { padding: 1.25rem; min-width: 0; }
.hr-main .card + .card { margin-top: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: .9rem 1rem; text-decoration: none; color: inherit; }
.stat b { font-family: var(--display); font-size: 2.4rem; line-height: 1; display: block; }
.stat span { color: var(--slate); font-weight: 600; font-size: .9rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
@media (max-width: 860px) {
  .hr-shell { grid-template-columns: 1fr; }
  .hr-nav { display: flex; overflow-x: auto; padding: .4rem; gap: .25rem; position: sticky; top: 3.4rem; z-index: 4; }
  .hr-nav a { white-space: nowrap; gap: .4rem; }
  .hr-main { padding: 1rem .75rem 2rem; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

.modal-wrap { position: fixed; inset: 0; background: rgba(20,22,26,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; padding: 0; }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 92dvh; overflow: auto; border-radius: 16px 16px 0 0; padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-b)); }
.modal.wide { max-width: 900px; }
@media (min-width: 700px) { .modal-wrap { align-items: center; padding: 1rem; } .modal { border-radius: 14px; } }

.toast { position: fixed; left: 50%; bottom: calc(5.5rem + var(--safe-b)); transform: translate(-50%, 1rem); background: var(--ink); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100% - 2rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--red-dark); }
.spin { display: inline-block; width: 1.1em; height: 1.1em; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .8s linear infinite; }
@keyframes s { to { transform: rotate(360deg); } }
.loading { padding: 3rem 0; text-align: center; color: var(--slate); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation-duration: 2s !important; } }
.grid2 > .card + .card, .grid3 > .card + .card { margin-top: 0; }
.login .crest { margin-bottom: 1rem; }
.mode-times .c-h, .mode-hours .c-t { display: none; }
#bt td { vertical-align: middle; }
#bt input[type=time], #bt select { min-height: 2.4rem; padding: .4rem .5rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cal-sum{cursor:pointer;list-style:none;display:flex;align-items:baseline;gap:.5rem;flex-wrap:wrap}
.cal-sum::-webkit-details-marker{display:none}
.cal-sum::before{content:"›";display:inline-block;transition:transform .15s;font-size:1.25rem;color:var(--slate)}
details[open]>.cal-sum::before{transform:rotate(90deg)}
/* Discipline links in the employee and HR headers use the school's gray */
a.pill[href="/discipline"], a.btn[href="/discipline"], .hr-nav a[href="/discipline"] { background: #4A4F55 !important; color: #fff !important; }
a.btn[href="/discipline"]:hover { background: #2B2F33 !important; }
.tabs a[href="/forms"] span[aria-label] { background: var(--red) !important; }
