/* ============================================================
   Printsyndikat Admin - Browser-UI
   Design: Linear/Stripe-inspiriert, Orange-Akzente, Sidebar dunkel
   ============================================================ */
:root {
  --orange: #ff6b00;
  --orange-hover: #e55f00;
  --orange-soft: #fff1e5;
  --sidebar-bg: #0f0f0f;
  --sidebar-hover: #1f1f1f;
  --sidebar-divider: #2a2a2a;
  --bg: #fafafb;
  --bg-subtle: #f4f4f6;
  --white: #ffffff;
  --text: #0f0f0f;
  --text-soft: #3a3a3c;
  --muted: #8e8e93;
  --muted-dark: #6e6e73;
  --hair: #e5e5ea;
  --hair-soft: #ededf0;
  --green: #34c759;
  --green-dark: #248a3d;
  --green-soft: #e8f7ec;
  --red: #ff3b30;
  --red-dark: #c1352c;
  --red-soft: #fdecea;
  --blue: #007aff;
  --blue-soft: #e6f2ff;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: #c7c7cc;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 4px 8px 12px;
  flex-shrink: 0;
}
.brand-logo {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}
/* Backwards-Compat: alte Brand-Title/Sub-Klassen falls irgendwo noch genutzt */
.brand-title { color: #fff; font-weight: 700; font-size: 13px; letter-spacing: 1px; }
.brand-sub { color: var(--muted); font-size: 10px; letter-spacing: 2px; text-transform: uppercase; margin-top: 2px; }

.sidebar nav { flex: 1; padding: 8px; overflow-y: auto; min-height: 0; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: #c7c7cc;
  text-decoration: none;
  border-radius: var(--radius-md);
  margin: 2px 0;
  font-size: 13px;
  font-weight: 500;
}
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar nav a.active {
  background: var(--orange);
  color: #fff;
  font-weight: 600;
}
.sidebar nav a .ico { width: 18px; text-align: center; }

.sidebar-search {
  padding: 12px 8px 8px;
  border-bottom: 1px solid var(--sidebar-divider);
  margin-bottom: 8px;
}
.sidebar-search input[type="search"] {
  display: block;
  width: 100%;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--sidebar-divider);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  font-family: inherit;
  text-align: center;
  -webkit-appearance: none;
  box-sizing: border-box;
  margin: 2px 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sidebar-search input[type="search"]::placeholder {
  color: #8e8e93;
  text-align: center;
}
.sidebar-search input[type="search"]:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 2px rgba(255, 107, 0, 0.25);
  text-align: left;
}
.sidebar-search input[type="search"]:focus::placeholder {
  text-align: left;
}
/* Doppelte Lupe vermeiden: WebKit-eigenes Lupen-Decoration ausblenden */
.sidebar-search input[type="search"]::-webkit-search-decoration,
.sidebar-search input[type="search"]::-webkit-search-cancel-button,
.sidebar-search input[type="search"]::-webkit-search-results-button,
.sidebar-search input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
  display: none;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-divider);
  margin-top: auto;
  flex-shrink: 0;
  background: var(--sidebar-bg);
}
.user-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-badge {
  width: 32px; height: 32px;
  background: var(--orange);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { color: var(--muted); font-size: 11px; }
.logout {
  display: block;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}
.logout:hover { color: #fff; background: var(--sidebar-hover); }

/* ============ Content ============ */
.content {
  padding: 32px 40px;
  overflow-y: auto;
}
h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 20px 0 8px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-dark); }
p.subtitle { color: var(--muted-dark); margin: 0 0 24px; font-size: 14px; }

