@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap");

:root {
  --rs-ink: #18181b;        /* zinc-900 — primary text / dark surfaces */
  --rs-ink-soft: #27272a;   /* zinc-800 — hover on dark */
  --rs-muted: #52525b;      /* zinc-600 — secondary text */
  --rs-faint: #a1a1aa;      /* zinc-400 — tertiary text */
  --rs-line: #e4e4e7;       /* zinc-200 — borders */
  --rs-surface: #ffffff;
  --rs-bg: #f4f4f5;         /* zinc-100 — page background */
  --rs-accent: #dc2626;     /* red-600 — brand accent */
  --rs-accent-dark: #b91c1c;/* red-700 */
  --rs-radius: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--rs-ink);
  background: var(--rs-bg);
}

h1, h2 { font-weight: 700; letter-spacing: -0.01em; }

/* ── Login / logout-success ── */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1.5rem;
  padding: 1.5rem;
}

.login-container .logo {
  width: 260px;
  max-width: 80vw;
  height: auto;
}

.login-container h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--rs-muted);
}

/* ── Layout ── */
header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.5rem;
  background: var(--rs-surface);
  border-bottom: 1px solid var(--rs-line);
}

.brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand .logo {
  height: 30px;
  width: auto;
  display: block;
}

header h1 {
  margin: 0;
  padding-left: 1.25rem;
  border-left: 1px solid var(--rs-line);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--rs-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: auto;
}

.header-nav a {
  color: var(--rs-muted);
  text-decoration: none;
  font-size: 0.9rem;
}

.header-nav a:hover {
  color: var(--rs-accent);
}

/* Yellow warning triangle to the left of "Einstellungen" when the Bexio token is about to expire. */
.token-warn {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 1.15rem;
  height: 1rem;
  margin-right: 0.35rem;
  padding-bottom: 0.06rem;
  background: #f5a623;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

main {
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.toolbar h2 {
  margin: 0;
  flex: 1;
  font-size: 1.4rem;
}

/* ── Messages ── */
.success {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--rs-radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

.error {
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--rs-radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}

/* ── Project overview (Projektübersicht) ── */
.proj-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}

.proj-heading h2 { margin: 0 0 0.3rem; font-size: 1.4rem; letter-spacing: -0.02em; }
.proj-count { font-size: 0.82rem; color: var(--rs-muted); }
.proj-heading form { flex-shrink: 0; }

.proj-searchbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.proj-search-icon { font-size: 0.95rem; color: var(--rs-faint); line-height: 1; }

.proj-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--rs-ink);
  padding: 0;
}

.proj-search-input:focus { outline: none; }
.proj-search-input::placeholder { color: var(--rs-faint); }

.proj-list {
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  overflow: hidden;
}

.proj-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid #f0f0f1;
  background: var(--rs-surface);
  text-decoration: none;
  color: inherit;
}

.proj-row:first-child { border-top: none; }
.proj-row:hover { background: #fafafa; }

.proj-row-main { flex: 1; min-width: 0; }

.proj-row-title { display: flex; align-items: baseline; gap: 0.6rem; min-width: 0; }

.proj-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--rs-ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proj-number {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--rs-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.proj-meta { margin-top: 0.2rem; font-size: 0.75rem; color: var(--rs-faint); }

.proj-open {
  flex-shrink: 0;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--rs-line);
  border-radius: 6px;
  background: var(--rs-surface);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--rs-muted);
  transition: border-color 0.15s, color 0.15s;
}

.proj-row:hover .proj-open { border-color: var(--rs-faint); color: var(--rs-ink); }

.proj-empty {
  padding: 2rem 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--rs-faint);
}

.proj-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.proj-pager-info { font-size: 0.78rem; color: var(--rs-muted); font-variant-numeric: tabular-nums; }

.proj-pager-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--rs-line);
  border-radius: 6px;
  background: var(--rs-surface);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--rs-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.proj-pager-btn:hover:not(:disabled) { border-color: var(--rs-faint); color: var(--rs-ink); }
