/* EVA-BS cockpit — one stylesheet, CSS variables.
 * Design language borrowed from vpl v2: warm paper, not a dashboard.
 * Light is default; dark is a variable swap. One accent, used sparingly. */

:root {
  --paper:        #faf8f4;
  --paper-2:      #f2eee6;   /* side pane */
  --paper-3:      #e9e3d8;   /* hairlines, hover */
  --ink:          #1f1d1a;
  --ink-2:        #55504a;
  /* was #8a8378: 3.5:1 on paper — measured, not guessed. A muted label still has to be readable. */
  --ink-3:        #6b6459;
  --line:         #e0d9cd;
  --line-strong:  #cdc3b2;
  --mark:         #b4531f;   /* the only accent */
  --danger:       #a3352b;
  --ok:           #4a6b3f;

  --sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Newsreader', ui-serif, Georgia, 'Times New Roman', serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --side-w: 17rem;
  --radius: 8px;
  --bar-h: 2.75rem;
}

[data-theme='dark'] {
  --paper:        #1a1816;
  --paper-2:      #232120;
  --paper-3:      #33302c;
  --ink:          #f7f3ec;
  --ink-2:        #e2dbd0;
  --ink-3:        #c0b7aa;
  --line:         #8a8177;
  --line-strong:  #a39a8f;
  --mark:         #ffb06b;
  --danger:       #ff9084;
  --ok:           #a8cc94;
}

/* In dark mode hairlines vanish on near-black surfaces, so structural dividers
 * are drawn in --line-strong and made 2px. */
[data-theme='dark'] .bar,
[data-theme='dark'] .side,
[data-theme='dark'] .dd-acts { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group + .nav-group { margin-top: 0.55rem; }
.nav-group-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3, #8a8a8a);
  padding: 0 0.5rem 0.18rem;
  user-select: none;
}
.side-head { border-color: var(--line-strong); }
[data-theme='dark'] .bar { border-bottom-width: 2px; }
[data-theme='dark'] .side { border-right-width: 2px; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --- top bar ------------------------------------------------------------ */

.bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: var(--bar-h);
  padding: 0 0.65rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex: 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-size: 0.92rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 4px;
  background: var(--mark);
  color: var(--paper);
  font-size: 0.75rem;
  font-weight: 700;
}

.bar-spacer { flex: 1; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  padding: 0.32rem 0.6rem;
  cursor: pointer;
  line-height: 1.2;
}

button:hover { background: var(--paper-3); }
button:focus-visible { outline: 2px solid var(--mark); outline-offset: 1px; }

button.icon {
  width: 2rem;
  padding: 0.32rem 0;
  text-align: center;
  color: var(--ink-2);
  font-size: 1rem;
}

button.primary {
  background: var(--mark);
  color: var(--paper);
  border-color: var(--mark);
  font-weight: 600;
  font-size: 0.85rem;
}
button.primary:hover { filter: brightness(1.06); }

button.ghost {
  border-color: var(--line-strong);
  color: var(--ink-2);
  font-size: 0.82rem;
}

/* --- layout ------------------------------------------------------------- */

.workspace {
  display: flex;
  height: calc(100vh - var(--bar-h));
  min-height: 0;
}

.side {
  width: var(--side-w);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--paper-2);
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.75rem 0.4rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.side-head:hover { color: var(--ink); background: var(--paper-3); }
.side-head .chev { transition: transform 0.16s ease; font-size: 0.66rem; }
.side.collapsed .chev { transform: rotate(-90deg); }
.side.collapsed .side-body,
.side.collapsed .side-nav { display: none; }

.side-foot {
  border-top: 1px solid var(--line);
  padding: 0.3rem;
  flex: 0 0 auto;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.42rem 0.5rem;
  font: inherit;
  font-size: 0.78rem;
  color: var(--ink-2);
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
  /* it is an <a>, so it must not look like one: the point is the browser's own "open in new tab",
     not underlined text */
  text-decoration: none;
}
.side-link:hover { background: var(--paper-3); color: var(--ink); }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--ink); }
th.sortable .arrow { opacity: 0.35; font-size: 0.7em; }
th.sortable[aria-sort='ascending'] .arrow,
th.sortable[aria-sort='descending'] .arrow { opacity: 1; color: var(--mark); }

