:root {
  color-scheme: light;
  --ground: #f4f7fc;
  --surface: #fff;
  --ink: #15223a;
  --muted: #566580;
  --rule: #e4eaf3;
  --control: #cbd6e6;
  --blue: #095ac7;
  --dark-blue: #08438e;
  --blue-soft: #eaf3ff;
  --soft: #f6f8fc;
  --error: #a52536;
  --radius: 20px;
  --control-radius: 10px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --space: 24px;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--ink); }
a { color: inherit; }
button, input, select { font: inherit; }
button, .button, nav a, summary { touch-action: manipulation; user-select: none; -webkit-user-select: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
h1, h2, p, ul { margin: 0; }
h1 { font-size: clamp(24px, 3.3vw, 32px); font-weight: 700; line-height: 1.17; letter-spacing: -.04em; }
h2 { font-size: 19px; font-weight: 700; line-height: 1.35; letter-spacing: -.02em; }
p + p { margin-top: 8px; }
.muted, .rule-note { color: var(--muted); }
.error { color: var(--error); }
.num, .amount, .countdown, .period { font-variant-numeric: tabular-nums; }

button, .button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid var(--control);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--dark-blue);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 135ms var(--ease-out), background-color 140ms ease;
}
button:active:not(:disabled), .button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: default; }
.primary { color: white; border-color: var(--blue); background: var(--blue); }

