/* =============================================================
   BauartistOfferte Web – Design-System
   Hell & freundlich, orientiert an bauartist.ch
   (Die Schwyzer Naturofloor Spezialisten)
   ============================================================= */

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

/* ----------------------------------------------------------
   1. CSS-Variablen (Design-Tokens: Bauartist Swiss Clean Light)
   ---------------------------------------------------------- */
:root {
  /* Helle Oberflächen & Hintergründe */
  --clr-bg:          #f8f9fb;
  --clr-surface:     #ffffff;
  --clr-surface-2:   #f3f4f6;
  --clr-surface-3:   #e5e7eb;
  --clr-border:      #e5e7eb;
  --clr-border-light:#f1f5f9;
  --clr-border-focus:#18181b;

  /* Typografie & Kontraste */
  --clr-text:        #111827;
  --clr-text-muted:  #4b5563;
  --clr-muted:       #6b7280;
  --clr-muted-light: #9ca3af;

  /* Primärfarben (Bauartist Schwarz / Graphit) */
  --clr-primary:     #18181b;
  --clr-primary-d:   #000000;
  --clr-primary-t:   rgba(24, 24, 27, 0.06);

  /* Naturofloor Mineral / Sand Akzent */
  --clr-accent:      #b45309;
  --clr-accent-sand: #c5a880;
  --clr-accent-t:    rgba(197, 168, 128, 0.15);

  /* Statusfarben */
  --clr-danger:      #dc2626;
  --clr-danger-bg:   #fef2f2;
  --clr-danger-border:#fecaca;

  --clr-success:     #16a34a;
  --clr-success-bg:  #f0fdf4;
  --clr-success-border:#bbf7d0;

  --clr-warning:     #d97706;
  --clr-warning-bg:  #fffbeb;
  --clr-warning-border:#fde68a;

  --clr-info:        #2563eb;
  --clr-info-bg:     #eff6ff;
  --clr-info-border: #bfdbfe;

  --clr-input-bg:    #ffffff;

  /* Radien */
  --radius-sm: 6px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  /* Schatten (sanft, modern, sauber) */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow:    0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
  --shadow-dropdown: 0 12px 24px -4px rgba(0, 0, 0, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.04);

  /* Layout-Metriken */
  --sidebar-w:        260px;
  --sidebar-w-mobile: 280px;
  --topbar-h:         60px;

  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------
   2. Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.55;
  min-height: 100dvh;
  letter-spacing: -0.01em;
}

a { color: var(--clr-text); text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; }

/* ----------------------------------------------------------
   3. Layout: App-Shell, Sidebar & Topbar
   ---------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

/* --- Topbar (Mobile) --- */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  z-index: 100;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-xs);
}

.topbar .hamburger {
  background: none;
  border: none;
  color: var(--clr-text);
  cursor: pointer;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}
.topbar .hamburger:hover { background: var(--clr-surface-2); }
.topbar .hamburger svg { width: 22px; height: 22px; }

.topbar-logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-logo-img {
  height: 28px;
  width: auto;
  object-fit: contain;
}
.topbar-logo-text {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-action {
  color: var(--clr-text);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}
.topbar-action:hover { background: var(--clr-surface-2); }

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: sticky;
  top: 0;
  z-index: 90;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--clr-border);
  background: var(--clr-surface);
}
.sidebar-logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
}
.sidebar-logo-text {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--clr-text);
}
.sidebar-logo-text small {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--clr-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--clr-muted);
  padding: 0.75rem 0.75rem 0.35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  color: #374151;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.nav-link:hover {
  background: var(--clr-surface-2);
  color: var(--clr-text);
}
.nav-link.active {
  background: #18181b;
  color: #ffffff;
  font-weight: 600;
}
.nav-link.active svg { color: #ffffff; }
.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #64748b;
  transition: color var(--transition);
}
.nav-link:hover svg { color: var(--clr-text); }

/* --- Sidebar Footer & User Menu Dropdown --- */
.sidebar-footer {
  border-top: 1px solid var(--clr-border);
  padding: 0.75rem;
  position: relative;
  background: var(--clr-surface);
}

.user-menu-container {
  position: relative;
  width: 100%;
}

