/* ========================================================================
   FINORA RECHNUNGEN — Pure HTML/CSS Stylesheet
   No JavaScript. All popups via :target pseudo-class.
   Namespace: .rl-* (Rechnung Layout)
   ======================================================================== */

@import url("https://api.fontshare.com/v2/css?f[]=satoshi@1,2&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");

/* ========================================================================
   DESIGN TOKENS
   ======================================================================== */
:root {
  --rl-blue: #2c6cf6;
  --rl-blue-dark: #1f57d4;
  --rl-blue-soft: #eaf1ff;
  --rl-text: #0f172a;
  --rl-text-2: #334155;
  --rl-muted: #64748b;
  --rl-muted-2: #94a3b8;
  --rl-border: rgba(15, 23, 42, 0.08);
  --rl-border-strong: rgba(15, 23, 42, 0.14);
  --rl-bg: #f4f6f9;
  --rl-bg-2: #eef1f5;
  --rl-white: #ffffff;
  --rl-paper: #fdfdfd;

  --rl-green: #16a34a;
  --rl-green-soft: #dcfce7;
  --rl-red: #ef4444;
  --rl-red-soft: #fee2e2;
  --rl-amber: #f59e0b;
  --rl-amber-soft: #fef3c7;

  --rl-radius-sm: 8px;
  --rl-radius: 12px;
  --rl-radius-lg: 18px;
  --rl-radius-xl: 24px;

  --rl-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);
  --rl-shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
  --rl-shadow-md: 0 12px 32px -8px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
  --rl-shadow-xl: 0 30px 80px -30px rgba(15, 23, 42, 0.35), 0 10px 24px -10px rgba(15, 23, 42, 0.18);

  --rl-grad-blue: linear-gradient(135deg, #4f8bff 0%, #2c6cf6 50%, #1f57d4 100%);
  --rl-grad-purple: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  --rl-grad-mesh: radial-gradient(900px 500px at 100% 0%, rgba(44, 108, 246, 0.08), transparent 60%),
                  radial-gradient(700px 400px at 0% 100%, rgba(139, 92, 246, 0.06), transparent 65%);

  --rl-font: "Satoshi", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --rl-sidebar-w: 232px;
  --rl-topbar-h: 64px;
}

/* ========================================================================
   BASE RESET
   ======================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body.rl-body {
  font-family: var(--rl-font);
  color: var(--rl-text);
  background: var(--rl-bg);
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
ul, ol { list-style: none; }
img, svg { display: block; max-width: 100%; }

/* ========================================================================
   SHELL — main 2-column layout
   ======================================================================== */
.rl-shell {
  display: grid;
  grid-template-columns: var(--rl-sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--rl-bg);
  background-image: var(--rl-grad-mesh);
}

/* ========================================================================
   SIDEBAR
   ======================================================================== */
.rl-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--rl-border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  z-index: 20;
}
.rl-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
}
.rl-logo-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--rl-grad-blue);
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 6px 14px -4px rgba(44, 108, 246, 0.45);
  position: relative;
  overflow: hidden;
}
.rl-logo-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent 50%);
  pointer-events: none;
}
.rl-brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--rl-text);
}

.rl-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rl-nav-divider { height: 1px; background: #e8edf3; margin: 6px 12px; }
.rl-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--rl-text-2);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.rl-nav-item:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-nav-item--active {
  background: var(--rl-blue-soft);
  color: var(--rl-blue);
  font-weight: 600;
}
.rl-nav-item--active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--rl-blue);
  border-radius: 0 3px 3px 0;
}
.rl-nav-icon { width: 17px; height: 17px; flex: none; opacity: .85; }
.rl-nav-item--active .rl-nav-icon { opacity: 1; }
.rl-nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--rl-blue);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* sidebar footer */
.rl-sidebar-foot {
  border-top: 1px solid var(--rl-border);
  padding-top: 10px;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rl-sidebar-company {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rl-text);
}
.rl-sidebar-foot-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--rl-muted);
  position: relative;
}
.rl-sidebar-foot-link:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-sidebar-foot-link svg { width: 14px; height: 14px; }
.rl-update-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: auto;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  animation: rl-pulse 2.4s ease-in-out infinite;
}
@keyframes rl-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18); }
  50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.06); }
}

/* ========================================================================
   MAIN
   ======================================================================== */
.rl-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ========================================================================
   TOPBAR
   ======================================================================== */
.rl-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: var(--rl-topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 26px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rl-border);
}
.rl-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.rl-tabs::-webkit-scrollbar { display: none; }
.rl-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  height: var(--rl-topbar-h);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--rl-muted);
  position: relative;
  white-space: nowrap;
  transition: color .15s ease;
}
.rl-tab svg { width: 14px; height: 14px; opacity: .8; }
.rl-tab:hover { color: var(--rl-text); }
.rl-tab--active { color: var(--rl-blue); font-weight: 600; }
.rl-tab--active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  background: var(--rl-blue);
  border-radius: 2px 2px 0 0;
}

.rl-search {
  flex: 0 1 320px;
  min-width: 180px;
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--rl-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background .15s ease, border-color .15s ease;
}
.rl-search:focus-within {
  background: white;
  border-color: var(--rl-blue);
  box-shadow: 0 0 0 3px rgba(44, 108, 246, 0.15);
}
.rl-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--rl-muted); }
.rl-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--rl-text);
}
.rl-search input::placeholder { color: var(--rl-muted-2); }
.rl-kbd {
  background: white;
  color: var(--rl-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--rl-border);
  letter-spacing: .04em;
}

.rl-bell {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--rl-text-2);
  transition: background .15s ease;
}
.rl-bell:hover { background: var(--rl-bg-2); }
.rl-bell svg { width: 18px; height: 18px; }
.rl-bell-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--rl-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid white;
}
/* ========================================================================
   USER MENU — details/summary dropdown, pure CSS, zero JS
   ======================================================================== */
.rl-user-menu {
  position: relative;
  flex-shrink: 0;
}
.rl-user-menu > summary { list-style: none; }
.rl-user-menu > summary::-webkit-details-marker { display: none; }

.rl-user-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: 13px;
  border: 1px solid var(--rl-border);
  background: #ffffff;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, border-color .18s ease, box-shadow .18s ease;
  white-space: nowrap;
}
.rl-user-btn:hover {
  background: var(--rl-bg);
  border-color: var(--rl-border-strong);
  box-shadow: 0 2px 8px rgba(15,23,42,.07);
}
.rl-user-menu[open] > .rl-user-btn {
  background: var(--rl-bg);
  border-color: var(--rl-blue);
  box-shadow: 0 0 0 3px rgba(44,108,246,.12);
}

.rl-user-avatar-lg {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.rl-user-info-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.rl-user-name-top {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--rl-text);
  line-height: 1.2;
}
.rl-user-company-top {
  font-size: 10.5px;
  color: var(--rl-muted);
  font-weight: 400;
  line-height: 1.2;
}

.rl-user-chevron {
  width: 13px;
  height: 13px;
  color: var(--rl-muted-2);
  flex-shrink: 0;
  transition: transform .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rl-user-menu[open] > .rl-user-btn .rl-user-chevron {
  transform: rotate(180deg);
}

/* ── Dropdown card ── */
.rl-user-dropdown {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  width: 268px;
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid var(--rl-border);
  box-shadow:
    0 0 0 1px rgba(15,23,42,.04),
    0 8px 24px -6px rgba(15,23,42,.14),
    0 32px 64px -20px rgba(15,23,42,.22);
  overflow: hidden;
  z-index: 500;
  animation: rl-drop-in .26s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transform-origin: top right;
}

@keyframes rl-drop-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}

/* ── Dropdown header ── */
.rl-udrop-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 16px 14px;
  background: linear-gradient(135deg, #f8faff 0%, #eef2ff 100%);
  border-bottom: 1px solid var(--rl-border);
}

.rl-udrop-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .04em;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(15,23,42,.28);
}

.rl-udrop-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rl-udrop-fullname {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--rl-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rl-udrop-role {
  font-size: 11px;
  color: var(--rl-blue);
  font-weight: 600;
  margin-top: 2px;
}
.rl-udrop-email {
  font-size: 10.5px;
  color: var(--rl-muted);
  font-weight: 400;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rl-udrop-online {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--rl-green);
  font-weight: 600;
  margin-top: 4px;
}
.rl-udrop-online::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rl-green);
  box-shadow: 0 0 0 2px rgba(22,163,74,.2);
  animation: rl-pulse-green 2s ease infinite;
}
@keyframes rl-pulse-green {
  0%, 100% { box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
  50%       { box-shadow: 0 0 0 4px rgba(22,163,74,.35); }
}

/* ── Nav sections ── */
.rl-udrop-nav {
  padding: 6px;
}

.rl-udrop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--rl-text-2);
  transition: background .12s ease, color .12s ease, transform .1s ease;
  cursor: pointer;
  position: relative;
}
.rl-udrop-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--rl-muted);
  transition: color .12s ease;
}
.rl-udrop-item:hover {
  background: var(--rl-blue-soft);
  color: var(--rl-blue);
  transform: translateX(2px);
}
.rl-udrop-item:hover svg { color: var(--rl-blue); }

.rl-udrop-item--danger { color: var(--rl-red); }
.rl-udrop-item--danger svg { color: var(--rl-red); opacity: .8; }
.rl-udrop-item--danger:hover {
  background: var(--rl-red-soft);
  color: var(--rl-red);
  transform: translateX(2px);
}
.rl-udrop-item--danger:hover svg { color: var(--rl-red); opacity: 1; }

/* "Pro" badge in menu item */
.rl-udrop-badge {
  margin-left: auto;
  background: var(--rl-grad-blue);
  color: #fff;
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.rl-udrop-section-sep {
  height: 1px;
  background: var(--rl-border);
  margin: 4px 10px;
}

/* ── Footer strip ── */
.rl-udrop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--rl-bg);
  border-top: 1px solid var(--rl-border);
}
.rl-udrop-foot-version {
  font-size: 10px;
  color: var(--rl-muted-2);
  font-weight: 500;
  letter-spacing: .02em;
}
.rl-udrop-foot-status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--rl-green);
  font-weight: 600;
}
.rl-udrop-foot-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--rl-green);
}

/* ========================================================================
   PAGE HEAD
   ======================================================================== */
.rl-page-head {
  padding: 22px 26px 14px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.rl-page-head-left h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--rl-text);
}
.rl-page-head-left p {
  margin-top: 3px;
  font-size: 13px;
  color: var(--rl-muted);
}
.rl-page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.rl-search-local {
  position: relative;
  width: 240px;
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 12px 0 36px;
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: 10px;
}
.rl-search-local svg { position: absolute; left: 12px; width: 14px; height: 14px; color: var(--rl-muted); }
.rl-search-local input { flex: 1; background: transparent; border: none; outline: none; font-size: 13px; }
.rl-search-local input::placeholder { color: var(--rl-muted-2); }

/* ========================================================================
   BUTTONS
   ======================================================================== */
.rl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
  border: 1px solid transparent;
}
.rl-btn svg { width: 15px; height: 15px; }
.rl-btn:active { transform: translateY(1px); }

.rl-btn--ghost {
  color: var(--rl-text-2);
  border-color: var(--rl-border);
  background: white;
}
.rl-btn--ghost:hover { background: var(--rl-bg-2); border-color: var(--rl-border-strong); color: var(--rl-text); }

