:root {
  color-scheme: light dark;
  font: 15px/1.4 system-ui, sans-serif;
  --background: var(--tg-theme-secondary-bg-color, light-dark(#f1f5f8, #10181f));
  --surface: var(--tg-theme-bg-color, light-dark(#ffffff, #18232c));
  --foreground: var(--tg-theme-text-color, light-dark(#12212c, #f0f5fa));
  --muted: var(--tg-theme-hint-color, light-dark(#526674, #a5b5c5));
  --accent: var(--tg-theme-link-color, light-dark(#02526e, #90ddf8));
  --line: color-mix(in srgb, var(--foreground) 12%, var(--surface));
  --highlight: color-mix(in srgb, var(--accent) 8%, var(--surface));
  --break: light-dark(#d9480f, #ffa94d);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--foreground); }
#app { max-width: 1240px; margin: auto; padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
header { margin: 4px 0 14px; }
h1, h2, h3, p, dl { margin: 0; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
h3 { margin: 12px 0 6px; }
header p, #status, .legend, small { color: var(--muted); }
nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
[hidden] { display: none !important; }
button, select, input { color: var(--foreground); font: inherit; }
button, select, input[type=date] { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
button { padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .48; cursor: default; }
button[aria-pressed=true] { color: var(--accent); border-color: var(--accent); font-weight: 650; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.selectors { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
label { min-width: 0; display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
.selectors > label:nth-child(2) { flex: 1 1 155px; }
select, input[type=date] { max-width: 100%; padding: 5px 7px; font-size: 1rem; }
.date-picker { display: flex; gap: 4px; align-items: end; }
/* A date field: the native input stays for its calendar, transparent, over the date written as day.month.year. */
.date-field { position: relative; display: inline-flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 38px; max-width: 100%; padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--foreground); font-size: 1rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-field::after { content: ""; width: 15px; height: 15px; background: var(--muted); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 1H6v2h4V1h1.5v2H14v12H2V3h2.5zm-1 5.5v7h9v-7z'/%3E%3C/svg%3E") center / contain no-repeat; }
.date-field input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
/* Chromium opens the calendar only from its indicator, so the indicator covers the whole field. */
.date-field input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; cursor: pointer; }
.date-field:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
#status { margin: 13px 0 7px; font-size: .85rem; }
.comparison { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 5px; border-bottom: 1px solid var(--line); font-size: .9rem; overflow-wrap: anywhere; }
thead th { vertical-align: top; background: var(--highlight); padding-block: 9px; }
tbody tr:last-child > * { border-bottom: 0; }
.comparison table { min-width: 320px; table-layout: fixed; }
.comparison th, .comparison td { text-align: right; vertical-align: middle; }
.comparison th:first-child { text-align: left; width: 28%; padding-left: 8px; position: sticky; left: 0; background: var(--surface); }
.comparison th[scope=row] { font-weight: 520; }
.comparison thead th:first-child { background: var(--highlight); }
.comparison thead strong, .comparison thead span { display: block; }
.comparison thead span { margin-top: 4px; font-weight: 500; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.comparison thead button { font-size: .75rem; min-height: 29px; padding: 3px 4px; margin-top: 5px; color: var(--accent); }
.comparison tbody tr:nth-child(2n) > * { background: var(--highlight); }
button.link { min-height: 0; padding: 0; border: 0; background: none; color: var(--accent); text-align: inherit; text-decoration: underline; text-underline-offset: 2px; }
.legend { margin: 8px 0; font-size: .82rem; }
#journal article, .payment, details, .message { padding: 10px; margin-bottom: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); overflow-wrap: anywhere; }
#journal article small { display: block; }
dialog { width: min(580px, calc(100vw - 18px)); max-height: 87dvh; padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--foreground); background: var(--background); }
dialog::backdrop { background: #050d17a8; }
.dialog-top { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--background); border-bottom: 1px solid var(--line); }
.dialog-top form { margin-left: auto; }
#details-body { padding: 12px; }
summary { cursor: pointer; font-weight: 650; }
details dl { margin-top: 8px; }
details dl div { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; border-top: 1px solid var(--line); }
dd { margin: 0; text-align: right; }
.payment, .chat-list { display: grid; gap: 5px; }
.payment button { justify-self: start; }
.chat-list button { text-align: left; }
.message { margin-right: 8%; }
.message.creator { margin-right: 0; margin-left: 8%; background: var(--highlight); }
.message p { white-space: pre-wrap; }
.message.highlighted { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Breaks: one bar per shift under the day table. A span of the bar and its line in the list highlight together. */
.break-timeline { margin: 10px 0 16px; }
.break-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; font-size: .9rem; }
.break-title span { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.break-track { position: relative; height: 28px; margin-top: 5px; border-radius: 5px; background: color-mix(in srgb, var(--foreground) 10%, var(--surface)); }
.break-hour, .break-unobserved, .break-span { position: absolute; top: 0; bottom: 0; }
.break-hour { width: 1px; background: color-mix(in srgb, var(--foreground) 16%, var(--surface)); }
.break-unobserved { right: 0; border-radius: 0 5px 5px 0; background: repeating-linear-gradient(135deg, var(--background) 0 5px, color-mix(in srgb, var(--foreground) 22%, var(--background)) 5px 7px); }
.break-span { min-width: 4px; min-height: 0; padding: 0; border: 0; border-left: 1px solid var(--surface); border-radius: 3px; background: var(--break); }
.break-span:is(.active, .focused, .pinned) { z-index: 1; outline: 2px solid var(--foreground); outline-offset: 1px; }
.break-tip { position: absolute; bottom: calc(100% + 7px); left: 50%; translate: -50% 0; visibility: hidden; padding: 4px 9px; border-radius: 6px; background: var(--foreground); color: var(--surface); font-size: .82rem; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.tip-left .break-tip { left: 0; translate: none; }
.tip-right .break-tip { left: auto; right: 0; translate: none; }
.break-span:is(.active, .focused, .pinned) .break-tip { visibility: visible; }
.break-axis { position: relative; height: 1.3em; margin-top: 2px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.break-axis span { position: absolute; translate: -50% 0; }
.break-axis span:first-child { translate: none; }
.break-axis span:last-child { translate: -100% 0; }
.break-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.break-list button { width: 100%; min-height: 30px; padding: 3px 10px; font-size: .85rem; font-variant-numeric: tabular-nums; text-align: left; white-space: nowrap; }
.break-list button:is(.active, .focused, .pinned) { border-color: var(--break); background: color-mix(in srgb, var(--break) 16%, var(--surface)); }

/* Carryovers: the list under the day table and the period tab. */
.section-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 22px 0 4px; }
.section-title span, .muted { color: var(--muted); }
#carryovers h2 { margin: 22px 0 8px; }
.quick-periods { display: flex; gap: 4px; }
label.check { display: flex; align-items: center; gap: 6px; min-height: 38px; font-size: .9rem; color: var(--foreground); }
#ledger-status { margin: 13px 0 7px; font-size: .85rem; color: var(--muted); }
.empty { padding: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.tiles div { display: grid; gap: 2px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.tiles span, .tiles small { color: var(--muted); font-size: .8rem; }
.tiles b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ledger-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.ledger th, .earnings th, .ledger td, .earnings td { padding: 8px 10px; text-align: left; vertical-align: top; }
.earnings td, .earnings thead th:not(:first-child) { text-align: right; }
.earnings th[scope=row] { font-weight: 520; }
.ledger td > b, .ledger td > span, .ledger td > small, .ledger td > button { display: block; }
.ledger td.amount { white-space: nowrap; }
.ledger .ppv-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-style: italic; }
.earnings { min-width: 640px; }
.earnings th, .earnings td { white-space: nowrap; }
.ledger form button.link { flex-basis: 100%; text-align: left; font-size: .85rem; }
.ledger tr.reassigned > td { background: var(--highlight); }
.ledger form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ledger form select { flex: 1 1 130px; min-width: 0; max-width: 260px; }
.ledger form.unsaved select { border-color: var(--accent); }
.ledger form p { flex-basis: 100%; font-size: .8rem; color: var(--muted); }
.ledger form p:empty { display: none; }
.ledger td > .badge { display: inline-block; justify-self: start; margin-bottom: 6px; }
.badge { padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--surface); font-size: .72rem; font-weight: 650; }
.history { margin: 6px 0 0; padding: 0; list-style: none; font-size: .8rem; color: var(--muted); }
.ledger-day h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 16px 0 6px; }
.ledger-day h3 span { font-size: .85rem; font-weight: 500; color: var(--muted); }
.unallocated { margin-top: 18px; }
.unallocated .legend { margin: 6px 0 10px; }
@media (min-width: 761px) {
  .carryover-table { table-layout: fixed; min-width: 980px; }
  .carryover-table th:nth-child(1) { width: 11%; }
  .carryover-table th:nth-child(2) { width: 17%; }
  .carryover-table th:nth-child(3) { width: 9%; }
  .carryover-table th:nth-child(4) { width: 26%; }
  .carryover-table th:nth-child(5) { width: 12%; }
  .carryover-table th:nth-child(6) { width: 25%; }
}
@media (max-width: 760px) {
  .ledger-scroll:has(.ledger) { border: 0; background: none; overflow: visible; }
  .ledger thead { display: none; }
  .ledger, .ledger tbody { display: block; }
  .ledger tr { display: grid; gap: 7px; padding: 10px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
  .ledger tr.reassigned { background: var(--highlight); }
  .ledger td { display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 8px; padding: 0; border: 0; }
  .ledger td::before { content: attr(data-label); grid-row: 1 / span 6; color: var(--muted); font-size: .8rem; }
  .ledger td > * { grid-column: 2; }
}