/* ============ Cards ============ */
.card {
  background: var(--white);
  border: 1px solid var(--hair-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-title { font-weight: 600; font-size: 15px; margin: 0; }
.card-subtitle { color: var(--muted-dark); font-size: 13px; margin-top: 4px; }

/* ============ KPI-Kacheln ============ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--white);
  border: 1px solid var(--hair-soft);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.kpi-icon {
  display: inline-flex;
  width: 36px; height: 36px;
  background: var(--orange-soft);
  border-radius: var(--radius-md);
  align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.kpi-label { color: var(--muted-dark); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; font-weight: 500; margin-top: 4px; }

/* ============ Tabellen ============ */
table.data {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--hair-soft);
  border-radius: var(--radius-lg);
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}
table.data th {
  background: var(--bg-subtle);
  color: var(--muted-dark);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  border-bottom: 1px solid var(--hair);
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--hair-soft);
  font-size: 13px;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--bg-subtle); }
table.data a { color: var(--text); text-decoration: none; font-weight: 500; }
table.data a:hover { color: var(--orange); }

.shop-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.status-pill.ok { background: var(--green-soft); color: var(--green-dark); }
.status-pill.bad { background: var(--red-soft); color: var(--red-dark); }
.status-pill.warn { background: #fff7d6; color: #9a7800; }
.status-pill.neutral { background: var(--hair-soft); color: var(--muted-dark); }

/* ============ Formulare ============ */
form .form-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--hair-soft);
}
form .form-row:last-of-type { border-bottom: none; }
form .form-row label { font-weight: 500; color: var(--text-soft); font-size: 13px; }
form .form-row .hint { grid-column: 2; color: var(--muted-dark); font-size: 12px; margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d2d2d7;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--white);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255,107,0,0.12);
}
input[type="color"] { height: 36px; width: 60px; padding: 2px; cursor: pointer; }
input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--orange);
  cursor: pointer;
}

fieldset { border: none; padding: 0; margin: 0; }
legend { display: none; }

.form-section {
  background: var(--white);
  border: 1px solid var(--hair-soft);
  border-radius: var(--radius-lg);
  padding: 8px 24px;
  margin-bottom: 16px;
}
.form-section h2 {
  margin: 16px 0 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--hair-soft);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--hair-soft);
}

/* ============ Buttons ============ */
.btn {
  padding: 9px 16px;
  border: 1px solid var(--hair);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  font-family: inherit;
}
.btn:hover { background: var(--bg-subtle); border-color: #86868b; }
.btn.primary,
.btn.btn-primary,
.btn-primary {
  background: var(--orange); color: #fff; border-color: var(--orange);
  font-weight: 600;
}
.btn.primary:hover,
.btn.btn-primary:hover,
.btn-primary:hover {
  background: var(--orange-hover); border-color: var(--orange-hover);
  color: #fff;
}
.btn.danger,
.btn.btn-danger,
.btn-danger {
  color: var(--red); border-color: var(--hair);
}
.btn.danger:hover,
.btn.btn-danger:hover,
.btn-danger:hover {
  background: var(--red-soft); border-color: var(--red);
}
.btn.ghost,
.btn.btn-ghost,
.btn-ghost {
  border-color: transparent; color: var(--muted-dark);
}
.btn.ghost:hover,
.btn.btn-ghost:hover,
.btn-ghost:hover {
  background: var(--bg-subtle); color: var(--text);
}
.btn.small,
.btn.btn-small,
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn.btn-full,
.btn-full { width: 100%; display: block; text-align: center; }
/* "active"-Marker (z.B. Zeitraum-Toggle 7/30/90 Tage): Orange-Highlight */
.btn-ghost.active,
.btn.ghost.active {
  background: var(--orange-soft);
  color: var(--orange);
  font-weight: 600;
}

/* ============ Alerts ============ */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert.success { background: var(--green-soft); color: var(--green-dark); border-color: #b9e6c3; }
.alert.error { background: var(--red-soft); color: var(--red-dark); border-color: #f5b9b2; }
.alert.info { background: var(--blue-soft); color: #1a3f80; border-color: #b9d5f5; }

/* ============ Shop-Access-Liste (Checkboxen fuer User-Edit) ============ */
.shop-access {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}
.shop-access label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--hair-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--bg-subtle);
  font-weight: 400 !important;
}
.shop-access label:has(input:checked) {
  background: var(--orange-soft);
  border-color: #ffb380;
}

/* ============ Login-Seite ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
}
.login-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-box h1 {
  font-size: 20px;
  text-align: center;
  margin: 0 0 4px;
}
.login-box p.subtitle {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo {
  display: block;
  width: 100%;
  max-width: 240px;
  height: auto;
  margin: 0 auto 16px;
}
.login-box form input {
  margin-bottom: 12px;
}

/* ============ Actions-Bar oben ============ */
.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}
.page-actions-left h1 { margin-bottom: 0; }

/* ============ Misc ============ */
.muted { color: var(--muted-dark); }
.small { font-size: 12px; }
code {
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--text-soft);
}

