/* ============================================
   OnePen – Industrial Field App Design
   Mobile-first, dark-mode optimized
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Colors - Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-accent: #0f172a;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;
  
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  
  --accent-primary: #0ea5e9;
  --accent-hover: #0284c7;
  --accent-subtle: #e0f2fe;
  
  --success: #10b981;
  --success-subtle: #d1fae5;
  --warning: #f59e0b;
  --warning-subtle: #fef3c7;
  --danger: #ef4444;
  --danger-subtle: #fee2e2;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  
  /* Typography */
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-inset: inset 0 1px 2px rgba(0,0,0,0.06);
}

/* ---------- Dark Mode ---------- */
body.theme-dark {
  --bg-primary: #0a0f1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1e293b;
  --bg-accent: #0ea5e9;
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;
  
  --border-light: #1e293b;
  --border-medium: #334155;
  
  --accent-subtle: #0c4a6e;
  
  --success-subtle: #064e3b;
  --warning-subtle: #78350f;
  --danger-subtle: #7f1d1d;
  
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --shadow-inset: inset 0 1px 2px rgba(0,0,0,0.3);
}

/* ---------- Google Fonts Import ---------- */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header (Glassmorphism) ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

@media (max-width: 480px) {
  header { padding: var(--space-xs) var(--space-sm); }
  .logo-text { display: none; }
  .logo-icon { width: 30px; height: 30px; }
  .logo-icon svg { width: 16px; height: 16px; }
  .action-btn { width: 38px; height: 38px; }
  .action-btn svg { width: 18px; height: 18px; }
  .settings-btn { width: 40px; height: 40px; }
  .settings-btn svg { width: 20px; height: 20px; }
  .action-pill { gap: 0; padding: 3px; }
}

body.theme-dark header {
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary) 0%, #6366f1 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.logo-icon svg {
  width: 20px;
  height: 20px;
}

.logo-text {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Offline-Indikator */
.offline-badge {
  background: var(--warning);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 3px var(--space-sm);
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* Glass Pill für Action Buttons */
.action-pill {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg);
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

body.theme-dark .action-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn svg {
  width: 20px;
  height: 20px;
}

.action-btn:hover {
  background: rgba(14, 165, 233, 0.1);
  color: var(--accent-primary);
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

body.theme-dark .action-btn:hover {
  background: rgba(14, 165, 233, 0.2);
}

/* Settings Button (separate, hervorgehoben) */
.settings-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-btn svg {
  width: 22px;
  height: 22px;
  transition: transform 0.3s ease;
}

.settings-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.settings-btn:hover svg {
  transform: rotate(90deg);
}

body.theme-dark .settings-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

body.theme-dark .settings-btn:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Overflow Menu */
.overflow-menu-wrap {
  position: relative;
}

.overflow-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
}

body.theme-dark .overflow-menu {
  background: var(--bg-secondary);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.overflow-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease;
  text-align: left;
}

.overflow-item:last-child {
  border-bottom: none;
}

.overflow-item:hover {
  background: rgba(14, 165, 233, 0.08);
  color: var(--accent-primary);
}

body.theme-dark .overflow-item:hover {
  background: rgba(14, 165, 233, 0.15);
}

.overflow-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Floating Action Button – ZIP Export */
.fab-zip {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(14, 165, 233, 0.4);
  transition: all 0.2s ease;
  z-index: 900;
}

.fab-zip svg {
  width: 24px;
  height: 24px;
}

.fab-zip:hover {
  background: var(--accent-hover, #0284c7);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.55);
  transform: translateY(-2px);
}

.fab-zip:active {
  transform: translateY(0);
}

/* ---------- Buttons ---------- */
button, .btn {
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  transition: all 0.15s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active {
  transform: scale(0.96);
  transition-duration: 0.05s;
}

.btn-primary {
  background: var(--accent-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-ghost:hover {
  background: var(--border-light);
  border-color: var(--border-medium);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-small {
  font-size: var(--text-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

.btn-add {
  background: var(--success);
  color: white;
}

.btn-add:hover {
  background: #059669;
}

/* ---------- Main Content ---------- */
main {
  padding: var(--space-lg);
  max-width: 800px;
  margin: 0 auto;
}

/* ---------- Cards / Sections ---------- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  overflow: hidden;
  animation: cardFadeIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.card:nth-child(2) { animation-delay: 40ms; }
.card:nth-child(3) { animation-delay: 80ms; }
.card:nth-child(4) { animation-delay: 120ms; }
.card:nth-child(5) { animation-delay: 160ms; }

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

@media (prefers-reduced-motion: reduce) {
  .card { animation: none; }
}

.card-header {
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.card-header h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--accent-primary);
  color: white;
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.card-body {
  padding: var(--space-lg);
}

/* ---------- Section 0: Arbeitsmodus (Special) ---------- */
#sec_arbeitsmodus {
  background: linear-gradient(135deg, var(--accent-subtle), var(--bg-secondary));
  border-color: var(--accent-primary);
  border-width: 2px;
  margin: var(--space-lg);
  max-width: calc(800px - var(--space-2xl));
  margin-left: auto;
  margin-right: auto;
}

body.theme-dark #sec_arbeitsmodus {
  background: linear-gradient(135deg, #0c4a6e, var(--bg-secondary));
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-row {
  display: grid;
  gap: var(--space-md);
}

@media (min-width: 480px) {
  .form-row {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.required-mark::after {
  content: ' *';
  color: var(--danger);
  font-weight: 600;
}

input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: var(--text-base);
  padding: var(--space-md);
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Checkbox & Radio */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
}

.check-group label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
  margin-bottom: 0;
}

.check-group input[type="checkbox"],
.check-group input[type="radio"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
}

/* ---------- Inline Fields ---------- */
.inline-fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

/* ---------- Hint Text ---------- */
.hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ---------- Datum Quick-Buttons ---------- */
.date-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}
.date-input-row input[type="date"] {
  flex: 1;
  min-width: 0;
}
.btn-quick-date {
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 5px var(--space-sm);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.btn-quick-date:hover {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

/* ---------- Muffe Schnelleingabe ---------- */
.muffe-quick-entry {
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-medium);
}
.muffe-quick-entry input[type="text"] {
  width: 100%;
  font-family: var(--font-mono, monospace);
  font-size: var(--text-sm);
  margin-bottom: var(--space-xs);
}
.muffe-quick-entry code {
  font-family: var(--font-mono, monospace);
  font-size: var(--text-xs);
  background: var(--bg-secondary);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

/* ---------- Warnings & Errors ---------- */
.warn {
  background: var(--warning-subtle);
  border: 1px solid var(--warning);
  color: var(--text-primary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-top: var(--space-md);
}

.error {
  color: var(--danger);
  font-size: var(--text-sm);
  white-space: pre-wrap;
}

.required-glow {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px var(--danger-subtle) !important;
}

/* ---------- Autocomplete Suggestions ---------- */
.suggest-wrap {
  position: relative;
}

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: var(--space-xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
}

.suggest-item {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:hover {
  background: var(--bg-tertiary);
}

.suggest-title {
  font-weight: 600;
  color: var(--text-primary);
}

.suggest-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- Cable List (Section 5) ---------- */
.cable-item {
  background: var(--bg-tertiary);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.cable-item .form-row {
  margin-bottom: var(--space-sm);
}

/* Cable rows generated by cableRowTemplate() */
.cable-row {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  transition: border-color 0.15s;
}

.cable-row:hover {
  border-color: var(--border-medium);
}

.cable-row .row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr;
  gap: var(--space-sm);
  align-items: end;
}

@media (max-width: 600px) {
  .cable-row .row {
    grid-template-columns: 1fr 1fr;
  }
}

.cable-row label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.cable-row .cable-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-xs);
}

.cable-actions {
  display: flex;
  gap: var(--space-sm);
  padding-top: var(--space-sm);
}

/* ---------- INSTANDSETZUNG (Section 9) ---------- */
#sec_instandsetzung {
  /* Jetzt innerhalb main, kein extra margin nötig */
}

/* ========== Muffen-Karten ========== */
.muffe-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  overflow: hidden;
}

.muffe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}

.muffe-card-title {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--accent-primary);
}

.muffe-card-delete {
  background: transparent;
  border: none;
  font-size: var(--text-lg);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.muffe-card-delete:hover {
  background: var(--danger-subtle);
}

.muffe-card-body {
  padding: var(--space-lg);
}

.muffe-field {
  margin-bottom: var(--space-md);
}

.muffe-field:last-child {
  margin-bottom: 0;
}

.muffe-field-full {
  width: 100%;
}

.muffe-field label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.muffe-field input,
.muffe-field select {
  width: 100%;
}

.muffe-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.muffe-field-row .muffe-field {
  margin-bottom: 0;
}

.muffe-field-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) 0;
  border-top: 1px solid var(--border-light);
  margin-top: var(--space-md);
}

.muffe-field-check input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  accent-color: var(--accent-primary);
}

.muffe-field-check label {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-primary);
  cursor: pointer;
}

/* ========== Kabel-Karten (Neue Kabel & Alt-Kabel) ========== */
.kabel-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  overflow: hidden;
}

.kabel-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}

.kabel-card-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--accent-primary);
}

