* { box-sizing: border-box; }
html { background: var(--surface); color: var(--ink); font: 500 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
body { margin: 0; }
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 4px; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.icon { width: 1.25em; height: 1.25em; flex: 0 0 auto; vertical-align: -0.25em; }

/* Shell: brand, top navigation, user */
.topbar { position: sticky; top: 0; z-index: 10; height: 68px; display: flex; align-items: center; gap: 32px; padding: 0 40px; background: rgb(255 255 255 / .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.02em; text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 9px; background: var(--ink); display: grid; place-items: center; }
.brand-mark::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.mainnav { display: flex; gap: 4px; margin-right: auto; position: relative; }
.mainnav a { position: relative; display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 600; }
.mainnav a:hover { color: var(--ink); background: var(--surface-2); }
.mainnav a.active { color: var(--ink); background: var(--surface-2); }
.mainnav a.active .icon { color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions form { margin: 0; }
.icon-button { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; }
.icon-button:hover, .icon-button.active { background: var(--surface-2); color: var(--ink); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); display: inline-grid; place-items: center; font-weight: 800; font-size: 13px; flex: 0 0 auto; }
.avatar-lg { width: 56px; height: 56px; border-radius: 18px; font-size: 20px; }
#main { padding: 40px; max-width: 1280px; margin: 0 auto; min-width: 0; }

/* Type */
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.02em; }
h1 { font-size: 34px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 750; margin-bottom: 16px; }
h3 { font-size: 16px; font-weight: 700; }
p { margin: 6px 0 14px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; margin: 0 0 32px; flex-wrap: wrap; }
.page-heading p { color: var(--muted); margin-bottom: 0; }
.page-heading h2 { margin: 0; }
.heading-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 16px; color: var(--muted); text-decoration: none; font-weight: 600; }
.back:hover { color: var(--ink); }
.top-context, .user, .muted, .hint, .empty { color: var(--muted); }
.hint { font-size: 13px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* Sections, lists, tables */
.work-section { padding: 28px 0; border-top: 1px solid var(--line); }
.work-section:first-of-type { border-top: 0; }
.work-list { list-style: none; padding: 0; margin: 0; }
.work-list li { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 650px; }
th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
th, td { padding: 14px 12px; vertical-align: top; }
td { border-bottom: 1px solid var(--line); }
tbody tr:hover td { background: #FCFBF9; }
td a { font-weight: 650; }
.instruction { background: var(--surface-2); font-size: 14px; }
.empty { padding: 28px; border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; }
.notice { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* Buttons: black primary, quiet secondary */
button, .button { min-height: 44px; border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 20px; font: 700 14px var(--font); cursor: pointer; text-decoration: none; display: inline-flex; gap: 8px; align-items: center; justify-content: center; background: transparent; color: var(--ink); transition: transform .15s ease, background .15s ease; }
button:active, .button:active { transform: scale(.97); }
.primary { background: var(--ink); color: var(--white); }
.primary:hover { background: #2A2A2E; color: var(--white); }
.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.secondary:hover { border-color: var(--ink); }
.accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.text-button { background: transparent; border: 0; padding: 0; min-height: 0; text-decoration: underline; font-weight: 600; }
button:disabled { opacity: .45; cursor: default; transform: none; }

/* Forms */
.form-panel { max-width: 720px; }
.field { margin: 0 0 18px; }
label { display: block; font-weight: 650; font-size: 14px; margin-bottom: 6px; }
input, select, .field textarea { min-height: 44px; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; width: 100%; transition: border-color .15s; }
input:hover, select:hover, textarea:hover { border-color: #D6D2CB; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
input[aria-invalid=true] { border-color: var(--error); }
.checkbox-field { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; }
.checkbox-field input { width: 22px; height: 22px; min-height: 22px; flex: 0 0 22px; accent-color: var(--ink); }
details { overflow-wrap: anywhere; }
summary { cursor: pointer; font-weight: 700; }
.field-error { color: var(--error); margin: 6px 0; font-size: 13px; font-weight: 600; }
.error-summary { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--error-soft); color: var(--error); font-weight: 600; margin-bottom: 20px; }
.form-actions { border-top: 1px solid var(--line); padding-top: 20px; display: flex; align-items: center; gap: 10px; }
.form-actions span { margin-right: auto; color: var(--muted); font-size: 13px; }
.compact-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.compact-form label { width: 100%; margin: 0; }
.compact-form input { width: min(100%, 330px); }
.inline-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: end; }
.inline-form .field { margin: 0; }
.inline-form button { justify-self: start; }
fieldset { border: 1.5px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; min-width: 0; padding: 16px 20px; }
.field textarea { min-height: 120px; resize: vertical; }
code { white-space: normal; overflow-wrap: anywhere; font-size: 13px; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
.file-hash { overflow-wrap: anywhere; }
.money { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* Login */
.login-main { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 40%), var(--surface); }
.login-panel { width: min(100%, 420px); }
.login-panel form { display: grid; gap: 10px; margin-top: 24px; }
.login-panel button { margin-top: 12px; }

/* Leistungen tables and totals */
.service-table { table-layout: fixed; }
.service-table td { overflow-wrap: anywhere; }
.service-table th:nth-child(1) { width: 22%; }
.service-table th:nth-child(2) { width: 27%; }
.service-table th:nth-child(3) { width: 18%; }
.service-table th:nth-child(4) { width: 18%; }
.service-table th:nth-child(5) { width: 15%; }
.service-totals { margin: 16px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.service-totals > div { padding: 16px; border-radius: var(--radius); background: var(--surface-2); }
.service-totals dt { font-size: 13px; color: var(--muted); font-weight: 600; }
.service-totals dd { margin: 4px 0 0; font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }

/* Tabs */
.workspace-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0 0 24px; background: var(--surface-2); border-radius: 999px; width: fit-content; max-width: 100%; }
.workspace-tabs a { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: 999px; text-decoration: none; font-weight: 650; color: var(--ink-2); }
.workspace-tabs a:hover { color: var(--ink); }
.workspace-tabs a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.workspace-tabs a.active .icon { color: var(--accent); }

/* Cards, chips, stats */
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 20px; padding: 22px; }
a.card { display: block; text-decoration: none; transition: border-color .2s, transform .2s; }
a.card:hover { border-color: var(--ink); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card-head { display: flex; align-items: center; gap: 14px; }
.card-head h2, .card-head h3 { margin: 0; }
.card-head > div { min-width: 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); font-size: 13px; font-weight: 650; color: var(--ink-2); text-decoration: none; }
.chip.accent-chip { background: var(--accent-soft); color: var(--accent-ink); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.warn { background: var(--accent-soft); color: var(--accent-ink); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.error { background: var(--error-soft); color: var(--error); }
.amount { font-weight: 800; font-size: 20px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.amount small { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 40px; }
.stat { padding: 22px; border-radius: 20px; background: var(--surface-2); }
.stat.highlight { background: var(--ink); color: var(--white); }
.stat.highlight .stat-label { color: #B9B9C0; }
.stat .icon { width: 28px; height: 28px; color: var(--accent); }
.stat-value { display: block; font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 14px; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-weight: 650; font-size: 13px; }
.dash { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 40px; }
.dash h2 { display: flex; align-items: center; gap: 10px; }
.dash h2 .icon { color: var(--accent); }

/* Revenue bars */
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.bars a { display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr) auto; gap: 16px; align-items: center; text-decoration: none; }
.bar-track { height: 12px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar { display: block; height: 100%; border-radius: inherit; background: var(--accent); transform-origin: left; }
.bars a:hover .bar { background: var(--ink); }
.bar-label { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Provider logos */
.logo { display: inline-grid; place-items: center; border-radius: 10px; background: var(--surface); border: 1.5px solid var(--line); flex: 0 0 auto; overflow: hidden; }
.logo img { width: 58%; height: 58%; object-fit: contain; }
.logo-sm { width: 28px; height: 28px; border-radius: 8px; font-size: 10px; }
.logo-md { width: 40px; height: 40px; font-size: 13px; }
.logo-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 16px; }
.logo-mono { background: var(--mono, var(--ink)); border-color: transparent; color: var(--white); font-weight: 800; }
.logo-stack { display: flex; align-items: center; }
.logo-stack .logo { margin-left: -6px; box-shadow: 0 0 0 2px var(--surface); }
.logo-stack .logo:first-child { margin-left: 0; }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.provider-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface); text-decoration: none; text-align: left; font: inherit; min-height: 0; color: var(--ink); cursor: pointer; transition: border-color .2s; }
.provider-tile:hover { border-color: var(--ink); }
.provider-tile strong { font-weight: 700; line-height: 1.25; }
.provider-tile small { color: var(--muted); font-weight: 600; font-size: 12px; }
.provider-tile .tile-add { position: absolute; top: 12px; right: 12px; color: var(--muted); }
.provider-tile.custom { border-style: dashed; justify-content: center; }
.provider-pick { position: relative; }
.provider-pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.provider-pick input:checked + .provider-tile { border-color: var(--ink); background: var(--surface-2); }
.provider-pick input:focus-visible + .provider-tile { outline: 3px solid var(--focus); outline-offset: 2px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #C9C5BE; display: inline-block; flex: 0 0 auto; }
.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--accent); }
.status-dot.error { background: var(--error); }
.connection-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.connection-list li { display: flex; align-items: center; gap: 12px; }
.connection-list .grow { flex: 1; min-width: 0; }
.connection-list small { display: block; color: var(--muted); font-size: 12px; }

/* Customer workspace */
.customer-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; }
.customer-head .grow { flex: 1; min-width: 200px; }
.customer-head p { margin: 2px 0 0; color: var(--muted); }
.company-card { padding: 0; overflow: hidden; }
.company-card > header { display: flex; align-items: center; gap: 14px; padding: 20px 22px; }
.company-card > header .grow { flex: 1; min-width: 0; }
.company-card > section { padding: 16px 22px; border-top: 1px solid var(--line); }
.company-card .eyebrow { margin-bottom: 10px; }
.service-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.service-lines li { display: flex; justify-content: space-between; gap: 16px; }
.service-lines a { text-decoration: none; font-weight: 650; }
.service-lines span:last-child { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.inline-create { display: flex; gap: 8px; flex-wrap: wrap; align-items: start; }
.inline-create .field { flex: 1; min-width: 220px; margin: 0; }
.date-filter { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.date-filter label { margin: 0; color: var(--muted); font-weight: 600; }
.date-filter input { width: auto; min-height: 40px; padding: 6px 12px; }
.date-filter button { min-height: 40px; }

[data-animate] > * { will-change: transform, opacity; }

@media (max-width: 900px) {
  .dash { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 0 12px; padding: 10px 16px 0; }
  .brand { order: 1; height: 44px; }
  .top-actions { order: 2; margin-left: auto; }
  .mainnav { order: 3; width: calc(100% + 32px); margin: 0 -16px; padding: 6px 12px 10px; overflow-x: auto; }
  .mainnav a { white-space: nowrap; }
  #main { padding: 24px 16px; }
  h1 { font-size: 28px; }
  .page-heading { align-items: start; }
  .inline-form { display: block; }
  .inline-form .field { margin-bottom: 16px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions span { width: 100%; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; }
  thead { display: none; }
  tbody, tr, td { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 12px 0; }
  td { border: 0; padding: 4px 0; overflow-wrap: anywhere; }
  td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
  .instruction { padding: 12px; }
  .money { text-align: left; }
  .stats { gap: 10px; }
  .stat { padding: 16px; }
  .stat-value { font-size: 24px; }
  .bars a { grid-template-columns: minmax(0, 1fr) auto; }
  .bars .bar-track { grid-column: 1 / -1; grid-row: 2; }
  .card-grid { grid-template-columns: 1fr; }
  .workspace-tabs { border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

.empty .icon { width: 40px; height: 40px; color: var(--ok); }

/* Panels: one quiet surface per topic (invoice editor, master data, Apollo) */
.panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 24px; }
.panel + .panel, .invoice-main > form > .panel + .panel { margin-top: 16px; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-heading h2, .panel-heading h3 { margin: 0; }
.panel-heading .muted { font-size: 13px; }
.panel > .field:last-child, .panel form > .field:last-of-type { margin-bottom: 0; }
.text-link { font-weight: 650; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.panel-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 8px; }
.panel-actions .hint { margin: 0 auto 0 0; }

/* Invoice editor, modelled on the e-invoice tool: form left, sticky total right */
.invoice-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.invoice-main > form { display: block; margin-top: 16px; }
.invoice-summary { position: sticky; top: 92px; display: grid; gap: 12px; }
.total-amount { font-size: 32px; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.summary-lines { display: grid; gap: 6px; padding: 12px 0; border-block: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.summary-lines div div, .summary-lines > div:first-child { display: flex; justify-content: space-between; gap: 12px; }
.invoice-summary .checkbox-field { font-size: 13px; font-weight: 600; align-items: flex-start; }
.invoice-summary .hint { margin: 0; }
.customer-pick select { max-width: 420px; }
.customer-summary { display: grid; gap: 2px; margin-top: 14px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); }
.invoice-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 20px; }
.invoice-dates .field { margin: 0; }
.add-position { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.add-position select { width: auto; flex: 0 1 340px; min-width: 0; }
@media (max-width: 1100px) {
  .invoice-layout { grid-template-columns: minmax(0, 1fr); }
  .invoice-summary { position: static; }
}
@media (max-width: 720px) {
  .form-grid, .invoice-dates { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
}

/* Apollo tab: connections per company */
.stack { display: grid; gap: 16px; }
.section-label { margin: 20px 0 8px; }
.setup-chips { margin: 0 0 4px; }
.setup-chips a { text-decoration: none; }
.source-rows { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--line); border-radius: var(--radius); }
.source-rows li { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.1fr) auto; align-items: center; gap: 14px; padding: 12px 14px; }
.source-rows li + li { border-top: 1px solid var(--line); }
.source-rows small, .source-state small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.source-state > span { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.row-actions form { margin: 0; }
.row-actions .button { min-height: 36px; padding: 0 14px; font-size: 13px; }
.add-source { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.add-source select { width: auto; flex: 0 1 240px; }
.add-source input { flex: 1 1 240px; width: auto; }
.add-source .field-error { width: 100%; }
.assign { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.assign form { margin-top: 14px; }
.checkbox-field.full, .panel-actions.full { grid-column: 1 / -1; }

/* Stammdaten */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 16px; align-items: start; margin-bottom: 16px; }
.company-rows { list-style: none; margin: 0; padding: 0; }
.company-rows form { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.company-rows input { flex: 1; }
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .source-rows li { grid-template-columns: auto minmax(0, 1fr); }
  .source-state, .row-actions { grid-column: 2; }
}
@media (max-width: 720px) {
  .company-rows form { flex-wrap: wrap; }
  .company-rows input { flex-basis: calc(100% - 40px); }
}
.settings-grid > .panel { margin-top: 0; }
.parties { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.parties > div { display: grid; gap: 2px; align-content: start; }
.parties .eyebrow { margin: 0 0 4px; }
.positions { min-width: 0; }
.pre { white-space: pre-line; }
.wide { width: 100%; }
.invoice-summary form { margin: 0; display: grid; gap: 10px; }
.invoice-summary .text-button { justify-self: start; justify-content: flex-start; text-align: left; display: inline-flex; gap: 6px; font-size: 13px; color: var(--ink-2); }
@media (max-width: 720px) { .parties { grid-template-columns: 1fr; } }

/* Start page: counts, then one card per problem with a coloured pill */
.tally { display: flex; flex-wrap: wrap; gap: 10px; margin: -8px 0 24px; }
.tally-item { display: flex; align-items: baseline; gap: 8px; padding: 10px 16px; border-radius: 14px; background: var(--surface-2); }
.tally-item strong { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tally-item span { font-weight: 650; color: var(--ink-2); font-size: 14px; }
.tally-item.error strong { color: var(--error); }
.tally-item.warn strong { color: var(--accent-ink); }
.tally-item.info strong { color: var(--info); }
.issue-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.issue { display: flex; align-items: center; gap: 14px; height: 100%; padding: 16px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); text-decoration: none; transition: border-color .15s; }
.issue:hover { border-color: var(--ink); }
.issue .grow { flex: 1; min-width: 0; display: grid; gap: 1px; }
.issue small { color: var(--muted); font-size: 12px; font-weight: 600; }
.issue strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.issue .reason { color: var(--ink-2); font-size: 13px; }
.pill { flex: 0 0 auto; align-self: flex-start; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 750; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); }
.pill.error { background: var(--error-soft); color: var(--error); }
.pill.warn { background: var(--accent-soft); color: var(--accent-ink); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
@media (max-width: 720px) { .issue-grid { grid-template-columns: 1fr; } }

/* Company page: setup summary, connections with details on demand */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 16px 24px; align-items: center; }
.setup-grid > div { display: grid; gap: 4px; justify-items: start; }
.tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11px; font-weight: 750; letter-spacing: .02em; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.source-list { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--line); border-radius: var(--radius); }
.source-list > li + li { border-top: 1px solid var(--line); }
.source-main { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 14px 16px; }
.source-main .grow { display: grid; gap: 2px; min-width: 0; }
.source-status { display: grid; gap: 3px; justify-items: start; }
.source-status small { color: var(--muted); font-size: 12px; }
.source-status .pill { align-self: auto; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0 0 12px; font-size: 13px; }
.facts dt { color: var(--muted); font-weight: 650; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.row-actions .button, .row-actions button { min-height: 36px; padding: 0 14px; font-size: 13px; }
.add-source .text-link { align-self: center; }
@media (max-width: 900px) {
  .setup-grid { grid-template-columns: 1fr; }
  .source-main { grid-template-columns: auto minmax(0, 1fr); }
  .source-status, .source-main .row-actions { grid-column: 2; }
}

/* Rechnungen area: list toolbar, table card, editor lines, catalog */
.list-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 0 16px; }
.segmented { display: inline-flex; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented button { min-height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font-weight: 650; padding: 0 16px; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
.search-field { display: flex; align-items: center; gap: 8px; margin: 0; padding: 0 14px; min-height: 44px; width: min(100%, 340px); border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted); }
.search-field input { border: 0; padding: 0; min-height: 40px; }
.search-field input:focus { outline: none; }
.table-card { border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.table-card table { min-width: 0; }
.table-card th { background: var(--surface-2); padding: 12px 20px; }
.table-card td { padding: 16px 20px; vertical-align: middle; }
.table-card tbody tr { cursor: pointer; }
.table-card .row-link { text-decoration: none; font-weight: 750; }
.table-foot { margin: 0; padding: 12px 20px; font-size: 13px; }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; margin-right: 6px; vertical-align: 2px; }
.chip-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.chip-picker .chip { border: 1px dashed var(--line); min-height: 32px; padding: 0 12px; cursor: pointer; font: 650 13px var(--font); }
.chip-picker .chip:hover { border-color: var(--ink); }
.chip-picker .chip:disabled { opacity: .45; cursor: default; }
.positions { padding-left: 0; padding-right: 0; }
.positions > .panel-heading, .positions > .add-position { padding: 0 24px; }
.line-head, .invoice-line { display: grid; grid-template-columns: minmax(0, 1fr) 64px 100px 128px 104px 96px 36px; gap: 10px; align-items: center; padding: 0 24px; }
.line-head { font-size: 12px; font-weight: 700; color: var(--muted); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.invoice-line { padding-top: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.invoice-line input, .invoice-line select { min-height: 40px; padding: 8px 10px; }
.line-description { display: flex; align-items: center; gap: 8px; min-width: 0; }
.line-description input { flex: 1; min-width: 0; }
.line-qty { text-align: center; }
.line-amount { justify-content: flex-end; min-height: 40px; }
.line-period { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 13px; color: var(--muted); }
.line-period input { width: auto; min-height: 34px; padding: 4px 8px; font-size: 13px; }
.line-period [data-reason] { flex: 1 1 260px; }
.add-position { justify-content: space-between; align-items: center; }
.form-narrow { max-width: 720px; }
.section-title { margin-top: 36px; }
.section-gap { margin-top: 36px; max-width: 720px; }
.package-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.package-card { display: grid; gap: 4px; align-content: start; padding: 20px; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); text-decoration: none; }
.package-card:hover { border-color: var(--ink); }
.package-card.archived { opacity: .6; }
.package-card > .muted { font-size: 12px; font-weight: 650; }
.package-name { font-size: 18px; }
.package-price { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.package-price small { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.package-card ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.package-card li .icon { color: var(--ok); margin-right: 6px; }
.catalog-list { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); }
.catalog-list > li + li { border-top: 1px solid var(--line); }
.catalog-list a, .recurring-row { display: flex; align-items: center; gap: 12px; padding: 14px 20px; text-decoration: none; }
.catalog-list a:hover { background: var(--surface-2); }
.catalog-list .grow { flex: 1; min-width: 0; display: grid; gap: 2px; }
.catalog-list small { color: var(--muted); font-size: 13px; }
.catalog-price { display: grid; text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; min-width: 96px; }
.catalog-price small { font-weight: 500; font-size: 12px; }
.inclusion-rows { display: grid; gap: 8px; margin-top: 10px; }
.inclusion-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 110px; gap: 8px; }
.inclusion-row[hidden] { display: none; }
@media (max-width: 900px) {
  .line-head { display: none; }
  .invoice-line { grid-template-columns: 1fr 1fr 1fr; }
  .invoice-line .line-description { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .recurring-row { flex-wrap: wrap; }
  .inclusion-row { grid-template-columns: 1fr 1fr; }
  .inclusion-row input:first-child { grid-column: 1 / -1; }
}
.input-pair { display: flex; min-width: 0; }
.input-pair input { border-radius: var(--radius-sm) 0 0 var(--radius-sm); min-width: 0; flex: 1; }
.input-pair select { width: 52px; flex: 0 0 52px; padding: 0 6px; border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.line-amount { display: flex; align-items: center; justify-content: flex-end; font-weight: 750; font-variant-numeric: tabular-nums; }
.tag.offer { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.offer.expired { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.package-card .tag.offer { justify-self: start; }

/* Own date picker (app.js); looks like an input, opens a German calendar. */
.date-wrap { position: relative; display: block; min-width: 0; }
.date-trigger { width: 100%; min-height: 44px; justify-content: space-between; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: 500 15px var(--font); white-space: nowrap; }
.date-trigger:hover { border-color: #D6D2CB; }
.date-trigger:focus-visible, .date-trigger[aria-expanded=true] { border-color: var(--ink); outline: none; }
.date-trigger:active { transform: none; }
.date-trigger[aria-invalid=true] { border-color: var(--error); }
.date-trigger .icon { color: var(--muted); }
.date-trigger .placeholder { color: var(--muted); }
.calendar { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: 296px; padding: 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; box-shadow: 0 12px 32px rgb(0 0 0 / .12); }
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar-head .icon-button { width: 32px; height: 32px; min-height: 32px; }
.calendar .flip .icon { transform: rotate(180deg); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.calendar-grid.months { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.calendar-grid .weekday { text-align: center; font-size: 11px; font-weight: 750; color: var(--muted); padding: 4px 0; }
.calendar-grid button { min-height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent; font: 600 14px var(--font); font-variant-numeric: tabular-nums; }
.calendar-grid button:hover { background: var(--surface-2); }
.calendar-grid button.today { color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent-soft); }
.calendar-grid button.selected { background: var(--ink); color: var(--white); }
.calendar-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.calendar-foot .text-button { font-size: 13px; color: var(--ink-2); }

/* Dialogs replace fold-out details: a centered sheet with a header and actions. */
dialog.sheet { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgb(0 0 0 / .18); overflow: visible; }
dialog.sheet::backdrop { background: rgb(11 11 12 / .32); backdrop-filter: blur(2px); }
.sheet-head, .sheet-body, .sheet-actions { padding-left: 24px; padding-right: 24px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { padding-top: 20px; padding-bottom: 8px; max-height: calc(100dvh - 200px); overflow: auto; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; padding-bottom: 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sheet-actions .grow { margin-right: auto; }
.provider-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 0 0 20px; }
.provider-picker button { justify-content: flex-start; min-height: 52px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 650; text-align: left; }
.provider-picker button:hover { border-color: var(--ink); }
.eyebrow-title { margin: 0 0 8px; font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* Connection method tags: colour tells API, Playwright and IMAP apart. */
.tag.api { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.playwright { background: #EFE8FC; color: #6B3FC6; border-color: transparent; }
.tag.imap { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* Tab content always starts with the same head row: title left, one secondary action right. */
.tab-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 44px; margin: 0 0 16px; flex-wrap: wrap; }
.tab-head h2 { margin: 0; }
.tab-head p { margin: 0; color: var(--muted); }

.run-list { list-style: none; margin: 0; padding: 0; }
.run-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.run-list li:first-child { border-top: 0; }
.run-list .grow { flex: 1; min-width: 0; display: grid; gap: 1px; }
.run-list small { color: var(--muted); font-size: 12px; }
.run-count { color: var(--ink-2); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.run-list time { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.inline-rename label { display: block; font-weight: 650; font-size: 14px; margin-top: 8px; }
.inline-rename .add-source { margin-top: 6px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.block { display: block; }
.table-card .muted.block { font-size: 12px; margin-top: 2px; }
@media (max-width: 720px) {
  .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .run-count { display: none; }
}

/* Monatsstand: month switch, counts, one row per expected invoice */
.flip .icon { transform: rotate(180deg); }
.block-gap { margin-top: 36px; }
.month-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: -8px 0 8px; }
.month-switch { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); }
.month-switch strong { min-width: 150px; text-align: center; font-size: 16px; }
.month-bar .tally { margin: 0; }
.month-list { list-style: none; margin: 0; padding: 0; border: 1.5px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.month-list li { display: flex; align-items: center; gap: 16px; padding: 14px 20px; border-top: 1px solid var(--line); }
.month-list li:first-child { border-top: 0; }
.month-list .grow { flex: 1; min-width: 0; display: grid; gap: 2px; }
.month-list .grow > span { color: var(--ink-2); font-size: 14px; }
.month-list small { color: var(--muted); font-size: 13px; }
.month-list .pill { align-self: center; }
.month-list .button { min-height: 36px; padding: 0 14px; font-size: 13px; }
.segmented a { display: inline-flex; align-items: center; min-height: 36px; border-radius: 10px; color: var(--ink-2); font-weight: 650; padding: 0 16px; text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .06); }
@media (max-width: 720px) {
  .month-list li { flex-wrap: wrap; padding: 14px 16px; }
  .month-list .grow { flex-basis: 100%; }
}
.history-item { padding: 12px 0; border-top: 1px solid var(--line); }
.history-item > strong { display: block; font-size: 14px; margin-bottom: 4px; }
.history-item p, .history-item dl { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }
dialog + .panel, dialog + section.panel { margin-top: 16px; }

/* Company page: expected invoices × months, one status per cell */
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.heading-actions form { margin: 0; }
.panel-heading p.muted { margin: 4px 0 0; font-size: 14px; }
.grid-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 640px; }
.grid-table th { padding: 8px 6px; font-size: 12px; font-weight: 750; color: var(--muted); text-align: left; border-bottom: 1px solid var(--line); }
.grid-table td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.grid-table tr:last-child td { border-bottom: 0; }
.grid-table .month-col { width: 88px; text-align: center; }
.grid-table th.month-col a { display: grid; text-decoration: none; color: var(--ink-2); font-weight: 750; font-size: 13px; text-transform: none; letter-spacing: 0; }
.grid-table th.month-col small { font-weight: 600; color: var(--muted); font-size: 11px; }
.grid-table .month-col.current { background: var(--surface-2); }
.grid-table th.month-col.current { border-radius: 10px 10px 0 0; }
.grid-table th.month-col.current a { color: var(--ink); }
.supplier-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.supplier-cell > span { display: grid; gap: 1px; min-width: 0; }
.supplier-cell small { color: var(--muted); font-size: 12px; }
.status-cell { display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 76px; min-height: 30px; border-radius: 8px; font-size: 12px; font-weight: 750; text-decoration: none; background: var(--surface-2); color: var(--ink-2); }
.status-cell .icon { width: 14px; height: 14px; }
.status-cell.ok { background: var(--ok-soft); color: var(--ok); }
.status-cell.error { background: var(--error-soft); color: var(--error); }
.status-cell.warn { background: var(--accent-soft); color: var(--accent-ink); }
.status-cell.none { background: transparent; color: var(--muted); }
.status-cell.open { background: transparent; border: 1.5px dashed var(--line); color: var(--muted); }
a.status-cell:hover { box-shadow: inset 0 0 0 1.5px currentColor; }
.grid-foot { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }

/* Lists as tables: fixed columns, so many companies or connections never change the layout */
.table-card td.chevron { width: 44px; color: var(--muted); text-align: right; }
.table-card td.muted { color: var(--muted); }
.table-card .clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-table td strong { font-variant-numeric: tabular-nums; }
.issue-table .supplier-cell .row-link { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 720px) { .table-card td.chevron { display: none; } .table-card .clip { max-width: 100%; } }
.count-logos { display: flex; align-items: center; gap: 10px; }
.status-cell.open { border: 0; }
.grid-wrap { overflow-x: auto; }
@media (max-width: 720px) {
  /* The month grid stays a real table and scrolls sideways; the supplier column stays visible. */
  .grid-table { min-width: 600px; }
  .grid-table thead { display: table-header-group; }
  .grid-table tbody { display: table-row-group; }
  .grid-table tr { display: table-row; padding: 0; border: 0; }
  .grid-table td, .grid-table th { display: table-cell; width: auto; padding: 10px 6px; border-bottom: 1px solid var(--line); }
  .grid-table td:first-child, .grid-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 180px; }
}
@media (max-width: 720px) {
  /* Compact rows on phones: name and status on top, details below; no repeated column labels. */
  .issue-table td::before, .customer-table td::before { display: none; }
  .issue-table tr, .customer-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 16px; }
  .issue-table td, .customer-table td { display: block; padding: 0; width: auto; border: 0; }
  .issue-table td:nth-child(1), .customer-table td:nth-child(5) { grid-column: 2; grid-row: 1; }
  .issue-table td:nth-child(2), .customer-table td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .issue-table td:nth-child(n+3), .customer-table td:nth-child(2), .customer-table td:nth-child(3), .customer-table td:nth-child(4) { grid-column: 1 / -1; font-size: 13px; color: var(--ink-2); }
  .customer-table td:nth-child(2) strong, .customer-table td:nth-child(3) strong { display: none; }
}
.issue-table td, .customer-table td { overflow-wrap: break-word; }
