:root {
  --bg:        #0d1117;
  --bg-card:   #161b22;
  --bg-raised: #1c2330;
  --bg-hover:  #212836;
  --border:    #30363d;
  --border-hi: #444c56;
  --text:      #e6edf3;
  --text-sub:  #8b949e;
  --text-muted:#6e7681;
  --accent:    #2f81f7;
  --accent-hi: #58a6ff;
  --green:     #238636;
  --green-fg:  #3fb950;
  --amber:     #9e6a03;
  --amber-fg:  #d29922;
  --red:       #b91c1c;
  --red-fg:    #f85149;

  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }

body { margin: 0; }

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

/* ── Header ──────────────────────────────────────── */
.header {
  background: #010409;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.header nav { display: flex; gap: 0.25rem; }

.header nav a {
  color: var(--text-sub);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: color 0.1s, background 0.1s;
}

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

.header nav a.nav-active {
  color: var(--text);
  background: var(--bg-raised);
  font-weight: 600;
}

.header h1 a {
  color: inherit;
}

#main-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
}

.nav-user {
  font-size: 0.85rem;
}

.btn-nav-logout {
  padding: 0.3rem 0.65rem;
  font-size: 0.85rem;
}

.auth-panel {
  max-width: 28rem;
}

.row-inline {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.users-table .users-actions {
  white-space: nowrap;
}

.users-table .users-actions button {
  margin-right: 0.35rem;
  margin-bottom: 0.25rem;
}

.options-page .options-section-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
}

.options-page .options-section .muted code {
  font-size: 0.85em;
}

/* LDAP-Synchronisation (Referenz-Layout) */
.ldap-section {
  padding: 0;
  overflow: hidden;
}

.ldap-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  margin: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.ldap-section-toggle:hover {
  background: var(--bg-hover);
}

.ldap-section-heading {
  flex: 1;
}

.ldap-chevron {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ldap-section-body {
  padding: 1rem 1.25rem 1.25rem;
}

.ldap-section-body[hidden] {
  display: none !important;
}

.ldap-subtitle {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-sub);
}