.kabel-card-delete {
  background: transparent;
  border: none;
  font-size: var(--text-base);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.kabel-card-delete:hover {
  background: var(--danger-subtle);
}

.kabel-card-body {
  padding: var(--space-md);
  display: grid;
  gap: var(--space-md);
}

@media (min-width: 400px) {
  .kabel-card-body {
    grid-template-columns: 2fr 1fr;
  }
}

.kabel-field label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kabel-field input,
.kabel-field select {
  width: 100%;
}

/* Fieldset Styling */
fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--space-xl) 0;
}

fieldset legend {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

fieldset legend::before {
  content: '';
  width: 4px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 2px;
}

/* Mobile-friendly item cards (replacing tables) */
.item-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-sm);
  position: relative;
}

.item-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--space-md);
}

.item-card-title {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--accent-primary);
}

.item-card-delete {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--danger-subtle);
  color: var(--danger);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  transition: all 0.15s;
}

.item-card-delete:hover {
  background: var(--danger);
  color: white;
}

.item-card-grid {
  display: grid;
  gap: var(--space-sm);
}

@media (min-width: 400px) {
  .item-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 600px) {
  .item-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.item-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.item-field-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.item-field input,
.item-field select {
  padding: var(--space-sm);
  font-size: var(--text-sm);
}

/* Checkbox inside item card */
.item-field-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-top: var(--space-md);
}

