/* RektByFirefish: ein Bondrucker auf dem Tisch.
   Große Schrift, starker Kontrast, Wörter statt Kürzel. Zweifarben-Thermopapier: schwarz und rot.
   Bewusst nur ein Look (kein Hell/Dunkel-Wechsel). */
:root {
  color-scheme: dark;
  --desk: #2e3236;
  --desk-ink: #c4cad0;
  --printer: #17191b;
  --paper: #fbfaf6;
  --paper-hover: #f1efe8;
  --ink: #141414;
  --ink-soft: #4a4842;
  --ink-red: #c01f18;
  --line: #d9d5cb;
  --track: #ece9e1;
  --ok: #3fbf5a;
  --warn: #f0b400;
  --bad: #e5484d;
  --font: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 17px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(24px, env(safe-area-inset-top, 0px)) max(64px, env(safe-area-inset-bottom, 0px));
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

.col { max-width: 1120px; margin-inline: auto; }

/* Drucker */
.printer { background: var(--printer); border-radius: 12px 12px 4px 4px; padding: 14px 20px 0; }
.printer-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; color: var(--desk-ink); font-size: 15px; padding-bottom: 12px; }
.printer-top .last { margin-right: auto; }
.lang select { font: inherit; font-size: 15px; color: var(--paper); background: #2a2d30; border: 1px solid #4a4f54; padding: 6px 8px; min-height: 44px; }
.led { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--warn); margin-right: 8px; }
.led.ok { background: var(--ok); }
.led.bad { background: var(--bad); }
.led.blink { animation: blink 1s steps(2, jump-none) 3; }
@keyframes blink { 50% { background: var(--warn); } }
.slot { height: 7px; background: #000; border-radius: 4px; }

/* Papier */
.paper {
  background: var(--paper); color: var(--ink);
  padding: 22px clamp(16px, 5vw, 32px) 36px;
  margin-inline: 10px; margin-top: -3px;
  --zz: 10px;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(var(--zz) * 2) 51% repeat-x,
        linear-gradient(#000 0 0) top / 100% calc(100% - var(--zz) + 1px) no-repeat;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(var(--zz) * 2) 51% repeat-x,
        linear-gradient(#000 0 0) top / 100% calc(100% - var(--zz) + 1px) no-repeat;
}
h1 { font-size: clamp(1.6rem, 6vw, 2.1rem); font-weight: 700; margin: 0; text-align: center; letter-spacing: -.01em; line-height: 1.1; text-wrap: balance; }
/* The original rose/orange/turquoise wordmark, as darker ink on light paper. */
.brand-name { display: inline-block; max-width: 100%; color: var(--ink); }
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  .brand-name {
    background: linear-gradient(90deg, #b92d56, #ad4b0b, #08788f);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}
@media print, (forced-colors: active) {
  .brand-name { background: none; color: var(--ink); -webkit-text-fill-color: currentColor; }
}
.lead { text-align: center; margin: 8px auto 18px; max-width: 36ch; color: var(--ink-soft); text-wrap: pretty; font-size: .95rem; }
.rule { border: 0; border-top: 2px dashed var(--ink); margin: 20px 0; opacity: .55; }
.small { font-size: .9rem; color: var(--ink-soft); }
.wrap-any { overflow-wrap: anywhere; }
.k { font-weight: 600; }
.empty { padding: 20px 0; text-align: center; color: var(--ink-soft); margin: 0; }

/* Zahlen */
.totals { display: grid; gap: 12px; }
.total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.total .val { font-size: 1.4rem; font-weight: 700; text-align: right; }
.total.main { border: 3px solid var(--ink-red); padding: 12px 14px; flex-wrap: wrap; }
@media (width < 480px) {
  .total.main { flex-direction: column; align-items: stretch; gap: 2px; }
  .total.main .val { text-align: left; }
}
.total.main .lbl { color: var(--ink-red); font-weight: 600; }
.total.main .val { color: var(--ink-red); font-size: clamp(1.5rem, 7vw, 2.2rem); white-space: nowrap; }
.total small { display: block; font-size: .85rem; color: var(--ink-soft); font-weight: 400; }

/* Ansicht wählen */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 3px solid var(--ink); margin-bottom: 16px; }
.tab { min-height: 52px; border: 0; background: var(--paper); cursor: pointer; font-weight: 700; font-size: 1.05rem; }
.tab + .tab { border-left: 3px solid var(--ink); }
.tab[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* Filter */
.filter-label { font-weight: 600; margin: 0 0 10px; font-size: 1rem; display: block; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; }
.key {
  min-height: 46px; border: 2px solid var(--ink); background: var(--paper); cursor: pointer;
  font-weight: 600; padding: 8px 14px; text-align: center; flex: 1 1 auto;
}
.key[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.amount { margin-top: 12px; }
.amount summary { cursor: pointer; text-decoration: underline; text-underline-offset: 4px; min-height: 44px; display: flex; align-items: center; gap: 6px; width: fit-content; }
.amount-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 4px 0 8px; }
.amount label { display: inline-flex; align-items: center; gap: 8px; }
.amount input, .search, textarea {
  border: 2px solid var(--ink); background: var(--paper); padding: 8px 10px; min-height: 44px; border-radius: 0;
}
.amount input { width: 8ch; text-align: right; }
.search { width: 100%; }
textarea { width: 100%; font-size: .85rem; resize: vertical; }
.link-btn { border: 0; background: none; padding: 8px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; min-height: 44px; }

/* Tage und Einträge */
.day { margin-top: 26px; }
.day:first-child { margin-top: 0; }
.day-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-weight: 700; font-size: 1.05rem; padding-bottom: 6px; border-bottom: 3px double var(--ink); }
.day-head span:last-child { font-weight: 400; color: var(--ink-soft); font-size: .9rem; align-self: end; }
ol.items, ol.loans { list-style: none; margin: 0; padding: 0; }
ol.items li { border-bottom: 1px solid var(--line); }
.item {
  display: grid; grid-template-columns: 4.2rem minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline;
  width: 100%; padding: 14px 4px; border: 0; background: none; cursor: pointer; text-align: left;
}
.item:hover { background: var(--paper-hover); }
.time { color: var(--ink-soft); }
.what { font-weight: 600; }
.what .hint { display: block; font-weight: 400; font-size: .85rem; color: var(--ink-soft); }
.amt { text-align: right; font-weight: 600; white-space: nowrap; }
.amt small { font-weight: 400; font-size: .8rem; }
li[data-type="liquidation"] .what, li[data-type="liquidation"] .amt { color: var(--ink-red); }
li[data-type="topup"] .amt { font-weight: 400; }
li.printing { clip-path: inset(0 0 0 0); transition: clip-path .9s steps(7, end); }
@starting-style { li.printing { clip-path: inset(0 0 100% 0); } }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; margin-top: 18px; }
.pager:empty { display: none; }
.pg { min-height: 48px; border: 2px solid var(--ink); background: var(--paper); cursor: pointer; font-weight: 600; padding: 8px 10px; }
.pg:disabled { opacity: .3; cursor: default; }
.pg-info { text-align: center; color: var(--ink-soft); font-size: .9rem; }

/* Kredite */
ol.loans li { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; gap: 4px; }
.loan-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tag { font-weight: 700; padding: 0 6px; border: 2px solid var(--ink); }
.tag.liquidated { background: var(--ink-red); border-color: var(--ink-red); color: var(--paper); }
.tag.defaulted { background: var(--ink); color: var(--paper); }
.loan-line { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 8px; font-size: .9rem; }
.loan-line > span:first-child { color: var(--ink-soft); }
@media (width < 480px) { .loan-line { grid-template-columns: minmax(0, 1fr); gap: 0; } }
a { color: var(--ink); text-underline-offset: 3px; }
a.hash { overflow-wrap: anywhere; display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; }

/* 14 Tage */
.bars { display: grid; gap: 4px; }
.bars .b { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) 2.4rem; gap: 10px; align-items: center; font-size: .95rem; }
.bars .track { height: 14px; background: var(--track); display: block; }
.bars .fill { height: 100%; background: var(--ink-red); display: block; }
.bars .b span:last-child { text-align: right; font-weight: 600; }

/* Fuß */
.field { margin-top: 14px; }
.copy { border: 2px solid var(--ink); background: none; padding: 4px 10px; cursor: pointer; font-size: .85rem; font-weight: 600; margin-top: 6px; min-height: 44px; }
canvas.barcode { display: block; width: 100%; height: 46px; margin-top: 16px; }
.admin-btn { display: block; margin: 10px auto 0; font-size: .85rem; color: var(--ink-soft); }

/* Fenster */
dialog {
  border: 0; padding: 0; background: none; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); color: var(--ink);
  opacity: 1; translate: 0 0;
  transition: opacity .2s, translate .3s steps(5), display .3s, overlay .3s;
  transition-behavior: allow-discrete;
}
@starting-style { dialog[open] { opacity: 0; translate: 0 -40px; } }
dialog:not([open]) { opacity: 0; translate: 0 -40px; }
dialog::backdrop { background: rgb(20 22 24 / .75); }
dialog .paper { margin: 0; }
.d-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.d-title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.d-title.red { color: var(--ink-red); }
.x { border: 2px solid var(--ink); background: none; cursor: pointer; min-width: 48px; min-height: 48px; font-size: 1.3rem; font-weight: 700; line-height: 1; flex: none; }
.d-amt { font-size: 1.8rem; font-weight: 700; margin-top: 6px; }
.steps { margin: 8px 0 0; padding-left: 1.4em; }
.steps li { margin-bottom: 6px; }
.ext { display: inline-flex; align-items: center; gap: .5em; min-height: 44px; margin-top: 18px; font-weight: 600; text-underline-offset: 4px; }
.row-btns { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-btns .key { min-width: 10rem; }

@media (prefers-reduced-motion: reduce) {
  li.printing, dialog { transition-duration: .01s; }
  .led.blink { animation: none; }
}

/* Zahlen als Kacheln */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.tile { display: grid; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.tile:nth-child(odd) { border-right: 1px solid var(--line); padding-right: 10px; }
.tile:nth-child(even) { padding-left: 14px; }
.tile .val { font-size: 1.45rem; font-weight: 700; line-height: 1.15; }
.tile .lbl { font-size: .85rem; color: var(--ink-soft); }
.tile.hot .val { color: var(--ink-red); }
.totals { gap: 14px; }

/* Aufteilung: Handy untereinander, Computer zwei Spalten */
.sheet { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "main" "extra"; column-gap: 40px; }
.area-head { grid-area: head; }
.area-main { grid-area: main; min-width: 0; }
.area-extra { grid-area: extra; }
.sheet .area-head .totals { margin-bottom: 20px; }
@media (width >= 900px) {
  .sheet { grid-template-columns: 330px minmax(0, 1fr); grid-template-areas: "head main" "extra main"; align-items: start; }
  .sheet .area-head h1, .sheet .area-head .lead { text-align: left; margin-left: 0; }
  .area-main { border-left: 2px dashed rgb(20 20 20 / .3); padding-left: 40px; grid-row: 1 / span 2; }
  .area-extra .rule:first-child { margin-top: 0; }
}
@media (width < 900px) { .col { max-width: 600px; } }

/* Handy: mehr Platz für die Liste */
.what { min-width: 0; overflow-wrap: anywhere; }
@media (width < 480px) {
  .printer { padding-inline: 14px; }
  .printer-top .lang { margin-left: auto; }
  .printer-top .last { order: 3; flex-basis: 100%; font-size: 14px; }
  .paper { margin-inline: 4px; padding-inline: 14px; }
  .item { grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: 2px 10px; font-size: .95rem; padding-inline: 0; }
  #typeKeys .key { padding: 8px 10px; font-size: .95rem; }
  .pager { grid-template-columns: 1fr 1fr; }
  .pg-info { grid-column: 1 / -1; grid-row: 1; }
}
