/* Faktura, internes Rechnungs-Tool (Demo). Stand 03/2026.
   v1.8.2: Tabellen dichter, Radien runter auf 5/3px, Akzent jetzt #1f4e79
   v1.7:   Space Grotesk (lokal) fürs Wortmarken-Logo, Rest bleibt System
   v1.5:   Druck-Styles für Rechnung und Mahnung */

@font-face {
  font-family: "Space Grotesk";
  src: url("./fonts/space-grotesk-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("./fonts/space-grotesk-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --accent: #1f4e79;
  --accent-600: #16385a;
  --accent-300: #7fa8cb;
  --accent-50: #e9eff5;
  --accent-100: #d4e0ec;
  --bg: #eef1f4;
  --surface: #ffffff;
  --border: #d9dee4;
  --border-strong: #b8c2cc;
  --text: #16202b;
  --muted: #5d6b7a;
  --green-bg: #e7f3ec;
  --green-fg: #1e6b45;
  --red-bg: #faeceb;
  --red-fg: #a3241c;
  --red-border: #ecc8c5;
  --gray-bg: #eceff2;
  --gray-fg: #46535f;
  --radius: 5px;
  --radius-sm: 3px;
  --shadow-sm: none;
  --shadow-md: 0 3px 10px rgba(22, 32, 43, 0.12);
  --shadow-lg: 0 14px 36px rgba(22, 32, 43, 0.25);
  --font:
    -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.ic {
  width: 18px;
  height: 18px;
  flex: none;
}

/* ---------- App-Shell ---------- */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.main-col {
  flex: 1;
  min-width: 0;
  margin-left: 248px;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  background: var(--gray-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  white-space: nowrap;
}

.demo-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.view {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px;
}

/* ---------- Globale Suche (Topbar) ---------- */

.gsearch {
  position: relative;
  flex: 1;
  max-width: 340px;
  margin-left: auto;
}

.gsearch > .ic {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.gsearch .input {
  padding: 8px 12px 8px 34px;
  font-size: 13.5px;
}

.gsearch-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(440px, calc(100vw - 24px));
  max-height: min(420px, 70vh);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 6px;
  z-index: 60;
}

.gsearch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.gsearch-item:hover,
.gsearch-item.active {
  background: var(--accent-50);
  text-decoration: none;
}

.gsearch-type {
  flex: none;
  width: 78px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--gray-bg);
  color: var(--gray-fg);
}

.type-rechnung {
  background: var(--accent-50);
  color: var(--accent-600);
}
.type-angebot {
  background: #fef3c7;
  color: #92400e;
}

.gsearch-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.gsearch-main strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gsearch-main small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gsearch-empty {
  padding: 14px;
  font-size: 13.5px;
  color: var(--muted);
}

/* ---------- Sidebar ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  display: inline-flex;
}
.brand-logo svg {
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.brand-text strong {
  /* Einzige Stelle mit Space Grotesk: die Wortmarke. */
  font-family: "Space Grotesk", var(--font);
  font-size: 17px;
  letter-spacing: 0.01em;
}
.brand-text small {
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--gray-fg);
  font-weight: 600;
  font-size: 13.5px;
  transition:
    background 0.15s,
    color 0.15s;
}

.nav a:hover {
  background: var(--gray-bg);
  text-decoration: none;
}