.item-field-check label {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

/* APL Block */
.sub-block {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-top: var(--space-lg);
  border: 1px solid var(--border-light);
}

.sub-block h4 {
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.field-row {
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (min-width: 480px) {
  .field-row {
    grid-template-columns: 140px 1fr;
    align-items: center;
  }
  
  .field-row label {
    margin-bottom: 0;
  }
}

/* Kugelmarker */
.single-field {
  max-width: 200px;
}

/* Calculate Button */
.calculate-btn {
  background: linear-gradient(135deg, var(--accent-primary), #6366f1);
  color: white;
  font-weight: 600;
  padding: var(--space-md) var(--space-xl);
  font-size: var(--text-base);
  margin-top: var(--space-lg);
}

.calculate-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Suggestions Grid */
.suggestions-grid {
  display: grid;
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

@media (min-width: 600px) {
  .suggestions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.suggestion-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.suggestion-box h4 {
  background: var(--bg-accent);
  color: var(--text-inverse);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  font-weight: 600;
  margin: 0;
}

body.theme-dark .suggestion-box h4 {
  background: var(--accent-primary);
  color: white;
}

.suggestion-box pre,
.suggest-box {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: var(--space-md);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: 0;
}

/* LÖ-Tabelle (horizontally scrollable on mobile) */
.lo-preview {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--space-md));
  padding: 0 var(--space-md);
}

.lo-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: var(--text-xs);
}

.lo-table th,
.lo-table td {
  padding: var(--space-sm);
  text-align: center;
  border: 1px solid var(--border-light);
  white-space: nowrap;
}

.lo-table th {
  background: var(--bg-accent);
  color: var(--text-inverse);
  font-weight: 600;
}

body.theme-dark .lo-table th {
  background: var(--accent-primary);
  color: white;
}

.lo-table td.muted {
  text-align: left;
  color: var(--text-muted);
}

/* Team Mode Highlights */
.af-team-box {
  border-left: 4px solid var(--success);
}

.af-m1 {
  border-left-color: var(--accent-primary);
}

.af-m2 {
  border-left-color: #f97316;
}

/* Monteur Column - wird durch .hide Klasse gesteuert */
.monteur-col {
  min-width: 110px;
}

/* ---------- Settings Dialog ---------- */
.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
}

.settings-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  width: calc(100% - 32px);
  max-width: 400px;
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xl) var(--space-xl) 0;
  margin-bottom: var(--space-lg);
  flex-shrink: 0;
}

.settings-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-xl) var(--space-xl);
  flex: 1;
}

.settings-dialog h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0;
}

/* ---------- Toast & Badge ---------- */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: var(--space-xl);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-lg);
  background: var(--bg-accent);
  color: var(--text-inverse);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
}

body.theme-dark .toast {
  background: var(--accent-primary);
  color: white;
}

.badge {
  position: fixed;
  right: var(--space-lg);
  bottom: var(--space-lg);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-md);
  background: var(--success);
  color: white;
  z-index: 999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s, transform 0.3s;
}
.badge[style*="opacity: 1"], .badge[style*="opacity:1"] {
  transform: translateY(0);
}

/* ---------- Utility Classes ---------- */
.hide {
  display: none !important;
}

.small {
  font-size: var(--text-xs);
}

.muted {
  color: var(--text-muted);
}

.text-center {
  text-align: center;
}

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ---------- Tables (for Instandsetzung) ---------- */
.compact-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.compact-table th,
.compact-table td {
  padding: var(--space-sm);
  border: 1px solid var(--border-light);
  text-align: left;
  vertical-align: middle;
}

.compact-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Inputs innerhalb von Tabellen */
.compact-table input,
.compact-table select {
  padding: var(--space-sm);
  font-size: var(--text-sm);
  min-width: 80px;
}

.compact-table input[type="checkbox"] {
  min-width: auto;
  width: 20px;
  height: 20px;
}

/* Delete Button in Tabelle */
.compact-table .btn-danger {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
}

/* Mobile: Make LÖ table scrollable */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--space-lg));
  padding: 0 var(--space-lg);
}

/* ---------- Print Styles ---------- */
@media print {
  .no-print {
    display: none !important;
  }
  
  body {
    background: white;
    color: black;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
}

/* ---------- Safe Area (iPhone Notch / Dynamic Island) ---------- */
@supports (padding: env(safe-area-inset-top)) {
  header {
    padding-top: calc(var(--space-sm) + env(safe-area-inset-top));
    padding-left: calc(var(--space-md) + env(safe-area-inset-left));
    padding-right: calc(var(--space-md) + env(safe-area-inset-right));
  }
  @media (max-width: 480px) {
    header {
      padding-top: calc(var(--space-xs) + env(safe-area-inset-top));
      padding-left: calc(var(--space-sm) + env(safe-area-inset-left));
      padding-right: calc(var(--space-sm) + env(safe-area-inset-right));
    }
  }
  main {
    padding-left: calc(var(--space-lg) + env(safe-area-inset-left));
    padding-right: calc(var(--space-lg) + env(safe-area-inset-right));
    padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom) + 20px);
  }
}

/* ---------- Scrollbar Styling ---------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ========== Muffen-Card Collapse ========== */
.muffe-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.muffe-card-toggle {
  background: transparent;
  border: none;
  font-size: var(--text-base);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  transition: background 0.15s, transform 0.2s;
  color: var(--text-secondary);
  line-height: 1;
}

.muffe-card-toggle:hover {
  background: var(--bg-tertiary);
}

.muffe-card.collapsed .muffe-card-body {
  display: none;
}

.muffe-card.collapsed .muffe-card-header {
  border-bottom: none;
}