.proj-pager-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Table ── */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: var(--rs-radius);
  overflow: hidden;
}

th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--rs-bg);
  border-bottom: 1px solid var(--rs-line);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-muted);
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--rs-line);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

.text-input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--rs-ink);
}

.text-input:focus {
  outline: none;
  border-color: var(--rs-accent);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.bexio-text {
  margin-top: 0.2rem;
  padding: 0 0.5rem;
  font-size: 12px;
  color: var(--rs-faint);
}

/* Duration validation: :user-invalid only kicks in after the user edits an invalid value,
   so untouched rows aren't flagged on load. Highlights the field and reveals its hint. */
.duration-input:user-invalid {
  border-color: var(--rs-accent);
  background: rgba(220, 38, 38, 0.06);
}

.duration-input:user-invalid:focus {
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.input-hint {
  display: none;
  margin-top: 0.2rem;
  padding: 0 0.5rem;
  font-size: 12px;
  color: var(--rs-accent);
}

.duration-input:user-invalid ~ .input-hint {
  display: block;
}

.actions {
  white-space: nowrap;
}

.print {
  text-align: center;
}

.deleted-row {
  background: var(--rs-bg);
}

.deleted-row .text-input {
  color: var(--rs-faint);
  background: var(--rs-bg);
  text-decoration: line-through;
}

.deleted-row td {
  color: var(--rs-faint);
}

/* ── Toggle switch ── */
.toggle {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 20px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .slider {
  position: absolute;
  inset: 0;
  background: #d4d4d8;
  border-radius: 10px;
  transition: background 0.15s;
}

.toggle .slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
}

.toggle input:checked + .slider {
  background: var(--rs-accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(14px);
}

/* ── Buttons ── */
button, .btn-primary {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  background: var(--rs-surface);
  color: var(--rs-ink);
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover, .btn-primary:hover {
  background: var(--rs-bg);
  border-color: var(--rs-faint);
}

.btn-primary {
  background: var(--rs-ink);
  border-color: var(--rs-ink);
  color: #fff;
}

.btn-primary:hover {
  background: var(--rs-ink-soft);
  border-color: var(--rs-ink-soft);
  color: #fff;
}

.btn-danger {
  border-color: var(--rs-accent);
  color: var(--rs-accent);
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: var(--rs-accent-dark);
  color: var(--rs-accent-dark);
}

input[type="date"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  color: var(--rs-ink);
}

/* ═══════════════════════════════════════════════════════════════════════
   Invoice page — decluttered layout (design iteration 9a)
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --date-col: 150px;
  --entry-cols: var(--date-col) 1fr 84px 56px;
}

/* ── Heading ── */
.invoice-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.heading-back {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--rs-muted);
  text-decoration: none;
}

.heading-back:hover { color: var(--rs-ink); }
.heading-back-chev { font-size: 1rem; line-height: 1; }

.invoice-heading h2 {
  margin: 0 0 0.35rem;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--rs-ink);
  letter-spacing: -0.02em;
}

.heading-number {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--rs-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.invoice-heading h2 .heading-title { vertical-align: baseline; }

/* Inline-editable project title: input inherits the heading's size/weight. */
.heading-title-input {
  width: min(28rem, 60vw);
  max-width: 100%;
  box-sizing: border-box;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--rs-ink);
  border: 1px solid #c4c4c8;
  border-radius: 5px;
  padding: 0.1rem 0.4rem;
}

/* "reset to Bexio original" affordance, shown only when the title has been edited. */
.heading-title-reset {
  margin-left: 0.6rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--rs-line);
  border-radius: 999px;
  background: var(--rs-surface);
  color: var(--rs-muted);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  vertical-align: middle;
}

.heading-title-reset:hover { color: var(--rs-ink); border-color: #c4c4c8; }
.heading-title-reset .reset-icon { font-size: 0.85rem; line-height: 1; }
.heading-title-reset .reset-orig { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.heading-range {
  font-size: 0.82rem;
  color: var(--rs-muted);
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-secondary {
  background: var(--rs-surface);
  border-color: var(--rs-line);
  color: var(--rs-muted);
  font-weight: 500;
}

/* ── Summenbox ── */
.summary-box {
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.summary-top {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0.9rem 1.25rem;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-label {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rs-faint);
  font-weight: 600;
}

.summary-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--rs-ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.summary-divider {
  width: 1px;
  height: 34px;
  background: var(--rs-line);
}

.summary-excluded {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--rs-faint);
}

.summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--rs-accent);
}

.summary-toggle-all {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-left: auto;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--rs-muted);
  cursor: pointer;
  user-select: none;
}

/* ── Aufschlüsselung pro Ansprechpartner ── */
.summary-breakdown {
  border-top: 1px solid #f0f0f1;
  padding: 0.9rem 1.25rem 1rem;
}

.breakdown-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rs-faint);
  font-weight: 600;
  margin-bottom: 0.85rem;
}