.user-menu-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.user-menu-trigger:hover,
.user-menu-container.open .user-menu-trigger {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #18181b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-avatar svg { width: 18px; height: 18px; }

.user-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.user-display-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--clr-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role-label {
  font-size: 0.7rem;
  color: var(--clr-muted);
}
.chevron-icon {
  color: var(--clr-muted);
  flex-shrink: 0;
  transition: transform var(--transition);
}
.user-menu-container.open .chevron-icon {
  transform: rotate(180deg);
}

/* User Dropdown Popover */
.user-menu-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dropdown);
  padding: 0.5rem;
  z-index: 200;
  animation: dropdownIn 0.15s ease-out;
}
.user-menu-container.open .user-menu-dropdown {
  display: block;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-menu-header {
  padding: 0.5rem 0.75rem 0.35rem;
}
.user-menu-header strong {
  display: block;
  font-size: 0.88rem;
  color: var(--clr-text);
}
.user-menu-divider {
  height: 1px;
  background: var(--clr-border);
  margin: 0.35rem 0;
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: #374151;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.user-menu-item:hover {
  background: var(--clr-surface-2);
  color: var(--clr-text);
}
.user-menu-item svg {
  width: 16px;
  height: 16px;
  color: #64748b;
  flex-shrink: 0;
}
.user-menu-logout {
  color: var(--clr-danger) !important;
}
.user-menu-logout svg {
  color: var(--clr-danger) !important;
}
.user-menu-logout:hover {
  background: var(--clr-danger-bg) !important;
}

.sidebar-version-badge {
  margin-top: 0.65rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--clr-muted);
  text-align: center;
  letter-spacing: 0.02em;
  opacity: 0.75;
}

/* --- Generische Dropdowns --- */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-dropdown);
  padding: 0.35rem;
  z-index: 250;
}

.dropdown-menu.open {
  display: block;
  animation: dropdownIn 0.15s ease-out;
}

.dropdown-menu form {
  margin: 0;
  padding: 0;
}

.dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0.45rem 0.65rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 0.85rem;
  color: var(--clr-text);
  transition: background var(--transition);
}

.dropdown-item:hover {
  background: var(--clr-surface-2);
}

.dropdown-item .badge {
  width: 100%;
  text-align: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
}

/* --- Hauptbereich --- */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 2rem 2.5rem;
}

/* ----------------------------------------------------------
   4. Page-Header & Body
   ---------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--clr-text);
}
.page-subtitle {
  font-size: 0.85rem;
  color: var(--clr-muted);
  margin-top: 0.25rem;
}

.page-body {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ----------------------------------------------------------
   5. Buttons (Bauartist Swiss Clean)
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.btn:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: #18181b;
  color: #ffffff;
  border-color: #18181b;
}
.btn-primary:hover {
  background: #27272a;
  border-color: #27272a;
  box-shadow: var(--shadow-sm);
  color: #ffffff;
}

.btn-ghost {
  background: #ffffff;
  color: #374151;
  border-color: #d1d5db;
}
.btn-ghost:hover {
  background: #f9fafb;
  color: #111827;
  border-color: #9ca3af;
}

.btn-danger {
  background: #ffffff;
  color: var(--clr-danger);
  border-color: var(--clr-danger-border);
}
.btn-danger:hover {
  background: var(--clr-danger-bg);
  border-color: var(--clr-danger);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.45rem;
  border-radius: var(--radius-sm);
}

/* ----------------------------------------------------------
   6. Cards & Stat-Kacheln (Übersichtlich, ohne Umbruchfehler)
   ---------------------------------------------------------- */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--clr-text);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

/* Stat-Kacheln */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: #e5e7eb;
  transition: background var(--transition);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #cbd5e1;
}
.stat-card:hover::before {
  background: #18181b;
}

.stat-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--clr-muted);
  line-height: 1.35;
  margin-bottom: 0.5rem;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: auto;
}

.stat-card-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--clr-text);
}

