@import url('https://fonts.googleapis.com/css2?family=Fraunces:wght@600;700&family=Work+Sans:wght@400;500;600&display=swap');

:root {
  --font-sans: "Work Sans", "Segoe UI", sans-serif;
  --font-serif: "Fraunces", "Georgia", serif;
  --ink: #1f2a35;
  --muted: #5f6b7a;
  --accent: #19a7b8;
  --accent-2: #6b52d6;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.78);
  --border: rgba(15, 23, 42, 0.12);
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-pill: 10px;
  --bubble-radius: 6px;
  --bubble-width: 15rem;
  --bg-start: #e2f6ff;
  --bg-mid: #eef2ff;
  --bg-end: #f5f7ff;
  --glow-accent: rgba(25, 167, 184, 0.18);
  --glow-secondary: rgba(107, 82, 214, 0.18);
  --panel-soft: #f1f7ff;
  --row-hover: #f7f8fb;
}

:root[data-db="test"] {
  --accent: #c81e1e;
  --accent-2: #f43f5e;
  --glow-accent: rgba(248, 113, 113, 0.2);
  --glow-secondary: rgba(244, 63, 94, 0.18);
}

:root[data-theme="dark"] {
  --ink: #eef4ff;
  --muted: #c3ccda;
  --surface: #111b2b;
  --surface-soft: rgba(17, 27, 43, 0.85);
  --border: rgba(148, 163, 184, 0.22);
  --shadow: 0 18px 40px rgba(5, 10, 20, 0.6);
  --bg-start: #0b1220;
  --bg-mid: #111827;
  --bg-end: #0f172a;
  --glow-accent: rgba(25, 167, 184, 0.25);
  --glow-secondary: rgba(107, 82, 214, 0.28);
  --panel-soft: rgba(17, 30, 50, 0.8);
  --row-hover: rgba(25, 32, 48, 0.9);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background-color: var(--bg-end);
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%);
  background-color: var(--bg-end);
  overscroll-behavior-y: none;
}

.text-muted {
  color: var(--muted) !important;
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: 0;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-accent) 0%, rgba(0, 0, 0, 0) 70%);
  filter: blur(2px);
}

body::before {
  top: -120px;
  right: 10%;
}

body::after {
  bottom: -140px;
  left: 5%;
  background: radial-gradient(circle, var(--glow-secondary) 0%, rgba(0, 0, 0, 0) 70%);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 100%;
  margin: 0;
  padding: 32px 24px 48px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.header-modules {
  flex: 1 1 420px;
  align-self: center;
  min-width: 0;
  max-width: 100%;
}

.header-modules .module-tabs {
  margin: 0;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
}

.header-modules .module-tabs .nav-item {
  margin-bottom: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand-mark--image {
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: 700;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.account-chip {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  text-align: right;
}

.account-label {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.account-name {
  font-weight: 600;
}

.account-db {
  font-size: 0.78rem;
  color: var(--muted);
}

.account-link {
  text-decoration: none;
  font-weight: 600;
  color: var(--accent);
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(11, 114, 133, 0.3);
  transition: all 0.2s ease;
}

.account-link:hover {
  color: #fff;
  background: var(--accent);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: rgba(25, 167, 184, 0.4);
}

.theme-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon--sun {
  display: inline-flex;
}

.theme-icon--moon {
  display: none;
}

html[data-theme="dark"] .theme-icon--sun {
  display: none;
}

html[data-theme="dark"] .theme-icon--moon {
  display: inline-flex;
}

.app-main {
  margin-top: 28px;
}

body.auth-page .app-shell {
  min-height: 100dvh;
  padding: 0;
}

body.auth-page .app-main {
  margin-top: 0;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.auth-page .welcome-grid {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

body.auth-page .welcome-card {
  width: 100%;
  margin: 0;
}

body.auth-page .auth-card {
  position: relative;
  padding-top: 56px;
}

body.auth-page .auth-card-toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
}

.welcome-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
}

.welcome-card,
.info-card,
.module-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.welcome-card {
  padding: 28px;
}

.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.welcome-card h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 2.6vw, 2.8rem);
  margin-bottom: 12px;
}

.welcome-card p {
  color: var(--muted);
  font-size: 1.05rem;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.status-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel-soft);
}

.db-switch {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.db-switch .form-select {
  min-width: 200px;
}

.status-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 6px;
}

.status-value {
  font-weight: 600;
}

.info-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-card h2 {
  font-size: 1.1rem;
  margin: 0;
}

.info-card ul {
    padding-left: 18px;
    margin: 0;
    color: var(--muted);
}

.selection-host .row-select {
    display: none;
}

.selection-host.is-selection-mode .row-select {
    display: table-cell;
}

.selection-mode-only {
    display: none;
}

.selection-host.is-selection-mode .selection-mode-only {
    display: inline-flex;
}

.selection-host.is-selection-mode .row-menu {
    display: none;
}

.selection-host.is-selection-mode .col-menu {
    display: none;
}

.selection-host {
    position: relative;
    z-index: 1;
}

.selection-host.menu-open {
    z-index: 3000;
}

.selection-toggle.is-active,
.selection-toggle[aria-pressed="true"] {
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.quick-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
    min-height: 68px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.02), transparent);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.quick-action:hover,