.nav a.active {
  background: var(--accent-50);
  color: var(--accent-600);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.demo-note {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  background: var(--gray-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.demo-note .ic {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.app-version {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 35;
}

.icon-btn.hamburger {
  display: none;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}

.btn:hover {
  background: var(--gray-bg);
}

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

.btn-primary:hover {
  background: var(--accent-600);
  border-color: var(--accent-600);
}

.btn-danger {
  color: var(--red-fg);
}
.btn-danger:hover {
  background: var(--red-bg);
  border-color: var(--red-border);
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gray-fg);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

.icon-btn:hover {
  background: var(--gray-bg);
  color: var(--text);
}
.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.icon-btn:disabled:hover {
  background: transparent;
  color: var(--gray-fg);
}
.icon-btn.danger:hover {
  background: var(--red-bg);
  color: var(--red-fg);
}

/* ---------- Karten / Allgemeines ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: 16px 18px;
}

.card-title {
  font-size: 14.5px;
  font-weight: 700;
}
.card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ---------- Badges & Chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge-entwurf {
  background: var(--gray-bg);
  color: var(--gray-fg);
}
.badge-offen {
  background: var(--accent-50);
  color: var(--accent-600);
}
.badge-bezahlt {
  background: var(--green-bg);
  color: var(--green-fg);
}
.badge-ueberfaellig {
  background: var(--red-bg);
  color: var(--red-fg);
}
.badge-mahn {
  background: #fef3c7;
  color: #92400e;
}

.badge-stack {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--gray-fg);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.chip:hover {
  background: var(--gray-bg);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Formulare ---------- */

.input,
select.input,
textarea.input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 78, 121, 0.18);
}

.input:focus-visible {
  outline: none;
}

.input.invalid {
  border-color: var(--red-fg);
}
.input.invalid:focus {
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-fg);
}

.field-hint {
  font-size: 12.5px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
}

.form-error {
  display: block;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red-fg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  white-space: pre-line;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-wrap .ic {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap .input {
  padding-left: 34px;
}

/* ---------- Tabellen ---------- */

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
}

.table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-strong);
  background: #f2f4f7;
  white-space: nowrap;
}

.table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.table tbody tr[data-rowlink] {
  cursor: pointer;
  transition: background 0.12s;
}
.table tbody tr[data-rowlink]:hover {
  background: var(--bg);
}

.table .ta-right {
  text-align: right;
}
.table a.row-no {
  font-weight: 700;
}
.cell-muted {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Dashboard ---------- */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.kpi {
  padding: 13px 16px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.kpi-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.kpi-value.alert {
  color: var(--red-fg);
}

.kpi-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.dash-grid {
  margin-bottom: 16px;
}

.chart-wrap {
  margin-top: 12px;
}
.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: var(--border);
  stroke-width: 1;
}
.chart-base-line {
  stroke: var(--border-strong);
  stroke-width: 1;
}
.chart-y-label,
.chart-x-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: var(--font);
}