.ldap-sync-check {
  margin-bottom: 1rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

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

.form-grid-ldap-attr {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

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

.options-page label.full-width {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.ldap-filter-ta {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  min-height: 5rem;
}

.ldap-hint {
  margin: -0.35rem 0 0.75rem;
  font-size: 0.82rem;
}

.options-actions {
  display: flex;
  justify-content: flex-start;
}

.btn-config-save {
  padding: 0.5rem 1.25rem;
  font-weight: 600;
}

/* LDAP Sync-Panel (Optionen) */
.sync-panel .sync-actions {
  margin-bottom: 0.75rem;
}

.btn-ldap-sync-now {
  padding: 0.5rem 1.1rem;
  font-weight: 600;
}

.sync-last-line {
  margin: 0 0 1rem;
  font-size: 0.92rem;
}

.sync-log-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-sub);
  text-transform: none;
  letter-spacing: normal;
}

.sync-log-table-wrap {
  overflow-x: auto;
}

table.sync-log-table {
  font-size: 0.88rem;
}

table.sync-log-table th,
table.sync-log-table td {
  padding: 0.45rem 0.65rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.sync-log-table th {
  font-weight: 600;
  color: var(--text-sub);
  text-align: left;
}

table.sync-log-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sync-status-badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.sync-status-badge.sync-status-ok {
  background: rgba(46, 160, 67, 0.25);
  color: #3fb950;
  border: 1px solid rgba(63, 185, 80, 0.45);
}

.sync-status-badge.sync-status-err {
  background: rgba(248, 81, 73, 0.15);
  color: var(--red, #f85149);
  border: 1px solid rgba(248, 81, 73, 0.35);
}

.tv-device-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.tv-device-row label {
  flex: 1;
  min-width: 12rem;
}

.tv-conn-hint {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
}

/* ── Layout ──────────────────────────────────────── */
.main {
  padding: 1.5rem 2rem;
  max-width: 100%;
}

/* ── Card ────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

/* ── Stack / Row ─────────────────────────────────── */
.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

/* [hidden] muss trotz .stack gelten (sonst bleibt z. B. #form-m sichtbar) */
.stack[hidden] {
  display: none !important;
}

.row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

/* ── Typography ─────────────────────────────────── */
h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
h3, h4 { margin: 0 0 0.5rem; font-size: 0.95rem; color: var(--text-sub); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

.muted  { color: var(--text-muted); font-size: 0.9rem; }
.error  { color: var(--red-fg); font-size: 0.9rem; }

/* ── Forms ───────────────────────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-sub);
}

input, select, textarea, button { font: inherit; }

input, select, textarea {
  padding: 0.45rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  min-width: 180px;
  transition: border-color 0.1s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

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

button {
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.12s;
}
button:hover { opacity: 0.85; }
button.secondary {
  background: transparent;
  color: var(--accent-hi);
  border-color: var(--border-hi);
}
button.secondary:hover { background: var(--bg-hover); opacity: 1; }
button.danger { border-color: var(--red); background: var(--red); color: #fff; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Table (global) ──────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-sub);
  font-weight: 600;
}

/* ── Badge ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--bg-raised);
  color: var(--text-sub);
  border: 1px solid var(--border-hi);
}

/* ── Timeline ────────────────────────────────────── */
.timeline {
  border-left: 2px solid var(--border);
  margin-left: 0.35rem;
  padding-left: 1rem;
}
.timeline-item { margin-bottom: 1rem; }
.timeline-item time { font-size: 0.78rem; color: var(--text-muted); }

/* ── Table-Wrap ──────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Extras / Anlagen ────────────────────────────── */
.extras-table { font-size: 0.88rem; }
.extras-table th {
  vertical-align: top;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-sub);
  border-right: 1px solid var(--border);
}
/* Nur Key-Value-Extras: feste Schlüsselspalte (nicht Anlagenliste mit 3 Spalten) */
.extras-table:not(.anlagen-voll) th {
  width: 11rem;
}

.extras-cell-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.35rem 0.45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
.extras-table th .extras-cell-input {
  font-weight: 500;
  text-transform: none;
  letter-spacing: normal;
}

.machine-detail-card-title {
  margin-top: 0;
  font-size: 1rem;
  font-weight: 600;
}

.machine-detail-actions {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.machine-detail-card-title + .machine-detail-actions {
  margin-bottom: 0.75rem;
}
/* Anlagenliste: Gruppe + Beschreibung schmal aber lesbar, „Wert“ der Rest.
   Kein width:100% auf der letzten Zelle — das drückt Spalte 2 auf Mindestbreite. */
.anlagen-voll {
  width: 100%;
  table-layout: fixed;
}
/* Spaltenbreiten über colgroup: 1+2 kompakt, 3 bekommt den Rest (kein width:100% auf Zellen) */
.anlagen-voll col.anlagen-col-gruppe {
  width: 10rem;
}
.anlagen-voll col.anlagen-col-beschr {
  width: 22%;
  min-width: 11rem;
}
.anlagen-voll col.anlagen-col-wert {
  width: auto;
}
.anlagen-voll:not(.gruppiert) thead th {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.75rem;
  vertical-align: bottom;
}
.anlagen-voll:not(.gruppiert) thead th:nth-child(1),
.anlagen-voll:not(.gruppiert) tbody td:nth-child(1) {
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.85rem;
}
.anlagen-voll:not(.gruppiert) thead th:nth-child(2),
.anlagen-voll:not(.gruppiert) tbody th:nth-child(2) {
  vertical-align: top;
  max-width: 28rem;
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
}
.anlagen-voll:not(.gruppiert) thead th:nth-child(3),
.anlagen-voll:not(.gruppiert) tbody td:nth-child(3) {
  vertical-align: top;
  word-break: break-word;
}

/* Gruppierte Anlagenliste: Box pro Gruppe, Kopfzeile = Gruppenname */
.anlagen-voll.gruppiert col.anlagen-col-beschr {
  width: 22%;
  min-width: 11rem;
}
.anlagen-voll.gruppiert col.anlagen-col-wert {
  width: auto;
}
.anlagen-voll.gruppiert thead th {
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.75rem;
  vertical-align: bottom;
}
.anlagen-voll.gruppiert thead th:first-child,
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf) th {
  vertical-align: top;
  max-width: 28rem;
  white-space: normal;
  word-break: break-word;
  hyphens: auto;
}
.anlagen-voll.gruppiert thead th:last-child,
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf) td {
  vertical-align: top;
  word-break: break-word;
}
.anlagen-voll.gruppiert tbody.anlagen-gruppe-spacer td {
  height: 0.85rem;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}
.anlagen-voll.gruppiert tr.anlagen-gruppe-kopf td {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: 0.02em;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border-hi);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
}
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr.anlagen-gruppe-kopf td:first-child {
  border-radius: 8px 8px 0 0;
}
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf) th,
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf) td {
  border-left: 1px solid var(--border-hi);
  border-right: 1px solid var(--border-hi);
}
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf) th {
  border-right: 1px solid var(--border);
}
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf):last-child th:first-child {
  border-bottom: 1px solid var(--border-hi);
  border-bottom-left-radius: 8px;
}
.anlagen-voll.gruppiert tbody.anlagen-gruppe tr:not(.anlagen-gruppe-kopf):last-child td:last-child {
  border-bottom: 1px solid var(--border-hi);
  border-bottom-right-radius: 8px;
}