.side-nav {
  /* Six modules do not fit in a horizontal row inside a 17rem sidebar: the last two
     items overflowed over the main content and clicks landed on cards instead of the
     menu. A column cannot overflow this way and stays readable at any count. */
  display: flex;
  flex-direction: column;
  gap: 1px;
  gap: 0.15rem;
  padding: 0.35rem 0.4rem 0.15rem;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.review-head { cursor: pointer; user-select: none; }
.review-head .chev { display: inline-block; font-size: 0.7em; color: var(--ink-3); transition: transform 0.12s; }
.review-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.review-head .count { font-size: 0.72rem; color: var(--ink-2); }
#needs { margin-bottom: 1.1rem; }

.build { font-size: 0.6rem; color: var(--ink-3); opacity: 0.7; margin-left: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  width: 100%;
  justify-content: flex-start;
  padding: 0.32rem 0.3rem;
  font: inherit;
  font-size: 0.74rem;
  color: var(--ink-2);
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}
.nav-item:hover { background: var(--paper-3); color: var(--ink); }
.nav-item.is-active { background: var(--paper-3); color: var(--ink); border-color: var(--line-strong); font-weight: 600; }
.nav-ic { font-size: 0.82rem; }

.side-body { overflow-y: auto; flex: 1; padding: 0.4rem; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* --- summary cards ------------------------------------------------------ */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.6rem;
  padding: 1rem 1.15rem 0.4rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  background: var(--paper);
}

.card-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-3);
  margin-bottom: 0.2rem;
}

.card-value {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.card-value.neg { color: var(--danger); }
.card-value.pos { color: var(--ok); }

.card-sub { font-size: 0.74rem; color: var(--ink-3); }

/* --- sections ----------------------------------------------------------- */

.section { padding: 0.6rem 1.15rem 1.2rem; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin: 0.6rem 0 0.5rem;
}

.section-head h2 {
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.005em;
}

.section-head .count {
  font-size: 0.75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.section-head .spacer { flex: 1; }

/* --- table -------------------------------------------------------------- */

table.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.sheet th {
  text-align: left;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}

table.sheet td {
  padding: 0.42rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.sheet tbody tr:hover { background: var(--paper-2); }

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.desc { color: var(--ink); }
td.muted, .muted { color: var(--ink-3); }

.mono { font-family: var(--mono); font-size: 0.82em; }

/* --- status pills ------------------------------------------------------- */

.pill {
  display: inline-block;
  padding: 0.05rem 0.42rem;
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid var(--line-strong);
  color: var(--ink-2);
  white-space: nowrap;
}

.pill.review { border-color: var(--mark); color: var(--mark); }
.pill.posted { border-color: var(--ok); color: var(--ok); }
.pill.draft  { border-color: var(--line-strong); color: var(--ink-3); }
.pill.danger { border-color: var(--danger); color: var(--danger); }

/* --- side list ---------------------------------------------------------- */

.side-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: none;
  color: var(--ink);
}
.side-item:hover { background: var(--paper-3); }
.side-item[aria-current='true'] { background: var(--paper-3); font-weight: 600; }

.side-item .li-main { display: flex; justify-content: space-between; gap: 0.5rem; }
.side-item .li-num { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 0.78rem; }
.side-item .li-sub { font-size: 0.75rem; color: var(--ink-3); }

/* --- empty / loading ---------------------------------------------------- */

.empty {
  padding: 1.4rem 0.9rem;
  color: var(--ink-3);
  font-size: 0.86rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
}

.skeleton {
  height: 1rem;
  border-radius: 4px;
  background: var(--paper-3);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

/* --- detail panel ------------------------------------------------------- */

.detail {
  /* A drawer, not a block at the bottom of the page: the point of the preview is
     to see the scan while the row is still in view. */
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(620px, 48vw);
  margin: 0;
  padding: 1rem 1.1rem 2rem;
  border: 0;
  border-left: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  box-shadow: -14px 0 40px rgba(31, 29, 26, 0.14);
  overflow-y: auto;
  z-index: 50;
}

@media (max-width: 900px) {
  .detail { width: 100%; }
}

.detail-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}

.detail-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.detail-meta { font-size: 0.78rem; color: var(--ink-3); }

.kv {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.2rem 0.75rem;
  font-size: 0.84rem;
  margin: 0.5rem 0;
}
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

/* --- toast -------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 10;
}
.toast.show { opacity: 1; }

@media (max-width: 720px) {
  .side { width: 100%; }
  .workspace { flex-direction: column; }
  .side { border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
}

/* --- document preview ---------------------------------------------------- */
.preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper-2);
  overflow: hidden;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-img {
  display: block;
  max-width: 100%;
  max-height: 46vh;
  object-fit: contain;
}
.preview-pdf {
  width: 100%;
  height: 46vh;
  border: 0;
  background: #fff;
}
.preview-empty {
  padding: 1.6rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  text-align: center;
}
.preview-empty a { color: var(--mark); }
.preview-link { display: block; max-width: 100%; }
.unverified {
  font-size: 0.78rem;
  color: var(--danger);
  font-style: italic;
}

a.view {
  font-size: 0.74rem;
  color: var(--mark);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 1px dotted currentColor;
}
a.view:hover { color: var(--ink); }

/* --- agent chat: one line, always there, never in the way ----------------- */
/* The chat lives inside the bar now: a compact pill between the brand and the
   language picker, so it costs no vertical space at all. */
.hintbar {
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}

.hint {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0.15rem 0 0.35rem;
  padding: 0.1rem 0.45rem 0.1rem 0.4rem;
  height: 1.75rem;
  flex: 0 1 30rem;
  min-width: 8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
}

.hint-mark {
  color: var(--mark);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}

.hint-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 0.75rem;
  padding: 0.1rem 0.1rem;
  color: var(--ink);
  background: none;
  border: 0;
  outline: none;
}
.hint-input::placeholder { color: var(--ink-3); }