.rl-btn--soft {
  color: var(--rl-text);
  background: var(--rl-bg-2);
}
.rl-btn--soft:hover { background: #e2e8f0; }

.rl-btn--primary {
  color: white;
  background: var(--rl-grad-blue);
  box-shadow: 0 6px 18px -6px rgba(44, 108, 246, 0.55), inset 0 1px 0 rgba(255,255,255,0.18);
  position: relative;
  overflow: hidden;
}
.rl-btn--primary:hover {
  box-shadow: 0 10px 22px -8px rgba(44, 108, 246, 0.65), inset 0 1px 0 rgba(255,255,255,0.22);
  transform: translateY(-1px);
}
.rl-btn--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.25), transparent 70%);
  transform: translateX(-100%);
  transition: transform .6s ease;
}
.rl-btn--primary:hover::after { transform: translateX(100%); }

.rl-btn--danger {
  color: white;
  background: var(--rl-red);
}
.rl-btn--danger:hover { background: #dc2626; }

.rl-btn--split {
  display: inline-flex;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 18px -6px rgba(44, 108, 246, 0.55);
}
.rl-btn--split .rl-btn { box-shadow: none; border-radius: 0; }
.rl-btn--split-divider {
  background: var(--rl-grad-blue);
  width: 1px;
  opacity: 0.4;
}
.rl-btn--split .rl-btn-caret {
  background: var(--rl-grad-blue);
  color: white;
  display: grid;
  place-items: center;
  width: 32px;
  height: 38px;
  border: none;
  cursor: pointer;
}

.rl-btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  transition: background .15s ease, color .15s ease;
}
.rl-btn-icon:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-btn-icon svg { width: 16px; height: 16px; }

/* ========================================================================
   3-COL GRID (rechnungen.html)
   ======================================================================== */
.rl-grid {
  display: grid;
  grid-template-columns: 270px 1fr 380px;
  gap: 16px;
  padding: 0 26px 26px;
  align-items: start;
}

.rl-col-folders, .rl-col-list, .rl-col-preview { min-width: 0; }

/* ========================================================================
   PANELS (folders / customers)
   ======================================================================== */
.rl-panel {
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  overflow: hidden;
}
.rl-panel + .rl-panel { margin-top: 14px; }
.rl-panel-head {
  padding: 14px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--rl-border);
}
.rl-panel-head h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--rl-text);
  letter-spacing: -0.005em;
}
.rl-panel-add {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  background: var(--rl-bg);
  transition: background .15s ease, color .15s ease;
}
.rl-panel-add:hover { background: var(--rl-blue); color: white; }
.rl-panel-add svg { width: 14px; height: 14px; }
.rl-panel-list { padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.rl-panel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--rl-text-2);
  position: relative;
  transition: background .12s ease, color .12s ease;
}
.rl-panel-item:hover { background: var(--rl-bg); color: var(--rl-text); }
.rl-panel-item--active {
  background: var(--rl-blue-soft);
  color: var(--rl-blue);
  font-weight: 600;
}
.rl-panel-item--active .rl-panel-item-count {
  background: var(--rl-blue);
  color: white;
}
.rl-panel-item-icon { width: 16px; height: 16px; flex: none; opacity: .8; }
.rl-panel-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-panel-item-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--rl-muted);
  background: var(--rl-bg);
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}
.rl-panel-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  margin: 4px 6px 8px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--rl-blue);
  border: 1px dashed rgba(44, 108, 246, 0.3);
  transition: background .15s ease, border-color .15s ease;
}
.rl-panel-add-row:hover { background: var(--rl-blue-soft); border-color: var(--rl-blue); }
.rl-panel-add-row svg { width: 12px; height: 12px; }

/* ========================================================================
   INVOICE LIST TABLE
   ======================================================================== */
.rl-list-card {
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  overflow: hidden;
}
.rl-list-head {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--rl-border);
}
.rl-list-head h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--rl-text);
}
.rl-list-head-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--rl-muted);
}
.rl-table-shell {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
}
.rl-table-shell::-webkit-scrollbar { display: none; }
.rl-table {
  width: 100%;
  min-width: 760px;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12.5px;
}
.rl-table th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--rl-muted);
  padding: 10px 12px;
  background: var(--rl-bg);
  border-bottom: 1px solid var(--rl-border);
  position: sticky;
  top: 0;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}
.rl-table th.rl-th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.rl-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  color: var(--rl-text);
  vertical-align: middle;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rl-table th:nth-child(1), .rl-table td:nth-child(1) { width: 26%; }
.rl-table th:nth-child(2), .rl-table td:nth-child(2) { width: 19%; }
.rl-table th:nth-child(3), .rl-table td:nth-child(3) { width: 90px; }
.rl-table th:nth-child(4), .rl-table td:nth-child(4) { width: 102px; }
.rl-table th:nth-child(5), .rl-table td:nth-child(5) { width: 104px; }
.rl-table th:nth-child(6), .rl-table td:nth-child(6) {
  width: 136px;
  overflow: visible;
}
.rl-table tr:last-child td { border-bottom: none; }
.rl-table tr.rl-row-active td { background: var(--rl-blue-soft); }
.rl-table tbody tr { transition: background .12s ease; }
.rl-table tbody tr:hover { background: rgba(44, 108, 246, 0.04); cursor: pointer; }

.rl-cell-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--rl-text);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-cell-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-cell-lock {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  flex: none;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.28);
}
.rl-cell-lock svg {
  width: 14px;
  height: 14px;
}
.rl-pdf-icon {
  width: 24px;
  height: 30px;
  border-radius: 4px;
  background: linear-gradient(135deg, #fff5f5, #fee2e2);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--rl-red);
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: -0.02em;
  position: relative;
  flex: none;
}
.rl-pdf-icon::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: linear-gradient(225deg, transparent 50%, rgba(239, 68, 68, 0.15) 50%);
}
.rl-cell-customer,
.rl-cell-date {
  color: var(--rl-text-2);
  overflow: hidden;
  text-overflow: ellipsis;
}
.rl-cell-link {
  color: inherit;
  text-decoration: none;
  font-weight: 650;
}
.rl-cell-link:hover { color: var(--rl-blue); text-decoration: underline; }
.rl-cell-amount {
  font-weight: 600;
  color: var(--rl-text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.rl-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.rl-status--paid { background: var(--rl-green-soft); color: #166534; }
.rl-status--paid::before { background: var(--rl-green); }
.rl-status--open { background: var(--rl-blue-soft); color: var(--rl-blue-dark); }
.rl-status--open::before { background: var(--rl-blue); }
.rl-status--overdue { background: var(--rl-red-soft); color: #b91c1c; }
.rl-status--overdue::before { background: var(--rl-red); }
.rl-status--draft { background: var(--rl-bg-2); color: var(--rl-muted); }
.rl-status--draft::before { background: var(--rl-muted); }

.rl-cell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 128px;
  white-space: nowrap;
}
.rl-action {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.rl-action:hover { background: var(--rl-blue-soft); color: var(--rl-blue); }
.rl-action svg { width: 16px; height: 16px; }
.rl-action--locked {
  color: #64748b;
  background: #f8fafc;
}
.rl-action--locked:hover {
  background: #eef4ff;
  color: var(--rl-blue-dark);
}

/* pagination */
.rl-pagination {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--rl-muted);
  border-top: 1px solid var(--rl-border);
}
.rl-pages { display: flex; align-items: center; gap: 4px; }
.rl-page {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rl-text-2);
  transition: background .12s ease, color .12s ease;
}
.rl-page:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-page--active { background: var(--rl-blue); color: white; }
.rl-page--active:hover { background: var(--rl-blue-dark); color: white; }
.rl-page--ellipsis { cursor: default; pointer-events: none; }
.rl-page svg { width: 13px; height: 13px; }

/* ========================================================================
   PREVIEW PANE (right side of rechnungen.html)
   ======================================================================== */
.rl-preview {
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: calc(var(--rl-topbar-h) + 16px);
  max-height: calc(100vh - var(--rl-topbar-h) - 32px);
}
.rl-preview-head {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--rl-border);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
}
.rl-preview-head h3 {
  font-size: 13px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-preview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex: none;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}
.rl-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--rl-border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--rl-text-2);
  transition: background .12s ease, border-color .12s ease;
}
.rl-preview-btn:hover { background: var(--rl-bg-2); border-color: var(--rl-border-strong); }
.rl-preview-btn svg { width: 13px; height: 13px; }
.rl-preview-btn--primary {
  background: var(--rl-blue);
  color: white;
  border-color: var(--rl-blue);
}
.rl-preview-btn--primary:hover { background: var(--rl-blue-dark); border-color: var(--rl-blue-dark); }
.rl-preview-more {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--rl-border);
  display: grid;
  place-items: center;
  color: var(--rl-muted);
}
.rl-preview-more:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-preview-more svg { width: 14px; height: 14px; }

.rl-preview-lock {
  margin-left: auto;
  margin-right: 8px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef4ff;
  border: 1px solid rgba(44, 108, 246, .18);
  color: var(--rl-blue-dark);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  flex: none;
}

.rl-preview-lock[hidden] {
  display: none;
}

.rl-preview-body {
  flex: 1;
  overflow: auto;
  padding: 18px;
  background:
    repeating-conic-gradient(rgba(15, 23, 42, 0.018) 0% 25%, transparent 0% 50%) 0 0/14px 14px,
    var(--rl-bg);
}

/* BLANK invoice paper — vlad fills himself */
.rl-paper-blank {
  background: white;
  width: 100%;
  aspect-ratio: 1 / 1.41421356;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.04),
    0 12px 32px -8px rgba(15, 23, 42, 0.18),
    0 30px 60px -30px rgba(15, 23, 42, 0.25);
  position: relative;
  overflow: hidden;
}

.rl-paper-blank:has(.rl-live-paper) {
  aspect-ratio: auto;
  overflow: visible;
}

.rl-paper-blank:has(.rl-template-paper-stack) {
  aspect-ratio: auto;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.rl-paper-blank::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--rl-grad-blue);
  opacity: 0;
  transition: opacity .25s ease;
}
.rl-paper-blank:hover::before { opacity: 1; }
.rl-paper-blank:has(.rl-template-paper-stack)::before { display: none; }
.rl-paper-blank--draft::after {
  content: "ENTWURF";
  position: absolute;
  top: 14px;
  right: 14px;
  background: var(--rl-green-soft);
  color: #166534;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
}

.rl-preview-zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--rl-border);
  background: white;
}
.rl-zoom-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--rl-bg);
  color: var(--rl-text-2);
  font-size: 14px;
  font-weight: 600;
  transition: background .12s ease;
}
.rl-zoom-btn:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-zoom-btn svg { width: 13px; height: 13px; }
.rl-zoom-level {
  min-width: 56px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--rl-text-2);
  padding: 0 8px;
}

/* ========================================================================
   CREATE PAGE (rechnung-neu.html)
   ======================================================================== */
.rl-create-head {
  padding: 22px 26px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rl-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--rl-muted);
  align-self: flex-start;
  padding: 4px 8px;
  margin-left: -8px;
  border-radius: 7px;
  transition: background .12s ease, color .12s ease;
}
.rl-back-link:hover { background: var(--rl-bg-2); color: var(--rl-text); }
.rl-back-link svg { width: 14px; height: 14px; }
.rl-create-head h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--rl-text);
}
.rl-create-head p {
  font-size: 13.5px;
  color: var(--rl-muted);
}