.quick-action:focus {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    box-shadow: 0 8px 20px rgba(15, 17, 20, 0.12);
    color: var(--text);
}

.module-panel {
  margin-top: 24px;
  padding: 22px;
}

.module-panel h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.module-panel p {
  color: var(--muted);
}

.module-tabs {
  margin-top: 16px;
  margin-bottom: 16px;
  border: none;
  gap: 8px;
}

.module-collapsible {
  width: auto;
  max-width: 100%;
}

.module-collapsible__summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--ink);
}

.module-collapsible__summary::marker,
.module-collapsible__summary::-webkit-details-marker {
  display: none;
}

.module-collapsible[open] .module-tabs {
  margin-top: 12px;
}

.module-tabs .nav-item {
  margin-bottom: 8px;
  min-width: 0;
}

.module-tabs .nav-link {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 1rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-soft);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.module-tab-icon {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.module-tabs .nav-link:hover {
  color: var(--ink);
  border-color: rgba(11, 114, 133, 0.4);
}

.module-tabs .nav-link.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 18px rgba(11, 114, 133, 0.25);
}

.module-content {
  margin-top: 20px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: var(--surface-soft);
}

.empty-state {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
}

.app-footer {
  margin-top: 32px;
  padding: 14px 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.app-footer a {
  color: inherit;
  text-decoration: none;
}

@media (max-width: 900px) {
  .app-shell {
    padding: 24px 18px 40px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-left {
    width: 100%;
  }

  .header-modules {
    width: 100%;
  }

  .module-collapsible {
    width: 100%;
  }

  .welcome-grid {
    grid-template-columns: 1fr;
  }

  .account {
    width: 100%;
    justify-content: space-between;
  }
}

.module-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header h1 {
  margin: 0;
  font-family: var(--font-serif);
}

.page-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.status-banner {
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(11, 114, 133, 0.2);
  background: rgba(11, 114, 133, 0.16);
  color: var(--ink);
}

.status-banner:empty {
  display: none;
}

.status-banner ul {
  margin: 0;
  padding-left: 18px;
}

.table-card,
.form-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.table-card {
  padding: 20px;
}

.table-card--compact {
  padding: 12px;
}

.table-responsive--menu {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

.invoice-table-scroll.is-limited {
  overflow-y: auto;
}

.invoice-table-scroll.is-limited.menu-open {
  overflow-y: auto;
}

.invoice-table-scroll.menu-open {
  position: relative;
  z-index: 3100;
}

.table-responsive.menu-open {
  position: relative;
  z-index: 3100;
}

.invoice-table-scroll.is-limited #invoiceTable thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
}

.table-responsive--menu .row-menu-list {
  z-index: 4000;
}

.table-card .table {
  --bs-table-color: var(--ink);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--row-hover);
  --bs-table-hover-color: var(--ink);
  color: var(--ink);
}

.table-card .table {
  margin-top: 16px;
  margin-bottom: 0;
}

.table-card--compact .table {
  margin-top: 8px;
}

.table-card .table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.table thead th {
  color: var(--muted);
}

.table-card .table tbody tr:hover {
  background: var(--row-hover);
}

.table-card .table tbody tr.row-link {
  cursor: pointer;
}

.table-card .table tbody tr.row-muted {
  background: rgba(148, 163, 184, 0.2);
}

.table-card .table tbody tr.row-selected {
  background: rgba(25, 167, 184, 0.12);
}

.table-compact thead th,
.table-compact tbody td {
  padding: 0.35rem 0.6rem;
  line-height: 1.2;
}

.table-compact .action-group {
  gap: 6px;
}

.table-compact .btn-sm {
  padding: 0.2rem 0.5rem;
  line-height: 1.2;
}

.order-positions-table th.col-artnr,
.order-positions-table td.col-artnr {
  width: 90px;
  min-width: 80px;
  white-space: nowrap;
}

.order-positions-table th.col-drag,
.order-positions-table td.col-drag {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

.order-positions-table th.col-menge,
.order-positions-table td.col-menge,
.order-positions-table th.col-einheit,
.order-positions-table td.col-einheit {
  width: 70px;
  min-width: 60px;
  white-space: nowrap;
}

.order-positions-table th.col-ek,
.order-positions-table td.col-ek,
.order-positions-table th.col-vk,
.order-positions-table td.col-vk {
  width: 90px;
  min-width: 80px;
  white-space: nowrap;
}

.order-positions-table th.col-beschreibung,
.order-positions-table td.col-beschreibung {
  min-width: 280px;
  width: 100%;
}

.order-positions-table .form-control-sm {
  padding: 0.25rem 0.5rem;
}

.position-drag-handle {
  cursor: grab;
  user-select: none;
  min-width: 2rem;
  padding-left: 0.35rem;
  padding-right: 0.35rem;
  line-height: 1;
}

.position-drag-handle span {
  font-size: 0.95rem;
}

.position-drag-handle:active {
  cursor: grabbing;
}

.position-remove-btn {
  min-width: 2rem;
  padding-left: 0.45rem;
  padding-right: 0.45rem;
  line-height: 1;
  color: #b42318;
  background: rgba(180, 35, 24, 0.08);
  border: 1px solid rgba(180, 35, 24, 0.28);
}

.position-remove-btn:hover,
.position-remove-btn:focus-visible {
  color: #8f1f15;
  background: rgba(180, 35, 24, 0.14);
  border-color: rgba(180, 35, 24, 0.4);
}

.position-remove-btn:disabled {
  opacity: 0.65;
}

.position-row.is-dragging {
  opacity: 0.45;
}

.position-row.drop-target {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.table-ultra-compact thead th,
.table-ultra-compact tbody td {
  padding: 0.25rem 0.5rem;
  line-height: 1.2;
  font-size: 0.85rem;
}


.search-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  min-width: 440px;
  flex: 0 1 520px;
  width: 100%;
  max-width: 520px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 0.45rem 1rem;
}

.search-filter {
  min-width: 160px;
  max-width: 200px;
  flex: 0 0 180px;
}

.form-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-collapsible__summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
}

.section-collapsible__summary::marker,
.section-collapsible__summary::-webkit-details-marker {
  display: none;
}

.section-collapsible__summary::after {
  content: "›";
  font-size: 1.4rem;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

.section-collapsible[open] .section-collapsible__summary::after {
  transform: rotate(180deg);
}

.section-collapsible__content {
  margin-top: 12px;
}

.aufgabe-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 700px));
  gap: 24px;
  align-items: start;
  justify-content: center;
}