.inline-form { display: inline-block; margin: 0; }

/* ============== TICKETS-ERGÄNZUNGEN ============== */

/* Sidebar-Section-Labels */
.sidebar .nav-section {
    color: #6a6a70;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 16px 20px 4px 20px;
    text-transform: uppercase;
}

.nav-badge {
    background: #ff6b00;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

/* Ticket-Statistik-Leiste */
.stat-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    display: block;
    background: #fff;
    border: 1px solid #ededf0;
    border-radius: 12px;
    padding: 16px 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s;
}
.stat-card:hover { border-color: #d2d2d7; }
.stat-card.active { border-color: #ff6b00; background: #fff9f3; }
.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: #6e6e73;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #0f0f0f;
}

/* Filter-Bar */
.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.filter-bar input[type=text] {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-size: 14px;
}
.filter-bar select {
    padding: 10px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
}

/* Daten-Tabelle */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    background: #f4f4f6;
    color: #6e6e73;
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #ededf0;
}
.data-table td {
    padding: 14px;
    border-bottom: 1px solid #f4f4f6;
    font-size: 14px;
    vertical-align: middle;
}
.data-table tr:hover { background: #fafafb; }
.cell-wide { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chips */
.shop-chip, .cat-chip, .user-chip {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.cat-chip { background: #f0f0f3; color: #3a3a3c; }
.cat-rekl { background: #ffe4cc; color: #ff6b00; }
.cat-angebot { background: #e8f7ec; color: #248a3d; }

/* Status-Labels */
.status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.status-open { background: #fff1e5; color: #ff6b00; }
.status-progress { background: #e6f2ff; color: #007aff; }
.status-waiting { background: #fff7d6; color: #b58900; }
.status-resolved { background: #e8f7ec; color: #248a3d; }
.status-closed { background: #f0f0f3; color: #6e6e73; }

.prio-urgent { color: #ff3b30; font-weight: 600; }
.prio-high { color: #ff6b00; font-weight: 600; }
.prio-low { color: #8e8e93; }

/* Empty-State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #8e8e93;
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-title { font-size: 18px; font-weight: 600; color: #3a3a3c; margin-bottom: 6px; }
.empty-sub { font-size: 14px; }
.empty-sub a { color: #ff6b00; text-decoration: none; }

/* Ticket-Edit-Layout */
.ticket-layout {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
    align-items: start;
}
.ticket-main { display: flex; flex-direction: column; gap: 16px; }
.ticket-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }

/* Formulare */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: #3a3a3c; margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea,
.form-grid input, .form-grid select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    box-sizing: border-box;
}
.form-row textarea { resize: vertical; min-height: 80px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus,
.form-grid input:focus, .form-grid select:focus {
    border-color: #ff6b00;
    outline: none;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}
.form-grid label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #3a3a3c;
    margin-bottom: 6px;
}

/* Reklamations-Flags */
.rekl-flags {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    padding: 12px;
    background: #fafafb;
    border: 1px solid #ededf0;
    border-radius: 8px;
    margin: 12px 0;
}
.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}
.check input[type=checkbox] { width: 16px; height: 16px; accent-color: #ff6b00; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-entry {
    padding: 12px 14px;
    border-left: 3px solid #ededf0;
    background: #fafafb;
    border-radius: 0 8px 8px 0;
}
.timeline-internal { border-left-color: #ffcc00; background: #fffbea; }
.timeline-status { border-left-color: #007aff; }
.timeline-assign { border-left-color: #34c759; }
.timeline-comment { border-left-color: #ff6b00; }
.timeline-meta { display: flex; gap: 10px; align-items: center; font-size: 11px; margin-bottom: 6px; }
.timeline-author { font-weight: 600; }
.timeline-time { color: #8e8e93; }
.timeline-body { font-size: 14px; white-space: pre-wrap; color: #1a1a1a; }
.kind-chip {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f0f0f3;
    color: #3a3a3c;
}
.kind-internal { background: #fff7d6; color: #b58900; }
.kind-status { background: #e6f2ff; color: #007aff; }
.kind-assign { background: #e8f7ec; color: #248a3d; }
.kind-comment { background: #ffe4cc; color: #ff6b00; }

/* Comment-Form */
.comment-form-inline textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d2d2d7;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    box-sizing: border-box;
    margin-bottom: 10px;
}
.form-actions { display: flex; gap: 8px; }
.form-actions.sticky { padding-top: 8px; }
.btn-full { width: 100%; }

/* Key-Value-Liste */
.kv {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid #f4f4f6;
}
.kv:last-child { border: 0; }
.kv span { color: #6e6e73; }

/* Flash-Messages */
.flash {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash-ok { background: #e8f7ec; color: #248a3d; border: 1px solid #c9ecd2; }
.flash-err { background: #fdecea; color: #c1352c; border: 1px solid #f5c6c1; }

/* Misc */
.crumb { font-size: 12px; color: #8e8e93; margin-bottom: 6px; }
.crumb a { color: #8e8e93; text-decoration: none; }
.crumb a:hover { color: #ff6b00; }
.muted { color: #8e8e93; }
.muted.small { font-size: 12px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: #0f0f0f; }
.card-title small { font-weight: 400; margin-left: 6px; }
.page-sub { color: #8e8e93; font-size: 14px; margin-top: 2px; }

/* === MAIL-TIMELINE === */
.timeline-mail-in {
    border-left-color: #007aff;
    background: linear-gradient(to right, #e6f2ff 0%, #fafafb 40%);
}
.timeline-mail-out {
    border-left-color: #34c759;
    background: linear-gradient(to right, #e8f7ec 0%, #fafafb 40%);
}
.timeline-subject {
    font-size: 13px;
    color: #3a3a3c;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #ededf0;
}
.kind-mail-in { background: #e6f2ff; color: #007aff; }
.kind-mail-out { background: #e8f7ec; color: #248a3d; }

/* === ATTACHMENTS === */
.attachments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #ededf0;
}
.attachments-header {
    font-size: 12px;
    font-weight: 600;
    color: #6e6e73;
    margin-bottom: 8px;
}
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.attachment-tile {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ededf0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: border-color 0.15s;
}
.attachment-tile:hover {
    border-color: #ff6b00;
}
.att-image-link {
    display: block;
    background: #fafafb;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}
.att-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.att-icon {
    font-size: 40px;
    text-align: center;
    padding: 24px 0;
    background: #fafafb;
    color: #8e8e93;
}
.att-meta {
    padding: 8px 10px;
    flex: 1;
    min-width: 0;
}
.att-name {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1a1a1a;
}
.att-size {
    font-size: 11px;
    color: #8e8e93;
    margin-top: 2px;
}
.att-download {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,0.95);
    border: 1px solid #d2d2d7;
    color: #3a3a3c;
    width: 28px;
    height: 28px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    transition: all 0.15s;
}
.att-download:hover {
    background: #ff6b00;
    color: #fff;
    border-color: #ff6b00;
}

/* === HTML/PLAIN-TOGGLE === */
.view-toggle {
    background: #fff1e5;
    color: #ff6b00;
    border: 0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-left: auto;
}
.view-toggle:hover {
    background: #ffe4cc;
}
.timeline-html {
    background: #fff;
    padding: 12px;
    border: 1px solid #ededf0;
    border-radius: 6px;
    font-size: 14px;
    /* Mail-HTML aus Drittquellen kann breite Tabellen/Bilder enthalten.
       Eingrenzen damit nichts ueber die Card hinausragt. */
    max-width: 100%;
    overflow-x: auto;
    overflow-wrap: break-word;
    word-break: break-word;
}
.timeline-html p { margin: 0 0 8px 0; }
.timeline-html a { color: #ff6b00; }
.timeline-html blockquote {
    margin: 8px 0;
    padding-left: 12px;
    border-left: 3px solid #ededf0;
    color: #6e6e73;
}
.timeline-html table {
    border-collapse: collapse;
    margin: 8px 0;
    max-width: 100%;
    table-layout: auto;
}
.timeline-html td, .timeline-html th {
    border: 1px solid #ededf0;
    padding: 4px 8px;
    word-break: break-word;
}
.timeline-html img,
.timeline-html iframe,
.timeline-html video {
    max-width: 100%;
    height: auto;
}
.timeline-html pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* === SLA === */
.sla-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-left: 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.sla-ok { background: #e8f7ec; color: #248a3d; }
.sla-warn { background: #fff7d6; color: #b58900; }
.sla-overdue { background: #fdecea; color: #c1352c; }

/* === MOBILE / RESPONSIVE === */
@media (max-width: 960px) {
    /* Sidebar wird zu Top-Bar */
    .app {
        display: block !important;
    }
    .sidebar {
        width: 100%;
        min-height: auto;
        max-height: 60px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding: 8px;
        position: sticky;
        top: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        gap: 4px;
    }
    .sidebar .brand {
        padding: 0 12px 0 4px;
        flex-shrink: 0;
    }
    .sidebar .brand-title {
        font-size: 14px;
    }
    .sidebar .brand-sub {
        display: none;
    }
    .sidebar nav {
        display: flex;
        flex-direction: row;
        gap: 2px;
        margin: 0;
        flex-shrink: 0;
    }
    .sidebar nav a {
        padding: 6px 10px;
        border-radius: 6px;
        font-size: 13px;
        white-space: nowrap;
    }
    .sidebar .nav-section {
        display: none;
    }
    .sidebar-footer {
        display: none;
    }
    /* Content nutzt volle Breite */
    .content {
        padding: 12px !important;
    }
    /* Ticket-Layout: einspaltig */
    .ticket-layout {
        grid-template-columns: 1fr !important;
    }
    .ticket-side {
        position: static !important;
    }
    /* Stat-Row: 2 Spalten statt 4 */
    .stat-row {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    /* Form-Grid: 1 Spalte */
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    /* Reklamations-Flags: 1 Spalte */
    .rekl-flags {
        grid-template-columns: 1fr !important;
    }
    /* Data-Table auf Mobile: scrollbar horizontal */
    .card {
        overflow-x: auto;
    }
    .data-table {
        min-width: 600px;
    }
    /* Page-Header stapelt */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    /* Filter-Bar stapelt */
    .filter-bar {
        flex-wrap: wrap;
    }
    .filter-bar input[type=text] {
        flex: 1 1 100%;
    }
    /* Attachments: 2 Spalten */
    .attachments-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    /* Page-Titel kleiner */
    .page-header h1 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .stat-row {
        grid-template-columns: 1fr !important;
    }
    .stat-value {
        font-size: 22px !important;
    }
    .attachments-grid {
        grid-template-columns: 1fr;
    }
}