.rl-create-grid {
  display: grid;
  grid-template-columns: minmax(360px, .82fr) minmax(0, 1.18fr);
  gap: 16px;
  padding: 0 26px 26px;
  align-items: start;
  max-width: 100%;
}

/* ========================================================================
   CHAT PANE
   ======================================================================== */
.rl-chat {
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 720px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.rl-create-grid > .rl-chat,
.rl-chat:has(.rl-invoice-editor--ai) {
  min-height: 0;
  height: min(760px, calc(100vh - 158px));
  max-height: calc(100vh - 158px);
}
.rl-chat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #8b5cf6, #2c6cf6, #06b6d4);
  background-size: 200% 100%;
  animation: rl-shimmer 8s ease-in-out infinite;
}
@keyframes rl-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.rl-chat-stream {
  flex: 1;
  min-height: 0;
  padding: 24px 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.rl-chat-msg { display: flex; gap: 12px; max-width: 100%; }
.rl-chat-msg--user { flex-direction: row-reverse; align-self: flex-end; max-width: 80%; }
.rl-chat-msg--ai { align-self: flex-start; max-width: 88%; }

.rl-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--rl-grad-purple);
  color: white;
  display: grid;
  place-items: center;
  flex: none;
  position: relative;
  box-shadow: 0 6px 14px -4px rgba(139, 92, 246, 0.5);
}
.rl-chat-avatar svg { width: 16px; height: 16px; }
.rl-chat-avatar::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  background: var(--rl-grad-purple);
  opacity: .25;
  filter: blur(8px);
  z-index: -1;
}
.rl-chat-msg--user .rl-chat-avatar { display: none; }

.rl-chat-bubble-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rl-chat-msg--user .rl-chat-bubble-wrap { align-items: flex-end; }
.rl-chat-name {
  font-size: 11.5px;
  font-weight: 700;
  color: #6d28d9;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.rl-chat-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--rl-text);
  background: var(--rl-bg);
  white-space: pre-wrap;
}
.rl-chat-msg--ai .rl-chat-bubble {
  border-top-left-radius: 4px;
}
.rl-chat-msg--user .rl-chat-bubble {
  background: var(--rl-blue-soft);
  color: var(--rl-text);
  border-top-right-radius: 4px;
}

.rl-chat-attachments {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 2px;
}
.rl-chat-attachment {
  width: 72px;
  height: 72px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 12px;
  overflow: hidden;
  background: white;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 8px 20px -16px rgba(15, 23, 42, 0.35);
}
.rl-chat-attachment img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rl-chat-bubble--thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 136px;
  color: var(--rl-muted);
}
.rl-chat-avatar--thinking svg {
  animation: rl-thinking-pulse 1.6s ease-in-out infinite;
}
.rl-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}
.rl-thinking-dots span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  opacity: .35;
  animation: rl-thinking-dot 1.2s ease-in-out infinite;
}
.rl-thinking-dots span:nth-child(2) { animation-delay: .16s; }
.rl-thinking-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes rl-thinking-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: .32; }
  40% { transform: translateY(-4px); opacity: .9; }
}
@keyframes rl-thinking-pulse {
  0%, 100% { transform: scale(1); opacity: .85; }
  50% { transform: scale(1.08); opacity: 1; }
}
.rl-chat-time {
  font-size: 11px;
  color: var(--rl-muted-2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.rl-chat-time svg { width: 12px; height: 12px; color: var(--rl-blue); }

/* summary card inside chat */
.rl-chat-summary {
  margin-top: 6px;
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--rl-shadow-sm);
}
.rl-summary-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--rl-border);
}
.rl-summary-row:last-child { border-bottom: none; }
.rl-summary-row--total {
  background: var(--rl-blue-soft);
  font-weight: 700;
  color: var(--rl-blue-dark);
}
.rl-summary-key { color: var(--rl-muted); font-size: 12px; }
.rl-summary-val { color: var(--rl-text); font-weight: 500; }
.rl-summary-val ul { display: flex; flex-direction: column; gap: 4px; }
.rl-summary-val li {
  position: relative;
  padding-left: 14px;
  font-size: 13px;
}
.rl-summary-val li::before {
  content: "•";
  position: absolute;
  left: 4px;
  color: var(--rl-blue);
  font-weight: 700;
}

.rl-chat-quickrow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.rl-chat-quickbtn {
  padding: 6px 12px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--rl-border);
  font-size: 12px;
  font-weight: 500;
  color: var(--rl-text-2);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.rl-chat-quickbtn:hover {
  background: var(--rl-blue-soft);
  border-color: var(--rl-blue);
  color: var(--rl-blue);
}

.rl-chat-input-wrap {
  padding: 14px 18px 12px;
  border-top: 1px solid var(--rl-border);
  background: white;
}
.rl-chat-saved-files {
  padding: 0 18px 12px;
  background: white;
}
.rl-chat-saved-files .rl-template-strip-head {
  margin-bottom: 8px;
}
.rl-chat-saved-files .rl-template-strip-head span {
  font-size: 11.5px;
}
.rl-chat-file-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  padding: 2px 2px 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.rl-chat-file-preview-card {
  position: relative;
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  border-radius: 14px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  background: #f8fafc;
  box-shadow: 0 10px 22px -18px rgba(15, 23, 42, 0.42);
}
.rl-chat-file-preview-card img,
.rl-chat-file-preview-fallback {
  width: 100%;
  height: 100%;
  border-radius: 13px;
}
.rl-chat-file-preview-card img {
  display: block;
  object-fit: cover;
}
.rl-chat-file-preview-fallback {
  display: grid;
  place-items: center;
  color: var(--rl-blue);
  background: var(--rl-blue-soft);
  font-size: 12px;
  font-weight: 800;
}
.rl-chat-file-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: 0 8px 18px -10px rgba(15, 23, 42, 0.42);
}
.rl-chat-file-remove:hover {
  color: #b91c1c;
  border-color: rgba(248, 113, 113, 0.45);
}
.rl-chat-file-remove svg {
  width: 14px;
  height: 14px;
}
.rl-chat-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border: 1.5px solid var(--rl-blue);
  border-radius: 14px;
  background: white;
  box-shadow: 0 0 0 4px rgba(44, 108, 246, 0.1);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.rl-chat-input:focus-within {
  border-color: var(--rl-blue-dark);
  box-shadow: 0 0 0 4px rgba(44, 108, 246, 0.18);
}
.rl-chat-input textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 32px;
  max-height: 220px;
  overflow-y: hidden;
  background: transparent;
  color: var(--rl-text);
}
.rl-chat-input textarea::placeholder { color: var(--rl-muted-2); }
.rl-chat-input-attach {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  background: var(--rl-bg);
  transition: background .12s ease, color .12s ease;
}
.rl-chat-input-attach:hover { background: var(--rl-blue-soft); color: var(--rl-blue); }
.rl-chat-input-attach svg { width: 14px; height: 14px; }
.rl-chat-send {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--rl-grad-blue);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 10px -2px rgba(44, 108, 246, 0.5);
}
.rl-chat-send svg { width: 14px; height: 14px; }

.rl-chat-quickstart {
  padding: 10px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rl-chat-quickstart-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--rl-muted);
  font-size: 11.5px;
}
.rl-chat-quickstart-divider::before,
.rl-chat-quickstart-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rl-border);
}
.rl-chat-quickstart-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.rl-chat-qsbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 12px;
  border-radius: 10px;
  background: white;
  border: 1px solid var(--rl-border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--rl-text-2);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.rl-chat-qsbtn:hover {
  background: var(--rl-blue-soft);
  border-color: var(--rl-blue);
  color: var(--rl-blue);
}
.rl-chat-qsbtn svg { width: 14px; height: 14px; }