/* ========== Auto-Fill Banner & Button ========== */
.autofill-banner {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #86efac;
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

body.theme-dark .autofill-banner {
  background: linear-gradient(135deg, #14532d 0%, #166534 100%);
  border-color: #22c55e;
}

.btn-autofill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-autofill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn-autofill:active {
  transform: translateY(0);
}

.autofill-icon {
  font-size: 1.2em;
}

/* ========== Needs Review Markierung ========== */
.muffe-card.needs-review {
  border-color: #fbbf24;
  background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
}

body.theme-dark .muffe-card.needs-review {
  background: linear-gradient(135deg, #422006 0%, #713f12 100%);
  border-color: #f59e0b;
}

.muffe-card.needs-review .muffe-card-header::after {
  content: '! Zuweisung prüfen';
  font-size: var(--text-xs);
  color: #b45309;
  margin-left: auto;
  padding: 2px 8px;
  background: #fef3c7;
  border-radius: var(--radius-sm);
}

body.theme-dark .muffe-card.needs-review .muffe-card-header::after {
  background: #78350f;
  color: #fcd34d;
}

/* ========== Needs Date Review Markierung ========== */
.muffe-card.needs-date-review {
  border-color: #60a5fa;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

body.theme-dark .muffe-card.needs-date-review {
  background: linear-gradient(135deg, #1e3a5f 0%, #1e40af 100%);
  border-color: #3b82f6;
}

.muffe-card.needs-date-review .muffe-card-header::after {
  content: 'Datum prüfen (mehrere Tage)';
  font-size: var(--text-xs);
  color: #1d4ed8;
  margin-left: auto;
  padding: 2px 8px;
  background: #dbeafe;
  border-radius: var(--radius-sm);
}

body.theme-dark .muffe-card.needs-date-review .muffe-card-header::after {
  background: #1e3a8a;
  color: #93c5fd;
}

/* Wenn beide Markierungen vorhanden sind */
.muffe-card.needs-review.needs-date-review {
  border-color: #f97316;
}

.muffe-card.needs-review.needs-date-review .muffe-card-header::after {
  content: '! Zuweisung & Datum prüfen';
}

/* ========== Sonderkabel Box ========== */
.sonderkabel-box {
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: var(--radius-lg);
}

body.theme-dark .sonderkabel-box {
  background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
  border-color: #f59e0b;
}

.sonderkabel-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  color: #92400e;
  margin-bottom: var(--space-md);
}

body.theme-dark .sonderkabel-header {
  color: #fcd34d;
}

.sonderkabel-icon {
  display: flex;
  align-items: center;
}

.sonderkabel-icon svg {
  width: 18px;
  height: 18px;
}

.check-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.check-inline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ========== ARCHIV DIALOG ========== */
.archiv-dialog {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 94%; max-width: 480px; max-height: 88vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  display: flex; flex-direction: column;
  overflow: hidden;
  border: 1.5px solid var(--border-medium);
}
.archiv-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-tertiary);
}
.archiv-header h2 { font-size: 1.15rem; font-weight: 700; margin: 0; color: var(--text-primary); }
.archiv-header .btn-icon {
  background: var(--bg-secondary); color: var(--text-secondary);
  border: 1px solid var(--border-light);
  width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 1.1rem;
}
.archiv-tabs {
  display: flex; border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}
.archiv-tab-btn {
  flex: 1; padding: 10px 12px;
  border: none; background: transparent;
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; border-bottom: 2.5px solid transparent;
  margin-bottom: -1px; transition: all 0.15s;
}
.archiv-tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
  background: var(--surface);
}
.archiv-toolbar {
  display: flex; gap: 6px; padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-secondary);
}
.archiv-new-btn, .archiv-export-btn, .archiv-import-btn {
  padding: 5px 10px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-medium); border-radius: var(--radius-sm);
  background: var(--bg-secondary); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s;
}
.archiv-new-btn { color: var(--accent-primary); border-color: var(--accent-primary); }
.archiv-import-btn { display: inline-flex; align-items: center; gap: 2px; }
.archiv-liste {
  flex: 1; overflow-y: auto;
  padding: 10px; display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-primary);
}
.archiv-loading, .archiv-empty, .archiv-error {
  text-align: center; padding: 32px 16px; color: var(--text-muted);
}
.archiv-empty-icon { font-size: 2.5rem; margin-bottom: 8px; opacity: 0.5; }
.archiv-empty-sub { font-size: 12px; margin-top: 4px; color: var(--text-muted); }