.breakdown-head:hover { color: var(--rs-muted); background: none; border: none; }
.breakdown-chev { font-size: 0.6rem; transition: transform 0.15s; }
.summary-box.breakdown-collapsed .breakdown-chev { transform: rotate(-90deg); }
.summary-box.breakdown-collapsed .breakdown-list { display: none; }
.summary-box.breakdown-collapsed .breakdown-head { margin-bottom: 0; }

.breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1.25rem;
  row-gap: 0.45rem;
}

.breakdown-name-wrap {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.breakdown-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--rs-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breakdown-name.none { color: var(--rs-faint); font-style: italic; }

.breakdown-pos {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--rs-faint);
  white-space: nowrap;
}

.breakdown-hours {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--rs-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.breakdown-bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: #f0f0f1;
  overflow: hidden;
}

.breakdown-bar-fill {
  display: block;
  height: 100%;
  background: var(--rs-accent);
  border-radius: 3px;
}

/* ── Filterleiste ── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  margin-bottom: 0.75rem;
}

.filter-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rs-faint);
  margin-right: 0.25rem;
}

.filter-dates {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--rs-line);
  border-radius: 6px;
  padding: 0.15rem 0.6rem;
  background: var(--rs-surface);
}

.filter-date-label { font-size: 0.75rem; color: var(--rs-muted); }

.filter-dates input[type="date"] {
  border: none;
  padding: 0.15rem 0;
  font-size: 0.8rem;
}

.filter-dates input[type="date"]:focus { outline: none; }

.filter-pill {
  appearance: none;
  -webkit-appearance: none;
  max-width: 180px;
  padding: 0.3rem 1.6rem 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--rs-muted);
  background-color: var(--rs-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6' viewBox='0 0 8 6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%23a1a1aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  border: 1px solid var(--rs-line);
  border-radius: 6px;
  cursor: pointer;
  text-overflow: ellipsis;
}

.filter-pill:hover { border-color: #c4c4c8; }
.filter-pill.active { border-color: var(--rs-accent); color: var(--rs-ink); }
.filter-pill:focus { outline: none; border-color: var(--rs-accent); }

/* The multi-select summary reuses .filter-pill; hide the native disclosure marker
   so the .filter-pill chevron background image is the only affordance shown. */
summary.filter-pill { list-style: none; }
summary.filter-pill::-webkit-details-marker { display: none; }

.filter-multi {
  display: inline-block;
  position: relative;
}

.filter-multi-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.3rem;
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.filter-multi-panel label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  color: var(--rs-ink);
  white-space: nowrap;
  cursor: pointer;
  border-radius: 4px;
}

.filter-multi-panel label:hover { background: var(--rs-hover, #f4f4f5); }
.filter-multi-panel input[type="checkbox"] { cursor: pointer; margin: 0; }

.filter-seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--rs-line);
  border-radius: 6px;
  padding: 2px;
  background: var(--rs-surface);
}