/* Liniendiagramm (Umsatz 12 Monate) */
.lc-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.lc-area {
  fill: rgba(31, 78, 121, 0.08);
  stroke: none;
}
.lc-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2.5;
}
.lc-hit {
  fill: transparent;
}
.lc-pt {
  cursor: pointer;
  outline: none;
}
.lc-pt:hover .lc-dot,
.lc-pt:focus-visible .lc-dot {
  fill: var(--accent);
}
.lc-pt:focus-visible .lc-dot {
  stroke: var(--accent-600);
  stroke-width: 3.5;
}
.lc-tip {
  pointer-events: none;
}
.lc-tip-bg {
  fill: rgba(15, 23, 42, 0.92);
}
.lc-tip-label {
  fill: #cbd5e1;
  font-size: 11px;
  font-family: var(--font);
}
.lc-tip-value {
  fill: #fff;
  font-size: 12.5px;
  font-weight: 700;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

/* Donut (Status-Verteilung) */
.donut-wrap {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
.donut {
  width: 172px;
  height: 172px;
  flex: none;
}
.donut-seg {
  fill: none;
  stroke-width: 30;
}
.donut-seg:focus-visible {
  stroke-opacity: 0.75;
}
.seg-offen {
  stroke: var(--accent);
}
.seg-ueberfaellig {
  stroke: #dc2626;
}
.seg-bezahlt {
  stroke: #10b981;
}
.seg-entwurf {
  stroke: #cbd5e1;
}
.seg-leer {
  stroke: var(--gray-bg);
}
.donut-num {
  font-size: 30px;
  font-weight: 800;
  fill: var(--text);
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.donut-cap {
  font-size: 12px;
  fill: var(--muted);
  font-family: var(--font);
}

.donut-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-width: 0;
  flex: 1;
}
.donut-legend li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.legend-dot.seg-offen {
  background: #1f4e79;
}
.legend-dot.seg-ueberfaellig {
  background: #dc2626;
}
.legend-dot.seg-bezahlt {
  background: #10b981;
}
.legend-dot.seg-entwurf {
  background: #cbd5e1;
}
.legend-label {
  color: var(--gray-fg);
  flex: 1;
}
.legend-val {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
}
.legend-empty {
  color: var(--muted);
  font-size: 13px;
}

.recent-list {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 6px;
  border-top: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

.recent-item:first-child {
  border-top: none;
}
.recent-item:hover {
  background: var(--bg);
  text-decoration: none;
}

.recent-main {
  min-width: 0;
}
.recent-main strong {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.recent-main small {
  color: var(--muted);
  font-size: 12.5px;
}

.recent-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.recent-side .amount {
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Kunden ---------- */

.customer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.customer-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.customer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--accent-50);
  color: var(--accent-600);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.customer-name {
  min-width: 0;
  flex: 1;
}
.customer-name h3 {
  font-size: 15.5px;
  font-weight: 700;
}
.customer-name p {
  font-size: 13px;
  color: var(--muted);
}

.customer-actions {
  display: flex;
  gap: 4px;
}
.customer-actions .icon-btn {
  width: 32px;
  height: 32px;
}
.customer-actions .ic {
  width: 16px;
  height: 16px;
}

.customer-body {
  font-size: 13.5px;
  color: var(--gray-fg);
  line-height: 1.55;
}
.customer-body a {
  word-break: break-all;
}

.customer-stats {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.customer-stats strong {
  color: var(--text);
}

[data-rowlink] {
  cursor: pointer;
}
.customer-card[data-rowlink]:hover {
  box-shadow: var(--shadow-md);
}

.customer-link {
  color: var(--text);
}
.customer-link:hover {
  color: var(--accent-600);
  text-decoration: none;
}

/* ---------- Kunden-Detail ---------- */

.cust-head-card {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 18px;
}

.cust-head-main {
  flex: 1;
  min-width: 200px;
}
.cust-head-main h2 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.cust-company {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 2px;
}
.cust-contact {
  font-size: 13.5px;
  margin-top: 6px;
  word-break: break-all;
}

.cust-head-addr {
  font-size: 13.5px;
  color: var(--gray-fg);
  line-height: 1.55;
  text-align: right;
}

.kpi-grid.kpi-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 4px 0 10px;
}

/* ---------- Verlauf / Timeline ---------- */

.timeline-card {
  margin-bottom: 16px;
  max-width: 860px;
}

.timeline {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.tl-item {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 0 0 14px 22px;
}

.tl-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  bottom: -4px;
  width: 2px;
  background: var(--border);
}

.tl-item:last-child::before {
  display: none;
}
.tl-item:last-child {
  padding-bottom: 2px;
}

.tl-dot {
  position: absolute;
  left: 0;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-100);
  border: 3px solid var(--accent);
  box-sizing: border-box;
}

.tl-item.warn .tl-dot {
  border-color: var(--red-fg);
  background: var(--red-bg);
}

.tl-date {
  flex: none;
  width: 86px;
  font-size: 12.5px;
  color: var(--muted);
}
.tl-text {
  font-size: 13.5px;
}
.tl-item.warn .tl-text {
  color: var(--red-fg);
  font-weight: 600;
}

/* ---------- Toolbar-Extras & Fußnoten ---------- */

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-footnote {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

/* ---------- Leere Zustände ---------- */

.empty {
  text-align: center;
  padding: 56px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: var(--accent-50);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.empty-icon .ic {
  width: 24px;
  height: 24px;
}

.empty h3 {
  font-size: 15.5px;
}
.empty p {
  color: var(--muted);
  font-size: 13.5px;
  max-width: 360px;
}
.empty .btn {
  margin-top: 10px;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.15s ease-out;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  animation: pop-in 0.18s ease-out;
}

.modal.modal-sm {
  max-width: 460px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  font-size: 16.5px;
  font-weight: 700;
}

.modal form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Positionszeilen (Rechnungsformular) ---------- */

.items-section h3 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 10px;
}

.item-grid-head,
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 116px 96px 36px;
  gap: 8px;
  align-items: center;
}

.item-grid-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 0 2px 6px;
}

.items-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-row .item-qty,
.item-row .item-price {
  text-align: right;
}

.add-item-row {
  margin-top: 12px;
}

.form-totals {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.totals-row .label {
  color: var(--gray-fg);
}

.totals-row.grand {
  border-top: 1px solid var(--border-strong);
  margin-top: 4px;
  padding-top: 10px;
  font-weight: 800;
  font-size: 15.5px;
}

/* ---------- Rechnungs-Detail ---------- */

.detail-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-fg);
  margin-right: auto;
}

.back-link:hover {
  color: var(--text);
  text-decoration: none;
}

.detail-toolbar .badge {
  margin-right: 4px;
}

.invoice-doc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: clamp(24px, 5vw, 56px);
  max-width: 860px;
}