.aufgabe-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: stretch;
}

.aufgabe-panel {
  width: 100%;
  max-width: 700px;
}

@media (max-width: 900px) {
  .aufgabe-grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}

@media (max-width: 500px) {
  .aufgabe-grid {
    justify-items: stretch;
  }

  .aufgabe-col {
    width: 100%;
  }

  .aufgabe-panel {
    max-width: none;
    width: 100%;
  }

  .page-actions,
  .page-actions .action-group {
    width: 100%;
  }

  .page-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-row--compact {
  gap: 6px;
}

.form-row--compact .form-label {
  margin-bottom: 0;
}

.form-row--comment {
  align-items: flex-start;
}

.comment-input {
  flex: 1 1 auto;
}

.comment-submit {
  margin-top: 26px;
}

.document-upload {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.document-upload-actions {
  display: flex;
  align-items: center;
}

.document-upload-actions .btn {
  width: 100%;
  justify-content: center;
}

.documents-table .document-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.documents-table .document-preview-cell {
  width: 60px;
}

.documents-table .doc-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.documents-table .doc-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.documents-table .doc-link:hover {
  text-decoration: underline;
}

.comments-table thead {
  display: none;
}

.comments-table tbody tr {
  display: block;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.comments-table td {
  display: block;
  border: none;
  padding: 0;
}

.comments-table .comment-meta {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
}

.comment-meta-text {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
}

.comment-author {
  font-weight: 600;
}

.comment-time {
  color: var(--muted);
  font-size: 0.85rem;
}

.comment-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.comment-body {
  margin-top: 8px;
}

.comment-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: pre-wrap;
  color: var(--ink);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.calendar-entry-group {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 12px;
  border-radius: 10px;
}

.calendar-entry-group__title {
  margin-bottom: 10px;
  color: var(--ink);
}

.calendar-entry-group__toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.calendar-entry-group__fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

fieldset.calendar-entry-group__fields {
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}

.form-grid--meta {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-grid--auftrag {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px 8px;
}

.form-grid--auftrag .form-control,
.form-grid--auftrag .form-select,
.form-grid--auftrag textarea.form-control {
  padding: 0.35rem 0.6rem;
}

.form-grid--auftrag .input-date {
  max-width: 160px;
}

.form-grid--auftrag textarea.form-control {
  min-height: 58px;
}

@media (max-width: 1100px) {
  .form-grid--auftrag {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .form-grid--auftrag {
    grid-template-columns: 1fr;
  }
}
.form-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.form-value {
  font-weight: 600;
  padding: 2px 0;
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] textarea.form-control,
html[data-theme="dark"] .search-input {
  background-color: #0f172a;
  color: #ffffff;
  border-color: var(--border);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .search-input::placeholder,
html[data-theme="dark"] textarea.form-control::placeholder {
  color: rgba(255, 255, 255, 0.65);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] textarea.form-control:focus,
html[data-theme="dark"] .search-input:focus {
  background-color: #0b1220;
  color: #ffffff;
  border-color: rgba(25, 167, 184, 0.6);
  box-shadow: 0 0 0 0.2rem rgba(25, 167, 184, 0.2);
}

.form-checks {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-actions--status .form-check-label--inline {
  margin-left: auto;
}

.form-check-label--inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
}

.customer-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.customer-row .typeahead {
  flex: 1 1 auto;
}

.collapsible {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
  padding: 8px 12px;
}

.collapsible-summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-summary::before {
  content: "+";
  font-weight: 700;
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 0.8rem;
}

.collapsible[open] .collapsible-summary::before {
  content: "–";
}

.collapsible-content {
  margin-top: 8px;
}

.filter-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: var(--surface-soft);
}

.filter-collapsible {
  border: none;
  padding: 0;
  margin: 0;
}

.filter-collapsible__summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0.45rem 1rem;
  margin-bottom: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-weight: 600;
  color: var(--ink);
}

.filter-collapsible__summary::marker,
.filter-collapsible__summary::-webkit-details-marker {
  display: none;
}

.filter-collapsible[open] .filter-collapsible__summary {
  margin-bottom: 10px;
}

.aufwaende-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.aufwaende-toolbar .filter-collapsible {
  flex: 1 1 auto;
  min-width: 0;
}

.aufwaende-toolbar .filter-collapsible__summary,
.aufwaende-toolbar .btn-soft {
  border-radius: 6px;
}

.aufwaende-toolbar__selection {
  flex: 0 0 auto;
  white-space: nowrap;
}

.filter-panel--compact {
  padding: 10px 12px;
  gap: 10px;
}

.filter-panel--compact .form-label {
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.filter-panel--compact .form-control,
.filter-panel--compact .form-select {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  height: 32px;
}

.filter-panel--compact .search-input {
  min-width: 220px;
  width: clamp(240px, 32vw, 360px);
  max-width: 360px;
  padding: 0.2rem 0.6rem;
  height: 32px;
}

#offersFilterForm .search-input {
  height: 32px !important;
  min-height: 32px;
  max-height: 32px;
  line-height: 1.2;
}

#ordersFilterForm .search-input,
#invoiceFilterForm .search-input,
#contractsFilterForm .search-input,
#ownContractsFilterForm .search-input,
#aufwaendeFilterForm .search-input,
#aufgabenFilterForm .search-input,
#zahlungenFilterForm .search-input {
  height: 32px !important;
  min-height: 32px;
  max-height: 32px;
  line-height: 1.2;
}

.filter-panel--compact input[type="date"] {
  min-width: 140px;
}

#aufwaendeFilterForm .filter-grid {
  display: grid;
  align-items: end;
  gap: 10px 4px;
  grid-template-columns: max-content max-content max-content max-content auto;
  grid-template-areas:
    "search status period quick actions";
}

#aufwaendeFilterForm .filter-block--search {
  grid-area: search;
}

#aufwaendeFilterForm .filter-block--search .search-input {
  width: clamp(220px, 26vw, 320px);
}