/* Archive cards */
.acard {
  background: var(--surface); border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md); padding: 10px 12px;
  transition: border-color 0.15s;
}
.acard:hover { border-color: var(--accent-primary); }
.acard-current { border-color: var(--accent-primary); background: rgba(14,165,233,0.04); }
.acard-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 4px;
}
.acard-df {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 1px 6px; border-radius: 3px; letter-spacing: 0.5px;
}
.acard-df-abr { background: #fef3c7; color: #92400e; }
.acard-df-ent { background: #dbeafe; color: #1e40af; }
.acard-df-apl { background: #d1fae5; color: #065f46; }
.acard-time { font-size: 11px; color: var(--text-muted); }
.acard-sm { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.acard-addr { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 2px; }
.acard-kabel { font-size: 11px; color: var(--text-muted); font-style: italic; }
.acard-uploader { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 2px; }
.acard-meta { display: flex; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.acard-tag {
  font-size: 10px; font-weight: 600; padding: 1px 6px;
  background: var(--bg-secondary); border: 1px solid var(--border-light);
  border-radius: 3px; color: var(--text-secondary);
}
.acard-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  color: var(--accent-primary); margin-top: 2px;
}
.acard-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.abtn {
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border-medium); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.12s; background: var(--bg-secondary);
}
.abtn-load {
  background: var(--accent-primary); color: #fff;
  border-color: var(--accent-primary); flex: 1;
}
.abtn-load:hover { background: #0369a1; }
.abtn-archive {
  color: #16a085; border-color: #16a085; background: rgba(22,160,133,0.06);
}
.abtn-archive:hover { background: rgba(22,160,133,0.15); }
.abtn-del {
  color: #dc2626; border-color: #fecaca; background: #fef2f2;
}
.abtn-del:hover { background: #fee2e2; border-color: #f87171; }

body.theme-dark .acard-df-abr { background: #451a03; color: #fbbf24; }
body.theme-dark .acard-df-ent { background: #172554; color: #60a5fa; }
body.theme-dark .acard-df-apl { background: #022c22; color: #34d399; }
body.theme-dark .abtn-del { background: #2d1b1b; color: #fca5a5; border-color: #7f1d1d; }

/* Count badges */
.archiv-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-primary); color: white;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px;
  margin-left: 4px;
}

.archiv-ursache {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* ========== KABELMAS-RECHNER (Inline in Kabel-Karten) ========== */
.kabelmass-inline {
  border-top: 1px dashed var(--border-light);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(16, 185, 129, 0.1) 100%);
}

body.theme-dark .kabelmass-inline {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.15) 100%);
}

.kabelmass-inline-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.kabelmass-inline-header:hover {
  background: rgba(16, 185, 129, 0.1);
}

.kabelmass-inline-icon {
  font-size: 0.9em;
}

.kabelmass-inline-title {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}

.kabelmass-inline-toggle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  transition: transform 0.2s;
}

.kabelmass-inline.expanded .kabelmass-inline-toggle {
  transform: rotate(90deg);
}

.kabelmass-inline-body {
  display: none;
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.kabelmass-inline.expanded .kabelmass-inline-body {
  display: block;
}

.kabelmass-inline-row {
  display: grid;
  grid-template-columns: 1fr 0.6fr 1fr 0.6fr;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

@media (max-width: 400px) {
  .kabelmass-inline-row {
    grid-template-columns: 1fr 0.5fr 1fr 0.5fr;
  }
}

.kabelmass-inline-field label {
  display: block;
  font-size: 9px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.kabelmass-inline-field input {
  width: 100%;
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  text-align: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
}

.kabelmass-inline-field input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.kabelmass-inline-korr input {
  background: rgba(16, 185, 129, 0.1);
}

.kabelmass-inline-korr label {
  text-align: center;
}

.btn-kabelmass-calc {
  width: 100%;
  padding: var(--space-sm);
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-kabelmass-calc:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-kabelmass-calc:active {
  transform: translateY(0);
}

/* Länge-Feld Hervorhebung */
.kabel-field-laenge input {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ============================================
   Dokufall-Auswahl
   ============================================ */

.dokufall-selector {
  padding: var(--space-md) var(--space-lg) !important;
}

.dokufall-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.dokufall-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: var(--space-md) var(--space-sm);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-sans);
}

.dokufall-card:active {
  transform: scale(0.97);
}

.dokufall-card.active {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.dokufall-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.dokufall-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.dokufall-card.active .dokufall-label {
  color: var(--accent-primary);
}

/* Dark mode adjustments */
.theme-dark .dokufall-card {
  background: var(--bg-tertiary);
  border-color: var(--border-light);
}
.theme-dark .dokufall-card.active {
  background: rgba(14, 165, 233, 0.1);
  border-color: var(--accent-primary);
}

/* Monospace Textfeld für Spleißplan */
textarea.mono-text {
  font-family: var(--font-mono) !important;
  font-size: var(--text-sm) !important;
  line-height: 1.6 !important;
  white-space: pre;
}

/* Entstörung section numbers */
.ent-num { background: #fef3c7; color: #92400e; }
.apl-num { background: #d1fae5; color: #065f46; }
.theme-dark .ent-num { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.theme-dark .apl-num { background: rgba(16, 185, 129, 0.15); color: #10b981; }

/* Utility classes (deduplicated) */
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }

/* ============================================
   1) MESSWERT-KARTEN
   ============================================ */
.messwert-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-sm);
  overflow: hidden;
}
.messwert-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
}
.messwert-header select {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 6px 8px;
}
.messwert-header .muffe-card-delete { flex-shrink: 0; }
.mw-timestamps {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 2px var(--space-md); font-size: 10px; color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}
.messwert-body {
  padding: var(--space-sm) var(--space-md) var(--space-md);
}
.mw-type-fields { margin-bottom: var(--space-sm); }
.mw-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}
.mw-field label {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.mw-field input {
  width: 100%;
  font-size: var(--text-sm);
  padding: 5px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.mw-field-full { grid-column: 1 / -1; }
.mw-checks {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.mw-checks label {
  font-size: var(--text-xs) !important;
  color: var(--text-primary) !important;
  display: flex; align-items: center; gap: 4px;
}

/* Messungstyp-Dropdown */
.mw-messung {
  background: rgba(14,165,233,0.1) !important;
  border: 1px solid var(--accent-primary) !important;
  color: var(--accent-primary) !important;
}

/* Section Labels (Paar, Küpfmüller, Dreipunkt) */
.mw-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 8px 0 4px;
  padding-bottom: 2px;
  border-bottom: 1px dashed var(--border-light);
}
.mw-section-label:first-child { margin-top: 0; }

/* 2 or 3 column rows */
.mw-row { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); }

/* Compact Grid (Isolation) */
.mw-compact-grid {
  display: flex; flex-direction: column; gap: 6px;
}
.mw-cg-row {
  display: flex; align-items: center; gap: 8px;
}
.mw-cg-label {
  font-size: 13px; font-weight: 700; min-width: 28px;
  color: var(--text-primary);
}
.mw-cg-row input {
  flex: 1; font-size: var(--text-sm); padding: 6px 10px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--bg-secondary); color: var(--text-primary);
}
.mw-cg-unit {
  font-size: 11px; color: var(--text-muted); min-width: 28px;
}

/* Messung-Feld Select gleich stylen */
.mw-messung-area select {
  width: 100%; font-size: var(--text-sm); padding: 5px 8px;
  border: 1px solid var(--border-light); border-radius: var(--radius-sm);
  background: var(--bg-secondary); color: var(--text-primary);
}

/* Mess-Grid Tabelle */
.mw-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  margin-top: var(--space-sm);
}
.mw-grid th {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  padding: 4px 2px;
  border-bottom: 1.5px solid var(--border-medium);
}
.mw-grid td {
  padding: 2px;
  text-align: center;
}
.mw-grid .mw-label {
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--accent-primary);
  width: 60px;
  text-align: left;
  padding-left: 4px;
  font-size: var(--text-xs);
  white-space: nowrap;
}
.mw-grid input {
  width: 100%;
  text-align: center;
  font-size: var(--text-sm);
  font-family: var(--font-mono);
  padding: 5px 4px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Messfoto als Nachweis */
.mw-foto-section { padding-top: var(--space-xs); }
.mw-foto-btn { cursor: pointer; }
.mw-foto-preview {
  margin-top: var(--space-xs);
  display: flex; gap: var(--space-sm);
}

/* ============================================
   2) SPLEISSPLAN-BUILDER
   ============================================ */
.spleiss-mode-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-light);
}
.spleiss-mode-btn {
  flex: 1;
  padding: 6px 10px;
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}
.spleiss-mode-btn.active {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.spleiss-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  padding: 4px 0;
}
.sp-cell { display: flex; align-items: center; gap: 4px; }
.sp-from, .sp-to { flex: 0 0 auto; min-width: 0; }
.sp-from select, .sp-to select {
  width: 90px;
  font-size: var(--text-sm);
  padding: 4px 6px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.sp-paare { flex: 1; min-width: 0; }
.sp-paare input {
  width: 100%;
  font-size: var(--text-sm);
  padding: 4px 6px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-mono);
  text-align: center;
}
.sp-arrow { flex: 0 0 auto; font-size: var(--text-sm); color: var(--text-muted); padding: 0 2px; }
.sp-del {
  flex: 0 0 24px; width: 24px; height: 24px;
  border: none; background: none; color: var(--text-muted);
  font-size: var(--text-sm); cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.sp-del:hover { color: var(--danger); background: var(--danger-subtle); }

.sp-color-badge {
  display: inline-block; width: 14px; height: 14px;
  border-radius: 3px; border: 1.5px solid transparent;
  flex-shrink: 0; vertical-align: middle;
}
.sp-color-badge.sp-stripe {
  background-image: repeating-linear-gradient(
    45deg, transparent, transparent 2px,
    rgba(0,0,0,0.15) 2px, rgba(0,0,0,0.15) 4px
  ) !important;
}

/* ============================================
   3) SKETCH-CANVAS (Einmaß)
   ============================================ */
.sketch-container {
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  touch-action: none;
}
@media (max-width: 480px) {
  /* Einmaß: weniger Padding für mehr Zeichenfläche */
  [data-show="entstoerung,apl"] > .card-body:has(.sketch-container) {
    padding: var(--space-xs);
  }
  .sketch-container { border-radius: var(--radius-sm); }
}
.sketch-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}
.sketch-tool {
  width: 34px; height: 34px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.1s;
}
.sketch-tool:active { transform: scale(0.93); }
.sketch-tool.active {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  box-shadow: 0 0 0 1px var(--accent-primary);
}
.sketch-color {
  width: 34px; height: 34px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 2px; cursor: pointer;
  background: var(--bg-secondary);
}
.sketch-size {
  width: 70px; height: 28px;
  accent-color: var(--accent-primary);
}
#sketchCanvas {
  display: block; width: 100%;
  cursor: crosshair; touch-action: none;
}

/* Stencil Palette */
.sketch-stencils {
  display: flex;
  align-items: stretch;
  gap: 3px;
  padding: 4px var(--space-sm);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stencil-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 6px 2px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  cursor: pointer;
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
  min-width: 40px;
  transition: all 0.15s;
}
.stencil-btn svg {
  width: 24px;
  height: 16px;
  color: var(--text-secondary);
}
.stencil-btn span {
  font-weight: 600;
  line-height: 1;
}
.stencil-btn:active { transform: scale(0.93); }
.stencil-btn.active {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
  color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}
.stencil-btn.active svg { color: var(--accent-primary); }
@media (max-width: 480px) {
  .stencil-btn { padding: 3px 5px 1px; min-width: 36px; }
  .stencil-btn svg { width: 20px; height: 14px; }
  .stencil-btn span { font-size: 8px; }
  .sketch-stencils { gap: 2px; padding: 3px var(--space-xs); }
}

/* Color palette */
.sketch-colors {
  display: flex; gap: 3px; align-items: center;
}
.sk-color {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--border-medium);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
}
.sk-color.active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-primary);
  transform: scale(1.15);
}