/* Typ-spezifische Akzentlinien für Stat-Cards */
.stat-card-offerte::before { background: #3b82f6; }
.stat-card-auftragsbestaetigung::before { background: #0d9488; }
.stat-card-akonto1::before,
.stat-card-akonto2::before,
.stat-card-akonto3::before { background: #f59e0b; }
.stat-card-regiearbeiten::before { background: #8b5cf6; }
.stat-card-rechnung::before { background: #10b981; }
.stat-card-schlussrechnung::before { background: #f43f5e; }

/* ----------------------------------------------------------
   7. Tabellen (Klar strukturiert, hell, lesbar)
   ---------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--clr-border-light);
  color: #374151;
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--transition);
}
.table tbody tr:hover {
  background: #f8fafc;
}

.table .actions-cell {
  text-align: right;
  white-space: nowrap;
}
.table .actions-cell .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

/* --- Kontaktnummern & Kommunikationslinks (SVG Icons statt Emojis) --- */
.contact-numbers {
  display: inline-flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: flex-start;
}

.contact-num-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--clr-text);
  text-decoration: none;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color var(--transition);
}

.contact-num-item:hover {
  color: var(--clr-primary);
}

.contact-num-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--clr-muted);
  transition: color var(--transition);
}

.contact-num-item:hover .contact-num-icon {
  color: var(--clr-primary);
}

/* ----------------------------------------------------------
   8. Formulare & Eingabefelder
   ---------------------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label,
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
}

.form-control, .input {
  background: var(--clr-input-bg);
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  color: var(--clr-text);
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
}
.form-control:focus, .input:focus {
  outline: none;
  border-color: #18181b;
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}
.form-control::placeholder, .input::placeholder {
  color: #9ca3af;
}

select.form-control, select.input {
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.65rem center;
  background-repeat: no-repeat;
  background-size: 1.2em 1.2em;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
}

.input-sm, .form-control-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
}

textarea.form-control, textarea.input {
  resize: vertical;
  min-height: 80px;
}

.field-error, .form-error {
  font-size: 0.75rem;
  color: var(--clr-danger);
  font-weight: 500;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-check {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #18181b;
  cursor: pointer;
  flex-shrink: 0;
}
.form-check label {
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  color: var(--clr-text);
  margin-bottom: 0;
}

/* ----------------------------------------------------------
   9. Badges & Filter-Tabs
   ---------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-offerte   { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-ab        { background: #f0fdfa; color: #0f766e; border: 1px solid #99f6e4; }
.badge-akonto    { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-regie     { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.badge-rechnung  { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-schluss   { background: #fff1f2; color: #be123c; border: 1px solid #fecdd3; }
.badge-admin     { background: #18181b; color: #ffffff; font-size: 0.65rem; padding: 0.15rem 0.45rem; }

/* Status-Badges & Status-Pills */
.badge-aktiv     { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-success   { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.badge-muted     { background: #f3f4f6; color: #4b5563; border: 1px solid #e5e7eb; }
.badge-warning   { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.badge-danger    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.status-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 9999px;
  cursor: pointer;
  transition: all var(--transition);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--clr-border);
}
.status-pill-btn:hover {
  background: var(--clr-surface-2);
  border-color: #cbd5e1;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot-aktiv { background-color: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25); }
.status-dot-abgeschlossen { background-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25); }
.status-dot-archiviert { background-color: #9ca3af; box-shadow: 0 0 0 2px rgba(156, 163, 175, 0.25); }

.filter-tabs {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--clr-border);
}
.filter-tab {
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--clr-muted);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.filter-tab:hover {
  background: var(--clr-surface-2);
  color: var(--clr-text);
}
.filter-tab.active {
  background: #18181b;
  color: #ffffff;
}

/* ----------------------------------------------------------
   10. Modals
   ---------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal-overlay.open {
  display: flex;
}

.modal, .modal-box {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--clr-border);
  background: #fafafa;
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--clr-text);
  margin: 0;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--clr-muted);
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.modal-close:hover {
  background: #e5e7eb;
  color: var(--clr-text);
}
.modal-body {
  padding: 1.25rem 1.4rem;
  overflow-y: auto;
  background: #ffffff;
}

/* Suchfeld in Modals & Listen */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.search-wrap svg {
  position: absolute;
  left: 0.85rem;
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  color: var(--clr-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  padding: 0.6rem 0.85rem 0.6rem 2.4rem;
  font-size: 0.88rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--clr-text);
  transition: all var(--transition);
  box-shadow: var(--shadow-xs);
}
.search-input:focus {
  outline: none;
  border-color: #18181b;
  box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

/* Filter-Leiste (z.B. in Projekten & Listen) */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.filter-bar .search-wrap {
  flex: 1 1 240px;
  max-width: 360px;
}
.filter-bar .search-input,
.filter-bar select,
.filter-bar .form-control,
.filter-bar .btn {
  height: 38px;
  box-sizing: border-box;
}
.filter-bar select,
.filter-bar .form-control {
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
}
.filter-bar .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ----------------------------------------------------------
   10b. Dokument-Editor & Positionen-Tabelle
   ---------------------------------------------------------- */
.positions-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}
.positions-table th {
  background: #fafafa;
  color: var(--clr-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--clr-border);
  text-align: left;
  white-space: nowrap;
}
.positions-table td {
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid var(--clr-border-light);
  vertical-align: middle;
}
.positions-table tbody tr:hover {
  background: #f8fafc;
}
.drag-handle {
  cursor: grab;
  color: var(--clr-muted-light);
  font-size: 1.1rem;
  user-select: none;
  text-align: center;
  padding: 0 0.25rem !important;
  transition: color var(--transition);
}
.drag-handle:hover {
  color: var(--clr-text);
}
.drag-handle:active {
  cursor: grabbing;
}
.pos-num {
  font-weight: 600;
  color: var(--clr-text-muted);
  text-align: center;
  font-size: 0.82rem;
}
.pos-input {
  width: 100%;
  padding: 0.45rem 0.55rem;
  font-size: 0.84rem;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--clr-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  box-sizing: border-box;
}
.pos-input:focus {
  outline: none;
  border-color: #18181b;
  box-shadow: 0 0 0 2px rgba(24, 24, 27, 0.08);
}
.pos-input-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pos-input-center {
  text-align: center;
}
select.pos-input-center,
.pos-select-einheit {
  text-align: center;
  text-align-last: center;
  cursor: pointer;
  padding: 0.45rem 0.2rem;
}
.pos-input-desc {
  line-height: 1.45;
  resize: none;
  overflow: hidden;
  min-height: 38px;
  word-break: break-word;
}
.pos-checkbox {
  accent-color: var(--clr-primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
  margin: 0 auto;
  display: block;
}
.pos-mobile-label,
.pos-mobile-check-hint {
  display: none;
}
.pos-check-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pos-total {
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--clr-text);
  font-variant-numeric: tabular-nums;
}
.btn-pos-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-pos-del:hover {
  background: #fee2e2;
  color: #dc2626;
}
.katalog-picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: #ffffff;
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: all var(--transition);
}
.katalog-picker-item:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Summen-Panel im Editor */
.totals-panel {
  background: #ffffff;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  max-width: 440px;
  margin-left: auto;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  border-bottom: 1px dashed var(--clr-border-light);
}
.totals-row:last-child {
  border-bottom: none;
}
.totals-row.highlight {
  font-weight: 700;
  color: var(--clr-text);
  font-size: 0.95rem;
  border-top: 1px solid var(--clr-border);
  border-bottom: none;
  padding-top: 0.6rem;
  margin-top: 0.35rem;
}
.totals-label {
  font-weight: 500;
}
.totals-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }

/* ----------------------------------------------------------
   11. Toasts
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  color: var(--clr-text);
}
.toast-success { border-color: var(--clr-success-border); background: var(--clr-success-bg); color: #14532d; }
.toast-error   { border-color: var(--clr-danger-border);  background: var(--clr-danger-bg);  color: #7f1d1d; }
.toast-info    { border-color: var(--clr-info-border);    background: var(--clr-info-bg);    color: #1e3a8a; }

/* ----------------------------------------------------------
   12. Login-Seite
   ---------------------------------------------------------- */
.login-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: #f8f9fb;
}
.login-card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo-img {
  height: 52px;
  margin: 0 auto 0.75rem;
  object-fit: contain;
}
.login-logo h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--clr-text);
}
.login-logo p {
  font-size: 0.82rem;
  color: var(--clr-muted);
  margin-top: 0.25rem;
}

