:root {
  color-scheme: dark;
  --signal: #67fff0;
  --signal-press: #3ad9cc;
  --signal-ink: #005c57;
  --signal-wash: #e7fffd;
  --canvas: #0a0a0a;
  --sidebar: #0a0a0a;
  --panel: #1c1c1c;
  --hover: #262626;
  --line: #2e2e2e;
  --type: #e5e5e5;
  --heading: #ffffff;
  --support: #e5e5e5;
  --nav: #e5e5e5;
  --mute: #8a8a8a;
  --input: #0a0a0a;
  --button: #67fff0;
  --button-ink: #000000;
  --button-hover: #3ad9cc;
  --button-focus: #000000;
  --link: #ffffff;
  --outline-hover: rgba(255, 255, 255, 0.1);
  --danger: #ffb4c0;
  --danger-wash: rgba(255, 180, 192, 0.1);
  --input-focus: #67fff0;
  --input-ring: none;
  --font-serif: "DM Serif Text", Georgia, serif;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--type);
  background: var(--canvas);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
}

html[data-theme="dark"] { color-scheme: dark; }

html[data-theme="light"] {
  color-scheme: light;
  --canvas: #ffffff;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --hover: #e7fffd;
  --line: #e6e6e6;
  --type: #1a1a1a;
  --heading: #000000;
  --support: #3a3a3a;
  --nav: #595959;
  --mute: #595959;
  --input: #ffffff;
  --button: #67fff0;
  --button-ink: #000000;
  --button-hover: #3ad9cc;
  --button-focus: #000000;
  --link: #005c57;
  --outline-hover: #e7fffd;
  --danger: #9f1239;
  --danger-wash: #fde8ec;
  --input-focus: #000000;
  --input-ring: 0 0 0 3px #67fff0;
}

html[data-theme="light"] .pill-active,
html[data-theme="light"] .pill-paid { background: #d8f5e8; color: #0d5c3d; }
html[data-theme="light"] .pill-pending,
html[data-theme="light"] .pill-part { background: #fff4d6; color: #6b4e00; }
html[data-theme="light"] .pill-approved,
html[data-theme="light"] .pill-upcoming { background: #e4f2fb; color: #0b4a6e; }
html[data-theme="light"] .pill-arrears { background: #fde8ec; color: #8f1d33; }

* { box-sizing: border-box; }

body { margin: 0; background: var(--canvas); color: var(--type); }

body.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 1.25rem 0.75rem;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.brand { display: block; padding: 0 0.75rem; color: inherit; text-decoration: none; }

.wordmark {
  display: inline-block;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 3.25rem;
  line-height: 0.92;
  color: var(--heading);
}

.wordmark span { display: block; }

.wordmark .idea {
  display: inline-block;
  width: fit-content;
  margin-top: 0.04em;
  padding: 0 0.1em;
  border-radius: 2px;
  background: var(--signal);
  color: #000000;
}

.product {
  display: block;
  margin-top: 1.1rem;
  color: var(--mute);
  font-size: 0.8rem;
  font-weight: 600;
}

.working {
  display: block;
  margin-top: 0.45rem;
  color: var(--heading);
  font-weight: 600;
  font-size: 0.95rem;
}

.place {
  display: block;
  margin-top: 0.15rem;
  color: var(--mute);
  font-size: 0.8rem;
  font-weight: 500;
}

.currency {
  margin: 0.75rem 0 0;
  padding: 0 0.75rem;
  color: var(--mute);
  font-size: 0.8rem;
  font-weight: 500;
}

.sidebar nav { display: grid; gap: 0.2rem; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--nav);
  text-decoration: none;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  font-weight: 500;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  color: var(--heading);
  background: var(--hover);
}

.who { margin-top: auto; display: grid; gap: 0.75rem; }
.who p { margin: 0; padding: 0 0.75rem; color: var(--mute); font-size: 0.85rem; font-weight: 500; }

.theme-switch {
  display: grid;
  gap: 0.35rem;
  padding: 0 0.75rem;
}

.theme-label {
  color: var(--mute);
  font-size: 0.8rem;
  font-weight: 500;
}

.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.theme-options label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--type);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-options input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.theme-options label:has(input:checked) {
  border-color: var(--heading);
  color: var(--heading);
}

.theme-options label:has(input:focus-visible) {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: block;
  pointer-events: none;
}

.icon-20 { width: 20px; height: 20px; }
.icon-24 { width: 24px; height: 24px; }
.icon-32 { width: 32px; height: 32px; }

.with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.search-field {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 12rem;
}

.search-field .icon {
  position: absolute;
  left: 0.75rem;
  color: var(--mute);
  pointer-events: none;
}

.search-field input { padding-left: 2.35rem; }

.empty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--mute);
}