/* Zoom group */
.sketch-zoom-group {
  display: flex; gap: 2px; margin-left: auto;
}
.sk-zoom {
  padding: 2px 6px; font-size: 11px; font-weight: 600;
  border: 1.5px solid var(--border-medium);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary); color: var(--text-secondary);
  cursor: pointer; transition: all 0.15s;
}
.sk-zoom.active {
  background: var(--accent-primary); color: #fff;
  border-color: var(--accent-primary);
}

/* Canvas scrollable wrapper */
.sketch-canvas-wrap {
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
}

/* Sketch comments */
.sketch-comments {
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  font-size: 13px;
}
.sketch-comments strong { font-size: 12px; color: var(--text-secondary); }
.sketch-comment-item {
  display: flex; align-items: flex-start; gap: var(--space-xs);
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
}
.sketch-comment-item:last-child { border-bottom: none; }
.sketch-comment-num {
  min-width: 20px; height: 20px;
  background: var(--accent-primary); color: #fff;
  border-radius: 50%; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sketch-comment-text { flex: 1; font-size: 13px; line-height: 1.3; }
.sketch-comment-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; padding: 0 2px;
}


/* ============================================
   4) MUFFE DUPLIZIEREN-BUTTON
   ============================================ */
.muffe-card-dup {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  width: 28px; height: 28px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.1s;
}
.muffe-card-dup:hover {
  border-color: var(--accent-primary);
  background: var(--accent-subtle);
}
.muffe-card-dup:active { transform: scale(0.93); }

/* ============================================
   BILDER UPLOAD & PREVIEW
   ============================================ */