#aufwaendeFilterForm .filter-block--status {
  grid-area: status;
}

#aufwaendeFilterForm .filter-block--period {
  grid-area: period;
}

#aufwaendeFilterForm .filter-block--quick {
  grid-area: quick;
}

#aufwaendeFilterForm .filter-actions {
  grid-area: actions;
  align-self: end;
}

@media (max-width: 1100px) {
  #aufwaendeFilterForm .filter-grid {
    grid-template-columns: max-content max-content auto;
    grid-template-areas:
      "search status actions"
      "period quick actions";
  }
}

@media (max-width: 700px) {
  .aufwaende-toolbar {
    flex-direction: column;
  }
}


.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-panel--compact .filter-row {
  gap: 10px;
}

.filter-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-panel--compact .filter-block {
  gap: 6px;
}

.filter-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.filter-radio {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 0.95rem;
}

.filter-panel--compact .filter-radio {
  gap: 8px;
  font-size: 0.85rem;
}

.filter-radio input {
  margin-right: 6px;
}

.filter-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-panel--compact .quick-buttons .btn,
.filter-panel--compact .filter-actions .btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
}

.table-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.table-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.table-responsive {
  position: relative;
  z-index: 1;
}

.table-responsive--scroll-bubble {
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-backdrop {
  z-index: 2040;
  background-color: #0f172a;
}

.modal-backdrop.show {
  opacity: 0.35;
}

.modal {
  z-index: 2050;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .modal-backdrop.show {
  opacity: 0.5;
}

html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-body,
html[data-theme="dark"] .modal-footer {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border);
}

html[data-theme="dark"] .modal .table {
  --bs-table-color: var(--ink);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--row-hover);
  --bs-table-hover-color: var(--ink);
  color: var(--ink);
}

html[data-theme="dark"] .modal .btn-close {
  filter: invert(1);
}