/* invoice editor inside rechnung-neu.html */
.rl-invoice-editor {
  min-height: 720px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.rl-invoice-mode-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 0;
  flex-wrap: wrap;
}
.rl-invoice-mode-tabs > span {
  color: var(--rl-muted);
  font-size: 12px;
  font-weight: 650;
}
.rl-invoice-editor--ai {
  background: #ffffff;
  position: relative;
  overflow: hidden;
  min-height: 0;
  height: 100%;
}
.rl-invoice-editor-head--ai {
  padding-top: 18px;
}
.rl-ai-context-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px 2px;
}
.rl-ai-context-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--rl-border);
  border-radius: 999px;
  background: #fff;
  color: var(--rl-text-2);
  font-size: 12px;
  font-weight: 650;
}
.rl-ai-context-row b {
  color: var(--rl-muted);
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.rl-chat-stream--invoice-ai {
  flex: 1 1 auto;
  min-height: 0;
  padding-top: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.rl-ai-choice-overlay {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 104px;
  z-index: 30;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.rl-ai-choice-card {
  width: min(760px, 100%);
  border-radius: 24px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow:
    0 34px 90px -28px rgba(15, 23, 42, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.8) inset;
  padding: 18px 18px 16px;
  pointer-events: auto;
}
.rl-ai-choice-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.rl-ai-choice-head h3 {
  max-width: 560px;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: 0;
}
.rl-ai-choice-counter {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #64748b;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.rl-ai-choice-counter button {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 25px;
  line-height: 1;
}
.rl-ai-choice-counter button:hover {
  color: #0f172a;
  background: rgba(59, 130, 246, 0.08);
}
.rl-ai-choice-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 16px;
}
.rl-ai-choice-option {
  width: 100%;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border-radius: 14px;
  color: #0f172a;
  text-align: left;
  border: 1px solid transparent;
}
.rl-ai-choice-option:hover,
.rl-ai-choice-option--active {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.28);
}
.rl-ai-choice-number {
  color: #94a3b8;
  font-size: 16px;
  font-weight: 700;
}
.rl-ai-choice-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rl-ai-choice-main strong {
  color: #0f172a;
  font-size: 15px;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-ai-choice-main small {
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-ai-choice-score {
  min-width: 34px;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.rl-ai-choice-empty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.95);
  color: #64748b;
}
.rl-ai-choice-empty strong { color: #0f172a; }
.rl-ai-choice-answer {
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border-radius: 14px;
  border: 1px solid rgba(203, 213, 225, 0.95);
  background: #ffffff;
  color: #0f172a;
  font: inherit;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
  outline: none;
  padding: 0 14px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}
.rl-ai-choice-answer::placeholder { color: #94a3b8; }
.rl-ai-choice-answer:focus {
  border-color: rgba(59, 130, 246, 0.75);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}
.rl-ai-choice-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.rl-ai-choice-dismiss {
  color: #64748b;
  font-size: 14px;
  font-weight: 650;
  padding: 8px 6px;
}
.rl-ai-choice-dismiss:hover { color: #0f172a; }
.rl-ai-choice-key {
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
  font-size: 13px;
  font-weight: 750;
}
.rl-ai-choice-continue {
  min-height: 38px;
  padding: 0 18px;
  border-radius: 18px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 14px;
  font-weight: 750;
  box-shadow: inset 0 -8px 0 rgba(30, 64, 175, 0.16);
}
.rl-ai-choice-continue:hover { background: #2563eb; }
.rl-ai-choice-continue:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.rl-invoice-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--rl-border);
  background:
    radial-gradient(520px 220px at 100% 0%, rgba(44, 108, 246, .10), transparent 64%),
    linear-gradient(180deg, #ffffff 0%, #f5f8ff 100%);
}
.rl-editor-eyebrow {
  display: inline-flex;
  margin-bottom: 5px;
  color: var(--rl-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.rl-invoice-editor-head h2 {
  color: var(--rl-text);
  font-size: 23px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: 0;
}
.rl-invoice-editor-head p {
  margin-top: 6px;
  color: var(--rl-muted);
  font-size: 13px;
}
.rl-invoice-status {
  flex: none;
  min-width: 118px;
  padding: 9px 12px;
  border: 1px solid rgba(44, 108, 246, .18);
  border-radius: 12px;
  background: rgba(255, 255, 255, .82);
  color: var(--rl-blue);
  box-shadow: 0 10px 24px -18px rgba(44, 108, 246, .65);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}
.rl-invoice-status b {
  display: block;
  color: var(--rl-text);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.rl-invoice-status--locked,
.rl-invoice-status--sent {
  border-color: rgba(22, 163, 74, .22);
  color: #15803d;
  background: rgba(240, 253, 244, .86);
}
.rl-invoice-status--overdue,
.rl-invoice-status--canceled {
  border-color: rgba(239, 68, 68, .2);
  color: #b91c1c;
  background: rgba(254, 242, 242, .9);
}
.rl-editor-lock-note,
.rl-editor-info-note {
  margin: 16px 18px 0;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid rgba(44, 108, 246, .14);
  background: #f8fbff;
  color: var(--rl-muted);
  font-size: 13px;
}
.rl-editor-lock-note {
  border-color: rgba(22, 163, 74, .22);
  background: #f0fdf4;
}
.rl-editor-lock-note strong {
  display: block;
  margin-bottom: 3px;
  color: #166534;
  font-size: 13px;
}
.rl-invoice-editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  overflow: auto;
}
.rl-editor-section {
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 16px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--rl-shadow-sm);
  overflow: hidden;
}
.rl-editor-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--rl-border);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}
.rl-editor-section-head span {
  display: block;
  margin-bottom: 2px;
  color: var(--rl-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}
.rl-editor-section-head strong {
  color: var(--rl-text);
  font-size: 14px;
}
.rl-editor-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.rl-editor-grid--customer {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.rl-editor-grid--invoice {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.rl-editor-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.rl-editor-field--wide {
  grid-column: span 2;
}
.rl-editor-field span,
.rl-line-total span {
  color: var(--rl-muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}
.rl-editor-input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(203, 213, 225, .86);
  border-radius: 11px;
  background: #ffffff;
  color: var(--rl-text);
  font-size: 13.5px;
  font-weight: 550;
  outline: none;
  padding: 10px 11px;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
textarea.rl-editor-input {
  resize: vertical;
  line-height: 1.45;
}
.rl-editor-input:focus {
  border-color: rgba(44, 108, 246, .62);
  box-shadow: 0 0 0 4px rgba(44, 108, 246, .10);
}
.rl-editor-input:disabled,
.rl-invoice-editor--locked .rl-editor-input {
  background: #f8fafc;
  color: var(--rl-muted);
  cursor: not-allowed;
}
.rl-line-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}
.rl-line-row {
  display: grid;
  grid-template-columns: minmax(210px, 2fr) minmax(76px, .65fr) minmax(86px, .72fr) minmax(96px, .85fr) minmax(72px, .64fr) minmax(96px, .9fr) 34px;
  align-items: end;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 14px;
  background: #ffffff;
}
.rl-line-total {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 42px;
  justify-content: center;
}
.rl-line-total strong {
  color: var(--rl-text);
  font-size: 14px;
}
.rl-line-remove {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--rl-muted);
  transition: background .14s ease, color .14s ease;
}
.rl-line-remove:hover {
  background: var(--rl-red-soft);
  color: #b91c1c;
}
.rl-line-remove svg {
  width: 15px;
  height: 15px;
}
.rl-editor-note {
  min-height: 92px;
  border: none;
  border-radius: 0;
  box-shadow: none;
}
.rl-invoice-editor-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--rl-border);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}
.rl-editor-totals {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rl-editor-totals div {
  min-width: 96px;
  padding: 7px 10px;
  border: 1px solid var(--rl-border);
  border-radius: 11px;
  background: #ffffff;
}
.rl-editor-totals span {
  display: block;
  color: var(--rl-muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.rl-editor-totals strong {
  color: var(--rl-text);
  font-size: 13px;
}
.rl-editor-totals .rl-editor-total {
  border-color: rgba(44, 108, 246, .2);
  background: var(--rl-blue-soft);
}
.rl-editor-totals .rl-editor-total strong {
  color: var(--rl-blue-dark);
}
.rl-editor-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* ========================================================================
   DRAFT PANE (right side rechnung-neu.html)
   ======================================================================== */
.rl-draft {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: calc(var(--rl-topbar-h) + 16px);
  min-width: 0;
}
.rl-draft-card {
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.rl-draft-head {
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  border-bottom: 1px solid var(--rl-border);
}
.rl-draft-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rl-draft-head-left { flex: 1; min-width: 0; }
.rl-draft-head h3 { font-size: 14px; font-weight: 700; color: var(--rl-text); }
.rl-draft-head p { font-size: 12px; color: var(--rl-muted); margin-top: 1px; }
.rl-draft-head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rl-draft-body {
  padding: 18px;
  background:
    repeating-conic-gradient(rgba(15, 23, 42, 0.018) 0% 25%, transparent 0% 50%) 0 0/14px 14px,
    var(--rl-bg);
  max-height: 540px;
  overflow: auto;
}

/* attachments */
.rl-attach-card {
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: var(--rl-radius-lg);
  box-shadow: var(--rl-shadow-sm);
  padding: 16px;
}
.rl-attach-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.rl-attach-head-left h3 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--rl-text);
}
.rl-attach-help {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--rl-bg-2);
  color: var(--rl-muted);
  display: inline-grid;
  place-items: center;
  font-size: 9px;
  font-weight: 700;
  cursor: help;
}
.rl-attach-head-left p { font-size: 12px; color: var(--rl-muted); margin-top: 1px; }
.rl-attach-add {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rl-attach-hint {
  font-size: 11.5px;
  color: var(--rl-muted-2);
  margin-left: 6px;
}
.rl-attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.rl-attach-grid--chat {
  grid-template-columns: 1fr;
}
.rl-attach-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--rl-border);
  border-radius: 10px;
  background: var(--rl-bg);
  position: relative;
  transition: background .12s ease, border-color .12s ease;
}
.rl-attach-file--selected {
  border-color: rgba(44, 108, 246, .34);
  background: #f8fbff;
}
.rl-attach-file--muted {
  opacity: .66;
}
.rl-attach-file:hover { background: white; border-color: var(--rl-blue); }
.rl-attach-file--image {
  min-height: 82px;
}
.rl-attach-file .rl-action {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  flex: none;
}
.rl-attach-file .rl-action svg {
  width: 13px;
  height: 13px;
}
.rl-attach-select {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 1px solid rgba(203, 213, 225, .9);
  background: white;
  color: var(--rl-blue);
  display: grid;
  place-items: center;
  flex: none;
}
.rl-attach-select svg {
  width: 14px;
  height: 14px;
}
.rl-attach-file--selected .rl-attach-select {
  border-color: rgba(44, 108, 246, .44);
  background: var(--rl-blue);
  color: white;
}
.rl-attach-icon {
  width: 32px;
  height: 36px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: none;
}
.rl-attach-icon--xlsx { background: #dcfce7; color: #166534; border: 1px solid rgba(22, 163, 74, 0.3); }
.rl-attach-icon--pdf { background: #fee2e2; color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.3); }
.rl-attach-icon--doc { background: #dbeafe; color: #1e40af; border: 1px solid rgba(37, 99, 235, 0.3); }
.rl-attach-icon--img { background: #fef3c7; color: #92400e; border: 1px solid rgba(217, 119, 6, 0.3); }
.rl-attach-preview {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
  border: 1px solid rgba(203, 213, 225, .95);
  flex: none;
  box-shadow: 0 8px 18px -18px rgba(15, 23, 42, .45);
}
.rl-attach-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.rl-attach-info { flex: 1; min-width: 0; }
.rl-attach-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rl-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rl-attach-meta {
  font-size: 11px;
  color: var(--rl-muted);
}
.rl-attach-remove {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  background: transparent;
  transition: background .12s ease, color .12s ease;
}
.rl-attach-remove:hover { background: var(--rl-red-soft); color: var(--rl-red); }
.rl-attach-remove svg { width: 12px; height: 12px; }
.rl-attach-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  border: 1.5px dashed var(--rl-border-strong);
  border-radius: 10px;
  background: rgba(44, 108, 246, 0.02);
  color: var(--rl-muted);
  font-size: 12px;
  text-align: center;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.rl-attach-drop:hover {
  background: var(--rl-blue-soft);
  border-color: var(--rl-blue);
  color: var(--rl-blue);
}
.rl-attach-drop svg { width: 18px; height: 18px; }
.rl-attach-drop strong { font-size: 12.5px; font-weight: 600; color: var(--rl-text); display: block; margin-top: 2px; }
.rl-attach-drop:hover strong { color: var(--rl-blue); }
.rl-attach-drop small { font-size: 11px; color: var(--rl-muted-2); }

/* ========================================================================
   POPUPS — :target based, no JS
   ======================================================================== */
.rl-popup {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.rl-popup:target,
.rl-popup.rl-popup--open { display: flex; animation: rl-popup-in .22s ease-out both; }
@keyframes rl-popup-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.rl-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.rl-popup-card {
  position: relative;
  background: white;
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow:
    0 30px 80px -20px rgba(15, 23, 42, 0.45),
    0 12px 30px -10px rgba(15, 23, 42, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  overflow: hidden;
  animation: rl-popup-rise .3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes rl-popup-rise {
  from { transform: translateY(20px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.rl-popup-card--md { max-width: 660px; }
.rl-popup-card--lg { max-width: min(980px, calc(100vw - 32px)); }
.rl-popup-card--xl { max-width: 940px; }
.rl-popup-card--lock { max-width: min(560px, calc(100vw - 28px)); }

.rl-popup-head {
  padding: 22px 24px 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--rl-border);
}
.rl-popup-head-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--rl-blue-soft);
  color: var(--rl-blue);
  flex: none;
  position: relative;
}
.rl-popup-head-icon::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: var(--rl-grad-blue);
  opacity: .18;
  filter: blur(8px);
  z-index: -1;
}
.rl-popup-head-icon svg { width: 18px; height: 18px; }
.rl-popup-head-icon--purple { background: #f3e8ff; color: #7c3aed; }
.rl-popup-head-icon--purple::after { background: var(--rl-grad-purple); }
.rl-popup-head-icon--green { background: var(--rl-green-soft); color: var(--rl-green); }
.rl-popup-head-icon--amber { background: var(--rl-amber-soft); color: var(--rl-amber); }
.rl-popup-head-icon--lock {
  background: linear-gradient(135deg, rgba(44, 108, 246, .13), rgba(139, 92, 246, .11));
  color: var(--rl-blue);
}
.rl-popup-head-icon--lock::after { background: var(--rl-grad-blue); opacity: .2; }

.rl-popup-head-text { flex: 1; min-width: 0; }
.rl-popup-head h2 { font-size: 17px; font-weight: 700; color: var(--rl-text); letter-spacing: -0.01em; }
.rl-popup-head p { font-size: 13px; color: var(--rl-muted); margin-top: 2px; }
.rl-popup-close {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  background: var(--rl-bg);
  flex: none;
  transition: background .12s ease, color .12s ease;
}
.rl-popup-close:hover { background: var(--rl-red-soft); color: var(--rl-red); }
.rl-popup-close svg { width: 16px; height: 16px; }

.rl-popup-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.rl-popup-foot {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--rl-border);
  background: var(--rl-bg);
}
.rl-popup-foot-left { margin-right: auto; font-size: 12px; color: var(--rl-muted); }

/* form elements */
.rl-form { display: grid; gap: 14px; }
.rl-form-row { display: grid; gap: 6px; }
.rl-form-row--split { grid-template-columns: 1fr 1fr; gap: 12px; }
.rl-form-row--three { grid-template-columns: 80px 1fr 1fr; gap: 12px; }
.rl-form-row--four { grid-template-columns: 80px 1fr 1fr 1fr; gap: 12px; }
.rl-form-section-title {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, .9);
  color: var(--rl-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.rl-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--rl-text-2);
  letter-spacing: 0.01em;
}
.rl-label .rl-required { color: var(--rl-red); margin-left: 2px; }
.rl-input, .rl-select, .rl-textarea {
  width: 100%;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--rl-border);
  border-radius: 10px;
  font-size: 13px;
  color: var(--rl-text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.rl-input:focus, .rl-select:focus, .rl-textarea:focus {
  border-color: var(--rl-blue);
  box-shadow: 0 0 0 4px rgba(44, 108, 246, 0.12);
}
.rl-input::placeholder, .rl-textarea::placeholder { color: var(--rl-muted-2); }
.rl-textarea { resize: vertical; min-height: 86px; }
.rl-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.rl-mail-source-select {
  font-weight: 700;
  color: var(--rl-text);
}
.rl-mail-source-select:disabled {
  cursor: not-allowed;
  background-color: var(--rl-bg);
  color: var(--rl-muted);
}
.rl-mail-source-lock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
  font-size: 11.5px;
  color: var(--rl-muted);
}
.rl-mail-source-lock::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--rl-blue);
  box-shadow: 0 0 0 3px rgba(44, 108, 246, .12);
}

.rl-checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--rl-text-2); cursor: pointer; }
.rl-checkbox {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--rl-border-strong);
  border-radius: 5px;
  background: white;
  cursor: pointer;
  position: relative;
  transition: background .12s ease, border-color .12s ease;
}
.rl-checkbox:checked {
  background: var(--rl-blue);
  border-color: var(--rl-blue);
}
.rl-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* mail popup recipient pill */
.rl-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--rl-blue-soft);
  border-radius: 999px;
  font-size: 12px;
  color: var(--rl-blue-dark);
  font-weight: 500;
}
.rl-pill-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--rl-grad-blue);
  color: white;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}