/* ----------------------------------------------------------
   13. Beleg-Vorschau (Detail & Print)
   ---------------------------------------------------------- */
.pdf-doc {
  background: #ffffff !important;
  color: #000000 !important;
  font-family: 'Inter', system-ui, sans-serif;
  border: 1px solid var(--clr-border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 3rem;
}

/* ----------------------------------------------------------
   14. Hilfsklassen
   ---------------------------------------------------------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.w-full { width: 100%; }
.text-sm { font-size: 0.82rem; }
.text-muted { color: var(--clr-muted); }
.text-danger { color: var(--clr-danger) !important; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }

/* ----------------------------------------------------------
   15. Responsive Anpassungen
   ---------------------------------------------------------- */

/* 15a. Zwischenbreiten: Laptops / Desktop-Splitscreen */
@media (max-width: 1280px) {
  .main-content {
    padding: 1.5rem 1.5rem;
  }
}

/* 15b. Tabellen -> Modernes Card-Layout bei <= 1180px
   Schaltet früher auf Touch/Karten um, verhindert horizontale
   Scrollbalken und abgeschnittene Buttons bei offener Sidebar */
@media (max-width: 1180px) {
  .table-wrap {
    overflow-x: visible;
  }
  .card:has(.table-responsive) {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  .table-responsive {
    display: block;
    width: 100%;
    border: none;
  }
  .table-responsive thead {
    display: none;
  }
  .table-responsive tbody {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
  }
  .table-responsive tbody tr {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    gap: 0.35rem;
    transition: box-shadow var(--transition), border-color var(--transition);
  }
  .table-responsive tbody tr:hover {
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
  }
  .table-responsive td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.88rem;
    width: 100%;
    box-sizing: border-box;
    text-align: right;
  }
  .table-responsive td > div:not(.actions-cell) {
    text-align: right;
  }
  .table-responsive td strong {
    text-align: right;
  }
  .table-responsive td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 0.4rem;
  }
  .table-responsive td::before {
    content: attr(data-label);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--clr-muted);
    margin-right: 0.75rem;
    padding-top: 0.12rem;
    flex-shrink: 0;
    text-align: left;
  }
  .table-responsive td:not([data-label])::before {
    display: none;
  }
  .table-responsive .actions-cell {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: stretch;
    padding-top: 0.65rem;
    border-top: 1px solid var(--clr-border-light);
  }
  .table-responsive .actions-cell .btn,
  .table-responsive .actions-cell form {
    flex: 1 1 calc(50% - 0.4rem);
    display: flex;
  }
  .table-responsive .actions-cell .btn,
  .table-responsive .actions-cell form .btn {
    width: 100%;
    min-height: 38px;
    justify-content: center;
    font-size: 0.82rem;
  }
  .table-responsive .contact-numbers {
    align-items: flex-end;
  }
  .table-responsive .contact-num-item {
    justify-content: flex-end;
  }
}