.doc-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 40px;
}

.doc-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 17px;
}
.doc-brand svg {
  display: block;
}

.doc-sender-block {
  text-align: right;
  font-size: 13px;
  color: var(--gray-fg);
  line-height: 1.55;
}
.doc-sender-block strong {
  color: var(--text);
}

.doc-addr-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.doc-sender-line {
  font-size: 10.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 10px;
}

.doc-recipient {
  font-size: 14px;
  line-height: 1.55;
  min-width: 220px;
}
.doc-recipient strong {
  display: block;
}

.doc-meta {
  font-size: 13.5px;
  color: var(--gray-fg);
}
.doc-meta table {
  border-collapse: collapse;
}
.doc-meta td {
  padding: 2px 0;
}
.doc-meta td:first-child {
  padding-right: 24px;
  color: var(--muted);
}
.doc-meta td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.doc-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}

.doc-items {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.doc-items th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border-strong);
  padding: 8px 10px;
}

.doc-items td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.doc-items .ta-right {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.doc-totals {
  margin: 20px 0 32px auto;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.doc-totals .totals-row.grand {
  font-size: 16px;
}

.doc-note {
  font-size: 13.5px;
  color: var(--gray-fg);
  line-height: 1.6;
}

.doc-footer {
  margin-top: 40px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- Responsiv ---------- */

@media (max-width: 1060px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-grid.kpi-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar .demo-badge {
    display: none;
  }
  .gsearch {
    max-width: 220px;
  }
}

@media (max-width: 460px) {
  .gsearch {
    max-width: 170px;
  }
  .gsearch .input {
    font-size: 13px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    visibility: hidden; /* eingeklappt nicht per Tab fokussierbar */
    transition:
      transform 0.22s ease-out,
      visibility 0.22s ease-out;
    box-shadow: none;
  }

  body.nav-open .sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar-backdrop {
    display: block;
  }
  body.nav-open {
    overflow: hidden;
  }

  .main-col {
    margin-left: 0;
  }
  .icon-btn.hamburger {
    display: inline-flex;
  }
  .topbar {
    padding: 0 16px;
  }
  .view {
    padding: 16px;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .item-grid-head {
    display: none;
  }

  .item-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 1.1fr) 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px;
    background: var(--bg);
  }

  .item-row .item-desc {
    grid-column: 1 / -1;
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 560px) {
  .demo-badge-long {
    display: none;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .kpi-grid.kpi-3 {
    grid-template-columns: 1fr;
  }
  .cust-head-addr {
    text-align: left;
    width: 100%;
  }
  .doc-top {
    flex-direction: column;
  }
  .doc-sender-block {
    text-align: left;
  }
  .invoice-doc {
    overflow-x: auto;
  } /* Positionstabelle läuft sonst aus der Karte */
  .doc-items th,
  .doc-items td {
    padding: 8px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------- Druck ---------- */

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .sidebar-backdrop,
  .topbar,
  .detail-toolbar,
  .table-footnote,
  .no-print,
  #modal-root {
    display: none !important;
  }

  .main-col {
    margin: 0;
  }

  .view {
    padding: 0;
    max-width: none;
  }

  .invoice-doc {
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    max-width: none;
  }
}

@page {
  margin: 18mm;
}

/* ---------- Demo-Ribbon (Portfolio-Backlink) ---------- */

.demo-ribbon {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 18, 22, 0.85);
  color: #fff;
  font:
    500 12px/1 system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  padding: 9px 13px;
  border-radius: 999px;
  text-decoration: none;
  letter-spacing: 0.01em;
  opacity: 0.85;
}
.demo-ribbon:hover,
.demo-ribbon:focus-visible {
  opacity: 1;
}
.demo-ribbon:hover {
  text-decoration: none;
}
@media print {
  .demo-ribbon {
    display: none;
  }
}

/* Platz für den Ribbon: Sidebar-Footer (Reset-Button) nicht verdecken */
.sidebar-footer {
  padding-bottom: 60px;
}