.main:has(.machines-overview) { max-width: 100%; }

code {
  font-size: 0.85em;
  background: var(--bg-raised);
  color: var(--text-sub);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* ═══════════════════════════════════════════════════
   Startseite — Offene Tickets
════════════════════════════════════════════════════ */
.home-open-tickets { gap: 1rem; }

.home-kpi-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.home-kpi-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kpi-pill .badge {
  font-size: 0.8rem;
  padding: 0.2rem 0.65rem;
}

.home-open-tickets h2 {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  margin: 0;
}

.home-ticket-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.home-ticket-card {
  padding: 0;
  overflow: hidden;
}

.home-ticket-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
}

.home-ticket-head.home-ticket-head-overdue {
  background-color: rgba(180, 40, 40, 0.12);
  box-shadow: inset 3px 0 0 0 #b42828;
}

.home-ticket-collapse-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 0.2rem 0.35rem 0 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.2;
  cursor: pointer;
  align-self: flex-start;
}

.home-ticket-collapse-btn:hover {
  color: var(--accent-hi);
}

.home-ticket-head-main {
  flex: 1;
  min-width: 12rem;
}

.home-ticket-collapsible[hidden] {
  display: none !important;
}

.home-ticket-titleline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.home-ticket-titleline > a {
  font-weight: 600;
}

.home-ticket-meta-row {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
}

.home-ticket-open {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-hi);
  transition: background 0.1s;
  flex-shrink: 0;
  text-decoration: none;
}

.home-ticket-open:hover {
  background: rgba(47, 129, 247, 0.12);
  text-decoration: none;
}

.home-ticket-context {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}

.home-ticket-context-h {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
}

.home-ticket-desc {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-sub);
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 0;
}

.home-ticket-machine {
  margin: 0.65rem 0 0;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.home-ticket-events {
  padding: 0.75rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.home-ticket-no-events {
  margin: 0;
  font-size: 0.88rem;
}

.home-event-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  font-size: 0.88rem;
}

.home-event-box-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.45rem;
}

.home-event-box-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.home-event-box-body :last-child {
  margin-bottom: 0;
}

/* Status badge variants */
.badge-open    { background: rgba(35, 134, 54, 0.15);  color: var(--green-fg);  border-color: rgba(63, 185, 80, 0.3); }
.badge-waiting { background: rgba(158, 106, 3, 0.15);  color: var(--amber-fg);  border-color: rgba(210, 153, 34, 0.3); }
.badge-done    { background: rgba(110, 118, 129, 0.12); color: var(--text-muted); border-color: var(--border); }

