/* Haushalt: calm, dense enough for numbers, light and dark. */
:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --sunken: #ebe8e1;
  --line: #dcd8cf;
  --text: #17160f;
  --muted: #5d5a52;
  --accent: #1f5c4a;
  --accent-text: #ffffff;
  --pos: #1f6b3a;
  --neg: #a1261b;
  --in: #3f8f6b;
  --out: #b0672f;
  --focus: #1f5c4a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121210;
    --surface: #1c1b18;
    --sunken: #25231f;
    --line: #34322d;
    --text: #edeae2;
    --muted: #a9a59b;
    --accent: #7fd1ae;
    --accent-text: #0b1a14;
    --pos: #8fd9a8;
    --neg: #ff8a80;
    --in: #6cc39b;
    --out: #e0a06b;
    --focus: #7fd1ae;
    color-scheme: dark;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px / 1.5 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  font-variant-numeric: tabular-nums;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
h1,
h2,
h3 {
  letter-spacing: -0.01em;
  line-height: 1.2;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* header and tabs */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top-inner,
.tabs,
main {
  max-width: 52rem;
  margin: 0 auto;
  padding: 0 1rem;
}
.top-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding-top: 0.5rem;
}
.home {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}
h1 {
  margin: 0;
  font-size: 1.75rem;
}
.tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs button {
  flex: none;
  border: 0;
  background: none;
  min-height: 44px;
  padding: 0 0.75rem;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tabs button[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
main {
  padding-top: 1rem;
  padding-bottom: 4rem;
}

/* building blocks */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  font-weight: 500;
}
.btn svg,
.icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.danger,
.link.danger {
  color: var(--neg);
}
.btn.small {
  min-height: 44px;
  padding: 0 0.625rem;
  font-size: 0.875rem;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: default;
}
.filebtn {
  position: relative;
}
.filebtn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.filebtn:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.link {
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  min-height: 44px;
  padding: 0 0.25rem;
  cursor: pointer;
}
.icon {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--muted);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.pos {
  color: var(--pos);
}
.neg {
  color: var(--neg);
}
.line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.25rem 0;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  margin: 0 0 1rem;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.card-head h3 {
  margin: 0;
  font-size: 1.125rem;
}
.period {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin-bottom: 0.75rem;
}
.period h2 {
  margin: 0;
  text-align: center;
  font-size: 1.375rem;
}
.toolbar,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}
.empty {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.empty h3 {
  margin: 0 0 0.25rem;
}
.empty p {
  color: var(--muted);
  margin: 0 0 1rem;
}
.note {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  background: var(--sunken);
  border-radius: 10px;
  padding: 0 0.75rem;
  margin: 0 0 1rem;
}
.loading {
  text-align: center;
  padding: 3rem 0;
}

/* numbers */
.kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}
@media (min-width: 40rem) {
  .kpis {
    grid-template-columns: repeat(4, 1fr);
  }
  .kpis.three {
    grid-template-columns: repeat(3, 1fr);
  }
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  min-width: 0;
}
.kpi b {
  display: block;
  font-size: 1.375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi span {
  color: var(--muted);
  font-size: 0.875rem;
}
.meter {
  display: block;
  height: 8px;
  border-radius: 4px;
  background: var(--sunken);
  overflow: hidden;
  margin: 0.25rem 0 0.5rem;
}
.meter i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.meter.over i {
  background: var(--neg);
}
.bars,
.budgets,
.plain,
.txs,
.preview {
  list-style: none;
  margin: 0;
  padding: 0;
}
.budgets li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--line);
}
.budgets li:last-child {
  border-bottom: 0;
}
.budgets label {
  font-weight: 600;
  align-self: center;
}
.budget-input {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.budget-input input {
  width: 8.5rem;
  text-align: right;
}
.chart {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0.25rem;
}
.col {
  border: 0;
  background: none;
  padding: 0.25rem 0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-height: 44px;
}
.col.sel {
  background: var(--sunken);
}
.pair {
  height: 120px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.pair i {
  display: block;
  width: 7px;
  border-radius: 3px 3px 0 0;
  min-height: 1px;
}
.pair .in,
.legend .in {
  background: var(--in);
}
.pair .out,
.legend .out {
  background: var(--out);
}
.col small {
  font-size: 0.75rem;
  color: var(--muted);
}
.legend {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--muted);
}
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-left: 0.5rem;
}