body.auth .auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(17rem, 1fr);
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--canvas);
}

body.auth .auth-layout .card {
  width: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line);
}

body.auth .auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  margin: 0;
  padding: 1.75rem 1.75rem 1.75rem 2rem;
  background: var(--canvas);
}

body.auth .auth-brand .muted { margin-top: 0.35rem; }

body.auth .card { margin-bottom: 0; }

body.auth .theme-switch {
  margin-top: 1.25rem;
  padding: 0;
  justify-items: center;
}

body.auth .theme-options { justify-content: center; }

.who button {
  width: 100%;
  margin: 0;
  min-height: 0;
  padding: 0.55rem calc(0.75rem - 2px);
  background: transparent;
  color: var(--heading);
  border: 2px solid var(--heading);
  font-size: 0.85rem;
  text-align: left;
  justify-content: flex-start;
}

.who button:hover { background: var(--outline-hover); }

main {
  height: 100%;
  min-height: 0;
  overflow: auto;
  width: auto;
  justify-self: stretch;
  padding: 1.5rem max(1.5rem, calc((100% - 72rem) / 2));
}

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

body.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--canvas);
}

body.auth main {
  width: min(44rem, calc(100% - 3rem));
  height: auto;
  overflow: visible;
  justify-self: center;
  align-self: center;
  padding: 0;
}

h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 2.25rem;
  line-height: 1.15;
  color: var(--heading);
}

h1.with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

h2 {
  margin: 0 0 0.85rem;
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--heading);
}

h2.with-icon {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--mute);
  font-size: 0.8rem;
  font-weight: 500;
}

.muted { color: var(--support); }
.help { margin: 0; color: var(--mute); font-size: 0.9rem; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.75rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stats.pairs {
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.stats article, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
}

.stats article {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stats p { margin: 0; color: var(--mute); font-size: 0.8rem; font-weight: 600; }
.stats p.with-icon { display: block; }
.stats p.with-icon .icon {
  display: inline-block;
  margin-right: 8px;
  vertical-align: -0.2em;
}
.stats strong {
  display: block;
  margin-top: auto;
  color: var(--heading);
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.card > :is(h2, p, .page-head, .plain, .table-wrap, .form) { margin: 0; }
.card > .eyebrow { margin: 0; }
.card > .eyebrow + h1 { margin-top: -0.75rem; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.split > * { margin-bottom: 0; }
.split > .form > button { margin-top: auto; }

.form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
  width: 100%;
  margin: 0;
}

label {
  display: block;
  margin: 0;
  color: var(--support);
  font-size: 0.85rem;
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  margin: 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input);
  color: var(--type);
  font: inherit;
  line-height: 1.25;
  min-height: 2.75rem;
}

input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  min-height: 1.15rem;
  padding: 0;
  align-self: start;
}

input[type="hidden"] { display: none; }

input::placeholder, textarea::placeholder { color: var(--mute); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: var(--input-ring);
}

.search, .form.inline {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1rem;
  width: 100%;
  margin-bottom: 1.25rem;
}

.form.inline { margin-bottom: 0; }

.search .field { flex: 0 0 12.5rem; width: 12.5rem; max-width: 100%; }
.form.inline .field { flex: 1 1 10rem; width: auto; max-width: none; }
.search > input { flex: 1; width: auto; min-width: 12rem; }
.search button, .form.inline button { margin: 0; width: auto; }
.search:not(:has(> input)) button { margin-left: auto; }

.card > .form.inline, .card > .search { margin-bottom: 0; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 2.75rem;
  padding: 0.6rem 1.15rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-ink);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background 300ms, color 300ms, transform 300ms;
}