/* Priority badge variants */
.badge-high   { background: rgba(185, 28, 28, 0.18); color: var(--red-fg);    border-color: rgba(248, 81, 73, 0.35); }
.badge-medium { background: rgba(158, 106, 3, 0.15); color: var(--amber-fg);  border-color: rgba(210, 153, 34, 0.3); }
.badge-low    { background: rgba(35, 134, 54, 0.1);  color: var(--green-fg);  border-color: rgba(63, 185, 80, 0.2); }

/* Ticket-Detail: Ereignisse als Tabelle (neueste zuerst) */
.events-table {
  font-size: 0.9rem;
}

.events-table thead th {
  background: var(--bg-raised);
  white-space: nowrap;
}

.events-table-time {
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 1%;
  vertical-align: top;
}

.events-table-desc {
  color: var(--text-sub);
  vertical-align: top;
  line-height: 1.5;
}

.event-inhalt-block {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.event-inhalt-label {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.event-inhalt-text {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.event-inhalt-meta {
  margin: 0;
  font-size: 0.88rem;
}

.event-artnr {
  font-size: 0.95em;
}

.event-tv-placeholder {
  font-size: 0.85em;
}

.ev-field-group[hidden] {
  display: none !important;
}

.event-type-badge {
  white-space: nowrap;
}

.event-type-note   { background: rgba(88, 166, 255, 0.12); color: var(--accent-hi); border-color: rgba(88, 166, 255, 0.35); }
.event-type-call   { background: rgba(163, 113, 247, 0.14); color: #d2a8ff; border-color: rgba(163, 113, 247, 0.35); }
.event-type-remote { background: rgba(35, 134, 54, 0.15); color: var(--green-fg); border-color: rgba(63, 185, 80, 0.3); }
.event-type-part   { background: rgba(210, 153, 34, 0.14); color: var(--amber-fg); border-color: rgba(210, 153, 34, 0.35); }
.event-type-attachment { background: rgba(244, 143, 177, 0.12); color: #f48fb1; border-color: rgba(244, 143, 177, 0.35); }
.event-type-system { background: rgba(110, 118, 129, 0.18); color: var(--text-muted); border-color: var(--border-hi); }

.event-attachment-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
.event-attachment-list a {
  font-weight: 500;
}

/* Vorschau-Modal — kein display auf dem Basis-Selektor: sonst überschreibt flex das UA- display:none und der Dialog ist immer sichtbar */
.attachment-preview-dialog {
  border: 1px solid var(--border-hi, #444);
  border-radius: 10px;
  padding: 0;
  max-width: min(960px, 96vw);
  width: 96vw;
  background: var(--bg, #0d1117);
  color: var(--text, #e6edf3);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}
.attachment-preview-dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: min(90vh, 900px);
  max-height: min(90vh, 900px);
}
.attachment-preview-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}
.attachment-preview-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.attachment-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-hi, #444);
  flex-shrink: 0;
}
.attachment-preview-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-preview-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 6px;
  background: var(--border-hi, #444);
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.attachment-preview-close:hover {
  filter: brightness(1.15);
}
.attachment-preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}
/* PDF: kein Scroll am äußeren Container — nur der Browser-PDF-Viewer im iframe scrollt */
.attachment-preview-body--embed {
  overflow: hidden;
  padding: 0;
}
/* Bild, Text, Video, Fehler: ein gemeinsamer Scrollbereich */
.attachment-preview-body--scroll {
  overflow: auto;
  padding: 0.75rem 1rem;
  align-items: center;
}
.attachment-preview-img {
  max-width: 100%;
  max-height: min(75vh, 800px);
  height: auto;
  object-fit: contain;
}
.attachment-preview-iframe {
  flex: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  background: #fff;
}
.attachment-preview-video {
  max-width: 100%;
  max-height: min(75vh, 800px);
}
.attachment-preview-audio {
  width: 100%;
  min-width: 280px;
}
.attachment-preview-text {
  margin: 0;
  align-self: stretch;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.45;
  max-height: min(75vh, 800px);
  overflow: auto;
  text-align: left;
}
.attachment-preview-footer {
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border-hi, #444);
  flex-shrink: 0;
}
.attachment-preview-loading {
  margin: 0;
}