html[data-theme="dark"] .table-card .table tbody tr.row-selected {
  background: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .table .table-active,
html[data-theme="dark"] .table-active > th,
html[data-theme="dark"] .table-active > td {
  background-color: rgba(148, 163, 184, 0.22);
  color: var(--ink);
}

html[data-theme="dark"] .status-banner {
  background: rgba(11, 114, 133, 0.38);
}

html[data-theme="dark"] .sum-chip,
html[data-theme="dark"] .status-pill,
html[data-theme="dark"] .task-badge {
  background: rgba(25, 167, 184, 0.2);
  border-color: rgba(25, 167, 184, 0.6);
  color: #e6f9fb;
}

html[data-theme="dark"] .status-pill--yes {
  background: rgba(13, 148, 136, 0.22);
  color: #d7f5ef;
  border-color: rgba(13, 148, 136, 0.6);
}

html[data-theme="dark"] .status-pill--no {
  background: rgba(126, 34, 206, 0.22);
  color: #f1e4ff;
  border-color: rgba(126, 34, 206, 0.6);
}

html[data-theme="dark"] .task-badge--ok {
  background: rgba(35, 139, 69, 0.24);
  border-color: rgba(35, 139, 69, 0.6);
  color: #dbf5e5;
}

html[data-theme="dark"] .task-badge--soon {
  background: rgba(245, 158, 11, 0.26);
  border-color: rgba(245, 158, 11, 0.62);
  color: #fff7db;
}

html[data-theme="dark"] .task-badge--overdue {
  background: rgba(240, 82, 82, 0.24);
  border-color: rgba(240, 82, 82, 0.6);
  color: #fee2e2;
}

.table-action-bar--compact {
  gap: 8px;
}

.table-action-bar--compact .sum-chip {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.row-menu {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
}

.table#invoiceTable td.col-menu .row-menu,
.table#offersTable td.col-menu .row-menu,
.table#ordersTable td.col-menu .row-menu,
.table#paymentsTable td.col-menu .row-menu,
.table#contractsTable td.col-menu .row-menu {
  justify-content: flex-start;
}

.row-menu-trigger {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.row-menu-trigger:hover {
  background: rgba(15, 23, 42, 0.08);
}

.row-menu.is-open .row-menu-trigger {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}

.row-menu-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
  display: none;
  z-index: 20;
}

.row-menu-list.is-floating {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 5000;
}

.table#invoiceTable td.col-menu .row-menu-list,
.table#offersTable td.col-menu .row-menu-list,
.table#ordersTable td.col-menu .row-menu-list,
.table#paymentsTable td.col-menu .row-menu-list,
.table#contractsTable td.col-menu .row-menu-list {
  left: 0;
  right: auto;
}

.row-menu.is-open .row-menu-list {
  display: block;
}

.row-menu-list form {
  margin: 0;
}

.row-menu-item {
  width: 100%;
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.2;
}

.row-menu-item:visited {
  color: var(--ink);
}

.row-menu-item:hover {
  background: rgba(15, 23, 42, 0.08);
}

.row-menu-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sum-chip,
.status-pill,
.task-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--bubble-width);
  border-radius: var(--bubble-radius);
  text-align: center;
}

.sum-chip {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  font-weight: 600;
}

.sum-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.subtask-panel {
  margin-top: 24px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.subtask-section {
  margin-top: 32px;
}

.subtask-section .page-header {
  margin-top: 0;
  margin-bottom: 12px;
}

.subtask-table {
  font-size: 0.9rem;
}

.subtask-table td,
.subtask-table th {
  padding: 0.2rem 0.4rem;
  line-height: 1;
}

.subtask-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.subtask-title {
  min-width: 0;
}

.subtask-title .form-control {
  width: 100%;
}

.subtask-meta {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
}

.subtask-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 0 1 180px;
}

.subtask-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.subtask-field .form-select {
  max-width: 180px;
}

.subtask-table .form-control,
.subtask-table .form-select {
  padding: 0.15rem 0.4rem;
  font-size: 0.85rem;
  height: 28px;
}

.subtask-table .form-check-input {
  width: 0.9rem;
  height: 0.9rem;
}

.subtask-table .btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

.subtask-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  margin-left: auto;
}

.subtask-actions[hidden] {
  display: none !important;
}

.subtask-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.subtask-meta.is-open .subtask-toggle {
  transform: rotate(90deg);
}

.subtask-done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-right: 4px;
  white-space: nowrap;
}

.btn-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.article-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-danger {
  border: 1px solid rgba(220, 38, 38, 0.35);
  color: #b91c1c;
  background: rgba(220, 38, 38, 0.08);
}

.btn-icon-danger:hover {
  color: #991b1b;
  border-color: rgba(220, 38, 38, 0.6);
  background: rgba(220, 38, 38, 0.16);
}

.btn-icon-copy {
  border: 1px solid rgba(22, 163, 74, 0.4);
  color: #166534;
  background: rgba(22, 163, 74, 0.12);
}

.btn-icon-copy:hover {
  color: #14532d;
  border-color: rgba(22, 163, 74, 0.7);
  background: rgba(22, 163, 74, 0.2);
}

@media (max-width: 700px) {
  .subtask-item {
    grid-template-columns: 1fr;
  }

  .subtask-meta {
    gap: 8px;
    flex-wrap: wrap;
  }

  .subtask-field {
    flex: 1 1 140px;
  }

  .subtask-field .form-select {
    max-width: 140px;
  }

  .subtask-actions {
    margin-left: 0;
  }
}

.task-row--overdue {
  background: rgba(240, 82, 82, 0.12);
  color: #7d1c1c;
  font-weight: 600;
}

.task-row--done {
  background: rgba(35, 139, 69, 0.12);
  color: #0f5132;
}

.task-row--high {
  background: rgba(255, 193, 7, 0.16);
  color: #7a5b00;
}

.task-row--medium {
  background: rgba(13, 110, 253, 0.12);
  color: #0a2f66;
}