.hint-send,
.hint-close {
  font: inherit;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--ink-3);
  background: none;
  border: 0;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  border-radius: 4px;
}
.hint-send:hover,
.hint-close:hover { background: var(--paper-3); color: var(--ink); }

.hint-status {
  font-size: 0.72rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.hint-out {
  /* A panel under the bar instead of a band inside the layout: a long answer
     must never push the work area down, and it stays reachable while reading. */
  position: fixed;
  top: calc(var(--bar-h) + 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(52rem, 92vw);
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 46vh;
  overflow-y: auto;
}
.hint-out.err { color: var(--neg, #a33); }

/* --- bank view ------------------------------------------------------------- */
.bank-tools { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.chip {
  font: inherit;
  font-size: 0.75rem;
  padding: 0.28rem 0.65rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-2);
  cursor: pointer;
}
.chip:hover { background: var(--paper-3); color: var(--ink); }
.bank-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.bank-table th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--line-strong);
}
.bank-table td { padding: 0.32rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.bank-table tr:hover td { background: var(--paper-2); }
.bank-pos { color: var(--ok, #287a3a); font-weight: 600; }
.bank-neg { color: var(--neg, #a33); }
.bank-match { font-size: 0.72rem; color: var(--ink-2); }

/* --- cash view ------------------------------------------------------------- */
.cash-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.cash-form label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.7rem; color: var(--ink-3); }
.cash-form input,
.cash-form select {
  font: inherit;
  font-size: 0.78rem;
  padding: 0.28rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.cash-form .cash-desc { flex: 1 1 14rem; }
.cash-form .cash-desc input { width: 100%; }
.tax-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; margin-bottom: 0.7rem; }
.tax-controls label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.7rem; color: var(--ink-3); }
.tax-controls input,
.tax-controls select {
  font: inherit; font-size: 0.78rem; padding: 0.26rem 0.4rem;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--paper); color: var(--ink);
}
.tax-controls .tax-check { flex-direction: row; align-items: center; gap: 0.3rem; }
.tax-box { display: flex; justify-content: space-between; gap: 0.6rem; padding: 0.22rem 0; border-bottom: 1px dotted var(--line); font-size: 0.8rem; }
.tax-box .kz { font-variant-numeric: tabular-nums; color: var(--ink-3); min-width: 2rem; }
.tax-box .amt { font-variant-numeric: tabular-nums; }
.tax-payable { display: flex; justify-content: space-between; margin-top: 0.5rem; font-weight: 600; font-size: 0.95rem; }
.tax-note { font-size: 0.74rem; color: var(--ink-3); margin: 0.35rem 0 0; }

.cash-balance { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.bank-match b { color: var(--ink); }

/* --- new invoice dialog ---------------------------------------------------- */
.inv-form { display: grid; gap: 0.55rem; }
.inv-form label { display: grid; gap: 0.18rem; font-size: 0.74rem; color: var(--ink-3); }
.inv-form input, .inv-form select, .inv-form textarea {
  font: inherit;
  font-size: 0.82rem;
  padding: 0.3rem 0.4rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}
.inv-row { display: grid; grid-template-columns: 1fr 5rem 6rem 5rem; gap: 0.4rem; }
.inv-actions { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.3rem; }
.inv-actions .primary {
  font: inherit; font-size: 0.82rem; padding: 0.35rem 0.8rem;
  color: var(--paper); background: var(--ink); border: 0; border-radius: 5px; cursor: pointer;
}
.inv-actions .primary:disabled { opacity: 0.5; cursor: default; }
.inv-total { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 0.85rem; }

/* Reports: BWA next to EÜR. Two questions about the same ledger, so they sit
   side by side at desktop width and stack when there is no room. */
.rep-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  gap: 0.8rem;
}
.rep-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: var(--panel);
}
.rep-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-transform: uppercase;
}
.rep-card table { width: 100%; }
.rep-card tfoot th { text-align: left; font-weight: 600; }
.rep-card tr.ok td, .rep-card tr.ok th { color: var(--ok, #1a7f37); }
.rep-card tr.bad td, .rep-card tr.bad th { color: var(--bad, #b42318); }

/* Statement balance vs ledger balance: the difference is the message, so it stands
   next to the numbers instead of hiding in a tooltip. */
.bank-balance {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: baseline;
  padding: 0.45rem 0.6rem;
  margin: 0 0 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 0.8rem;
}
.bank-balance .bb-item b { font-variant-numeric: tabular-nums; }
.bank-balance .ok b { color: var(--ok, #1a7f37); }
.bank-balance .bad b { color: var(--bad, #b42318); }

/* The agent chip and the answer head: who answered, and in which mode. */
.hint-agent {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  font: 0.72rem/1 var(--mono);
  padding: 0.18rem 0.34rem;
  cursor: pointer;
  white-space: nowrap;
}
.hint-agent:hover { background: var(--panel); color: var(--ink); }
.hint-out-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.chat-mode {
  border: 1px solid var(--bad, #b42318);
  border-radius: 4px;
  color: var(--bad, #b42318);
  padding: 0 0.25rem;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chat-action {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  flex-wrap: wrap;
}
.chip-xs { font-size: 0.7rem; padding: 0 0.3rem; }

/* An element with `hidden` is hidden. Author display rules (flex, grid) beat the
   browser default, which silently showed the empty action card until this rule. */
[hidden] { display: none !important; }

/* The typed-total box: only shown when the machine could not read the amount. */
.amount-box {
  margin-top: 0.7rem;
  padding: 0.5rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  gap: 0.3rem;
}
.amount-box label { font-size: 0.72rem; color: var(--ink-soft); }
.amount-row { display: flex; gap: 0.35rem; align-items: center; }
.amount-row input {
  flex: 1;
  min-width: 0;
  padding: 0.22rem 0.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  text-align: right;
}
.amount-box .err { color: var(--bad, #b42318); }

/* The steps of a Pi answer: small, monospaced, quiet — evidence, not decoration. */
.chat-steps {
  margin: 0.4rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.72rem;
  color: var(--muted, #6b7280);
}
.chat-step { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-step.error { color: var(--danger, #b91c1c); }

/* The model dropdown in the chat header: small, quiet, and only as wide as it needs. */
.chat-model {
  max-width: 16rem;
  padding: 0.1rem 0.3rem;
  font-size: 0.72rem;
  color: inherit;
  background: transparent;
  border: 1px solid var(--line, #d4d4d8);
  border-radius: 0.4rem;
}

/* The registry list: one row per action, quiet until hovered. */
.chat-actions {
  margin: 0.4rem 0 0;
  max-height: 14rem;
  overflow-y: auto;
  border-top: 1px solid var(--line, #e4e4e7);
}
.chat-action-row {
  display: grid;
  grid-template-columns: 1rem 1fr auto;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.12rem 0.1rem;
  font-size: 0.72rem;
  cursor: pointer;
  border-radius: 0.25rem;
}
.chat-action-row:hover { background: var(--hover, #f4f4f5); }
.chat-action-row.dim { opacity: 0.45; }
.chat-action-row.money .ca-badge { color: var(--warn, #b45309); }
.chat-action-row.code .ca-badge { color: var(--danger, #b91c1c); }
.ca-id { color: var(--muted, #6b7280); }
.ca-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Open items: a card above the bank list, not a second screen. */
.opos {
  margin: 0.5rem 0 0.8rem;
  border: 1px solid var(--line, #e4e4e7);
  border-radius: 0.5rem;
  padding: 0.5rem 0.6rem;
}
.opos-head { display: flex; align-items: baseline; gap: 0.6rem; font-size: 0.78rem; }
.opos-totals { font-size: 0.74rem; color: var(--muted, #6b7280); }
.opos-aging {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin: 0.35rem 0 0.4rem;
  font-size: 0.72rem;
}
.opos-bucket.late { color: var(--danger, #b91c1c); font-weight: 600; }
.opos-row {
  display: grid;
  grid-template-columns: 8rem 1fr 6rem 7rem 6rem auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.15rem 0;
  font-size: 0.76rem;
  border-top: 1px solid var(--line, #f1f1f3);
}
.opos-party { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opos-days { text-align: right; color: var(--muted, #6b7280); }
.opos-days.late { color: var(--danger, #b91c1c); }

/* Closing card: state and plan side by side, actions on the right. */
.closing-line { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; margin: 0.25rem 0; }

/* SEPA profile inputs: one row, mono for the account fields. */
.sepa-profile { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.3rem 0; }
.sepa-profile input { padding: 0.2rem 0.35rem; border: 1px solid var(--line, #e4e4e7); border-radius: 0.3rem; font-size: 0.76rem; }

/* CRM: follow-ups and the log form on top, contacts and history below. */
.crm-top { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; align-items: start; }
.crm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 0.8rem; align-items: start; }
@media (max-width: 1100px) { .crm-top, .crm-grid { grid-template-columns: 1fr; } }
.crm-form { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: flex-end; }
.crm-form label { display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.72rem; }
.crm-form input, .crm-form select { padding: 0.2rem 0.35rem; border: 1px solid var(--line, #e4e4e7); border-radius: 0.3rem; font-size: 0.76rem; }
.crm-new-contact { margin-top: 0.5rem; font-size: 0.76rem; }
.crm-new-contact summary { cursor: pointer; color: var(--muted, #6b7280); }
.crm-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 5rem auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.2rem 0;
  font-size: 0.76rem;
  border-top: 1px solid var(--line, #f1f1f3);
}
.crm-main { overflow: hidden; text-overflow: ellipsis; }
/* Contact rows carry three columns, not four: party, person, contact details. */
.crm-row-contact { grid-template-columns: 7rem 1fr minmax(0, 15rem) auto; }
.crm-row-contact > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Dunning rows reuse the open-item grid but add a level and an action column. */
/* eight cells now: number, party, due, days, open, level, returned (optional), action */
#dunning .dunning-row { grid-template-columns: 7rem minmax(0, 1fr) 6.5rem 5.5rem 6rem 8rem 7.5rem auto; align-items: center; }
#dunning .dunning-row .chip-level { border-color: var(--accent); }
.dunning-letter {
  white-space: pre-wrap;
  font-family: var(--mono, monospace);
  font-size: 0.76rem;
  line-height: 1.45;
  background: var(--bg-soft, rgba(0,0,0,0.03));
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  margin: 0.5rem 0 0;
  max-height: 18rem;
  overflow: auto;
}

/* Party book: name, roles, address, VAT id, IBAN, open. One row per party, no cards. */
.party-book { margin-bottom: 0.8rem; }
.party-book .opos-head { gap: 0.5rem; flex-wrap: wrap; }
.party-book #party-search { max-width: 20rem; }
.party-row.party-head {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  cursor: default;
  background: none;
}
.party-row.party-head:hover { background: none; }
.party-row {
  display: grid;
  grid-template-columns: 16rem 9rem minmax(0, 1fr) 9rem 15rem auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.28rem 0.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.8rem;
  cursor: pointer;
}
.party-row:hover { background: var(--hover); }
.party-row .party-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-row .party-roles { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.party-row .party-addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-row .party-vat, .party-row .party-iban { font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-row .party-iban.ok { color: var(--ok, #2e7d32); }
.party-row .party-iban.bad { color: var(--bad, #c62828); }

.party-archived-toggle { display: flex; align-items: center; gap: 0.25rem; font-size: 0.74rem; color: var(--muted); }
.party-roles-edit, .party-merge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  margin: 0.5rem 0 0;
}
.party-roles-edit label { display: flex; align-items: center; gap: 0.2rem; }
.party-merge select { max-width: 18rem; }
.chip-danger { border-color: var(--bad, #c62828); color: var(--bad, #c62828); }
.party-row.is-archived { opacity: 0.55; }

/* SEPA rows must not share the open-item grid: the supplier picker needs its own column,
   otherwise the amount cell sits on top of the button and the click never lands. */
.sepa-row { grid-template-columns: 7rem minmax(0, 1fr) 17rem 6.5rem 7rem; align-items: center; }
.sepa-row .sepa-link { display: flex; gap: 0.25rem; align-items: center; min-width: 0; }
.sepa-row .sepa-link select { min-width: 0; flex: 1 1 auto; }

/* SEPA profile: labelled fields, because "Zahlungskonto Inhaber" as a placeholder looked like a value. */
.sepa-profile { display: grid; grid-template-columns: 14rem 20rem 9rem auto; gap: 0.5rem 0.6rem; align-items: end; }
/* the direct-debit form has one field more: party, reference, date, IBAN, button */
#direct-debit .sepa-profile { grid-template-columns: 12rem 12rem 9.5rem 18rem auto; }
@media (max-width: 1240px) { #direct-debit .sepa-profile { grid-template-columns: 1fr 1fr; } }
.sepa-profile label { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.sepa-profile input { width: 100%; min-width: 0; }
@media (max-width: 1100px) { .sepa-profile { grid-template-columns: 1fr 1fr; } }
.sepa-link { display: flex; gap: 0.3rem; align-items: center; }
.sepa-link select { max-width: 11rem; font-size: 0.72rem; }

/* Party master data: two rows. An IBAN is 22+ characters and must not be clipped. */
#party-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 0.5rem 0.6rem; align-items: end; }
#party-form label { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
#party-form input { width: 100%; min-width: 0; }
#party-form label:nth-child(1) { grid-column: 1 / span 2; }
#party-form label:nth-child(2) { grid-column: 3; }
#party-form label:nth-child(3) { grid-column: 4; }
#party-form label:nth-child(4) { grid-column: 1 / span 2; }
#party-form label:nth-child(5) { grid-column: 3; }
#party-form label:nth-child(6) { grid-column: 4; }
#party-form button { align-self: end; }
@media (max-width: 980px) { #party-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } #party-form label { grid-column: auto !important; } }

/* --- Bilanz / GuV: two columns of the same ledger ----------------------- */
/* The sheet needs the width of both columns, otherwise account names end up as ellipses. */
#view-reports .rep-card:has(#rep-bilanz) { grid-column: 1 / -1; }
.bil-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 1180px) { .bil-grid { grid-template-columns: 1fr; } }
.bil-col h4 { font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; margin: 0 0 0.4rem; color: var(--muted); }
.bil-head, .bil-row { display: grid; grid-template-columns: 3.6rem minmax(0, 1fr) 6.5rem; gap: 0.5rem; align-items: baseline; }
/* the comparison column is wider than the current one: two figures side by side.
   The class sits on the sheet, not on the row, so every row keeps the same column widths. */
.bil-has-prior .bil-row { grid-template-columns: 3.6rem minmax(0, 1fr) 6.5rem 6.5rem; }
.bil-prior { color: var(--muted, #6b7280); }
.bil-prior-head { color: var(--muted, #6b7280); font-weight: 400; }
.bil-head { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 0.2rem; }
.bil-row { font-size: 0.8rem; padding: 0.16rem 0; }
.bil-row .bil-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bil-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.bil-sum { border-top: 1px solid var(--line); margin-top: 0.2rem; padding-top: 0.28rem; font-weight: 600; }
.bil-diff { margin-top: 0.35rem; font-weight: 600; }
.bil-diff.ok .num { color: var(--ok, #4a7a4a); }
.bil-diff.late .num { color: var(--late, #a33); }

/* §266 Gliederung: the statute's hierarchy must be visible, otherwise it is just a long list. */
.bil-row.bil-level-1 .bil-name { padding-left: 0.9rem; }
.bil-row.bil-level-2 .bil-name { padding-left: 1.6rem; }
.bil-row.bil-unmatched .bil-name { color: var(--late, #a33); }
.bil-warn { font-size: 0.7rem; color: var(--late, #a33); margin-top: 0.3rem; line-height: 1.4; }

/* BWA drill-down: the report answers "why is this line this number" in place. */
.bwa-accounts { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; padding: 0.4rem 0.2rem; }
.bwa-account { color: var(--mark, #b4531f); text-decoration: none; font-size: 0.78rem; border-bottom: 1px dotted var(--line); }
.bwa-account:hover { border-bottom-color: var(--mark, #b4531f); }
.ledger-detail { border: 1px solid var(--line); border-radius: 6px; padding: 0.45rem 0.55rem; margin: 0.3rem 0 0.6rem; font-size: 0.78rem; background: var(--paper); }
.ledger-head { font-weight: 600; margin-bottom: 0.3rem; }
.ledger-line { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) 7rem; gap: 0.6rem; padding: 0.1rem 0; }
.ledger-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Direct debit: seven columns, and the mandate reference must never push the amount away. */
.dd-row { grid-template-columns: 6.5rem minmax(0, 1fr) 8rem 6.5rem 3.6rem 6.5rem 9rem; }
@media (max-width: 1100px) { .dd-row { grid-template-columns: 6rem minmax(0, 1fr) 7rem 6rem; } }
.dd-head { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); border-bottom: 1px solid var(--line); }

/* Returned direct debits: six columns — date, party, amount, reason, picker, action. */
.chip-warn { border-color: var(--late, #b45309); color: var(--late, #b45309); }
.return-row {
  grid-template-columns: 92px minmax(120px, 1fr) 110px minmax(120px, 1.2fr) 190px 120px;
  align-items: center;
  gap: 0.4rem;
}
.return-row .return-pick {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--paper);
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.15rem 0.25rem;
  max-width: 190px;
}
#bank-returns .opos-head h3 { margin: 0; font-size: 0.82rem; }
.return-step { color: var(--mark, #1d4ed8); }

/* cash: the allocation controls sit in their own narrow column */
.cash-alloc { display: flex; gap: 0.35rem; align-items: center; justify-content: flex-end; }
.cash-pick { max-width: 15rem; font-size: 0.74rem; padding: 0.15rem 0.3rem; }
.chip-ok { font-size: 0.7rem; color: #15803d; }

/* A sentence under a form: quiet enough to be read, not ignored. */
.hint-line {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  opacity: 0.65;
}

/* First steps: a short list where the tick is a fact, not a decoration. */
.ob-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  font-size: 0.84rem;
}
.ob-list li {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.18rem 0;
}
.ob-list li.is-done { opacity: 0.55; text-decoration: line-through; }
.ob-list .ob-mark { width: 1rem; text-align: center; }
.ob-list .ob-detail { color: var(--ink-3); margin-left: auto; font-size: 0.76rem; }

/* --- the manual, read inside the program ---------------------------------- */
/* Work beside the conversation: one number, and only when there is work. */
.job-badge {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 0.72rem;
  font-family: var(--mono, monospace);
  cursor: pointer;
}
.job-badge.is-busy { border-color: var(--accent); color: var(--ink); }

/* Who is at the machine: a chip that states the current name and a dialog that changes it. */
.who-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 0.78rem;
  cursor: pointer;
  max-width: 16rem;
  overflow: hidden;
}
.who-chip:hover { border-color: var(--accent); color: var(--ink); }
.who-chip.is-in { color: var(--ink); border-color: var(--accent); }
.who-role {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.who-panel {
  z-index: 62;
  width: min(460px, 92vw);
  overflow-y: auto;
}
.who-form { display: grid; gap: 0.35rem; padding: 0.4rem 0 0.6rem; }
.who-label { font-size: 0.75rem; color: var(--ink-3); }
.who-form input, .who-form select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
}
.who-hint { margin: 0.1rem 0 0.2rem; font-size: 0.78rem; color: var(--ink-2); }
.who-hint:empty { display: none; }
.who-actions { display: flex; gap: 0.4rem; margin-top: 0.2rem; }
.who-h4 { margin: 0.8rem 0 0.3rem; font-size: 0.8rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.who-list { display: grid; gap: 0.25rem; max-height: 12rem; overflow-y: auto; }
.who-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
}
.who-row-name { flex: 1; min-width: 0; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; }

.help-panel {
  z-index: 62;
  width: min(700px, 54vw);
  overflow-y: auto;
}
.help-list { display: grid; gap: 0.35rem; }
.help-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.help-item:hover { border-color: var(--line-strong); background: var(--paper-2); }
.help-item-title { font-weight: 600; font-size: 0.86rem; }
.help-item-meta { color: var(--ink-3); font-size: 0.72rem; white-space: nowrap; }
.help-body { font-size: 0.84rem; line-height: 1.55; }
.help-body h3 { font-family: var(--serif); font-size: 1rem; margin: 1rem 0 0.3rem; }
.help-body h4 { font-size: 0.88rem; margin: 0.8rem 0 0.2rem; }
.help-body p { margin: 0 0 0.5rem; }
.help-body ul { margin: 0 0 0.5rem 1rem; }
.help-body code { background: var(--paper-2); padding: 0 0.2rem; border-radius: 4px; font-family: var(--mono); }
.help-code {
  background: var(--paper-2);
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.74rem;
  white-space: pre-wrap;
}

/* --- reachable from the network ------------------------------------------ */
.lan-note {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid #c8a24a;
  border-radius: 6px;
  background: #fdf6e3;
  color: #6b4f13;
  font-size: 0.74rem;
}

/* --- one searchable dropdown (combo.js) ---------------------------------- */
.combo-wrap { position: relative; display: inline-flex; width: 100%; }
.combo-input { width: 100%; }
.combo-source.combo-hidden { display: none; }
.combo-list {
  position: absolute;
  z-index: 80;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 17rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.15rem;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(60, 50, 35, 0.12);
}
.combo-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.82rem;
  cursor: pointer;
}
.combo-item.is-active, .combo-item:hover { background: var(--paper-3); }
.combo-note { color: var(--ink-3); font-size: 0.72rem; }
.combo-empty { padding: 0.3rem 0.4rem; color: var(--ink-3); font-size: 0.8rem; }

/* ── guided start and the party editor ───────────────────────────────────────────
   Both are side panels: the list behind them stays visible, because both are about
   one row of that list. A full page would make the owner lose his place. */
.tour-panel,
.party-editor {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  /* The tour panel was 560 px wide and full height, so "Zum Feld" scrolled a form field to the
     centre of the screen *behind* it: the button worked and the field was still invisible. A tour is
     a hint at the edge, not a second window. */
  width: min(380px, 34vw);
  display: flex;
  flex-direction: column;
  background: var(--paper, #faf8f4);
  border-left: 1px solid var(--line-strong, #cdc3b2);
  box-shadow: -18px 0 40px -24px rgba(38, 34, 28, 0.35);
  z-index: 62;
}
.tour-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.1rem 1rem;
}
.tour-body h4 {
  font-family: var(--serif, Georgia, serif);
  font-size: 1.15rem;
  margin: 0.2rem 0 0.5rem;
}
/* "Zum Feld" scrolls with block:'center'; the offset keeps the field clear of the top bar and of the
   panel's own shadow instead of sitting flush against the viewport edge. */
.tour-target,
#co-name, #co-street, #pc-name, #inv-party, #bank-file, #cash-amount, #crm-party, #rep-bwa {
  scroll-margin-block: 6rem;
}
.tour-body p {
  font-size: 0.9rem;
  line-height: 1.55;
  margin: 0 0 0.7rem;
}
.tour-level {
  border-top: 1px solid var(--line, #ded6c7);
  padding: 0.5rem 0 0.2rem;
  margin-bottom: 0.2rem;
}
.tour-level summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--ink-3, #8a8378);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tour-level p {
  margin: 0.5rem 0 0.2rem;
  font-size: 0.88rem;
}
.tour-foot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border-top: 1px solid var(--line, #ded6c7);
  background: var(--paper-2, #f4f0e8);
}
.tour-foot .bar-spacer { flex: 1; }

.party-editor {
  width: min(620px, 48vw);
  overflow-y: auto;
  padding-bottom: 2rem;
}
.party-editor .crm-form {
  padding: 0 1.1rem;
}
.pe-wide { grid-column: 1 / -1; }
.pe-roles {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.pe-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.3rem;
}
.pe-sub {
  margin: 1.1rem 1.1rem 0.3rem;
  font-family: var(--serif, Georgia, serif);
  font-size: 1rem;
}
.pe-contacts {
  padding: 0 1.1rem;
  display: grid;
  gap: 0.3rem;
}
.pe-contact {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--line, #ded6c7);
  border-radius: 6px;
}
.pe-contact.is-primary {
  border-color: var(--line-strong, #cdc3b2);
  background: #f6f1e7;
}
.pe-contact-name {
  font-weight: 600;
}
.pe-contact .chip {
  margin-left: auto;
}
.pe-contact-form {
  padding: 0.6rem 1.1rem 0;
}
.pe-primary {
  align-self: end;
  font-size: 0.82rem;
}

/* A line in another currency says so, and the rate field sits where the amount is decided. */
.fx-ccy {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-3, #8a8378);
}
.fx-rate {
  width: 8.5rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
}

/* A VAT id is checked while typing, but a dot is not a lock: green = shape matches the country,
   amber = probably a digit missing, no dot = no opinion (no prefix, or a country with no rule). */
.vat-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.vat-wrap input {
  flex: 1;
}
.vat-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: transparent;
  flex: none;
}
.vat-dot.is-valid {
  background: #3f8f52;
}
.vat-dot.is-invalid {
  background: #b8772a;
}
.co-wide { grid-column: 1 / -1; }

/* One page of 25 with a pager under the list: a number the eye can hold, not an endless scroll. */
.pager {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.2rem 0.1rem;
  font-size: 0.75rem;
  color: var(--ink-3, #8a8378);
}
.pager button[disabled] {
  opacity: 0.35;
  cursor: default;
}
.pager-info {
  font-family: var(--mono, monospace);
  padding: 0 0.3rem;
}

/* Verlauf: five rows on screen, the rest scrolls. A list that pushes the page down as it grows makes
   the whole view move while you are reading it. */
.history-tools {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0 0.4rem;
}
.history-tools input { flex: 1; min-width: 0; }
.history-list {
  max-height: 13.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
}
.history-list .crm-row { align-items: flex-start; }
/* the contact rows in the party panel: name, contact data and the three actions on one line */
.pe-contact-acts { display: inline-flex; gap: 0.2rem; margin-left: auto; align-items: center; }
.pe-contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  width: 100%;
}
.pe-contact.is-editing { flex-wrap: wrap; gap: 0.3rem; }
.pe-contact-grid input { font-size: 0.78rem; }

/* Statement screen: search + selection. The pick column is narrow so the numbers keep the room. */
.bank-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
  flex-wrap: wrap;
}
.bank-tools input[type='search'] { flex: 1 1 14rem; min-width: 8rem; }
.bank-table th.pick,
.bank-table td.pick { width: 1.6rem; padding-right: 0; }
.bank-table tr.is-picked { background: var(--paper-3); }

/* Language switch: in dark mode the browser drew black letters on the dark paper (1.2:1), because a
   <select> does not inherit the page colour the way text does. Explicit, and a size that can be read. */
#lang {
  color: var(--ink);
  background: var(--paper-2);
  border-color: var(--line-strong);
  font-size: 0.82rem;
  font-weight: 500;
}
#lang option { color: var(--ink); background: var(--paper); }
#lang { padding: 0.22rem 0.35rem; border: 1px solid var(--line-strong); border-radius: 6px; }

/* While the tour is open the content steps aside instead of hiding behind it: "Zum Feld" was
   scrolling a form field to the centre of the screen, which was exactly where the panel sat. */
[data-tour='1'] .main,
[data-tour='1'] .bar {
  padding-right: min(396px, 35vw);
  transition: padding-right 0.15s ease-out;
}
.chat-model-note {
  font-size: 0.72rem;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18rem;
}

/* The way in, said once, above everything. Amber because it is a state, not an error: the numbers are real, the
   booking is what needs a name. */
.login-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  background: color-mix(in srgb, var(--mark, #b4531f) 12%, var(--paper, #fff));
  border-bottom: 1px solid color-mix(in srgb, var(--mark, #b4531f) 30%, transparent);
  font-size: 0.86rem;
}
.login-banner span:first-child { flex: 1; min-width: 0; }