.filter-seg button {
  padding: 0.25rem 0.65rem;
  border: none;
  border-radius: 4px;
  background: none;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--rs-muted);
  cursor: pointer;
}

.filter-seg button:hover { background: none; color: var(--rs-ink); border: none; }
.filter-seg button.active { background: var(--rs-ink); color: #fff; }

.filter-meta {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

#filter-result {
  font-size: 0.75rem;
  color: var(--rs-muted);
  font-variant-numeric: tabular-nums;
}

.filter-reset {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rs-accent);
}

.filter-reset:hover { text-decoration: underline; background: none; border: none; }

.filter-empty {
  padding: 2.25rem 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--rs-faint);
}

/* ── Entries list ── */
.entries {
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  overflow: hidden;
}

.entries-head {
  display: grid;
  grid-template-columns: var(--entry-cols);
  align-items: center;
  padding: 0.7rem 1.25rem;
  border-bottom: 1px solid var(--rs-line);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-faint);
  font-weight: 600;
}

.entries-head .col-right { text-align: right; }
.entries-head .col-center { text-align: center; }

.entry-row { border-bottom: 1px solid #f0f0f1; }
.entry-row:has(+ .filter-empty) { border-bottom: none; }

.entry-main {
  display: grid;
  grid-template-columns: var(--entry-cols);
  align-items: start;
  padding: 0.8rem 1.25rem;
}

.entry-row.excluded .cell-date,
.entry-row.excluded .cell-leistung,
.entry-row.excluded .cell-dauer {
  opacity: 0.45;
}

.cell-date {
  font-size: 0.82rem;
  color: var(--rs-muted);
  white-space: nowrap;
  padding-top: 1px;
  padding-right: 1.25rem;
}

.cell-leistung {
  min-width: 0;
  padding-right: 1.25rem;
}

.leistung-head {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.cell-dauer {
  font-size: 0.9rem;
  color: var(--rs-ink);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
  justify-self: end;
}

.cell-verr {
  display: flex;
  justify-content: center;
}

/* ── Inline click-to-edit ── */
.editable { position: relative; min-width: 0; }
.editable.text-editable { flex: 1; min-width: 0; }

.editable-display {
  display: inline-block;
  cursor: text;
  border-radius: 4px;
  padding: 1px 4px;
  margin: -1px -4px;
  max-width: 100%;
}

.text-editable .editable-display {
  display: block;
  font-size: 0.9rem;
  color: var(--rs-ink);
  line-height: 1.45;
  white-space: pre-wrap;
}

.editable-display:hover { background: #f0f0f1; }

.editable-input { display: none; font-family: inherit; }
.editable.editing .editable-display { display: none; }
.editable.editing .editable-input { display: block; }

.date-input,
.duration-input {
  padding: 0.2rem 0.35rem;
  border: 1px solid #c4c4c8;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--rs-ink);
}

.date-input { width: 100%; max-width: 100%; box-sizing: border-box; }
.duration-input { width: 72px; text-align: right; }

.text-area {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.9rem;
  color: var(--rs-ink);
  line-height: 1.45;
  border: 1px solid #c4c4c8;
  border-radius: 5px;
  padding: 0.4rem 0.5rem;
  resize: vertical;
}

.editable-input:focus {
  outline: none;
  border-color: var(--rs-accent);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

.cell-dauer .input-hint {
  display: none;
  margin-top: 0.25rem;
  padding: 0;
  font-size: 0.72rem;
  color: var(--rs-accent);
  white-space: normal;
}

.cell-dauer.editing .duration-input:user-invalid ~ .input-hint { display: block; }

/* ── "Bearbeitet" badge ── */
.badge-edited {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-muted);
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  line-height: 1.6;
}

.badge-edited:hover { background: var(--rs-bg); border-color: #c4c4c8; }

.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--rs-accent); }
.badge-chev { font-size: 0.55rem; color: var(--rs-faint); transition: transform 0.15s; }

.entry-row.open .badge-chev,
#entries-container.show-all-orig .entry-row:not(.closed) .badge-chev { transform: rotate(180deg); }

/* ── Tag chips ── */
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }

.chip {
  appearance: none;
  -webkit-appearance: none;
  max-width: 100%;
  padding: 0.12rem 1.3rem 0.12rem 0.5rem;
  font-size: 0.72rem;
  font-family: inherit;
  color: var(--rs-muted);
  background-color: var(--rs-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6' viewBox='0 0 8 6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%23a1a1aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  border: 1px solid var(--rs-line);
  border-radius: 4px;
  cursor: pointer;
  text-overflow: ellipsis;
}

.chip:hover { background-color: #eeeef0; border-color: #c4c4c8; }
.chip:focus { outline: none; border-color: var(--rs-accent); }

/* ── Original values ── */
.orig-body { display: none; padding: 0 1.25rem 0.75rem; }

.entry-row.open .orig-body,
#entries-container.show-all-orig .entry-row:not(.closed) .orig-body { display: block; }

.orig-inner {
  margin-left: var(--date-col);
  border-left: 2px solid color-mix(in srgb, var(--rs-accent) 40%, #fff);
  background: color-mix(in srgb, var(--rs-accent) 4%, #fff);
  border-radius: 0 6px 6px 0;
  padding: 0.55rem 0.9rem 0.6rem;
}

.orig-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }

.orig-tag {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rs-accent);
  background: var(--rs-surface);
  border: 1px solid color-mix(in srgb, var(--rs-accent) 35%, #fff);
  border-radius: 4px;
  padding: 1px 6px;
}

.orig-reset {
  margin-left: auto;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--rs-accent);
  line-height: 1.4;
}

.orig-reset:hover { text-decoration: underline; background: none; border-color: transparent; }

.orig-diffs { display: flex; flex-direction: column; gap: 0.25rem; }

.diff { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.75rem; line-height: 1.5; }

.diff-label {
  flex-shrink: 0;
  width: 120px;
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-faint);
}

.diff-old { min-width: 0; color: var(--rs-muted); }

.empty-hint { font-size: 0.85rem; color: var(--rs-faint); }

/* ── New (user-added) rows ── */
.text-editable .editable-display:empty::before {
  content: "Leistung erfassen…";
  color: var(--rs-faint);
}

.badge-new {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-accent);
  background: color-mix(in srgb, var(--rs-accent) 6%, #fff);
  border: 1px solid color-mix(in srgb, var(--rs-accent) 35%, #fff);
  border-radius: 4px;
  line-height: 1.6;
}

.entry-delete {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: none;
  color: var(--rs-faint);
  cursor: pointer;
}

.entry-delete:hover { background: #fef2f2; color: var(--rs-accent); border: none; }

.add-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: none;
  border-top: 1px solid #f0f0f1;
  border-radius: 0;
  background: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--rs-muted);
  cursor: pointer;
  text-align: left;
}

.add-row:hover { background: #fafafa; color: var(--rs-ink); border-top-color: #f0f0f1; }

.add-row-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px dashed #c4c4c8;
  color: var(--rs-muted);
  font-size: 0.75rem;
  line-height: 1;
}

/* ── Error page (404) ── */
.error-main {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  text-align: center;
}

.error-card {
  width: 100%;
  max-width: 520px;
}

.error-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  margin-bottom: 1.75rem;
  border-radius: 99px;
  background: color-mix(in srgb, var(--rs-accent) 8%, #fff);
}

.error-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rs-accent);
}