.task-badge {
  padding: 2px 10px;
  width: var(--bubble-width);
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.task-badge--ok {
  background: rgba(35, 139, 69, 0.14);
  color: #0f5132;
  border-color: rgba(35, 139, 69, 0.3);
}

.task-badge--soon {
  background: rgba(245, 158, 11, 0.18);
  color: #7c2d12;
  border-color: rgba(245, 158, 11, 0.45);
}

.task-badge--overdue {
  background: rgba(240, 82, 82, 0.16);
  color: #7d1c1c;
  border-color: rgba(240, 82, 82, 0.35);
}

.tasks-table {
  font-size: 1.2em;
}

.tasks-table thead th,
.tasks-table tbody td {
  line-height: 1.2;
}

.calendar-card {
  padding: 18px 20px 24px;
}

.calendar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.calendar-header h2 {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.5rem;
}

.calendar-toggle {
  display: inline-flex;
}

.calendar-card.is-collapsed .calendar-week {
  display: none;
}

@media (max-width: 767.98px) {
  .calendar-header {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .calendar-nav {
    width: 100%;
    justify-content: flex-start;
  }

  .calendar-toggle {
    display: inline-flex;
  }
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.calendar-nav-arrow {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 6px;
}

.calendar-weekend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 2px;
}

.calendar-weekend-toggle .form-check-input {
  margin: 0;
}

.calendar-card.hide-weekends .calendar-day[data-weekend="1"] {
  display: none;
}

.calendar-week {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.calendar-day {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
}

.calendar-day-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}

.calendar-day-name {
  text-transform: capitalize;
}

.calendar-day-date {
  font-size: 0.85rem;
  color: var(--muted);
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.calendar-event {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-event--task {
  border-color: rgba(11, 114, 133, 0.35);
  box-shadow: 0 8px 18px rgba(11, 114, 133, 0.12);
}

.calendar-event-time {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.calendar-event-title {
  font-weight: 600;
}

.calendar-event-title-link {
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  align-self: flex-start;
}

.calendar-event-title-link:hover {
  text-decoration: underline;
}

.calendar-event-location {
  font-size: 0.85rem;
  color: var(--muted);
}

.calendar-event-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  align-self: flex-start;
}

.calendar-event-link:hover {
  text-decoration: underline;
}

.calendar-empty {
  color: var(--muted);
  font-size: 0.85rem;
}

.aufwaende-table {
  font-size: 1.2em;
}

.aufwaende-table thead th,
.aufwaende-table tbody td {
  line-height: 1.2;
}

.aufwaende-table th.col-mitarbeiter,
.aufwaende-table td.col-mitarbeiter {
  white-space: nowrap;
  min-width: 170px;
  width: 1%;
}

.aufwaende-table th.col-abgerechnet,
.aufwaende-table td.col-abgerechnet {
  width: 7.5rem;
  min-width: 7.5rem;
  max-width: 7.5rem;
}

.aufwaende-table td.col-abgerechnet .status-pill {
  width: 100%;
}

.table#ordersTable th.col-abgeschlossen,
.table#ordersTable td.col-abgeschlossen {
  width: 7.5rem;
  min-width: 7.5rem;
  max-width: 7.5rem;
}

.table#ordersTable td.col-abgeschlossen .status-pill {
  width: 100%;
}

.table#invoiceTable th.col-menu,
.table#invoiceTable td.col-menu,
.table#offersTable th.col-menu,
.table#offersTable td.col-menu,
.table#ordersTable th.col-menu,
.table#ordersTable td.col-menu,
.table#paymentsTable th.col-menu,
.table#paymentsTable td.col-menu,
.table#contractsTable th.col-menu,
.table#contractsTable td.col-menu {
  width: 2.2rem;
  min-width: 2.2rem;
  max-width: 2.2rem;
  text-align: center;
}

.table#invoiceTable thead th:nth-child(8),
.table#invoiceTable thead th:nth-child(9),
.table#invoiceTable thead th:nth-child(10),
.table#invoiceTable tbody td:nth-child(8),
.table#invoiceTable tbody td:nth-child(9),
.table#invoiceTable tbody td:nth-child(10) {
  width: 6rem;
  min-width: 6rem;
  max-width: 6rem;
  text-align: center;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

.table#invoiceTable thead th:nth-child(8),
.table#invoiceTable thead th:nth-child(9),
.table#invoiceTable thead th:nth-child(10) {
  white-space: normal;
  line-height: 1.05;
  letter-spacing: 0.04em;
}

.table#invoiceTable tbody td:nth-child(8),
.table#invoiceTable tbody td:nth-child(9),
.table#invoiceTable tbody td:nth-child(10) {
  white-space: nowrap;
}

.table#invoiceTable tbody td:nth-child(8) .status-pill,
.table#invoiceTable tbody td:nth-child(9) .status-pill,
.table#invoiceTable tbody td:nth-child(10) .status-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  padding: 1px 6px;
  box-sizing: border-box;
  text-align: center;
}

.table#ordersTable thead th,
.table#ordersTable tbody td,
.table#invoiceTable thead th,
.table#invoiceTable tbody td,
.table#contractsTable thead th,
.table#contractsTable tbody td {
  padding-top: 0.2rem;
  padding-bottom: 0.2rem;
}