.bilder-upload-btn { cursor: pointer; }
.bilder-upload-btn .btn-add { display: inline-block; cursor: pointer; }
.bilder-btn-row {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}
.bilder-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.bild-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-light);
}
.bild-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.bild-del {
  position: absolute; top: 2px; right: 2px;
  width: 22px; height: 22px;
  background: rgba(0,0,0,0.6); color: #fff;
  border: none; border-radius: 50%;
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-danger-small {
  background: none; border: 1px solid var(--danger);
  color: var(--danger); border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: var(--text-xs);
  cursor: pointer;
}
.btn-danger-small:hover { background: var(--danger-subtle); }

/* ============================================
   TIEFBAU EMAIL PREVIEW
   ============================================ */
.btn-link-small {
  background: none; border: none;
  color: var(--accent-primary);
  font-size: var(--text-xs);
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
}
.btn-link-small:hover { color: var(--accent-hover); }
/* ONKZ Anzeige */
.tb-onkz-wrap {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}
.tb-onkz-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
}
.tb-onkz-label { color: var(--text-muted); }
.tb-onkz-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.tb-onkz-badge.verified {
  background: #059669;
  color: #fff;
}
.tb-onkz-badge.offline {
  background: #d97706;
  color: #fff;
}
.tb-onkz-badge.manual {
  background: var(--accent-primary);
  color: #fff;
}
.tb-onkz-warning {
  font-size: var(--text-xs);
  color: #d97706;
  margin-top: 4px;
  padding: 6px 8px;
  background: rgba(217,119,6,0.08);
  border-radius: var(--radius-sm);
  line-height: 1.4;
}
.tb-onkz-manual {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.tb-onkz-manual input {
  max-width: 160px;
  padding: 5px 8px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* Leitungsdaten Fieldset */
.leitung-fieldset {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: 0;
}
.leitung-fieldset legend {
  font-weight: 600;
  font-size: var(--text-sm);
  padding: 0 var(--space-sm);
  color: var(--text-secondary);
}

/* Leitungsdaten Historie-Hinweis */
.ld-historie {
  margin-top: var(--space-sm);
}
.ld-historie-card {
  background: rgba(14, 165, 233, 0.06);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}
.ld-historie-card .ld-info {
  flex: 1;
  min-width: 0;
}
.ld-historie-card .ld-sm {
  font-weight: 600;
  color: var(--accent-primary);
}
.ld-historie-card .ld-addr {
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ld-historie-card .ld-date {
  color: var(--text-muted);
  font-size: var(--text-xs);
  white-space: nowrap;
}
.ld-historie-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: var(--space-xs);
}
.ld-historie-card .btn-link-small {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Cloud-Suche */
.archiv-cloud-search {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-light);
}
.archiv-cloud-search .form-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Suchvorschläge */
.cloud-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
}
.cloud-suggestions:empty { display: none; }
.cloud-chip {
  background: rgba(99,102,241,0.12);
  color: var(--primary);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 16px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cloud-chip:hover, .cloud-chip:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.chip-count {
  background: rgba(255,255,255,0.25);
  border-radius: 8px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

/* Cloud-Status Badge */
.cloud-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  margin-left: 4px;
}
.cloud-badge.synced { background: #059669; color: #fff; }
.cloud-badge.local { background: #64748b; color: #fff; }

/* Historie Dialog */
.historie-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 301;
  width: calc(100% - 32px);
  max-width: 500px;
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.historie-dialog .settings-header {
  padding: var(--space-lg) var(--space-lg) 0;
  margin-bottom: var(--space-md);
}
.historie-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 var(--space-lg) var(--space-lg);
  flex: 1;
}
.historie-detail {
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.historie-detail-header {
  background: var(--bg-tertiary);
  padding: var(--space-sm) var(--space-md);
  font-weight: 600;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-light);
}
.historie-detail-body {
  padding: var(--space-md);
  font-size: var(--text-sm);
}
.historie-detail-body dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: var(--text-xs);
  margin-top: var(--space-sm);
}
.historie-detail-body dd {
  margin: 0 0 var(--space-xs) 0;
}
.historie-muffe-tag {
  display: inline-block;
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: var(--text-xs);
  margin: 2px;
}
.historie-actions {
  padding: var(--space-md);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
}

.tb-firma-hint {
  margin-top: 4px; padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.4;
  border-left: 3px solid var(--accent-primary);
  background: rgba(14,165,233,0.08);
}
.tb-firma-hint.warn {
  border-left-color: #e67e22;
  background: rgba(230,126,34,0.08);
}
#ent_tiefbauer option.tb-greyed {
  color: #aaa;
}
#ent_tiefbauer option.tb-recommended {
  font-weight: bold;
}
.tb-ort-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: 4px;
}

.tb-email-preview {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  font-size: var(--text-sm);
}
.tb-email-header-row {
  margin-bottom: 4px;
  font-size: var(--text-sm);
}
.tb-email-header-row strong {
  display: inline-block;
  width: 55px;
  color: var(--text-muted);
}
.tb-email-body {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-sm);
  max-height: 300px;
  overflow-y: auto;
  color: var(--text-primary);
}
.tb-email-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* Anhänge */
.tb-attachment-section {
  border-top: 1px solid var(--border-light);
  padding-top: var(--space-sm);
}
.tb-attachment-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.tb-attachment-label strong {
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.btn-attach {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.btn-attach:hover {
  opacity: 0.85;
}
.tb-attachment-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tb-attachment-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
}
.tb-attach-icon {
  flex-shrink: 0;
}
.tb-attach-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}
.tb-attach-size {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.tb-attach-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}
.tb-attach-remove:hover {
  color: #e74c3c;
}
.tb-attachment-warning {
  background: rgba(231,76,60,0.10);
  border: 1px solid rgba(231,76,60,0.35);
  border-left: 3px solid #e74c3c;
  border-radius: var(--radius-sm);
  color: #c0392b;
  padding: 6px 10px;
  font-size: 12px;
  margin-top: 4px;
}