.rl-pill-x {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(44, 108, 246, 0.2);
  margin-left: 4px;
  color: var(--rl-blue-dark);
  font-size: 10px;
}

.rl-attach-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--rl-bg);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--rl-text-2);
}
.rl-attach-row svg { width: 14px; height: 14px; color: var(--rl-blue); flex: none; }
.rl-attach-row strong { color: var(--rl-text); font-weight: 600; }

.rl-lock-warning {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(44, 108, 246, .18);
  background:
    linear-gradient(135deg, rgba(44, 108, 246, .08), rgba(255, 255, 255, .92) 46%),
    #f8fbff;
  box-shadow: 0 14px 34px rgba(44, 108, 246, .08);
}

.rl-lock-warning strong {
  color: var(--rl-text);
  font-size: 14px;
  line-height: 1.35;
}

.rl-lock-warning span {
  color: var(--rl-text-2);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ========================================================================
   POPUP — Kunde (with tabs for select/create new)
   ======================================================================== */
.rl-tabs-pill {
  display: inline-flex;
  background: var(--rl-bg);
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}
.rl-tab-pill {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--rl-muted);
  transition: background .12s ease, color .12s ease;
}
.rl-tab-pill--active {
  background: white;
  color: var(--rl-text);
  box-shadow: var(--rl-shadow-sm);
}