.top { background: var(--surface); border-bottom: 1px solid var(--rule); padding-top: env(safe-area-inset-top, 0px); }
.bar, .wrap {
  max-width: 1056px;
  margin-inline: auto;
  padding-inline: max(var(--space), env(safe-area-inset-left)) max(var(--space), env(safe-area-inset-right));
}
.bar { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 20px; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-size: 16px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}
.mark { display: grid; width: 34px; height: 34px; place-items: center; color: white; background: var(--blue); border-radius: 11px; }
.paper-icon {
  position: relative;
  display: inline-block;
  flex: none;
  width: 15px;
  height: 18px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.paper-icon::before, .paper-icon::after {
  position: absolute;
  inset-inline-start: 3px;
  width: 6px;
  height: 1px;
  border-radius: 1px;
  background: currentColor;
  content: "";
}
.paper-icon::before { top: 5px; }
.paper-icon::after { top: 9px; width: 4px; }
nav, .nav-tabs { display: flex; align-items: center; }
nav { gap: 12px; }
.nav-tabs { gap: 2px; padding: 3px; border-radius: 12px; background: var(--soft); }
nav a, .nav-exit {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}
nav a[aria-current="page"] { background: var(--blue-soft); color: var(--dark-blue); }
.nav-exit { background: transparent; }

.wrap { padding-block: 46px calc(64px + env(safe-area-inset-bottom, 0px)); }
.narrow { max-width: 620px; }
.headline, .toolbar, .receipt-header, .audit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.headline { min-height: 66px; margin-bottom: 25px; }
.headline h1 + p { margin-top: 9px; font-size: 14px; }
.preview-label { flex: none; align-self: start; padding: 5px 8px; border-radius: 7px; background: var(--blue-soft); color: var(--dark-blue); font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel { min-width: 0; padding: var(--space); border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
.panel h2 { margin-bottom: 14px; }
.panel > :last-child { margin-bottom: 0; }
.empty { padding-top: 15px; border-top: 1px solid var(--rule); font-size: 14px; }
.voice:not(:empty) { margin-top: 12px; }
.label { display: block; color: var(--muted); font-size: 13px; font-weight: 650; margin-bottom: 6px; }

/* On desktop the 310px month list and 24px gap leave 674px for the receipt. */
#employee-layout { display: grid; grid-template-columns: minmax(260px, 310px) minmax(0, 1fr); align-items: start; gap: var(--space); }
#employee-detail { min-width: 0; }
#employee-status:not(:empty) { margin: 12px 5px 0; }
.slip-row { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; }
.slip-row + .slip-row { border-top: 1px solid var(--rule); }
.slip-period { display: grid; gap: 3px; min-width: 0; }
.period { font-size: 15px; line-height: 1.4; font-weight: 700; }
.slip-status { color: var(--muted); font-size: 12px; }
.slip-row button { min-height: 37px; padding-inline: 10px; border-color: transparent; background: var(--soft); font-size: 13px; }
.slip-row.is-active .period { color: var(--blue); }
.slip-row > .slip-status { padding: 5px 8px; border-radius: 7px; background: var(--soft); white-space: nowrap; }
.slip-row.is-active > .slip-status { color: var(--dark-blue); background: var(--blue-soft); }
.receipt-empty { display: grid; min-height: 255px; justify-items: center; align-content: center; gap: 10px; text-align: center; }
.receipt-empty .paper-icon { color: var(--blue); transform: scale(1.25); margin-bottom: 7px; }
.receipt-empty h2 { margin: 0; }
.receipt-empty p { font-size: 14px; }
.has-receipt .receipt-empty { display: none; }
.receipt-panel { scroll-margin-top: 12px; }
.receipt-header { align-items: flex-start; margin-bottom: 21px; }
.receipt-header h2 { margin-bottom: 3px; }
.receipt-identity { font-size: 13px; overflow-wrap: anywhere; }
.countdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--dark-blue);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.countdown::before { width: 9px; height: 9px; border: 1.5px solid currentColor; border-radius: 50%; content: ""; }
.balance { padding: 18px 21px; border-radius: 14px; background: var(--blue-soft); color: var(--dark-blue); }
.balance .label { color: var(--dark-blue); margin-bottom: 4px; }
.amount { font-size: clamp(24px, 6vw, 42px); font-weight: 650; line-height: 1.1; letter-spacing: -.05em; overflow-wrap: anywhere; }
.receipt-facts { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 12px; margin: 0; }
.receipt-facts > div { display: grid; gap: 3px; padding: 13px 0; }
.receipt-facts > div + div { border-left: 1px solid var(--rule); padding-left: 16px; }
.receipt-facts dt { color: var(--muted); font-size: 12px; }
.receipt-facts dd { font-size: 17px; }
.receipt-facts + .receipt-groups { margin-top: 0; }
.receipt-groups { margin-top: 10px; }
.receipt-group { border-top: 1px solid var(--rule); }
.receipt-group-head { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 9px; min-height: 47px; cursor: pointer; font-size: 14px; font-weight: 650; }
.receipt-group-head::-webkit-details-marker { display: none; }
.receipt-group-head::after { grid-column: 3; width: 7px; height: 7px; margin-right: 3px; border-right: 1.5px solid var(--blue); border-bottom: 1.5px solid var(--blue); transform: rotate(45deg); content: ""; }
.receipt-group[open] .receipt-group-head::after { transform: rotate(225deg); }
.group-total { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.receipt-group dl { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); column-gap: 16px; margin: -2px 0 11px; }
.receipt-group dt, .receipt-group dd { padding: 6px 0; font-size: 14px; }
.receipt-group dt { color: var(--muted); }
.receipt-group dd { text-align: right; }
.receipt-group .subtotal { border-top: 1px solid var(--rule); padding-top: 9px; color: var(--ink); }
.receipt-panel dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; font-variant-numeric: tabular-nums; }
.receipt-note { margin-top: 12px; padding: 12px 14px; border-radius: var(--control-radius); background: var(--soft); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.receipt-note strong { display: block; margin-bottom: 3px; color: var(--ink); }
.receipt-close { margin-top: 14px; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(258px, 310px); gap: var(--space); }
.admin-view > .panel { margin-top: var(--space); }
.upload { display: grid; grid-template-columns: minmax(125px, 166px) minmax(0, 1fr); align-items: end; column-gap: 15px; row-gap: 16px; }
.upload label { min-width: 0; }
.upload input[type="month"] {
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--control);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
.file-target {
  position: relative;
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px dashed var(--control);
  border-radius: var(--control-radius);
  background: var(--soft);
  color: var(--dark-blue);
  font-size: 14px;
}
.file-target input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-target:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.file-type { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.upload-actions { grid-column: 1 / -1; display: flex; justify-content: end; }
.upload-actions button { min-width: 124px; }
.upload-panel > p:not(:empty) { margin-top: 10px; }
.rules { display: grid; gap: 7px; padding-left: 16px; color: var(--muted); font-size: 14px; }
.rules li::marker { color: var(--blue); }
.rule-note { margin-top: 12px; font-size: 13px; }
.rules-panel details { margin-top: 10px; border-top: 1px solid var(--rule); }
.rules-panel details[open] { padding-bottom: 5px; }

.scroll { overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; }
tbody tr { border-top: 1px solid var(--rule); }
th, td { padding: 9px 8px; text-align: left; font-size: 14px; }
th { color: var(--muted); font-size: 13px; font-weight: 650; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.user, td.state, .user-id { overflow-wrap: anywhere; }
td:first-child, th:first-child { padding-left: 0; }
td:last-child, th:last-child { padding-right: 0; }
.check { display: grid; width: 32px; min-height: 32px; place-items: center; cursor: pointer; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--blue); }
.toolbar { margin-bottom: 11px; }
.toolbar p { font-size: 13px; }
.details-toggle, .audit-head { min-height: 38px; cursor: pointer; }
.details-toggle { padding-block: 8px; color: var(--dark-blue); font-size: 13px; font-weight: 650; }
td details ul { padding-left: 18px; }
.audit { border-top: 1px solid var(--rule); padding-block: 6px; }
.audit-head { justify-content: flex-start; flex-wrap: wrap; }
.audit-head::after { width: 6px; height: 6px; margin-left: auto; border-right: 1.5px solid var(--blue); border-bottom: 1.5px solid var(--blue); transform: rotate(-45deg); content: ""; }
.audit[open] .audit-head::after { transform: rotate(45deg); }
.audit-head::-webkit-details-marker { display: none; }
.audit-head .muted { font-size: 13px; }
.mono { font-size: 13px; font-variant-numeric: tabular-nums; }

.view-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.view-controls select {
  min-height: 42px;
  padding: 7px 10px;
  border: 1px solid var(--control);
  border-radius: var(--control-radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
.view-controls select:disabled { opacity: .58; }
.view-chart { margin-block: 16px; }
.view-chart:empty { display: none; }
.view-legend { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.view-legend .seen { color: var(--dark-blue); font-weight: 700; }
.view-chart meter {
  display: block;
  width: 100%;
  height: 10px;
  border: 0;
  border-radius: 5px;
  background: var(--rule);
  appearance: none;
}
.view-chart meter::-webkit-meter-bar { border: 0; border-radius: 5px; background: var(--rule); }
.view-chart meter::-webkit-meter-optimum-value { border-radius: 5px; background: var(--blue); }
.view-chart meter::-moz-meter-bar { border-radius: 5px; background: var(--blue); }
.view-tag { display: inline-block; padding: 4px 8px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 13px; white-space: nowrap; }
.view-tag.seen { background: var(--blue-soft); color: var(--dark-blue); }
.view-time { font-variant-numeric: tabular-nums; white-space: nowrap; }

dialog {
  width: min(424px, calc(100% - 32px));
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 24px;
  color: var(--ink);
  box-shadow: 0 20px 60px rgb(20 38 64 / 16%);
}
dialog h2 { margin-bottom: 9px; }
dialog p { color: var(--muted); }
dialog::backdrop { background: rgb(16 33 62 / 36%); }
.dialog-actions { justify-content: end; margin-top: 23px; }
dialog[open] { transition: opacity 160ms var(--ease-out), transform 160ms var(--ease-out); }
@starting-style { dialog[open] { opacity: 0; transform: scale(.97); } }

@media (hover: hover) and (pointer: fine) {
  button:hover:not(:disabled), .button:hover, .file-target:hover { background-color: var(--blue-soft); }
  .primary:hover:not(:disabled) { background-color: var(--dark-blue); }
  nav a:hover { color: var(--dark-blue); }
}

@media (max-width: 840px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .wrap { padding-top: 35px; }
}

@media (max-width: 720px) {
  :root { --space: 16px; }
  #employee-layout { grid-template-columns: minmax(0, 1fr); }
  #employee-layout:not(.has-receipt) #employee-detail { display: none; }
  #employee-layout.has-receipt #employee-detail { grid-row: 1; }
  .receipt-empty { display: none; }
  .panel { padding: 18px; }
  .bar { min-height: 58px; gap: 6px; }
  .brand { gap: 7px; font-size: 14px; }
  .mark { width: 29px; height: 29px; border-radius: 9px; }
  nav { gap: 4px; }
  nav a, .nav-exit { padding-inline: 7px; min-height: 38px; font-size: 12px; }
  .wrap { padding-top: 29px; }
  .headline { display: block; min-height: auto; margin-bottom: 20px; }
  h1 { font-size: 24px; }
  .employee-view .headline { display: flex; align-items: start; }
  .headline .actions { margin-top: 13px; }
  .panel h2 { font-size: 17px; }
  .receipt-header h2 { margin-bottom: 3px; }
  .slip-row button, button, .button { min-height: 44px; }
  .slip-row button { padding-inline: 12px; }
  .upload { grid-template-columns: 1fr; }
  .upload-actions button { width: 100%; }
  .toolbar { flex-wrap: wrap; }
  .scroll table { min-width: 550px; }
}

@media (max-width: 360px) {
  .bar { flex-wrap: wrap; padding-block: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  button, .button, dialog[open] { transition: none; }
  button:active:not(:disabled), .button:active, dialog[open] { transform: none; }
}
