:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #e2e8f0;
  --surface: #fff;
  --canvas: #f6f8fb;
  --heading: #101828;
  --field-border: #cbd5e1;
  --field-focus: #60a5fa;
  --focus-ring: #dbeafe;
  --subtle-surface: #f8fafc;
  --code-surface: #eef2f6;
  --nav-hover: #eff4ff;
  --callout-line: #bfdbfe;
  --callout-surface: #eff6ff;
  --header-surface: rgba(255, 255, 255, 0.92);
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --danger: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e5e7eb;
    --muted: #a8b3c7;
    --line: #334155;
    --surface: #172033;
    --canvas: #0f172a;
    --heading: #f8fafc;
    --field-border: #475569;
    --field-focus: #60a5fa;
    --focus-ring: #1e3a5f;
    --subtle-surface: #1e293b;
    --code-surface: #263449;
    --nav-hover: #1e3a5f;
    --callout-line: #1d4f8c;
    --callout-surface: #172b4d;
    --header-surface: rgba(15, 23, 42, 0.92);
    --brand: #60a5fa;
    --brand-dark: #93c5fd;
    --danger: #ef4444;
  }
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font:
    16px / 1.5 Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
a {
  color: var(--brand);
  text-underline-offset: 0.16em;
}
a:hover {
  color: var(--brand-dark);
}
code {
  padding: 0.12rem 0.35rem;
  border-radius: 5px;
  background: var(--code-surface);
}
.container {
  width: min(1120px, calc(100% - 40px));
  margin-inline: auto;
}
.site-header {
  background: var(--header-surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.site-nav {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  color: var(--ink);
  font-weight: 750;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}
.nav-links form {
  margin: 0;
}
.nav-links .sign-out {
  min-height: 0;
  border: 0;
  background: transparent;
}
.nav-links a,
.nav-links .sign-out {
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 0.94rem;
  font-weight: 600;
  text-decoration: none;
}
.nav-links a:hover,
.nav-links .sign-out:hover {
  background: var(--nav-hover);
  color: var(--brand-dark);
}
.nav-toggle {
  display: none;
  margin-left: auto;
}
.page-content {
  margin-block: 48px 64px;
}
h1,
h2 {
  color: var(--heading);
  letter-spacing: -0.03em;
  line-height: 1.2;
}
h1 {
  margin: 0 0 28px;
  font-size: clamp(2rem, 4vw, 2.65rem);
}
h2 {
  margin: 40px 0 16px;
  font-size: 1.25rem;
}
p {
  margin: 0 0 16px;
}
.card {
  margin-bottom: 28px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
}
.wide {
  grid-column: span 3;
}
label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 650;
}
input,
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--field-focus);
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea {
  min-height: 88px;
  resize: vertical;
}
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.94rem;
  font-weight: 650;
  text-decoration: none;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.15s;
}
button:hover,
.button:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}
button:active,
.button:active {
  transform: translateY(1px);
}
.button.secondary {
  background: var(--surface);
  border-color: var(--field-border);
  color: var(--ink);
}
.button.secondary:hover {
  background: var(--subtle-surface);
  border-color: var(--muted);
  color: var(--ink);
}
.danger {
  background: var(--danger);
  border-color: var(--danger);
}
.danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}
.form-actions,
.filters,
.week-nav,
.invoice-actions,
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
}
.filters,
.week-nav {
  margin-bottom: 24px;
}
.filters label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.filters input,
.filters select {
  width: auto;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
}
.checkbox input {
  width: auto;
}
.week-nav {
  justify-content: flex-start;
}
.week-nav-group {
  display: flex;
  align-items: stretch;
}
.week-nav-group .button,
.week-nav-group input {
  border-radius: 0;
}
.week-nav-group > :first-child {
  border-radius: 8px 0 0 8px;
}
.week-nav-group > :last-child {
  border-radius: 0 8px 8px 0;
}
.week-nav-group form {
  display: flex;
}
.week-nav-group input {
  border-inline: 0;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--subtle-surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
tr:last-child td {
  border-bottom: 0;
}
.number,
.total {
  text-align: right;
}
small,
.muted {
  color: var(--muted);
}
.total {
  margin-top: 12px;
  color: var(--heading);
  font-size: 1.1rem;
  font-weight: 700;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--muted);
}
.breadcrumbs a + a::before,
.breadcrumbs a + span::before {
  content: "/";
  margin-right: 10px;
  color: var(--muted);
}
.pagination {
  justify-content: space-between;
  margin-top: 18px;
}
.empty {
  padding: 22px;
  border: 1px dashed var(--field-border);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}