.rl-customer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 380px;
  overflow-y: auto;
  margin-top: 12px;
  padding: 4px;
}
.rl-customer-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: white;
  border: 1px solid transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.rl-customer-row:hover {
  background: var(--rl-blue-soft);
  border-color: var(--rl-blue);
}
.rl-customer-row--active {
  background: var(--rl-blue-soft);
  border-color: rgba(44, 108, 246, .42);
  box-shadow: 0 12px 26px rgba(44, 108, 246, .12);
}
.rl-customer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--rl-grad-blue);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex: none;
}
.rl-customer-avatar--p { background: linear-gradient(135deg, #f97316, #ea580c); }
.rl-customer-avatar--g { background: linear-gradient(135deg, #22c55e, #16a34a); }
.rl-customer-avatar--s { background: linear-gradient(135deg, #f59e0b, #d97706); }
.rl-customer-avatar--b { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.rl-customer-avatar--w { background: linear-gradient(135deg, #ec4899, #db2777); }
.rl-customer-avatar--n { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.rl-customer-info { flex: 1; min-width: 0; }
.rl-customer-name { font-size: 13px; font-weight: 600; color: var(--rl-text); }
.rl-customer-meta { font-size: 11.5px; color: var(--rl-muted); margin-top: 1px; }
.rl-customer-stat { font-size: 11px; color: var(--rl-muted-2); font-weight: 500; }

.rl-selected-customer-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(44, 108, 246, .24);
  border-radius: 16px;
  background: linear-gradient(180deg, #f8fbff, #eef4ff);
  box-shadow: 0 14px 34px rgba(44, 108, 246, .09);
}

.rl-selected-customer-card--empty {
  border-color: rgba(203, 213, 225, .72);
  background: #fff;
  box-shadow: none;
}

.rl-selected-customer-card div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.rl-selected-customer-card span {
  color: var(--rl-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.rl-selected-customer-card strong {
  color: var(--rl-text);
  font-size: 14px;
  font-weight: 800;
}

.rl-selected-customer-card small {
  color: var(--rl-muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.rl-selected-customer-badge {
  flex: none;
  min-width: 52px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(203, 213, 225, .78);
  color: var(--rl-blue);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

/* Tab switch using inner :target trick */
#popup-kunde .rl-kunde-create { display: none; }
#popup-kunde .rl-kunde-select { display: block; }
#popup-kunde-neu .rl-kunde-create { display: block; }
#popup-kunde-neu .rl-kunde-select { display: none; }
#popup-kunde-neu .rl-tab-pill[href="#popup-kunde-neu"] {
  background: white;
  color: var(--rl-text);
  box-shadow: var(--rl-shadow-sm);
}
#popup-kunde-neu .rl-tab-pill[href="#popup-kunde"] {
  background: transparent;
  color: var(--rl-muted);
  box-shadow: none;
}

/* ========================================================================
   POPUP — Files (Finder-style)
   ======================================================================== */
.rl-finder {
  display: grid;
  grid-template-columns: 200px 1fr;
  height: 460px;
}
.rl-finder-sidebar {
  background: var(--rl-bg);
  padding: 14px 8px;
  border-right: 1px solid var(--rl-border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.rl-finder-section h4 {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--rl-muted);
  padding: 0 10px 6px;
}
.rl-finder-section ul { display: flex; flex-direction: column; gap: 1px; }
.rl-finder-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--rl-text-2);
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}
.rl-finder-link:hover { background: white; color: var(--rl-text); }
.rl-finder-link--active { background: var(--rl-blue); color: white; }
.rl-finder-link svg { width: 14px; height: 14px; flex: none; }

.rl-finder-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: white;
}
.rl-finder-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--rl-border);
}
.rl-finder-path {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--rl-text-2);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.rl-finder-path svg { width: 11px; height: 11px; color: var(--rl-muted-2); }
.rl-finder-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--rl-bg);
  border-radius: 7px;
  font-size: 12px;
  width: 160px;
}
.rl-finder-search svg { width: 12px; height: 12px; color: var(--rl-muted); }
.rl-finder-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 12px;
  color: var(--rl-text);
}
.rl-finder-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  align-content: start;
}
.rl-finder-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: 9px;
  cursor: pointer;
  text-align: center;
  transition: background .12s ease;
}
.rl-finder-file:hover { background: var(--rl-bg); }
.rl-finder-file--selected {
  background: var(--rl-blue-soft);
}
.rl-finder-file--selected .rl-finder-thumb {
  outline: 2px solid var(--rl-blue);
  outline-offset: 2px;
}
.rl-finder-thumb {
  width: 56px;
  height: 70px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border: 1px solid rgba(15, 23, 42, 0.08);
  color: var(--rl-muted);
  position: relative;
  flex: none;
}
.rl-finder-thumb--xlsx { background: #dcfce7; color: #166534; border-color: rgba(22, 163, 74, 0.3); }
.rl-finder-thumb--pdf { background: #fee2e2; color: #b91c1c; border-color: rgba(239, 68, 68, 0.3); }
.rl-finder-thumb--doc { background: #dbeafe; color: #1e40af; border-color: rgba(37, 99, 235, 0.3); }
.rl-finder-thumb--img { background: #fef3c7; color: #92400e; border-color: rgba(217, 119, 6, 0.3); }
.rl-finder-thumb--folder { background: linear-gradient(135deg, #fde68a, #fbbf24); color: #78350f; border: none; box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2); }
.rl-finder-name {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--rl-text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}

.rl-finder-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--rl-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--rl-bg);
}
.rl-finder-foot-info {
  font-size: 11.5px;
  color: var(--rl-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.rl-finder-foot-actions { display: flex; gap: 8px; }

/* drop area inside finder popup */
.rl-finder-drop {
  margin: 14px;
  padding: 24px;
  border: 2px dashed var(--rl-border-strong);
  border-radius: 12px;
  background: rgba(44, 108, 246, 0.03);
  text-align: center;
  color: var(--rl-muted);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.rl-finder-drop svg { width: 28px; height: 28px; color: var(--rl-blue); }
.rl-finder-drop strong { color: var(--rl-text); font-size: 13px; font-weight: 600; }

/* ========================================================================
   POPUP — Drucken
   ======================================================================== */
.rl-print-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
}
.rl-print-preview {
  background: var(--rl-bg);
  border-radius: 10px;
  padding: 20px;
  display: grid;
  place-items: center;
  min-height: 320px;
  border: 1px solid var(--rl-border);
}
.rl-print-preview--full {
  width: 100%;
  min-height: min(72vh, 760px);
  max-height: min(72vh, 760px);
  padding: 18px;
  overflow: auto;
  align-items: start;
  justify-items: center;
  background: #f8fafc;
}
.rl-print-live-page {
  width: min(100%, 700px);
  margin: 0 auto;
  min-width: 0;
}
.rl-print-live-page .rl-template-paper,
.rl-print-live-page .rl-live-paper {
  width: 100%;
  min-height: auto;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .14);
  transform-origin: top center;
}

.rl-print-preview--full .rl-template-paper--draft::after,
.rl-print-preview--full .rl-paper-blank--draft::after {
  display: none;
}
.rl-print-page {
  width: 180px;
  aspect-ratio: 1 / 1.41421356;
  background: white;
  border-radius: 4px;
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.06),
    0 12px 24px -8px rgba(15, 23, 42, 0.18);
  position: relative;
}
.rl-print-page::before {
  content: "";
  position: absolute;
  top: 14px; left: 14px; right: 14px; height: 6px;
  background: var(--rl-bg-2);
  border-radius: 2px;
}
.rl-print-page::after {
  content: "";
  position: absolute;
  top: 26px; left: 14px; right: 60px; height: 4px;
  background: var(--rl-bg-2);
  border-radius: 2px;
  box-shadow:
    0 8px 0 var(--rl-bg-2),
    0 16px 0 var(--rl-bg-2),
    0 28px 0 var(--rl-bg-2),
    0 36px 0 var(--rl-bg-2);
}
.rl-print-form { display: flex; flex-direction: column; gap: 14px; }

.rl-print-document-root {
  display: none;
}

/* ========================================================================
   RESPONSIVE
   ======================================================================== */
@media (max-width: 1280px) {
  .rl-grid { grid-template-columns: 240px 1fr 340px; }
  .rl-create-grid { grid-template-columns: minmax(340px, .9fr) minmax(0, 1.1fr); }
  .rl-editor-grid--customer,
  .rl-editor-grid--invoice { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rl-line-row { grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(82px, 1fr)) 72px 112px 34px; }
}
@media (max-width: 1520px) {
  .rl-line-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .rl-line-row .rl-editor-field--description {
    grid-column: 1 / -1;
  }

  .rl-line-row .rl-line-total {
    grid-column: 1 / span 3;
  }

  .rl-line-row .rl-line-remove {
    grid-column: 4;
    justify-self: end;
    align-self: center;
  }
}
@media (max-width: 1100px) {
  .rl-grid { grid-template-columns: 1fr; }
  .rl-col-preview { position: static; max-height: none; }
  .rl-create-grid { grid-template-columns: 1fr; }
  .rl-draft { position: static; }
}
@media (max-width: 720px) {
  .rl-shell { grid-template-columns: 1fr; }
  .rl-sidebar {
    display: none;
  }
  .rl-topbar {
    gap: 10px;
    padding: 0 14px;
    overflow: hidden;
  }
  .rl-tabs {
    flex: 1 1 auto;
    max-width: 100%;
    overflow-x: auto;
  }
  .rl-user-menu {
    flex: 0 0 auto;
    max-width: 44px;
  }
  .rl-user-btn {
    width: 38px;
    padding: 4px;
    justify-content: center;
  }
  .rl-user-info-wrap,
  .rl-user-btn > svg,
  .rl-user-dropdown {
    display: none;
  }
  .rl-page-head { padding: 16px; }
  .rl-grid, .rl-create-grid { padding: 0 16px 16px; }
  .rl-invoice-editor-head,
  .rl-invoice-editor-foot { flex-direction: column; align-items: stretch; }
  .rl-editor-grid--customer,
  .rl-editor-grid--invoice,
  .rl-line-row { grid-template-columns: 1fr; }
  .rl-editor-field--wide { grid-column: auto; }
  .rl-editor-actions { justify-content: stretch; }
  .rl-editor-actions .rl-btn { flex: 1; }
  .rl-form-row--split, .rl-form-row--three, .rl-form-row--four { grid-template-columns: 1fr; }
  .rl-finder { grid-template-columns: 1fr; height: auto; }
  .rl-finder-sidebar { display: none; }
  .rl-print-grid { grid-template-columns: 1fr; }
}

/* ========================================================================
   LIVE DATA LAYER
   ======================================================================== */
.rl-live-pending .rl-table tbody,
.rl-live-pending .rl-preview-body,
.rl-live-pending .rl-chat,
.rl-live-pending .rl-chat-stream,
.rl-live-pending .rl-invoice-editor,
.rl-live-pending .rl-draft-body,
.rl-live-pending .rl-attach-grid,
.rl-live-pending .rl-finder-grid {
  opacity: 0;
}

button.rl-action,
button.rl-preview-btn,
button.rl-zoom-btn {
  font: inherit;
  cursor: pointer;
}

.rl-status--draft { background: #e0e7ff; color: #3730a3; }
.rl-status--sent { background: #dbeafe; color: #1d4ed8; }
.rl-status--canceled { background: #f1f5f9; color: #64748b; }

.rl-live-empty-cell,
.rl-paper-empty {
  color: var(--rl-muted);
  font-size: 12.5px;
  text-align: center;
}

.rl-paper-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px;
}

.rl-paper-blank:has(.rl-live-paper)::before { opacity: 1; }

.rl-live-paper {
  height: auto;
  min-height: 100%;
  padding: clamp(18px, 4.8%, 34px);
  display: flex;
  flex-direction: column;
  color: #172033;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.07), transparent 26%),
    #fff;
  font-size: clamp(7px, 0.72vw, 12px);
  overflow: visible;
}

.rl-live-paper-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2e8f0;
}

.rl-live-paper-head > div:first-child {
  min-width: 0;
}

.rl-live-paper-head > div:first-child,
.rl-live-address-grid > div,
.rl-live-paper-foot {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.rl-live-paper-head strong { font-size: 1.08em; }

.rl-live-paper-head span,
.rl-live-address-grid span,
.rl-live-paper-foot {
  color: #64748b;
  line-height: 1.45;
}

.rl-live-paper-title {
  align-items: flex-end;
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: none;
  max-width: 52%;
  min-width: 0;
}

.rl-live-paper-title h2 {
  margin: 0;
  color: #172033;
  font-size: clamp(17px, 2.1vw, 31px);
  line-height: 1;
  letter-spacing: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.rl-live-paper-title span {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.rl-live-draft-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e0e7ff;
  color: #3730a3 !important;
  font-weight: 800;
  font-size: .88em;
  text-transform: uppercase;
}

.rl-live-address-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(120px, .85fr);
  gap: 22px;
  margin: 22px 0;
}

.rl-live-address-grid strong {
  color: #172033;
  font-size: 1.05em;
  margin-bottom: 2px;
}

.rl-live-address-grid b {
  color: #334155;
  display: inline-block;
  min-width: 92px;
  margin-right: 8px;
}

.rl-live-label {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78em;
  font-weight: 800;
  color: #94a3b8 !important;
}

.rl-live-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
  table-layout: fixed;
}

.rl-live-table th:first-child,
.rl-live-table td:first-child {
  width: 42px;
}

.rl-live-table th:nth-child(3),
.rl-live-table td:nth-child(3) {
  width: 68px;
}

.rl-live-table th:nth-child(4),
.rl-live-table td:nth-child(4),
.rl-live-table th:nth-child(6),
.rl-live-table td:nth-child(6) {
  width: 78px;
}

.rl-live-table th:nth-child(5),
.rl-live-table td:nth-child(5) {
  width: 82px;
}

.rl-live-table th {
  padding: 9px 7px;
  background: #f8fafc;
  color: #64748b;
  font-size: .78em;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid #e2e8f0;
}

.rl-live-table td {
  padding: 9px 7px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: top;
  color: #334155;
  overflow-wrap: anywhere;
  word-break: normal;
}

.rl-live-table td:nth-child(3),
.rl-live-table td:nth-child(4),
.rl-live-table td:nth-child(6) {
  text-align: right;
  white-space: nowrap;
}

.rl-live-optional-section {
  margin-top: 18px;
}

.rl-live-optional-section h3 {
  margin: 0 0 4px;
  color: #172033;
  font-size: .96em;
}

.rl-live-optional-section p {
  margin: 0 0 8px;
  color: #64748b;
  font-size: .82em;
}

.rl-live-table--optional {
  margin-top: 8px;
}

.rl-live-totals {
  width: min(245px, 62%);
  margin: 18px 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rl-live-totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #64748b;
}

.rl-live-totals strong { color: #172033; }

.rl-live-grand {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a !important;
}

.rl-live-grand strong {
  color: #1e3a8a;
  font-size: 1.08em;
}

.rl-live-paper-foot {
  margin-top: 22px;
  padding-top: 20px;
  color: #64748b;
  overflow-wrap: anywhere;
  word-break: normal;
  border-top: 1px solid #e2e8f0;
}

.rl-live-paper-foot p {
  margin: 0;
}

.rl-live-signatures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(16px, 5%, 34px);
  margin-top: clamp(28px, 7%, 56px);
}

.rl-live-signatures div {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.rl-live-signatures span {
  color: #64748b;
  font-size: .82em;
  font-weight: 800;
}

.rl-live-signatures i {
  display: block;
  height: 1px;
  background: #94a3b8;
}

.rl-live-signatures strong {
  min-height: 1.2em;
  color: #172033;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rl-live-footer-meta {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: clamp(20px, 5%, 42px);
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, .3);
  color: #94a3b8;
  font-size: .8em;
}

.rl-live-footer-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rl-live-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1000;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 45px -24px rgba(15, 23, 42, 0.45);
  color: var(--rl-text);
  font-size: 13px;
  font-weight: 650;
  backdrop-filter: blur(14px);
}

.rl-live-toast[data-tone="error"] {
  border-color: rgba(239, 68, 68, 0.24);
  color: #b91c1c;
}

.rl-live-customer-picker {
  display: grid;
  gap: 10px;
}

.rl-live-customer-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--rl-border);
  border-radius: 12px;
  background: white;
  color: var(--rl-text);
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.rl-live-customer-choice:hover {
  background: var(--rl-blue-soft);
  border-color: rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

.rl-live-customer-choice span:last-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.rl-live-customer-choice small {
  color: var(--rl-muted);
  font-size: 12px;
}

.rl-live-new-customer {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--rl-border);
  display: grid;
  gap: 8px;
}

.rl-live-sender-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(203, 213, 225, .74);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.rl-live-file-empty {
  grid-column: 1 / -1;
  min-height: 180px;
  border: 1px dashed var(--rl-border-strong);
  border-radius: 12px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--rl-muted);
  text-align: center;
  padding: 24px;
}

.rl-live-file-empty strong {
  color: var(--rl-text);
  font-size: 13px;
}

@media (max-width: 900px) {
  .rl-live-paper { font-size: 9px; }
  .rl-live-address-grid { grid-template-columns: 1fr; }
}

/* ========================================================================
   MIKROFON-MODUS + LAUT-MODUS — CSS-only via hidden checkbox toggles
   ======================================================================== */

/* Hidden toggles */
.rl-mic-toggle,
.rl-loud-toggle { display: none; }

/* ── LAUT-MODUS button ── */
.rl-chat-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 18px 2px;
  gap: 8px;
}

.rl-loud-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 20px;
  border: 1.5px solid var(--rl-border);
  background: white;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--rl-muted);
  cursor: pointer;
  user-select: none;
  transition: background .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
  white-space: nowrap;
}
.rl-loud-btn:hover {
  border-color: var(--rl-border-strong);
  color: var(--rl-text-2);
  background: var(--rl-bg);
}
.rl-loud-btn .rl-loud-icon { width: 12px; height: 12px; flex-shrink: 0; }

/* Sound-wave bars inside the loud button (hidden off) */
.rl-loud-waves {
  display: none;
  align-items: center;
  gap: 2px;
  height: 12px;
}
.rl-loud-waves span {
  width: 2.5px;
  height: 100%;
  border-radius: 1.5px;
  background: currentColor;
  transform-origin: bottom;
  animation: rl-lwave 1s ease-in-out infinite alternate;
}
.rl-loud-waves span:nth-child(1) { animation-delay: 0s;    animation-duration: 0.8s; }
.rl-loud-waves span:nth-child(2) { animation-delay: .2s;   animation-duration: 1.1s; }
.rl-loud-waves span:nth-child(3) { animation-delay: .1s;   animation-duration: 0.9s; }
.rl-loud-waves span:nth-child(4) { animation-delay: .3s;   animation-duration: 1.2s; }
.rl-loud-waves span:nth-child(5) { animation-delay: .15s;  animation-duration: 0.7s; }
@keyframes rl-lwave {
  from { transform: scaleY(0.2); }
  to   { transform: scaleY(1);   }
}

/* LOUD ACTIVE state */
.rl-loud-toggle:checked ~ .rl-chat-controls .rl-loud-btn {
  background: #0f172a;
  border-color: #0f172a;
  color: white;
  box-shadow: 0 4px 16px rgba(15,23,42,.3);
}
.rl-loud-toggle:checked ~ .rl-chat-controls .rl-loud-btn .rl-loud-waves { display: flex; }
.rl-loud-toggle:checked ~ .rl-chat-controls .rl-loud-btn .rl-loud-icon { display: none; }

/* Speaking indicator strip (between stream and controls) */
.rl-loud-indicator {
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0 18px 4px;
  padding: 9px 14px;
  background: #0f172a;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  animation: rl-drop-in .22s cubic-bezier(0.34,1.56,0.64,1) both;
}
.rl-loud-toggle:checked ~ .rl-loud-indicator { display: flex; }

.rl-loud-indicator-waves {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  flex-shrink: 0;
}
.rl-loud-indicator-waves span {
  width: 3px;
  border-radius: 2px;
  background: #ef4444;
  animation: rl-lwave 1s ease-in-out infinite alternate;
}
.rl-loud-indicator-waves span:nth-child(1) { animation-duration: 0.6s; }
.rl-loud-indicator-waves span:nth-child(2) { animation-duration: 0.9s; animation-delay: .15s; }
.rl-loud-indicator-waves span:nth-child(3) { animation-duration: 0.7s; animation-delay: .05s; }
.rl-loud-indicator-waves span:nth-child(4) { animation-duration: 1.1s; animation-delay: .25s; }
.rl-loud-indicator-waves span:nth-child(5) { animation-duration: 0.8s; animation-delay: .1s; }

.rl-loud-indicator-stop {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.7);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
  user-select: none;
}
.rl-loud-indicator-stop:hover { background: rgba(255,255,255,.22); color: white; }

/* ── MIC TRIGGER button inside chat input ── */
.rl-mic-trigger {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--rl-muted);
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, color .15s ease, transform .1s ease;
  background: var(--rl-bg);
  flex-shrink: 0;
}
.rl-mic-trigger svg { width: 14px; height: 14px; }
.rl-mic-trigger:hover {
  background: rgba(239,68,68,.1);
  color: var(--rl-red);
  transform: scale(1.08);
}

/* ── Text input hidden when recording ── */
.rl-mic-toggle:checked ~ .rl-chat-input-wrap .rl-chat-input--text { display: none; }

/* ── RECORDING UI ── */
.rl-rec-ui { display: none; }
.rl-mic-toggle:checked ~ .rl-chat-input-wrap .rl-rec-ui {
  display: flex;
  animation: rl-rec-appear .3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes rl-rec-appear {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)     scale(1); }
}