.table#ordersTable .row-menu-trigger,
.table#invoiceTable .row-menu-trigger,
.table#contractsTable .row-menu-trigger {
  width: 24px;
  height: 24px;
  font-size: 15px;
}

.table#customersTable thead th,
.table#customersTable tbody td {
  padding: 0.35rem 0.6rem;
  line-height: 1.2;
}

@media (min-width: 901px) {
  .aufwaende-table th.col-kunde,
  .aufwaende-table td.col-kunde {
    white-space: nowrap;
    min-width: 180px;
  }
}

.table-select {
  width: 34px;
}

.typeahead {
  position: relative;
  z-index: 5;
}

.typeahead-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 2000;
  display: none;
  max-height: 220px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
}

.typeahead-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.typeahead-item:hover {
  background: var(--surface-soft);
}

.typeahead-item.is-active {
  background: var(--panel-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.typeahead-empty {
  padding: 8px 12px;
  color: var(--muted);
}

.form-card {
  overflow: visible;
}

.table thead .sort-link {
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
}

.table thead .sort-link:hover {
  text-decoration: underline;
}

.table thead .sort-asc::after {
  content: " ^";
  font-size: 0.75em;
}

.table thead .sort-desc::after {
  content: " v";
  font-size: 0.75em;
}

.table thead th.client-sortable {
  cursor: pointer;
  user-select: none;
}

.table thead th.client-sortable::after {
  content: "";
  font-size: 0.75em;
}

.table thead th.client-sort-asc::after {
  content: " ^";
}

.table thead th.client-sort-desc::after {
  content: " v";
}

.status-pill {
  padding: 2px 10px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-soft);
}

.status-pill--yes {
  color: #0b7285;
  background: rgba(13, 148, 136, 0.14);
  border-color: rgba(13, 148, 136, 0.35);
}

.status-pill--no {
  color: #6b21a8;
  background: rgba(126, 34, 206, 0.14);
  border-color: rgba(126, 34, 206, 0.35);
}

.btn-accent {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  padding: 0.5rem 1.2rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.btn-accent:hover {
  color: #fff;
  filter: brightness(0.98);
}

.btn-soft {
  border: 1px solid var(--border);
  color: var(--ink);
  background: rgba(15, 23, 42, 0.04);
  padding: 0.45rem 1rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--muted);
  background: transparent;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

.btn-ghost:hover,
.btn-soft:hover {
  color: var(--ink);
  border-color: rgba(11, 114, 133, 0.3);
}

@media (max-width: 900px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 500px) {
  .app-shell {
    padding: 18px 14px 32px;
  }

  .page-header h1 {
    font-size: 1.5rem;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .table-card--compact {
    padding: 10px;
  }

  .filter-panel--compact {
    padding: 8px;
  }

  .filter-panel--compact .filter-row {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-panel--compact .filter-block,
  .filter-panel--compact .filter-actions {
    width: 100%;
  }

  .filter-panel--compact .filter-actions {
    justify-content: flex-start;
  }

  .filter-panel--compact .search-input {
    min-width: 0;
    width: 100%;
  }

  .filter-collapsible__summary {
    width: 100%;
    justify-content: center;
  }

  .module-collapsible__summary {
    width: 100%;
    justify-content: center;
  }

  .table-action-bar--compact {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-action-bar--compact .sum-chip {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  .sum-group {
    gap: 6px;
  }

  .sum-group .sum-chip:nth-child(3),
  .sum-group .sum-chip:nth-child(5) {
    display: none;
  }

  .table-ultra-compact thead th,
  .table-ultra-compact tbody td {
    padding: 0.25rem 0.35rem;
    line-height: 1.2;
  }

  .tasks-table {
    font-size: 0.95rem;
  }

  .tasks-table thead th,
  .tasks-table tbody td {
    line-height: 1.3;
  }

  .task-badge {
    padding: 1px 8px;
    font-size: 0.7rem;
  }

  .sum-chip,
  .status-pill,
  .task-badge {
    width: 12rem;
  }

  .table#invoiceTable tbody td:nth-child(8) .status-pill,
  .table#invoiceTable tbody td:nth-child(9) .status-pill,
  .table#invoiceTable tbody td:nth-child(10) .status-pill {
    width: 100%;
    min-width: 0;
  }

  .tasks-table th:nth-child(4),
  .tasks-table td:nth-child(4),
  .tasks-table th:nth-child(5),
  .tasks-table td:nth-child(5),
  .tasks-table th:nth-child(6),
  .tasks-table td:nth-child(6),
  .tasks-table th:nth-child(8),
  .tasks-table td:nth-child(8) {
    display: none;
  }

  .form-row--comment {
    flex-direction: column;
    align-items: stretch;
  }

  .comment-submit {
    margin-top: 8px;
  }

  .comment-submit .btn {
    width: 100%;
    justify-content: center;
  }

  .comment-actions-inline {
    margin-left: 0;
    justify-content: flex-end;
  }
}


.stat-card {
  padding: 0;
  overflow: hidden;
}

.stat-tabs {
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}

.stat-tabs .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 12px 16px;
}

.stat-tabs .nav-link.active {
  color: var(--ink);
  border-color: var(--accent);
  background: transparent;
}

.stat-content {
  padding: 18px 20px 24px;
}

.stat-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 12px;
}

.stat-summary {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.stat-chart {
  position: relative;
  height: 380px;
  overflow: hidden;
}

.stat-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.stat-tooltip {
  position: absolute;
  z-index: 1050;
  width: min(500px, calc(100% - 16px));
  max-width: calc(100% - 16px);
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  font-size: 0.85rem;
  line-height: 1.35rem;
  pointer-events: none;
}

.stat-tooltip-title {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.stat-tooltip-body {
  display: grid;
  gap: 0.2rem;
}

.stat-tooltip-line {
  white-space: normal;
  word-break: break-word;
}

.stat-tooltip.is-scroll .stat-tooltip-body {
  max-height: calc(10 * 1.35rem);
  overflow-y: auto;
  padding-right: 0.35rem;
}

@media (max-width: 900px) {
  .stat-chart {
    height: 280px;
  }
  .stat-tooltip {
    width: min(300px, calc(100% - 16px));
    max-width: calc(100% - 16px);
  }
}


.settings-tabs {
  margin-top: 8px;
  margin-bottom: 18px;
  gap: 8px;
  border: none;
}

.settings-tabs .nav-link {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-soft);
}

.settings-tabs .nav-link.active {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(520px, 1fr));
  gap: 16px;
}

.settings-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.settings-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.settings-employee-grid {
  display: grid;
  gap: 20px;
}

.settings-employee-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-employee-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-employee-header h2 {
  font-size: 1.05rem;
  margin: 0;
}

.settings-permissions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.settings-permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.settings-month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.settings-month-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface-soft);
}

.settings-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-section-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.settings-table {
  margin-top: 18px;
}

.settings-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.settings-table-wide {
  font-size: 0.9rem;
}

.settings-preview {
  background: var(--panel-soft);
  font-weight: 600;
  color: var(--ink);
}

.settings-logo-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 16px;
  align-items: center;
}