button:hover, .button:hover { background: var(--button-hover); }
button:active, .button:active { transform: scale(0.95); }

.form:not(.inline) > button { width: 100%; }

button.text {
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: 500;
  border-radius: 0;
  justify-content: start;
}

button.text:hover { background: none; text-decoration: underline; }
button.text:active { transform: none; }

button.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

button.danger:hover { background: var(--danger-wash); }

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
}
.actions form, .actions p { margin: 0; width: 100%; }

table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th + th, td + td { padding-left: 1rem; }
th:last-child, td:last-child { text-align: right; }
td form { display: inline-flex; margin: 0 0 0 0.75rem; vertical-align: middle; }
th {
  color: var(--mute);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.plain { list-style: none; margin: 0; padding: 0; }
.plain li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.plain li:first-child { padding-top: 0; }
.plain li:last-child { padding-bottom: 0; border-bottom: 0; }
.plain li form { display: inline-flex; margin: 0; }

main a { color: var(--link); font-weight: 500; text-decoration: underline; }
html[data-theme="light"] main a { text-decoration: none; }
main a:hover { text-decoration: underline; }

.pill {
  display: inline-block;
  padding: 0.15rem 0.65rem;
  border-radius: 999px;
  background: var(--line);
  color: var(--type);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.pill-active, .pill-paid { background: #14332c; color: #b7f0d8; }
.pill-draft, .pill-rejected, .pill-closed { background: var(--line); color: var(--support); }
.pill-pending, .pill-part { background: #3a3014; color: #f3d48a; }
.pill-approved, .pill-upcoming { background: #1a2c38; color: #c5e4f7; }
.pill-arrears { background: #3a1820; color: #ffb4c0; }

.messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.message {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 2px 0 0 var(--signal);
}
.message .icon { margin-top: 0.15rem; }
.message.error { box-shadow: inset 2px 0 0 var(--danger); }

.error, .errorlist { color: var(--danger); margin: 0.2rem 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

button:focus-visible, .button:focus-visible { outline-color: var(--button-focus); }
.who button:focus-visible,
button.text:focus-visible,
button.danger:focus-visible { outline-color: var(--signal); }

.sheet,
.sheet .card,
.sheet .stats article {
  background: #fff;
  color: #1a1a1a;
  border-color: #e6e6e6;
}

.sheet h1, .sheet h2, .sheet strong { color: #000; }
.sheet .eyebrow, .sheet .muted, .sheet .help, .sheet th { color: #595959; }
.sheet a { color: var(--signal-ink); }
.sheet .stats p { color: #595959; }
.sheet .stats strong { color: #000; }
.sheet td, .sheet th, .sheet .plain li { border-color: #e6e6e6; }
.sheet button.no-print {
  background: var(--signal);
  color: #000;
  border-color: transparent;
}
.sheet button.no-print:hover { background: var(--signal-press); }
.sheet button.no-print:focus-visible { outline-color: #000; }

@media print {
  .sidebar, .no-print, .messages { display: none !important; }
  body, body.app, main, .card, .stats article, .sheet {
    display: block;
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
    color: #1a1a1a !important;
  }
  main { max-width: none; padding: 0; }
  h1, h2, strong, p, th, td, li, .muted, .help, .eyebrow { color: #1a1a1a !important; }
  a { color: var(--signal-ink) !important; }
  .card, .stats article { border-color: #ccc !important; }
}

@media (prefers-reduced-motion: reduce) {
  button, .button { transition: none; }
  button:active, .button:active { transform: none; }
}

@media (max-width: 800px) {
  h1 { font-size: 1.85rem; }
  body.app { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .sidebar, main { height: auto; overflow: visible; }
  .sidebar { gap: 0.75rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar nav { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
  .who { margin-top: 0; }
  .split { grid-template-columns: 1fr; }
  body.auth .auth-layout { grid-template-columns: 1fr; }
  body.auth .auth-layout .card { border-right: 0; border-top: 1px solid var(--line); }
  body.auth .auth-brand { order: -1; padding: 1.5rem; }
  main { padding: 1rem; }
}