.rl-rec-ui {
  flex-direction: column;
  gap: 16px;
  padding: 18px 16px 14px;
  background: linear-gradient(145deg, #0c1220 0%, #141f35 50%, #0c1220 100%);
  border-radius: 16px;
  border: 1.5px solid rgba(239,68,68,.3);
  box-shadow:
    0 0 0 4px rgba(239,68,68,.06),
    0 16px 40px -8px rgba(12,18,32,.7),
    inset 0 1px 0 rgba(255,255,255,.06);
  position: relative;
  overflow: hidden;
}
/* Subtle glow from bottom */
.rl-rec-ui::before {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60%;
  background: radial-gradient(ellipse 90% 70% at 50% 110%, rgba(239,68,68,.14), transparent 70%);
  pointer-events: none;
}

/* Header: indicator + timer */
.rl-rec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

.rl-rec-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #ef4444;
}

.rl-rec-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239,68,68,.8);
  animation: rl-rec-blink 1.3s ease infinite;
}
@keyframes rl-rec-blink {
  0%, 100% { opacity: 1;    box-shadow: 0 0 8px rgba(239,68,68,.8); }
  50%       { opacity: 0.2; box-shadow: 0 0 2px rgba(239,68,68,.2); }
}

.rl-rec-timer {
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: .1em;
  font-variant-numeric: tabular-nums;
}

/* ── WAVEFORM ── */
.rl-waveform {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 56px;
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, black 8%, black 92%, transparent 100%);
}

.rl-waveform span {
  flex: 1;
  max-width: 5px;
  border-radius: 3px;
  background: #ef4444;
  box-shadow: 0 0 4px rgba(239,68,68,.4);
}