.callout {
  margin-bottom: 28px;
  padding: 18px 20px;
  border: 1px solid var(--callout-line);
  border-radius: 10px;
  background: var(--callout-surface);
}
.callout p:last-child {
  margin-bottom: 0;
}
.preserve-lines {
  white-space: pre-line;
}
.error-page {
  max-width: 680px;
  padding-block: 80px;
}
.error-page .eyebrow {
  color: var(--brand);
  font-weight: 800;
}

.invoice-actions {
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 900px;
}
.invoice-sheet {
  max-width: 900px;
  min-height: 1060px;
  margin: 0 auto;
  padding: 54px 58px;
  background: #fff;
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.12);
  color: #202124;
  font:
    13px / 1.45 Arial,
    sans-serif;
}
.invoice-header,
.invoice-addresses {
  display: flex;
  justify-content: space-between;
  gap: 48px;
}
.invoice-header h1 {
  margin: 0;
  color: #202124;
  font:
    400 36px / 1 Arial,
    sans-serif;
  letter-spacing: 0;
}
.invoice-party {
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr);
  gap: 18px;
}
.invoice-party > span,
.invoice-meta dt {
  color: #666;
}
.invoice-party strong {
  font-size: 15px;
}
.invoice-party p {
  margin: 4px 0 0;
  white-space: pre-line;
}
.invoice-header .invoice-party {
  width: 255px;
}
.invoice-addresses {
  align-items: start;
  margin-top: 76px;
}
.invoice-addresses > .invoice-party {
  flex: 1;
  grid-template-columns: 72px minmax(180px, 1fr);
}
.invoice-meta {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 20px;
  margin: 0;
}
.invoice-meta dt {
  text-align: right;
}
.invoice-meta dd {
  margin: 0;
  font-weight: 600;
}
.invoice-lines {
  margin-top: 58px;
  border: 1px solid #b7b7b7;
}
.invoice-lines th {
  padding: 8px;
  border-bottom: 1px solid #b7b7b7;
  background: #fff;
  color: #202124;
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
}
.invoice-lines td {
  padding: 8px;
  border-bottom: 0.5px solid #b7b7b7;
}
.invoice-lines th + th,
.invoice-lines td + td {
  border-left: 0.5px solid #b7b7b7;
  text-align: right;
}
.invoice-lines tbody tr:nth-child(even) {
  background: #f1f1f1;
}
.invoice-total {
  margin-top: 16px;
  font-size: 16px;
  text-align: right;
}
.invoice-total strong {
  margin-left: 18px;
}

@media (max-width: 720px) {
  .container {
    width: min(100% - 28px, 1120px);
  }
  .site-nav {
    min-height: 60px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    padding: 4px 0 14px;
  }
  .nav-links.is-open {
    display: flex;
  }
  .nav-links a {
    padding: 10px;
  }
  .page-content {
    margin-block: 30px 44px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  .form-actions,
  .filters,
  .week-nav {
    align-items: stretch;
    flex-direction: column;
  }
  .form-actions > *,
  .filters input,
  .filters select {
    width: 100%;
  }
  .filters label {
    display: grid;
  }
  .week-nav-group {
    width: 100%;
  }
  .week-nav-group > * {
    flex: 1;
  }
  .week-nav-group input {
    min-width: 0;
  }
  .invoice-page .container {
    width: 100%;
  }
  .invoice-sheet {
    min-height: 0;
    padding: 30px 24px;
  }
  .invoice-header,
  .invoice-addresses {
    flex-direction: column;
  }
  .invoice-addresses {
    margin-top: 48px;
  }
}

@page {
  size: Letter;
  margin: 0.5in;
}
@media print {
  body,
  .invoice-page {
    min-height: 0;
    background: #fff;
  }
  .no-print {
    display: none !important;
  }
  .invoice-page .page-content {
    width: auto;
    margin: 0;
  }
  .invoice-sheet {
    max-width: none;
    min-height: 0;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
  .invoice-lines tr {
    break-inside: avoid;
  }
}