/* Senden-Button */
.btn-send-email {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  background: #27ae60;
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-send-email:hover {
  background: #229954;
}

/* Settings divider + section title */
.settings-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: var(--space-lg) 0 var(--space-md);
}
.settings-section-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

/* ========== SVG Icon Sizing ========== */
.btn-icon svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.sketch-tool svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.dokufall-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.dokufall-icon svg {
  width: 26px;
  height: 26px;
}
.section-num svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.autofill-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}
.autofill-icon svg {
  width: 1.4em;
  height: 1.4em;
}
/* Inline SVGs in text buttons and headings */
.btn-add svg,
.btn-small svg,
.btn-link-small svg,
.archiv-tab-btn svg,
.archiv-new-btn svg,
.archiv-export-btn svg,
.archiv-import-btn svg,
.btn-send-email svg,
.settings-section-title svg,
.archiv-header h2 svg,
.settings-header h2 svg,
.calculate-btn svg,
.sketch-comments strong svg,
.tb-onkz-warning svg,
.tb-attachment-warning svg {
  width: 15px;
  height: 15px;
  vertical-align: -0.2em;
  margin-right: 3px;
  flex-shrink: 0;
}

/* ================== Feedback-Bereich (Bugs & Verbesserungen) ================== */
.feedback-liste {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.feedback-card {
  background: var(--color-bg);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.feedback-card-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.feedback-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.feedback-tag-bug {
  background: #fee2e2;
  color: #b91c1c;
}

.feedback-tag-verbesserung {
  background: #dbeafe;
  color: #1d4ed8;
}

.feedback-date {
  font-size: 11px;
  color: var(--color-muted);
  margin-left: auto;
  white-space: nowrap;
}

.feedback-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--color-muted);
  line-height: 0;
  flex-shrink: 0;
}
.feedback-del-btn:hover { color: var(--color-danger); }
.feedback-del-btn svg { width: 15px; height: 15px; }

.feedback-text {
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.feedback-dokufall {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--color-bg);
  border: 1px solid var(--border-light);
  color: var(--color-muted);
  flex-shrink: 0;
}

.feedback-sektion {
  font-size: 11px;
  color: var(--color-muted);
  font-style: italic;
  margin-top: 2px;
  margin-bottom: 4px;
}

.feedback-screenshot-details summary {
  font-size: 11px;
  color: var(--color-muted);
  cursor: pointer;
  margin-top: 6px;
}

.feedback-screenshot-preview { margin-top: 6px; }

/* ================== Bugfix-Modus ================== */
.bugfix-floating-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--color-surface);
  border: 1.5px solid var(--border-light);
  border-radius: 40px;
  padding: 8px 14px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
}

.bugfix-bar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.bugfix-bar-btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.bugfix-bar-btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.bugfix-bar-btn-primary:hover { opacity: 0.85; }
.bugfix-bar-btn-active {
  background: #f59e0b;
  color: #fff;
}

.bugfix-bar-btn-end {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1.5px solid var(--border-light);
}
.bugfix-bar-btn-end:hover { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }

.bugfix-comment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.3);
  border-radius: 12px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
}

/* Element-Highlight im Bugfix-Modus */
.bugfix-element-highlight {
  outline: 2.5px solid #f59e0b !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 4px rgba(245,158,11,0.2) !important;
  border-radius: 3px;
  position: relative;
  z-index: 9998;
}

.bugfix-element-saved {
  outline: 2px solid #22c55e !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15) !important;
  border-radius: 3px;
}

/* Cursor in Kommentar-Auswahl-Modus */
.bugfix-comment-mode,
.bugfix-comment-mode * {
  cursor: crosshair !important;
}
/* Aber Floating-Bar-Buttons behalten Pointer */
.bugfix-comment-mode .bugfix-floating-bar,
.bugfix-comment-mode .bugfix-floating-bar * {
  cursor: pointer !important;
}

/* Kommentar-Dialog */
.bugfix-comment-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 10001;
}

.bugfix-comment-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10002;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: min(92vw, 400px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}

.bugfix-comment-dialog-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 12px 0;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 7px;
}
.bugfix-comment-dialog-title svg { width: 18px; height: 18px; color: var(--color-primary); }

.bugfix-comment-target {
  font-size: 0.82rem;
  background: var(--color-bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  margin-bottom: 10px;
  color: var(--color-text);
  word-break: break-word;
  min-height: 1.5em;
}
.bugfix-comment-target:empty { display: none; }
.bugfix-comment-sektion {
  font-size: 0.78rem;
  color: var(--color-muted);
  font-style: italic;
}

.bugfix-comment-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

.bugfix-comment-btn-cancel,
.bugfix-comment-btn-save {
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.bugfix-comment-btn-cancel {
  background: var(--color-bg);
  color: var(--color-muted);
  border: 1.5px solid var(--border-light);
}
.bugfix-comment-btn-cancel:hover { color: var(--color-text); }
.bugfix-comment-btn-save {
  background: var(--color-primary);
  color: #fff;
}
.bugfix-comment-btn-save:hover { opacity: 0.85; }

/* ======================================================
   PC-OPTIMIERTES LAYOUT (Wide Screen ≥960px)
   Zwei-Spalten: Links = docForm, Rechts = Sektion 9
   ====================================================== */
@media (min-width: 960px) {
  main {
    max-width: 1400px;
    padding: var(--space-lg) var(--space-xl);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--space-xl);
    align-items: start;
  }

  #docForm {
    grid-column: 1;
  }

  #sec_instandsetzung {
    grid-column: 2;
  }

  /* Dokufall-Selektor und Arbeitsmodus: volle Breite und zentriert */
  #sec_dokufall,
  #sec_arbeitsmodus {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
  }
}