/* 15c. Tablet & Mobile: Offcanvas Sidebar, kompakter Header, Positionstabelle */
@media (max-width: 900px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w-mobile);
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    z-index: 85;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main-content {
    margin-top: var(--topbar-h);
    padding: 1.25rem 1rem;
  }
  .stat-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
  }
  .stat-card {
    padding: 0.9rem;
    min-height: 90px;
  }
  .stat-card-value {
    font-size: 1.75rem;
  }
  .card {
    padding: 1rem;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .page-header > div:last-child {
    width: 100%;
  }
  .search-wrap {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }
  .filter-bar {
    width: 100%;
  }
  .filter-bar .search-wrap {
    width: 100%;
    max-width: 100%;
  }
  .filter-bar select,
  .filter-bar .form-control {
    flex: 1 1 auto;
  }

  /* Positionstabelle im Editor -> Touch-optimierte Karten */
  .positions-table {
    display: block;
    width: 100%;
  }
  .positions-table thead {
    display: none;
  }
  .positions-table,
  .positions-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    width: 100%;
  }
  .positions-table tbody tr.pos-row {
    display: grid;
    grid-template-columns: 28px 32px auto 1fr auto;
    grid-template-areas:
      "handle num check total del"
      "desc desc desc desc desc"
      "val-m val-m val-e val-e val-e"
      "val-p val-p val-r val-r val-r";
    background: #ffffff;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    gap: 0.5rem;
    align-items: center;
  }
  .pos-cell-handle {
    grid-area: handle;
    font-size: 1.25rem;
    padding: 0.2rem !important;
  }
  .pos-cell-num {
    grid-area: num;
    font-size: 0.95rem;
    font-weight: 700;
  }
  .pos-cell-check {
    grid-area: check;
    display: flex;
    align-items: center;
  }
  .pos-check-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
  }
  .pos-mobile-check-hint {
    display: inline-block;
    font-size: 0.72rem;
    color: var(--clr-muted);
    font-weight: 600;
  }
  .pos-cell-total {
    grid-area: total;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--clr-text);
    text-align: right;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
  }
  .pos-cell-total .pos-mobile-label {
    display: none;
  }
  .pos-cell-del {
    grid-area: del;
    text-align: right;
  }
  .btn-pos-del {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    background: #f8fafc;
    border: 1px solid var(--clr-border);
  }
  .pos-cell-desc {
    grid-area: desc;
    width: 100%;
  }
  .pos-cell-m {
    grid-area: val-m;
    width: 100%;
  }
  .pos-cell-e {
    grid-area: val-e;
    width: 100%;
  }
  .pos-cell-p {
    grid-area: val-p;
    width: 100%;
  }
  .pos-cell-r {
    grid-area: val-r;
    width: 100%;
  }
  .pos-mobile-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--clr-muted);
    margin-bottom: 0.25rem;
  }
  .positions-table td {
    padding: 0;
    border: none;
  }
}

@media print {
  .no-print { display: none !important; }
  .main-content { padding: 0 !important; margin: 0 !important; }
  .pdf-doc { border: none !important; box-shadow: none !important; padding: 0 !important; }
}