/* bookings */
.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
@media (min-width: 36rem) {
  .filters {
    grid-template-columns: 2fr 1fr;
  }
}
.day h3 {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 600;
  margin: 1rem 0 0.25rem;
}
.txs {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.txs li + li {
  border-top: 1px solid var(--line);
}
.tx {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  border: 0;
  background: none;
  padding: 0.625rem 1rem;
  min-height: 56px;
  cursor: pointer;
}
.tx-main,
.tx-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tx-main b {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tx-main small,
.tx-side small {
  color: var(--muted);
  font-size: 0.8125rem;
}
.tx-side {
  align-items: flex-end;
  text-align: right;
  flex: none;
  max-width: 45%;
}
.tx-side small.tag {
  color: var(--accent);
}

/* forms */
input,
select,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
  width: 100%;
  min-width: 0;
}
input[type="checkbox"],
input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 0;
  accent-color: var(--accent);
}
.f {
  display: grid;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.f input,
.f select {
  font-size: 1rem;
  color: var(--text);
}
.f small {
  font-size: 0.8125rem;
}
.grid2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 30rem) {
  .grid2 {
    grid-template-columns: 1fr 1fr;
  }
}
.check {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  cursor: pointer;
}
.profile {
  display: grid;
  gap: 0.5rem;
}
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--sunken);
  border-radius: 10px;
  padding: 3px;
}
.seg label {
  position: relative;
  cursor: pointer;
}
.seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.seg span {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.seg input:checked + span {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.seg input:focus-visible + span {
  outline: 2px solid var(--focus);
}
.rowbtn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  text-align: left;
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
  min-height: 48px;
  padding: 0.25rem 0;
  cursor: pointer;
}
.rowbtn small {
  color: var(--muted);
  text-align: right;
}
.plain .group {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0.75rem 0 0.25rem;
}

/* dialog */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(34rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop {
  background: rgb(8 10 12 / 0.5);
}
.dlg-form header,
.dlg-form footer {
  position: sticky;
  background: var(--surface);
  padding: 1rem 1.25rem;
  z-index: 1;
}
.dlg-form header {
  top: 0;
  border-bottom: 1px solid var(--line);
}
.dlg-form header h2 {
  margin: 0;
  font-size: 1.25rem;
}
.dlg-form footer {
  bottom: 0;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.spacer {
  flex: 1;
}
.dlg-body {
  padding: 1rem 1.25rem;
  display: grid;
  gap: 0.875rem;
}
.dlg-body p {
  margin: 0;
}
.error {
  color: var(--neg);
  margin: 0 1.25rem 1rem;
}
.preview li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.875rem;
  padding: 0.25rem 0;
  border-top: 1px solid var(--line);
}

/* tax forms */
.form-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  margin: 0 0 1rem;
  padding: 0 0 0.5rem;
  break-inside: avoid;
}
.form-sheet header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
}
.form-sheet header h3 {
  margin: 0;
  font-size: 1.0625rem;
}
.form-sheet header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.form-sheet > p {
  margin: 0.5rem 1rem;
}
.form-sheet table {
  width: 100%;
  border-collapse: collapse;
}
.form-sheet th,
.form-sheet td {
  padding: 0.5rem 1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.form-sheet thead th {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 600;
}
.form-sheet td small {
  display: block;
  color: var(--muted);
  font-size: 0.8125rem;
}
.form-sheet td small.pos {
  color: var(--pos);
}
.form-sheet .num {
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}
.form-sheet td.num span {
  display: block;
}
.form-sheet td.num .btn {
  margin-top: 0.375rem;
}
.form-sheet details {
  margin-top: 0.25rem;
  font-size: 0.8125rem;
}
.form-sheet summary {
  cursor: pointer;
  color: var(--accent);
  min-height: 44px;
  display: flex;
  align-items: center;
}
.form-sheet details li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.form-sheet details ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.summary {
  font-size: 0.875rem;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 1rem);
  background: var(--text);
  color: var(--bg);
  padding: 0.625rem 1rem;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
  max-width: calc(100% - 2rem);
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

/* print: only the filled forms */
@media print {
  .top,
  .no-print,
  .toast,
  main > .period button {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
  }
  .form-sheet details {
    display: none;
  }
}
.form-sheet td b {
  hyphens: auto;
  overflow-wrap: anywhere;
}
@media (max-width: 30rem) {
  .form-sheet th,
  .form-sheet td {
    padding: 0.5rem 0.625rem;
  }
}