.error-badge-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--rs-accent) 82%, var(--rs-ink));
}

.error-numeral {
  font-size: 88px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--rs-ink);
  font-variant-numeric: tabular-nums;
}

.error-headline {
  margin: 1.375rem 0 0.625rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--rs-ink);
}

.error-message {
  margin: 0 auto;
  max-width: 400px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--rs-muted);
  text-wrap: pretty;
}

.error-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  margin-top: 2rem;
}

/* Local-only debug panel (see fragments/error-debug.html) — full width, left aligned. */
.error-debug {
  max-width: 960px;
  margin: 0 auto 3rem;
  padding: 0 1.5rem;
  text-align: left;
}

.error-debug-title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--rs-muted);
  margin: 0 0 0.75rem;
}

.error-debug-meta {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.375rem;
  font-size: 13px;
}

.error-debug-meta div {
  display: flex;
  gap: 0.5rem;
}

.error-debug-meta dt {
  flex: 0 0 84px;
  font-weight: 600;
  color: var(--rs-muted);
}

.error-debug-meta dd {
  margin: 0;
  color: var(--rs-ink);
  word-break: break-word;
}

.error-debug-trace {
  margin: 0;
  padding: 1rem;
  max-height: 420px;
  overflow: auto;
  border-radius: 8px;
  background: #1e1e22;
  color: #e6e6e6;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
  tab-size: 2;
}