/* Each bar: own animation duration + delay = organic, non-AI-looking */
.rl-waveform span:nth-child(1)  { animation: rl-wb 0.9s  0.00s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(2)  { animation: rl-wb 1.3s  0.12s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(3)  { animation: rl-wb 0.7s  0.24s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(4)  { animation: rl-wb 1.1s  0.08s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(5)  { animation: rl-wb 0.8s  0.36s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(6)  { animation: rl-wb 1.4s  0.16s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(7)  { animation: rl-wb 0.6s  0.04s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(8)  { animation: rl-wb 1.2s  0.28s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(9)  { animation: rl-wb 1.0s  0.20s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(10) { animation: rl-wb 0.85s 0.32s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(11) { animation: rl-wb 1.15s 0.06s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(12) { animation: rl-wb 0.75s 0.40s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(13) { animation: rl-wb 1.35s 0.18s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(14) { animation: rl-wb 0.95s 0.44s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(15) { animation: rl-wb 1.05s 0.10s ease-in-out infinite alternate; }
.rl-waveform span:nth-child(16) { animation: rl-wb 0.65s 0.34s ease-in-out infinite alternate; }

@keyframes rl-wb {
  from { height: 3px;  opacity: 0.4; }
  to   { height: 48px; opacity: 1;   }
}

/* ── Recording actions ── */
.rl-rec-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.rl-rec-cancel {
  padding: 9px 16px;
  border-radius: 10px;
  border: 1.5px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.6);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  user-select: none;
  white-space: nowrap;
}
.rl-rec-cancel:hover {
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.9);
}

.rl-rec-done {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 10px;
  background: #ef4444;
  color: white;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, box-shadow .15s ease, transform .12s ease;
  box-shadow: 0 4px 16px rgba(239,68,68,.45);
}
.rl-rec-done:hover {
  background: #dc2626;
  box-shadow: 0 6px 22px rgba(239,68,68,.6);
  transform: translateY(-1px);
}
.rl-rec-done svg { width: 13px; height: 13px; flex-shrink: 0; }

.rl-template-paper {
  position: relative;
  width: min(100%, 794px);
  aspect-ratio: 794 / 1123;
  min-height: 620px;
  margin: 0 auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .12);
  overflow: hidden;
  box-sizing: border-box;
  color: #0f172a;
}

.rl-template-paper-stack {
  display: grid;
  gap: 22px;
  width: min(100%, 794px);
  margin: 0 auto;
}

.rl-template-paper-stack .rl-template-paper {
  width: 100%;
  margin: 0;
}

.rl-print-live-page .rl-template-paper-stack {
  width: 100%;
  gap: 18px;
}

.rl-template-paper--draft::after {
  content: "Entwurf";
  position: absolute;
  top: 18px;
  right: 18px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(59, 130, 246, .1);
  color: var(--rl-blue);
  font-size: 11px;
  font-weight: 800;
}

.rl-template-badge {
  position: absolute;
  left: 18px;
  bottom: 14px;
  z-index: 4;
  max-width: calc(100% - 36px);
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .86);
  border: 1px solid rgba(148, 163, 184, .28);
  color: #64748b;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}

.rl-template-block {
  position: absolute;
  box-sizing: border-box;
  white-space: pre-line;
  overflow: hidden;
  z-index: 2;
  overflow-wrap: break-word;
  word-break: normal;
}

.rl-template-block--details,
.rl-template-block--table {
  overflow: visible;
}

.rl-template-block--text {
  display: flex;
  align-items: flex-start;
  overflow: hidden;
}

.rl-template-block--doc-title {
  width: max-content !important;
  max-width: calc(100% - 12px);
  height: auto !important;
  white-space: nowrap;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
}

.rl-template-block--image {
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #f8fafc;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
}

.rl-template-block--image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rl-template-block--shape {
  border-radius: 10px;
  background: rgba(59, 130, 246, .12);
}

.rl-template-details {
  display: grid;
  gap: 10px;
  font-size: 11px;
}

.rl-template-details div {
  display: grid;
  gap: 2px;
}

.rl-template-details span,
.rl-template-details small {
  color: #64748b;
  font-size: 10px;
}

.rl-template-invoice-details-card {
  width: 100%;
  height: 100%;
  display: grid;
  align-content: start;
  gap: 5px;
  overflow: visible;
}

.rl-template-invoice-details-title {
  font-size: .74em;
  line-height: 1.2;
  color: #94a3b8;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.rl-template-invoice-details-grid {
  display: grid;
  gap: 3px;
}

.rl-template-invoice-details-grid--split {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 14px;
}

.rl-template-invoice-details-column {
  display: grid;
  gap: 4px;
  min-width: 0;
  align-content: start;
}

.rl-template-details-row {
  display: grid;
  grid-template-columns: minmax(42px, .42fr) minmax(0, 1fr);
  gap: 7px;
  align-items: baseline;
  min-height: 14px;
}

.rl-template-invoice-details-grid--split .rl-template-details-row {
  grid-template-columns: minmax(48px, .42fr) minmax(0, 1fr);
  gap: 6px;
}

.rl-template-details-row span {
  color: #64748b;
  font-size: .78em;
  line-height: 1.15;
}

.rl-template-details-row strong {
  color: #0f172a;
  font-size: .86em;
  line-height: 1.18;
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.rl-template-details-row.is-placeholder strong {
  color: #94a3b8;
  font-weight: 600;
}

.rl-template-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 9.2px;
  table-layout: fixed;
}

.rl-template-table th,
.rl-template-table td {
  padding: 5px 3px;
  border-bottom: 1px solid rgba(148, 163, 184, .24);
  text-align: left;
  vertical-align: top;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}

.rl-template-table th:first-child,
.rl-template-table td:first-child {
  width: 7%;
}

.rl-template-table th:nth-child(2),
.rl-template-table td:nth-child(2) {
  width: 34%;
}

.rl-template-table th:nth-child(3),
.rl-template-table td:nth-child(3),
.rl-template-table th:nth-child(4),
.rl-template-table td:nth-child(4) {
  width: 12%;
}

.rl-template-table th:nth-child(5),
.rl-template-table td:nth-child(5),
.rl-template-table th:nth-child(6),
.rl-template-table td:nth-child(6),
.rl-template-table th:nth-child(7),
.rl-template-table td:nth-child(7) {
  width: 11%;
}

.rl-template-table th {
  color: #64748b;
  font-weight: 800;
  text-transform: uppercase;
  font-size: 7.6px;
  line-height: 1.15;
}

.rl-template-table-summary td {
  border-bottom: 0;
  padding-top: 7px;
  color: #475569;
  font-weight: 700;
}

.rl-template-table-summary td:first-child {
  text-align: right;
  color: #64748b;
}

.rl-template-table-summary td:last-child {
  text-align: right;
  white-space: normal;
  overflow-wrap: anywhere;
}

.rl-template-table-summary .emph td {
  padding-top: 9px;
  color: #0f172a;
  font-size: 1.06em;
}

.rl-template-total {
  position: absolute;
  right: 42px;
  bottom: 66px;
  z-index: 3;
  min-width: 190px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #eef4ff;
  color: #0f172a;
}

.rl-template-total span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.rl-template-total strong {
  font-size: 16px;
  font-weight: 900;
}

.rl-template-block--signature {
  display: block;
}

.rl-template-signature {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
  height: 100%;
  align-items: end;
}

.rl-template-signature div {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.rl-template-signature span {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.rl-template-signature i {
  display: block;
  height: 1px;
  background: #94a3b8;
}

.rl-template-signature strong {
  color: #0f172a;
  font-size: 10.5px;
  font-weight: 800;
}

.rl-template-qr-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, .3);
  border-radius: 12px;
  background: rgba(248, 250, 252, .9);
}

.rl-template-qr-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.rl-template-qr-copy strong {
  color: #0f172a;
  font-size: 11px;
}

.rl-template-qr-copy p,
.rl-template-qr-copy span {
  margin: 0;
  color: #64748b;
  font-size: 9.5px;
}

.rl-template-qr-code {
  width: 48px;
  height: 48px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  flex: none;
  border: 1px solid rgba(148, 163, 184, .35);
}

.rl-template-qr-code img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.rl-template-block--table-note {
  display: grid;
  align-content: center;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(248, 250, 252, .9);
  color: #64748b;
  overflow: visible;
}

.rl-template-block--ai-notes {
  width: min(62%, 430px) !important;
  max-width: calc(100% - 278px) !important;
  height: auto !important;
  min-height: 0 !important;
  display: block;
  overflow: visible;
  padding-right: 12px;
  background: transparent;
  color: #0f172a;
  font-size: .92em;
  line-height: 1.38;
  white-space: pre-line;
}

.rl-template-block--table-note.rl-template-block--ai-notes {
  padding: 0 14px 0 0;
  border-radius: 0;
  background: transparent;
  color: #0f172a;
}

.rl-template-block--footer-details {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid rgba(148, 163, 184, .3);
  padding-top: 8px;
  color: #64748b;
  font-size: 9px;
  align-items: start;
}

.rl-template-block--footer-details div {
  display: grid;
  gap: 2px;
}

.rl-template-block--footer-details div:last-child {
  text-align: right;
}

.rl-template-auto-signature {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 7.5%;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px;
  pointer-events: none;
}

.rl-template-auto-signature div {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.rl-template-auto-signature span {
  color: #64748b;
  font-size: 10px;
  font-weight: 800;
}

.rl-template-auto-signature i {
  display: block;
  height: 1px;
  background: #94a3b8;
}

.rl-template-auto-signature strong {
  min-height: 13px;
  color: #0f172a;
  font-size: 10.5px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.rl-template-auto-footer {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 3%;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, .3);
  color: #64748b;
  font-size: 9px;
  pointer-events: none;
}

.rl-template-auto-footer span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rl-template-auto-footer span:last-child {
  text-align: right;
}

.rl-template-strip {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(203, 213, 225, .72);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff, #f8fbff);
}

.rl-template-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.rl-template-strip-head div {
  display: grid;
  gap: 2px;
}

.rl-template-strip-head strong {
  color: var(--rl-text);
  font-size: 13px;
}

.rl-template-strip-head span,
.rl-template-strip-head a {
  color: var(--rl-muted);
  font-size: 11.5px;
}

.rl-template-strip-head a {
  color: var(--rl-blue);
  font-weight: 800;
  text-decoration: none;
}

.rl-template-options {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.rl-template-option {
  flex: 0 0 154px;
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid rgba(203, 213, 225, .82);
  border-radius: 13px;
  background: #fff;
  text-align: left;
  color: var(--rl-text);
  cursor: pointer;
}

.rl-template-option span {
  font-size: 12px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rl-template-option small,
.rl-template-empty {
  color: var(--rl-muted);
  font-size: 11px;
}

.rl-template-option--active {
  border-color: rgba(47, 100, 255, .58);
  background: #eef4ff;
  box-shadow: 0 12px 26px rgba(47, 100, 255, .13);
}

.rl-live-customer-choice--active {
  border-color: rgba(47, 100, 255, .58);
  background: #eef4ff;
}

.rl-live-create-summary {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  background: #f8fbff;
  border: 1px solid rgba(203, 213, 225, .74);
}

.rl-live-create-summary div {
  display: grid;
  gap: 3px;
}

.rl-live-create-summary span {
  color: var(--rl-muted);
  font-size: 11px;
  font-weight: 800;
}

.rl-live-create-summary strong {
  color: var(--rl-text);
  font-size: 13px;
}

/* ========================================================================
   PRINT
   ======================================================================== */
@page {
  size: A4;
  margin: 0;
}

@media print {
  html,
  body {
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    overflow: visible !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body.rl-printing-document > :not(.rl-print-document-root) {
    display: none !important;
  }

  body.rl-printing-document .rl-print-document-root {
    display: block !important;
    position: static !important;
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  body.rl-printing-document .rl-print-document-pages,
  body.rl-printing-document .rl-template-paper-stack {
    display: block !important;
    width: 210mm !important;
    max-width: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  body.rl-printing-document .rl-template-paper {
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    max-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    break-after: page;
    page-break-after: always;
  }

  body.rl-printing-document .rl-live-paper {
    width: 210mm !important;
    min-height: 297mm !important;
    height: auto !important;
    margin: 0 !important;
    padding: 16mm !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    break-after: page;
    page-break-after: always;
  }

  body.rl-printing-document .rl-template-paper:last-child,
  body.rl-printing-document .rl-live-paper:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  body.rl-printing-document .rl-template-badge,
  body.rl-printing-document .rl-template-paper--draft::after,
  body.rl-printing-document .rl-paper-blank--draft::after,
  body.rl-printing-document .rl-live-draft-badge {
    display: none !important;
  }

  body.rl-printing-document .rl-template-block--ai-notes,
  body.rl-printing-document .rl-template-block--table-note {
    white-space: pre-line !important;
    overflow-wrap: break-word !important;
  }

  .rl-sidebar, .rl-topbar, .rl-page-head, .rl-col-folders, .rl-col-list, .rl-preview-head, .rl-preview-zoom {
    display: none !important;
  }
  .rl-grid { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .rl-preview { position: static; max-height: none; box-shadow: none; border: none; }
  .rl-preview-body { padding: 0; background: white; }
  .rl-paper-blank { box-shadow: none; }
}

/* ════════════════════════════════════════════════
   Angebote — Status badges & convert-to-invoice FAB
   ════════════════════════════════════════════════ */
.rl-status--created { background: #e0e7ff; color: #3730a3; }
.rl-status--opened { background: #dbeafe; color: #1e40af; }
.rl-status--accepted { background: #dcfce7; color: #166534; }
.rl-status--rejected { background: #fee2e2; color: #991b1b; }

.rl-convert-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #2563eb, #1e40af);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 14px 32px -12px rgba(37,99,235,0.55), 0 6px 14px -6px rgba(15,23,42,0.25);
  z-index: 90;
  transition: transform .15s ease, box-shadow .15s ease;
}
.rl-convert-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 38px -12px rgba(37,99,235,0.6), 0 10px 18px -6px rgba(15,23,42,0.3);
  color: #fff;
}
.rl-convert-fab svg {
  width: 16px;
  height: 16px;
}

/* Rabatt-Tab-Pills — interactive button variant */
button.rl-tab-pill {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
  color: var(--rl-muted);
  padding: 6px 14px;
  border-radius: 999px;
  transition: background .15s ease, color .15s ease;
}
button.rl-tab-pill.rl-tab-pill--active {
  background: var(--rl-blue);
  color: #fff;
  border-color: var(--rl-blue);
}

/* ════════════════════════════════════════════════
   Row action — Öffnen + 3-dot context menu
   ════════════════════════════════════════════════ */
.rl-action--edit { color: var(--rl-blue); }
.rl-action--edit:hover { background: var(--rl-blue-soft); color: var(--rl-blue-dark); }

.rl-row-more {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}
.rl-row-more > .rl-action { background: transparent; border: none; cursor: pointer; }
.rl-row-menu {
  position: fixed;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--rl-border);
  border-radius: 10px;
  box-shadow: 0 18px 36px -16px rgba(15,23,42,0.25), 0 6px 14px -8px rgba(15,23,42,0.18);
  padding: 6px;
  z-index: 9000;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.rl-row-more.rl-row-more--open .rl-row-menu { display: flex; }
.rl-row-menu-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--rl-text);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.rl-row-menu-item:hover { background: var(--rl-bg-2); color: var(--rl-blue); }
.rl-row-menu-item svg { width: 14px; height: 14px; flex: 0 0 14px; }
.rl-row-menu-divider {
  height: 1px;
  background: var(--rl-border);
  margin: 4px 2px;
}

.rl-floating-action-menu {
  position: fixed;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--rl-border);
  border-radius: 10px;
  box-shadow: 0 18px 36px -16px rgba(15,23,42,0.25), 0 6px 14px -8px rgba(15,23,42,0.18);
  padding: 6px;
  z-index: 9100;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ======== ROW HOVER TOOLTIP ======== */
.rl-table td:first-child { position: relative; overflow: visible; }
.rl-row-tip {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 400;
  width: 276px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15,23,42,.13), 0 3px 12px rgba(15,23,42,.07);
  padding: 14px 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.rl-row-tip::before {
  content: '';
  position: absolute;
  top: -7px;
  left: 22px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
  transform: rotate(45deg);
}
tr:hover .rl-row-tip {
  opacity: 1;
  transform: translateY(0);
}
.rl-tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}
.rl-tip-num {
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.01em;
}
.rl-tip-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.rl-tip-badge--paid   { background: #dcfce7; color: #15803d; }
.rl-tip-badge--open   { background: #dbeafe; color: #1d4ed8; }
.rl-tip-badge--overdue{ background: #fee2e2; color: #dc2626; }
.rl-tip-badge--draft  { background: #f1f5f9; color: #64748b; }
.rl-tip-badge--sent   { background: #ede9fe; color: #6d28d9; }
.rl-tip-customer {
  font-size: 12.5px;
  font-weight: 500;
  color: #334155;
  margin-bottom: 8px;
}
.rl-tip-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: #64748b;
  margin-bottom: 10px;
}
.rl-tip-meta strong {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}
.rl-tip-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 0 -2px 10px;
}
.rl-tip-items { display: flex; flex-direction: column; gap: 3px; }
.rl-tip-item {
  font-size: 11px;
  color: #64748b;
  padding-left: 12px;
  position: relative;
}
.rl-tip-item::before {
  content: '·';
  position: absolute;
  left: 2px;
  color: #94a3b8;
}
.rl-tip-item--more { color: #94a3b8; font-style: italic; }
.rl-tip-item--more::before { content: ''; }

/* Finora readiness branding */
.rl-logo-mark,
.rl-brand-mark,
.rl-sidebar-org-logo {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: none;
  background: transparent url("assets/finora-logo-mark.png") center / contain no-repeat !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: transparent !important;
  font-size: 0 !important;
  overflow: visible !important;
}

.rl-logo-mark svg,
.rl-brand-mark svg,
.rl-sidebar-org-logo svg,
.rl-logo-mark::after,
.rl-brand-mark::after,
.rl-sidebar-org-logo::after {
  display: none !important;
}
