/* Company palette: blue #2075C2, grey #899098, icon greens #0EB121, #4CC65A, #87D78F.
   Text uses darker or lighter tints of these where the exact colour would be hard to read. */
:root {
  --brand-green-1: #0eb121;
  --brand-green-2: #4cc65a;
  --brand-green-3: #87d78f;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eaeef2;
  --text: #1b2733;
  --muted: #5c646c;
  --border: #d3d8dc;
  --accent: #2075c2;
  --accent-text: #ffffff;
  --success: #0a7a17;
  --success-soft: #dff5e2;
  --danger: #b3382c;
  --danger-soft: #f8e3df;
  --warn: #8a5a00;
  --warn-soft: #f7ecd0;
  --info: #1b65a8;
  --info-soft: #e1edf8;
  --row-alt: #eef5fb;
  --row-hover: #dfedf9;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11171d;
    --surface: #1a222a;
    --surface-2: #252f39;
    --text: #e8edf1;
    --muted: #a3abb3;
    --border: #36414b;
    --accent: #64a9e8;
    --accent-text: #0b1e30;
    --success: #6bd977;
    --success-soft: #17351b;
    --danger: #ef8d80;
    --danger-soft: #472420;
    --warn: #e0b758;
    --warn-soft: #3d3118;
    --info: #8fc1ee;
    --info-soft: #1b3044;
    --row-alt: #1c2b3a;
    --row-hover: #243749;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.hidden { display: none !important; }

/* Layout */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar { position: relative; }
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: linear-gradient(to right,
    var(--brand-green-1) 0 33.33%, var(--brand-green-2) 33.33% 66.66%, var(--brand-green-3) 66.66% 100%);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
/* The logo's dark-blue lettering needs a white backing in dark mode. */
.logo { display: block; height: auto; background: #ffffff; border-radius: 6px; padding: 4px 6px; }
.logo-small { width: 150px; max-width: 100%; }
.logo-large { width: 100%; max-width: 280px; margin: 0 auto; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs {
  display: flex; gap: 4px; overflow-x: auto; padding: 0 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 12px; border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.tab:hover { background: none; color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
main.narrow { max-width: 620px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--info-soft); color: var(--info); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Forms */
button, .button {
  display: inline-block; padding: 8px 14px; font: inherit; font-weight: 500; text-decoration: none;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
button:hover, .button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.6; cursor: default; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
button.primary { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: var(--accent); filter: brightness(1.08); }
button.link { padding: 2px 6px; border: 0; background: none; color: var(--accent); }
label { display: grid; gap: 4px; font-size: 0.875rem; font-weight: 500; }
input, select {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
}
input[type="checkbox"] { width: auto; }
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.form-section { margin-top: 8px; padding-top: 12px; font-size: 1rem; color: var(--accent); border-top: 1px solid var(--border); }
.check-group { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 1rem; }
.error { color: var(--danger); font-size: 0.875rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
th.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: 0; }
.row-quiet td { color: var(--muted); }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }

.email-check-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.email-check-actions .row-button { overflow-wrap: anywhere; white-space: normal; text-align: left; }

/* Actions inside a table row */
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-button {
  padding: 4px 12px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap;
  color: var(--accent); background: var(--surface); border-color: var(--accent); border-radius: 6px;
}
.row-button:hover { color: var(--accent-text); background: var(--accent); }
.row-button-accent { color: var(--accent-text); background: var(--accent); }
.row-button-accent:hover { background: var(--accent); filter: brightness(1.08); }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 500;
  background: var(--surface-2); color: var(--muted);
}
.pill.good { background: var(--success-soft); color: var(--success); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }

/* End of service */
.eos-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.eos-sheet { display: grid; gap: 6px; }
.eos-sheet h2 { margin-bottom: 6px; }
.eos-line { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; }
.eos-line span:first-child { color: var(--muted); }
.eos-line.strong { padding-top: 6px; font-weight: 700; border-top: 1px solid var(--border); }
.eos-line.strong span:first-child { color: var(--text); }

/* Employee salary slips */
.slip-list { list-style: none; margin: 0; padding: 0; }
.slip-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.slip-item:first-child { padding-top: 0; }
.slip-item:last-child { padding-bottom: 0; border-bottom: 0; }
.request-status {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px;
  border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.request-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pending { color: var(--warn); background: var(--warn-soft); }
.status-approved { color: var(--success); background: var(--success-soft); }
.status-rejected, .status-withdrawn { color: var(--danger); background: var(--danger-soft); }
.status-cancelled { color: var(--muted); background: var(--surface-2); }
.request-text { min-width: 0; flex: 1 1 200px; overflow-wrap: anywhere; }
.requests-table td { white-space: normal; }
.requests-table td:last-child { white-space: nowrap; }
.wrap-cell { min-width: 120px; max-width: 280px; overflow-wrap: anywhere; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; display: grid; gap: 16px; }

/* Check-in */
.clock-card { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 28px 16px; }
.clock { font-size: 2.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.check-button { width: 100%; max-width: 320px; padding: 16px; font-size: 1.15rem; font-weight: 600; }
.times { display: flex; justify-content: center; gap: 12px 24px; flex-wrap: wrap; }
.times span { display: block; }

dialog {
  width: min(440px, calc(100vw - 32px)); padding: 20px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin-bottom: 12px; }

/* Team summary and dashboard. Each kind of day keeps its colour everywhere, and also has a letter so colour is never the only clue. */
:root {
  --kind-punctual: #3aa655;
  --kind-late: #e0a526;
  --kind-absent: #c43d30;
  --kind-leave: #2563b8;
  --kind-sick: #e07ac0;
  --kind-worked: #008f8a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --kind-punctual: #2f9a47;
    --kind-late: #ecc25a;
    --kind-absent: #d95a4a;
    --kind-leave: #4f8fdb;
    --kind-sick: #f0a8dc;
    --kind-worked: #1fa29e;
  }
}
.kind-punctual { background: var(--kind-punctual); fill: var(--kind-punctual); }
.kind-late { background: var(--kind-late); fill: var(--kind-late); color: #1b2733; }
.kind-absent { background: var(--kind-absent); fill: var(--kind-absent); color: #ffffff; }
.kind-leave { background: var(--kind-leave); fill: var(--kind-leave); color: #ffffff; }
.kind-sick { background: var(--kind-sick); fill: var(--kind-sick); color: #0b1e30; }
.kind-workedDayOff { background: var(--kind-worked); fill: var(--kind-worked); color: #ffffff; }
.kind-dayOff { background: var(--surface-2); }
.kind-notEmployed, .kind-upcoming { background: transparent; border: 1px dashed var(--border); }
@media (prefers-color-scheme: dark) {
  .kind-absent, .kind-workedDayOff, .kind-leave { color: #0b1e30; }
}

.chart-scroll { overflow-x: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0; padding: 0; list-style: none; font-size: 0.8rem; color: var(--muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.chart-key { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 3px; font-size: 0.65rem; font-weight: 700; }

.team-chart { display: block; max-width: none; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-hit { fill: transparent; }
.chart-column:hover .chart-hit { fill: var(--surface-2); }

.score-bars { display: grid; gap: 8px; }
.score-row { display: grid; grid-template-columns: minmax(90px, 180px) minmax(60px, 1fr) 44px; align-items: center; gap: 10px; }
.score-name { overflow: hidden; font-size: 0.875rem; white-space: nowrap; text-overflow: ellipsis; }
.score-track { height: 10px; overflow: hidden; background: var(--surface-2); border-radius: 4px; }
.score-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.score-value { font-size: 0.875rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.day-grid { display: grid; gap: 2px; width: max-content; }
.day-grid-row { display: grid; grid-template-columns: 130px repeat(var(--days), 22px); gap: 2px; align-items: center; }
.day-grid-name { overflow: hidden; padding-right: 8px; font-size: 0.8rem; white-space: nowrap; text-overflow: ellipsis; }
.day-grid-date { font-size: 0.7rem; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-cell { display: grid; place-items: center; height: 22px; border-radius: 3px; font-size: 0.7rem; font-weight: 700; cursor: default; }
.day-cell:hover { outline: 2px solid var(--text); outline-offset: 1px; }
/* Tablets: wide tables scroll sideways, with the first column staying in view. */
@media (max-width: 1024px) {
  main { padding: 16px 16px 40px; }
  .tabs { scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .table-wrap th, .table-wrap td { padding: 8px; }
  .table-wrap tbody td:first-child, .table-wrap thead th:first-child, .table-wrap tfoot td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--surface);
  }
  .table-wrap tbody tr:nth-child(even) td:first-child { background: var(--row-alt); }
}

/* Touch screens: controls big enough for a finger. */
@media (pointer: coarse) {
  button, .button { min-height: 44px; }
  .button { display: inline-flex; align-items: center; justify-content: center; }
  button.link { min-height: 40px; padding: 4px 8px; }
  .row-button { min-height: 40px; }
  input, select { min-height: 44px; }
  input[type="checkbox"] { min-height: 0; width: 22px; height: 22px; }
  .tab { min-height: 46px; }
}

/* Phones */
@media (max-width: 700px) {
  body { font-size: 15px; }
  /* A smaller size makes iPhones zoom into the page when a field is tapped. */
  input, select { font-size: 16px; }
  h1 { font-size: 1.25rem; }
  main { padding: 12px 12px 32px; gap: 12px; }
  .card { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .topbar-actions button { flex: 1 1 auto; }
  .tabs { padding: 0 8px; }

  .row { align-items: stretch; }
  .row > h1, .row > h2 { flex: 1 1 auto; align-self: center; }
  .controls { align-items: stretch; flex-direction: column; }
  .controls > label, .controls > .button, .controls > button { width: 100%; }
  .topbar-actions > .button, .topbar-actions > button { flex: 1 1 auto; text-align: center; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 1.35rem; }
  .eos-line { flex-wrap: wrap; }

  /* Each table row becomes a card, with the column name beside its value. */
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tfoot, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr, .table-wrap tfoot tr {
    margin-bottom: 8px; padding: 6px 10px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 8px;
  }
  .table-wrap tbody tr:nth-child(even) { background: var(--row-alt); }
  .table-wrap tbody tr:last-child { margin-bottom: 0; }
  .table-wrap tfoot tr { margin-top: 8px; margin-bottom: 0; border-width: 2px; }
  .table-wrap tbody td, .table-wrap tfoot td, .requests-table td, .requests-table td:last-child {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 5px 0; text-align: right; white-space: normal; overflow-wrap: anywhere;
    border: 0; position: static; background: transparent !important;
  }
  .table-wrap td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 45%;
    font-size: 0.8rem; font-weight: 500; text-align: left; color: var(--muted);
  }
  .table-wrap td:not([data-label])::before { display: none; }
  .table-wrap td:empty, .table-wrap td.cell-blank { display: none; }
  .table-wrap td.cell-actions { display: block; padding-top: 8px; text-align: left; }
  .table-wrap td.cell-title { justify-content: flex-start; font-weight: 700; }
  .table-wrap .row-collapsible:not(.row-open) td.cell-more { display: none; }
  .table-wrap .row-collapsible td.cell-toggle { display: block; padding-top: 8px; }
  .wrap-cell { min-width: 0; max-width: none; }
  .row-actions { justify-content: stretch; }
  .row-actions .row-button { flex: 1 1 0; }

  .score-row { grid-template-columns: minmax(70px, 110px) minmax(40px, 1fr) 40px; gap: 8px; }
  .day-grid-row { grid-template-columns: 96px repeat(var(--days), 22px); }
  .day-grid-name { position: sticky; left: 0; z-index: 1; align-self: stretch; margin-right: -2px; line-height: 22px; background: var(--surface); }

  dialog { width: calc(100vw - 16px); max-width: none; padding: 16px; }
  .form-actions button { flex: 1 1 0; }
}

.table-wrap td.cell-toggle { display: none; }
.row-toggle { width: 100%; padding: 6px 10px; font-size: 0.875rem; color: var(--accent); background: transparent; border-color: var(--border); }

.chart-detail { min-height: 1.4em; font-size: 0.875rem; white-space: pre-line; }
.chart-detail:empty { display: none; }
.chart-detail:not(:empty) { padding: 8px 10px; background: var(--info-soft); color: var(--info); border-radius: 6px; }

dialog { max-height: calc(100dvh - 16px); overflow-y: auto; }
.login { min-height: 100dvh; }