/* ═══════════════════════════════════════════════════════════════════════
   Loading states — light skeleton variants (design “Bexio Ladebildschirm” 1c/1d)
   Shown while a “Von Bexio laden” request is in flight. HTMX toggles the
   .htmx-request class on the element issuing the request (the <form>) and on
   its hx-indicator target, which drives the visibility swaps below.
   ═══════════════════════════════════════════════════════════════════════ */

@keyframes bx-shimmer { from { background-position: -220px 0; } to { background-position: 220px 0; } }
@keyframes bx-spin { to { transform: rotate(360deg); } }

/* Shimmering placeholder block. Width/height are set inline per skeleton. */
.bx-sk {
  background: linear-gradient(90deg, #eeeef0 0%, #f7f7f8 50%, #eeeef0 100%);
  background-size: 440px 100%;
  animation: bx-shimmer 1.3s linear infinite;
  border-radius: 5px;
}

/* Small inline spinner used inside the “Von Bexio laden” button and status pill. */
.bx-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--rs-line);
  border-top-color: var(--rs-accent);
  animation: bx-spin 0.7s linear infinite;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* Button loading affordance: swap the label for a spinner + muted “…” while the
   request is in flight. hx-disabled-elt sets [disabled] on the button for the
   duration of the request, which drives this state for both page buttons. */
.btn-loadable { display: inline-flex; align-items: center; gap: 0.45rem; }
.btn-loadable .bx-spinner { display: none; }
.btn-loadable:disabled {
  color: var(--rs-faint);
  cursor: default;
  background: var(--rs-surface);
  border-color: var(--rs-line);
}
.btn-loadable:disabled .bx-spinner { display: inline-block; }
.btn-loadable:disabled .btn-label::after { content: "…"; }

/* Skeleton ↔ real-content swap. The skeleton is present in the swap target's
   markup but hidden until the target (hx-indicator) carries .htmx-request. */
.load-skeleton { display: none; }
.htmx-request > .load-skeleton { display: block; }
.htmx-request > .load-content { display: none; }

/* Rows share the card chrome of the real lists so nothing shifts on swap-in. */
.skel-card {
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  overflow: hidden;
}

/* 1c — Projektübersicht skeleton row (name/meta + status + open button). */
.skel-proj-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #f0f0f1;
}
.skel-proj-row:first-child { border-top: none; }
.skel-proj-row .skel-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.5rem; }

/* 1d — Rechnungsansicht skeletons (Summenbox + table). */
.skel-summary {
  background: var(--rs-surface);
  border: 1px solid var(--rs-line);
  border-radius: 8px;
  margin-bottom: 1rem;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.skel-summary .skel-stat { display: flex; flex-direction: column; gap: 0.5rem; }
.skel-summary .skel-divider { width: 1px; height: 34px; background: var(--rs-line); }
.skel-summary .skel-stat.skel-stat-end { margin-left: auto; align-items: flex-end; }

.skel-table-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #fafafa;
  border-bottom: 1px solid var(--rs-line);
}
.skel-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid #f0f0f1;
}
.skel-row:first-of-type { border-top: none; }
.skel-row .skel-lines { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.375rem; }
