:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #111827;
  --ink-2: #5b6474;
  --line: #e3e6ee;
  --accent: #1c6cf2;
  --accent-2: #e8f0ff;
  --good: #0f9d58;
  --night: #6d4bd8;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1117;
    --card: #171b24;
    --ink: #eef1f7;
    --ink-2: #9aa3b5;
    --line: #262c39;
    --accent: #5b9bff;
    --accent-2: #1a2640;
    --good: #3ccf8e;
    --night: #a68bff;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

.top {
  padding: 14px 16px;
  max-width: 720px;
  margin: 0 auto;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 120px;
}

.intro h1 {
  margin: 6px 0 6px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.intro p {
  margin: 0 0 18px;
  color: var(--ink-2);
}

/* ---------- tool ---------- */

.tool {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 6px 24px rgba(17, 24, 39, 0.06);
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.seg {
  display: flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.seg button {
  white-space: nowrap;
  border: 0;
  background: none;
  padding: 8px 14px;
  border-radius: 9px;
  font: 600 14px var(--font);
  color: var(--ink-2);
  cursor: pointer;
}

.seg button.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.round {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-2);
}

select,
input {
  font: 500 16px var(--font);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 0;
}

select:focus,
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.head-row,
.row {
  display: grid;
  grid-template-columns: 38px 1fr 1fr 50px 54px;
  gap: 5px;
  align-items: center;
}

.head-row {
  padding: 0 2px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.row {
  padding: 5px 2px;
  border-top: 1px solid var(--line);
}

.row .day {
  font-weight: 700;
  font-size: 14px;
}

.row input[type='time'] {
  width: 100%;
  padding: 9px 4px;
  font-size: 15px;
  text-align: center;
}

/* the whole box opens the picker on phones; the little clock icon only costs width */
.row input[type='time']::-webkit-calendar-picker-indicator {
  display: none;
}

.row input[type='time']::-webkit-datetime-edit {
  padding: 0;
}

.row input[type='number'] {
  width: 100%;
  text-align: center;
}

.hrs {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.hrs b {
  font-size: 16px;
}

.hrs small {
  font-size: 12px;
  color: var(--ink-2);
}

.row.filled .day {
  color: var(--accent);
}

.week + .week {
  margin-top: 14px;
}

.week-title {
  display: flex;
  justify-content: space-between;
  margin: 4px 2px 6px;
  font-weight: 700;
}

.week-total {
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  font: 600 14px var(--font);
  cursor: pointer;
}

.ghost:hover {
  border-color: var(--accent);
}

.pay {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-2);
}

.pay label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.money {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.money i {
  position: absolute;
  left: 10px;
  font-style: normal;
  color: var(--ink-2);
}

.money input {
  width: 110px;
  padding-left: 22px;
}

#otx {
  width: 64px;
  text-align: center;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* the total stays visible at the bottom while you type */
.summary {
  position: sticky;
  bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  margin: 14px -4px -4px;
  padding: 12px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 30px rgba(28, 108, 242, 0.35);
}

.summary > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.summary small {
  font-size: 12px;
  opacity: 0.8;
}

.summary b {
  font-size: 24px;
  font-weight: 800;
}

.summary em {
  font-style: normal;
  font-size: 13px;
  opacity: 0.85;
}

/* ---------- article ---------- */

.content {
  margin-top: 36px;
}

.content h2 {
  margin: 28px 0 8px;
  font-size: 21px;
  letter-spacing: -0.01em;
}

.content p,
.content li {
  color: var(--ink-2);
}

.table-wrap {
  overflow-x: auto;
}

.dec {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.dec th,
.dec td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.dec th {
  color: var(--ink-2);
  font-weight: 600;
}

.dec td:nth-child(even) {
  font-weight: 600;
}

.foot {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 40px;
  color: var(--ink-2);
  font-size: 13px;
}

@media (max-width: 360px) {
  .head-row,
  .row {
    grid-template-columns: 30px 1fr 1fr 44px 50px;
    gap: 4px;
  }
  .row input[type='time'] {
    font-size: 14px;
  }
  .seg button {
    padding: 8px 10px;
  }
}

@media print {
  .top,
  .controls,
  .actions,
  .content,
  .foot {
    display: none;
  }
  .summary {
    position: static;
    box-shadow: none;
  }
  body {
    background: #fff;
  }
  .tool {
    box-shadow: none;
    border: 0;
  }
}

/* ---------- v2: nav, week navigation, punch, settings, export ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px;
  padding: 0 16px 4px;
  max-width: 100vw;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  flex: none;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--ink);
}

.nav a[aria-current='page'] {
  background: var(--accent-2);
  color: var(--accent);
}

.weeknav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.icon {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.punch {
  width: 100%;
  margin: 0 0 10px;
  padding: 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-2);
  color: var(--accent);
  font: 700 16px var(--font);
  cursor: pointer;
}

.punch:disabled {
  opacity: 0.6;
  cursor: default;
}

.row .day {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.row .day small {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
}

.row.today {
  background: linear-gradient(90deg, var(--accent-2), transparent 70%);
  border-radius: 10px;
}

.settings {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink-2);
}

.settings summary {
  cursor: pointer;
  font-weight: 600;
  padding: 6px 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 6px 0 4px;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-grid .wide {
  grid-column: 1 / -1;
}

.export {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.print-head {
  display: none;
}

.foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin-bottom: 8px;
}

.foot a {
  color: var(--ink-2);
}

/* ---------- simple calculators (hours, decimal, overtime) ---------- */

.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.calc-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}

.calc-grid input,
.calc-grid select {
  width: 100%;
  font-size: 18px;
  padding: 11px 12px;
}

.calc-grid .wide {
  grid-column: 1 / -1;
}

.big-result {
  margin-top: 14px;
  padding: 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.big-result div {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.big-result small {
  font-size: 12px;
  opacity: 0.8;
}

.big-result b {
  font-size: 28px;
  font-weight: 800;
}

.shift-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.shift-list .row {
  grid-template-columns: 1fr 1fr 64px 60px 28px;
}

.x {
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 18px;
  cursor: pointer;
}

@media print {
  .nav,
  .punch,
  .export,
  .settings,
  .weeknav .icon,
  .toast {
    display: none !important;
  }
  .print-head {
    display: block;
    font-weight: 700;
  }
}

.seg.mode {
  display: inline-flex;
  flex-wrap: wrap;
}

.seg.mode label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.seg.mode label:has(input:checked) {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.note {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--ink-2);
}

.shift-head {
  grid-template-columns: 1fr 1fr 64px 60px 28px;
}

.content h3 {
  margin: 18px 0 4px;
  font-size: 17px;
}

.controls {
  flex-wrap: wrap;
}

.weeknav {
  margin-left: auto;
}

.intro h1 {
  line-height: 1.15;
}

.content h2 {
  line-height: 1.25;
}

/* ---------- ads: hidden until Google fills them, gone when it does not ---------- */

.ad {
  margin: 28px 0;
  text-align: center;
  overflow: hidden;
}
.ad:has(ins[data-ad-status='filled'])::before {
  content: 'Advertisement';
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.ad ins,
.ad-rail ins {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.ad ins[data-ad-status='filled'],
.ad-rail ins[data-ad-status='filled'] {
  opacity: 1;
}
.ad ins[data-ad-status='unfilled'],
.ad-rail ins[data-ad-status='unfilled'] {
  display: none !important;
}
.ad:has(ins[data-ad-status='unfilled']) {
  display: none;
}

/* rail beside the 720px column, only where it fits without touching the page */
.ad-rail {
  display: none;
  position: fixed;
  top: 50%;
  left: calc(50% + 384px);
  transform: translateY(-50%);
}
.rail-ins {
  display: inline-block;
  width: 160px;
  height: 600px;
}
@media (min-width: 1120px) and (min-height: 660px) {
  .ad-rail {
    display: block;
  }
}
@media (min-width: 1400px) {
  .rail-ins {
    width: 300px;
  }
}

@media print {
  .ad,
  .ad-rail {
    display: none !important;
  }
}

/* ---------- small shared bits: checkbox rows, state list ---------- */

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}
.check input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  flex: none;
}
.state-list {
  columns: 2;
  column-gap: 24px;
}
@media (max-width: 480px) {
  .state-list {
    columns: 1;
  }
}

/* ---------- printable time card ---------- */

.pt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 16px 0 4px;
  font-size: 14px;
  color: var(--ink-2);
}
.pt-actions a {
  color: var(--accent);
  font-weight: 600;
}
button.primary {
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: 700 16px var(--font);
  cursor: pointer;
}
.sheet-wrap {
  margin: 16px -14px -14px;
  padding: 16px;
  overflow-x: auto;
  background: var(--bg);
  border-top: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
}
/* the paper itself stays black on white in dark mode too */
.sheet {
  min-width: 620px;
  padding: 28px 30px 34px;
  background: #fff;
  color: #111;
  border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  font-size: 13px;
}
.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}
.sheet h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sheet .fields {
  flex: 1;
  max-width: 360px;
}
.sheet .f {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
}
.sheet .f span {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #666;
}
.sheet .f b {
  min-height: 22px;
  padding: 3px 0 2px;
  border-bottom: 1px solid #333;
  font-weight: 600;
}
.tc {
  width: 100%;
  margin-top: 18px;
  border-collapse: collapse;
  table-layout: fixed;
}
.tc caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 4px;
}
.tc th,
.tc td {
  height: 34px;
  padding: 0 6px;
  border: 1px solid #444;
  text-align: left;
  font-size: 12px;
}
.sheet.two .tc th,
.sheet.two .tc td {
  height: 26px;
}
.tc thead th {
  background: #e8efff;
  font-size: 11px;
}
.tc tbody th {
  font-weight: 600;
}
.tc .date {
  color: #333;
}
.tc tfoot td {
  font-weight: 700;
}
.sheet .sums,
.sheet .signs {
  display: grid;
  gap: 8px 24px;
  margin-top: 20px;
}
.sheet .sums {
  grid-template-columns: repeat(3, 1fr);
}
.sheet .signs {
  grid-template-columns: 2fr 1fr;
}

@media print {
  @page {
    size: letter;
    margin: 0.5in;
  }
  .printable-page .intro,
  .printable-page .pt-options {
    display: none !important;
  }
  .printable-page .tool {
    padding: 0;
    border: 0;
    background: none;
  }
  .printable-page main {
    padding: 0;
    max-width: none;
  }
  .printable-page .sheet-wrap {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    overflow: visible;
  }
  .printable-page .sheet {
    min-width: 0;
    padding: 0;
    box-shadow: none;
  }
  .sheet .tc thead th {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
@media print {
  .printable-page .sheet {
    zoom: 1 !important;
  }
}

/* ---------- embed: forced themes, bare page, code generator ---------- */

html.theme-light {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #111827;
  --ink-2: #5b6474;
  --line: #e3e6ee;
  --accent: #1c6cf2;
  --accent-2: #e8f0ff;
  --good: #0f9d58;
  --night: #6d4bd8;
  color-scheme: light;
}
html.theme-dark {
  --bg: #0e1117;
  --card: #171b24;
  --ink: #eef1f7;
  --ink-2: #9aa3b5;
  --line: #262c39;
  --accent: #5b9bff;
  --accent-2: #1a2640;
  --good: #3ccf8e;
  --night: #a68bff;
  color-scheme: dark;
}
body.embed {
  background: transparent;
  padding: 2px;
}
body.embed .tool {
  box-shadow: none;
}
.embed-credit {
  margin: 8px 4px 2px;
  font-size: 12px;
  color: var(--ink-2);
}
.embed-credit a {
  color: var(--ink);
  text-decoration: none;
}
.eg-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.eg-label {
  display: block;
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
}
.eg-code {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
  resize: vertical;
}
.eg-preview {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: repeating-linear-gradient(45deg, transparent 0 10px, var(--bg) 10px 20px);
}
