:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #687083;
  --border: #e1e4ea;
  --accent: #2f5bea;
  --accent-soft: #e7edfd;
  --ok: #1f8a4c;
  --ok-soft: #e3f4ea;
  --warn: #a8660b;
  --warn-soft: #fdf1dc;
  --danger: #c0392b;
  --danger-soft: #fbe7e5;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --text: #e7e9ee;
    --muted: #98a0b0;
    --border: #2c323d;
    --accent: #7c9cff;
    --accent-soft: #24304f;
    --ok: #5fcf8e;
    --ok-soft: #1c3427;
    --warn: #f0b45a;
    --warn-soft: #3a2d17;
    --danger: #ff7b6e;
    --danger-soft: #3d1f1c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem;
  padding: .6rem 1.25rem; background: #1b2230; color: #fff; border-bottom: 1px solid #000;
}
.brand { display: flex; align-items: center; gap: .7rem; font-weight: 700; font-size: 1.05rem; color: #fff; text-decoration: none; }
.brand img { height: 31px; width: auto; display: block; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar nav a, .topbar button.link { color: #dfe6ff; text-decoration: none; }
.topbar nav a:hover, .topbar button.link:hover { color: #fff; text-decoration: underline; }
@media (max-width: 480px) { .brand { font-size: .95rem; } .brand img { height: 26px; } }
.site-footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 16px 2rem; border-top: 1px solid var(--border); }

main { max-width: 1200px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
main.narrow { max-width: 420px; padding-top: 3rem; }
.page-title { font-size: 1.5rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.card.highlight { border-color: var(--accent); background: var(--accent-soft); }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.spread { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.spread h2 { margin: 0; }

label { display: block; margin-bottom: .85rem; font-weight: 500; }
label.check { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
input, textarea, select {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .65rem;
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}
input[type=checkbox], input[type=radio] { display: inline; width: auto; margin: 0; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { display: block; font-weight: 400; font-size: .85rem; color: var(--muted); margin-top: .25rem; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.row input { min-width: 0; padding-left: .45rem; padding-right: .3rem; }
fieldset.choice { border: 0; padding: 0; margin: 0 0 .85rem; min-width: 0; }
fieldset.choice legend { font-weight: 500; padding: 0; margin-bottom: .35rem; }
fieldset.choice label { display: inline-flex; gap: .4rem; align-items: center; margin: 0 1.25rem 0 0; font-weight: 400; }

button {
  font: inherit; cursor: pointer; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); border-color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
form.inline { display: inline; }
.side form + form { margin-top: .5rem; }

.notice { padding: .65rem .85rem; border-radius: 8px; margin-bottom: 1rem; background: var(--accent-soft); }
.notice.ok { background: var(--ok-soft); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.pill { display: inline-block; font-size: .8rem; padding: .15rem .55rem; border-radius: 99px; background: var(--accent-soft); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.note { max-width: 260px; overflow-wrap: anywhere; color: var(--muted); }
td.actions { white-space: nowrap; }
td.actions button { padding: .3rem .65rem; font-size: .85rem; }
tr.inactive td { opacity: .55; }
.status { font-size: .8rem; font-weight: 600; padding: .1rem .5rem; border-radius: 99px; }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.approved { background: var(--ok-soft); color: var(--ok); }
.status.declined, .status.cancelled { background: var(--danger-soft); color: var(--danger); }
.temp-pw code { font-size: 1.4rem; padding: .3rem .6rem; background: var(--surface); border-radius: 6px; user-select: all; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.cal-head h2 { margin: 0; font-size: 1.25rem; }
.cal-nav { display: flex; gap: .35rem; }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekdays span { font-size: .75rem; color: var(--muted); text-align: center; padding-bottom: .3rem; }
.grid { gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.grid.loading { opacity: .6; }
.day {
  display: flex; flex-direction: column; gap: 2px; align-items: stretch; text-align: left;
  min-height: 96px; padding: 4px; border: 0; border-radius: 0; background: var(--surface); overflow: hidden;
}
.day.other { background: var(--bg); color: var(--muted); }
.day.selected { box-shadow: inset 0 0 0 2px var(--accent); }
.day .num { font-size: .8rem; font-weight: 600; align-self: flex-start; padding: 0 .3rem; border-radius: 99px; }
.day.today .num { background: var(--accent); color: #fff; }
.chip {
  display: block; font-size: .72rem; line-height: 1.3; padding: 1px 5px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent);
}
.chip.holiday.approved { background: var(--ok-soft); border-left-color: var(--ok); }
.chip.holiday.pending { background: var(--warn-soft); border-left-color: var(--warn); border-left-style: dashed; }
.more { font-size: .7rem; color: var(--muted); padding-left: 4px; }
@media (max-width: 600px) {
  .day { min-height: 56px; }
  .day .chip { font-size: 0; height: 6px; padding: 0; border-left-width: 0; }
  .day .more { font-size: .6rem; }
}
.legend { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .6rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.dot.event { background: var(--accent); }
.dot.approved { background: var(--ok); }
.dot.pending { background: var(--warn); }

.day-events { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.chip.wide {
  width: 100%; text-align: left; white-space: normal; font-size: .9rem; padding: .45rem .6rem;
  border-top: 0; border-right: 0; border-bottom: 0; border-radius: 6px; cursor: pointer;
}
.chip.wide .when { display: block; font-size: .78rem; color: var(--muted); }
.chip.wide .what { display: block; font-weight: 500; }

dialog {
  max-width: min(520px, calc(100vw - 32px)); width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }
#ev-desc { max-height: 50vh; overflow: auto; }

/* holiday summary */
.year-nav { display: flex; align-items: center; gap: .6rem; }
.year-nav a { text-decoration: none; font-size: 1.2rem; padding: 0 .4rem; }
.year-nav span { width: 1.3rem; }
.allowance-head { margin: 0 0 .5rem; }
.big-num { font-size: 2rem; font-weight: 700; margin-right: .25rem; }
.allowance-bar { display: block; width: 100%; height: 14px; border-radius: 7px; overflow: hidden; }
.allowance-bar .track { fill: var(--border); }
.allowance-bar .approved { fill: var(--ok); }
.allowance-bar .pending { fill: var(--warn); }
.dot.track { background: var(--border); }
.allowance .notice { margin: .75rem 0 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin: 1rem 0 .5rem; }
@media (max-width: 600px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; }
.stat .label { display: block; font-size: .8rem; color: var(--muted); }
.stat .value { display: block; font-size: 1.5rem; font-weight: 700; }
.stat .sub { display: block; font-size: .75rem; color: var(--muted); }
.left-low { color: var(--warn); font-weight: 600; }
.left-none { color: var(--danger); font-weight: 600; }

/* team holidays and the staff-off limit */
.chip.team { background: var(--bg); color: var(--muted); border-left-color: var(--muted); }
.chip.team.pending { border-left-style: dashed; }
.dot.team { background: var(--muted); }
.dot.full { background: var(--danger); }
.day-top { display: flex; justify-content: space-between; align-items: center; gap: 2px; }
.full-tag { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--danger); background: var(--danger-soft); border-radius: 4px; padding: 0 4px; }
.day.full { box-shadow: inset 0 -3px 0 var(--danger); }
.day.full.selected { box-shadow: inset 0 0 0 2px var(--accent), inset 0 -3px 0 var(--danger); }
.notice.rule { font-size: .88rem; }
.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.team-list li { display: flex; flex-wrap: wrap; gap: .3rem .75rem; align-items: center;
  padding: .45rem 0; border-bottom: 1px solid var(--border); }
.team-list li:last-child { border-bottom: 0; }
.admin-tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-tabs a { text-decoration: none; padding: .4rem .8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.admin-tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.status.sent { background: var(--ok-soft); color: var(--ok); }
.status.queued { background: var(--warn-soft); color: var(--warn); }
.status.failed { background: var(--danger-soft); color: var(--danger); }
.status.skipped { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
td.nowrap { white-space: nowrap; }

/* holiday filter */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem .75rem; }
.filters label { margin: 0; font-size: .8rem; font-weight: 500; color: var(--muted); }
.filters select { margin-top: .15rem; padding: .35rem .5rem; min-width: 150px; }
.filters button { padding: .4rem .8rem; }

/* sign-in page */
.login-card { padding-top: 0; overflow: hidden; }
.login-brand { margin: 0 -1.25rem 1.25rem; padding: 1.5rem 1rem 1.1rem; background: #1b2230; text-align: center; color: #fff; }
.login-brand img { height: 78px; width: auto; display: block; margin: 0 auto .6rem; }
.login-brand p { margin: 0; font-weight: 700; font-size: 1.05rem; }

/* start date / approvals */
.subtitle { margin: -.5rem 0 1rem; font-size: .9rem; }
.joined { margin: -.25rem 0 .9rem; }
.period-left { margin: -.5rem 0 .75rem; padding-left: 1.1rem; }
.decision-cell { font-size: .85rem; min-width: 150px; }
.decision { display: block; }

/* admin: full-width staff table, the two forms side by side below it */
.forms-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
@media (max-width: 900px) { .forms-row { grid-template-columns: minmax(0, 1fr); } }

/* admin team calendar */
.count-tag { font-size: .65rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 0 5px; }
.tc-day { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .9rem; }
.tc-day h3 { font-size: 1rem; }
.tc-day-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.tc-person { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .75rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.tc-person:last-child { border-bottom: 0; }
.cal-head .pill { margin-left: auto; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  main { padding-top: 1rem; }
}

@media (max-width: 700px) {
  body { font-size: 15px; }
  /* 16px stops iPhones zooming in when a field is tapped */
  input, select, textarea { font-size: 16px; }
  button, .admin-tabs a { min-height: 40px; }
  .card { padding: .9rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
  .page-title { font-size: 1.3rem; margin-bottom: .5rem; }
  .subtitle { margin-top: -.25rem; }

  .topbar { padding: .55rem 16px; }
  .topbar nav { width: 100%; justify-content: space-between; gap: .25rem; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: .4rem; }
  .topbar nav a, .topbar button.link { padding: .35rem .2rem; font-size: .95rem; }

  /* tables become one card per row, each value labelled */
  .table-wrap { overflow: visible; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--border); border-radius: 8px; padding: .45rem .75rem; margin-bottom: .7rem; background: var(--bg); }
  table.stack tr.inactive { opacity: .7; }
  table.stack tr.inactive td { opacity: 1; }
  table.stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    border: 0; padding: .3rem 0; text-align: right; white-space: normal; max-width: none; }
  table.stack td::before { content: attr(data-label); flex: none; text-align: left; font-size: .78rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
  table.stack td[data-label=""]::before { content: none; }
  table.stack td[data-label=""] { justify-content: flex-start; }
  table.stack td:empty { display: none; }
  table.stack td.actions { flex-wrap: wrap; justify-content: flex-start; gap: .5rem; padding-top: .55rem; border-top: 1px solid var(--border); margin-top: .3rem; }
  table.stack td.actions:not(:has(*)) { display: none; }
  td.actions button { padding: .45rem .9rem; font-size: .95rem; }
  .decision-cell { min-width: 0; }
  .decision { text-align: right; }

  .filters { width: 100%; }
  .filters label { flex: 1 1 140px; }
  .filters select { width: 100%; min-width: 0; }

  .cal-head { gap: .5rem .75rem; }
  .cal-head h2 { font-size: 1.05rem; }
  .cal-head .pill { margin-left: 0; }
  .year-nav strong { font-size: .9rem; }
  .big-num { font-size: 1.7rem; }
  .temp-pw code { font-size: 1.1rem; word-break: break-all; }
}

@media (max-width: 600px) {
  .day { min-height: 52px; padding: 3px 2px; }
  .day .num { font-size: .75rem; padding: 0 .25rem; }
  .full-tag { font-size: .5rem; padding: 0 2px; }
  .count-tag { font-size: .6rem; padding: 0 4px; }
  .weekdays span { font-size: .68rem; }
  .legend { gap: .4rem .9rem; }
}

@media (max-width: 400px) {
  .row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .brand span { font-size: .88rem; }
  .stats { gap: .5rem; }
  .stat .value { font-size: 1.3rem; }
}

@media (max-width: 600px) {
  /* chips shrink to coloured bars on phones; make every kind clearly visible */
  .day .chip { height: 5px; border-radius: 3px; background: var(--accent); }
  .day .chip.holiday.approved { background: var(--ok); }
  .day .chip.holiday.pending { background: var(--warn); }
  .day .chip.team { background: var(--muted); }
}