.settings-logo-preview {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--surface-soft);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-logo-preview img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
}

.settings-logo-placeholder {
  color: var(--muted);
  text-align: center;
}

.settings-logo-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-testmail {
  margin-top: 14px;
}

.ai-chat-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 20px;
  align-items: stretch;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.ai-chat-threads,
.ai-chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 480px;
  min-width: 0;
}

.ai-chat-threads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
}

.ai-thread-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-thread-item:hover {
  background: rgba(15, 23, 42, 0.06);
}

.ai-thread-item.is-active {
  border-color: rgba(11, 114, 133, 0.4);
  background: rgba(11, 114, 133, 0.12);
}

.ai-thread-title {
  font-weight: 600;
}

.ai-thread-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.ai-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.ai-chat-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.ai-chat-title-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-title-form .form-control {
  min-width: 220px;
}

.ai-chat-model-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ai-chat-model-form .form-select {
  min-width: 160px;
}

.ai-chat-messages {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: var(--surface-soft);
  overflow: auto;
}

.ai-chat-message {
  max-width: 80%;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.ai-chat-message--user {
  align-self: flex-end;
  border-color: rgba(11, 114, 133, 0.4);
  background: rgba(11, 114, 133, 0.08);
}

.ai-chat-message--assistant {
  align-self: flex-start;
}

.ai-chat-message--system {
  align-self: center;
  background: rgba(15, 23, 42, 0.06);
}

.ai-chat-message-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.ai-chat-message-body {
  white-space: pre-wrap;
}

.ai-chat-message-body code {
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.08);
  border: 1px solid var(--border);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.9em;
}

.ai-chat-input {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.ai-chat-input .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

.ai-chat-scroll-anchor {
  height: 1px;
}

.ai-voice-button svg {
  width: 18px;
  height: 18px;
}

.ai-voice-button.is-recording {
  border-color: rgba(220, 38, 38, 0.4);
  color: #b91c1c;
}

.ai-voice-button {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  padding: 0;
}

.ai-voice-button.is-transcribing {
  opacity: 0.65;
  cursor: wait;
}

.ai-voice-status {
  min-height: 1.2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.ai-voice-status.is-error {
  color: #b91c1c;
}

.ai-thread-empty,
.ai-chat-empty {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: 12px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  color: var(--muted);
  background: rgba(15, 23, 42, 0.02);
  text-align: center;
}

.status-banner--error {
  border-color: rgba(220, 38, 38, 0.3);
  background: rgba(220, 38, 38, 0.18);
  color: #b91c1c;
}

@media (max-width: 900px) {
  .settings-logo-row {
    grid-template-columns: 1fr;
  }

  .ai-chat-layout {
    grid-template-columns: 1fr;
  }

  .ai-chat-message {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .ai-chat-threads,
  .ai-chat-panel {
    padding: 12px;
    min-height: 0;
  }

  .ai-chat-title-form .form-control {
    min-width: 160px;
  }

  .ai-chat-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-chat-input {
    gap: 8px;
  }
}

.pdf-preview-dialog {
  max-width: 1100px;
}

.pdf-preview-frame {
  width: 100%;
  height: 75vh;
  border: 0;
  background: #fff;
}

