/* ==========================================================================
   Mail Manager – Design System
   Angelehnt an die AutoCRM-Oberflaeche: Inter, OKLCH-Indigo (Hue 265),
   Light + Dark, weiche Schatten, ruhige shadcn-Anmutung.
   ========================================================================== */

:root {
  /* Light-Theme (Default) */
  --background:        oklch(0.97 0.005 265);
  --foreground:        oklch(0.18 0.02 265);
  --card:              oklch(1.00 0 0);
  --card-2:            oklch(0.985 0.004 265);
  --card-foreground:   oklch(0.18 0.02 265);
  --primary:           oklch(0.55 0.22 265);
  --primary-strong:    oklch(0.50 0.24 265);
  --primary-foreground:oklch(1.00 0 0);
  --primary-soft:      oklch(0.55 0.22 265 / 0.12);
  --secondary:         oklch(0.95 0.01 265);
  --secondary-foreground: oklch(0.40 0.04 265);
  --muted:             oklch(0.96 0.005 265);
  --muted-foreground:  oklch(0.50 0.02 265);
  --accent:            oklch(0.93 0.02 265);
  --accent-foreground: oklch(0.40 0.15 265);
  --destructive:       oklch(0.58 0.22 25);
  --destructive-soft:  oklch(0.58 0.22 25 / 0.12);
  --success:           oklch(0.60 0.16 150);
  --success-soft:      oklch(0.60 0.16 150 / 0.14);
  --warning:           oklch(0.70 0.16 75);
  --border:            oklch(0.91 0.01 265);
  --border-strong:     oklch(0.86 0.015 265);
  --input:             oklch(1.00 0 0);
  --ring:              oklch(0.55 0.22 265);
  --sidebar:           oklch(0.98 0.006 265);

  --radius:    0.75rem;
  --radius-sm: 0.5rem;
  --radius-lg: 0.9rem;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;

  --shadow-xs: 0 1px 2px oklch(0.2 0.02 265 / 0.06);
  --shadow-sm: 0 1px 3px oklch(0.2 0.02 265 / 0.08), 0 1px 2px -1px oklch(0.2 0.02 265 / 0.08);
  --shadow-md: 0 4px 12px oklch(0.2 0.02 265 / 0.08), 0 2px 4px -2px oklch(0.2 0.02 265 / 0.06);
  --shadow-lg: 0 12px 32px oklch(0.2 0.02 265 / 0.14), 0 4px 8px -4px oklch(0.2 0.02 265 / 0.10);
  --shadow-primary: 0 6px 20px oklch(0.55 0.22 265 / 0.35);
}

.dark {
  --background:        oklch(0.13 0.02 270);
  --foreground:        oklch(0.95 0.01 265);
  --card:              oklch(0.165 0.02 270);
  --card-2:            oklch(0.19 0.022 270);
  --card-foreground:   oklch(0.95 0.01 265);
  --primary:           oklch(0.62 0.20 265);
  --primary-strong:    oklch(0.66 0.20 265);
  --primary-foreground:oklch(1.00 0 0);
  --primary-soft:      oklch(0.62 0.20 265 / 0.18);
  --secondary:         oklch(0.22 0.02 270);
  --secondary-foreground: oklch(0.85 0.02 265);
  --muted:             oklch(0.20 0.02 270);
  --muted-foreground:  oklch(0.68 0.02 265);
  --accent:            oklch(0.25 0.03 265);
  --accent-foreground: oklch(0.92 0.02 265);
  --destructive:       oklch(0.65 0.20 25);
  --destructive-soft:  oklch(0.65 0.20 25 / 0.18);
  --success:           oklch(0.72 0.16 155);
  --success-soft:      oklch(0.72 0.16 155 / 0.16);
  --warning:           oklch(0.78 0.15 80);
  --border:            oklch(0.26 0.02 270);
  --border-strong:     oklch(0.32 0.025 270);
  --input:             oklch(0.20 0.02 270);
  --ring:              oklch(0.62 0.20 265);
  --sidebar:           oklch(0.145 0.02 270);

  --shadow-xs: 0 1px 2px oklch(0 0 0 / 0.3);
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.35), 0 1px 2px -1px oklch(0 0 0 / 0.35);
  --shadow-md: 0 6px 18px oklch(0 0 0 / 0.4), 0 2px 6px -2px oklch(0 0 0 / 0.3);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5), 0 6px 12px -6px oklch(0 0 0 / 0.4);
  --shadow-primary: 0 8px 24px oklch(0.62 0.20 265 / 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: color-mix(in oklch, var(--primary) 30%, transparent); border-radius: 9999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--primary); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in oklch, var(--primary) 30%, transparent) transparent; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  position: relative; overflow: hidden; background: var(--background);
}
/* Animierter Hintergrund */
.login-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.login-bg .aurora {
  position: absolute; inset: -30%;
  background:
    radial-gradient(40% 55% at 20% 30%, oklch(0.55 0.24 265 / 0.55), transparent 60%),
    radial-gradient(45% 50% at 80% 25%, oklch(0.55 0.22 300 / 0.45), transparent 60%),
    radial-gradient(50% 55% at 60% 85%, oklch(0.55 0.22 220 / 0.40), transparent 60%);
  filter: blur(60px); opacity: .8; animation: aurora 18s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(-4%, -2%, 0) rotate(0deg) scale(1.05); }
  50%  { transform: translate3d(3%, 3%, 0) rotate(8deg) scale(1.15); }
  100% { transform: translate3d(2%, -3%, 0) rotate(-6deg) scale(1.08); }
}
.login-bg .orb { position: absolute; border-radius: 50%; filter: blur(14px); opacity: .5; mix-blend-mode: screen; }
.login-bg .orb-1 { width: 320px; height: 320px; left: 8%; top: 12%; background: radial-gradient(circle at 30% 30%, oklch(0.65 0.22 265), transparent 70%); animation: float1 14s ease-in-out infinite; }
.login-bg .orb-2 { width: 260px; height: 260px; right: 10%; top: 20%; background: radial-gradient(circle at 30% 30%, oklch(0.62 0.22 300), transparent 70%); animation: float2 17s ease-in-out infinite; }
.login-bg .orb-3 { width: 300px; height: 300px; left: 42%; bottom: 4%; background: radial-gradient(circle at 30% 30%, oklch(0.62 0.20 215), transparent 70%); animation: float3 20s ease-in-out infinite; }
@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(40px,-30px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-36px,26px); } }
@keyframes float3 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(24px,-38px); } }
.login-bg .grid-overlay {
  position: absolute; inset: 0;
  background-image: linear-gradient(oklch(0.7 0.05 265 / 0.05) 1px, transparent 1px), linear-gradient(90deg, oklch(0.7 0.05 265 / 0.05) 1px, transparent 1px);
  background-size: 46px 46px; mask-image: radial-gradient(70% 70% at 50% 50%, #000 40%, transparent 100%);
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, #000 40%, transparent 100%);
}
/* Video-Hintergrund (liegt ueber der Aurora, die als Fallback dient). */
.login-bg .login-video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  z-index: 1;
}
/* Abdunkelung fuer Kontrast/Lesbarkeit der Login-Karte. */
.login-bg .login-scrim {
  position: absolute; inset: 0; z-index: 2;
  background:
    radial-gradient(60% 60% at 50% 45%, transparent 0%, oklch(0.10 0.02 265 / 0.35) 100%),
    linear-gradient(180deg, oklch(0.10 0.02 265 / 0.30), oklch(0.08 0.02 265 / 0.55));
}

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px; background: color-mix(in oklch, var(--card) 45%, transparent);
  backdrop-filter: blur(18px) saturate(1.3); border: 1px solid var(--border-strong);
  border-radius: 22px; padding: 38px 34px; box-shadow: var(--shadow-lg), 0 0 0 1px oklch(1 0 0 / 0.04) inset;
  animation: cardIn .6s cubic-bezier(.2,.8,.25,1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(22px) scale(.97); } }
.login-card .reveal { opacity: 0; animation: revealUp .5s cubic-bezier(.2,.8,.25,1) both; }
@keyframes revealUp { from { opacity: 0; transform: translateY(10px); } }
.lang-pill {
  position: absolute; top: 16px; right: 16px; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 9999px; border: 1px solid var(--border-strong);
  background: var(--card); color: var(--muted-foreground); cursor: pointer; font-weight: 600; font-size: 12px; transition: .12s; z-index: 2;
}
.lang-pill:hover { background: var(--accent); color: var(--accent-foreground); }
.lang-pill svg { width: 14px; height: 14px; }
.login-card .brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-card h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.login-card p.sub { color: var(--muted-foreground); font-size: 13px; margin-top: 1px; }
/* Logo mit pulsierendem Glow-Ring */
.logo-mark.glow { position: relative; }
.logo-mark.glow::after {
  content: ''; position: absolute; inset: -5px; border-radius: 15px;
  background: linear-gradient(140deg, var(--primary), oklch(0.55 0.22 300)); z-index: -1;
  filter: blur(12px); opacity: .55; animation: glowPulse 3s ease-in-out infinite;
}
@keyframes glowPulse { 0%,100% { opacity: .4; transform: scale(1); } 50% { opacity: .8; transform: scale(1.12); } }
/* Anmelde-Button mit Shine-Sweep */
.login-btn { position: relative; overflow: hidden; }
.login-btn::before {
  content: ''; position: absolute; top: 0; left: -120%; width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, oklch(1 0 0 / 0.35), transparent); transform: skewX(-18deg);
  animation: shine 3.6s ease-in-out infinite;
}
@keyframes shine { 0% { left: -120%; } 55%,100% { left: 130%; } }
@media (prefers-reduced-motion: reduce) {
  .login-bg .aurora, .login-bg .orb, .logo-mark.glow::after, .login-btn::before,
  .login-card, .login-card .reveal { animation: none; }
  .login-card .reveal { opacity: 1; }
}

/* ---------- App-Layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px; gap: 3px;
}
.sidebar .logo { display: flex; align-items: center; gap: 12px; padding: 8px 8px 18px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, var(--primary), oklch(0.55 0.22 300));
  box-shadow: var(--shadow-primary); flex: none;
}
.logo-mark svg { width: 21px; height: 21px; }
.logo-text b { font-size: 15px; font-weight: 680; letter-spacing: -0.3px; display: block; }
.logo-text span { font-size: 11.5px; color: var(--muted-foreground); }

.nav-label { font-size: 10.5px; font-weight: 650; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted-foreground); padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--muted-foreground); cursor: pointer; font-weight: 500; user-select: none; transition: .12s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--accent); color: var(--accent-foreground); }
.nav-item.active { background: var(--primary); color: var(--primary-foreground); font-weight: 550; box-shadow: var(--shadow-sm); }
.nav-item.active:hover { background: var(--primary-strong); color: var(--primary-foreground); }
.nav-item .badge { margin-left: auto; }
.nav-item.active .badge { background: oklch(1 0 0 / 0.25); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .foot { padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); color: var(--muted-foreground); }
.user-chip .av { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); display: grid; place-items: center; font-weight: 650; color: var(--primary-foreground); flex: none; font-size: 13px; }

.main { overflow: hidden; display: flex; flex-direction: column; background: var(--background); }
.topbar {
  height: 64px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 14px; padding: 0 28px; flex: none; background: color-mix(in oklch, var(--card) 55%, transparent);
  backdrop-filter: blur(8px);
}
.topbar h2 { font-size: 17px; font-weight: 680; letter-spacing: -0.4px; }
.topbar .sub { color: var(--muted-foreground); font-size: 12.5px; margin-top: 1px; }
.topbar .grow { flex: 1; }
.content { flex: 1; overflow: auto; padding: 26px 28px 64px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--card); color: var(--foreground);
  cursor: pointer; font-weight: 550; transition: .12s; white-space: nowrap;
}
.btn:hover { background: var(--accent); border-color: var(--border-strong); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: transparent; color: var(--primary-foreground); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--primary-strong); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted-foreground); }
.btn.ghost:hover { background: var(--accent); color: var(--accent-foreground); }
.btn.danger { color: var(--destructive); border-color: color-mix(in oklch, var(--destructive) 35%, transparent); background: var(--destructive-soft); }
.btn.danger:hover { background: color-mix(in oklch, var(--destructive) 22%, transparent); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--card); cursor: pointer; color: var(--muted-foreground); transition: .12s;
}
.icon-btn:hover { background: var(--accent); color: var(--accent-foreground); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field label { font-size: 12.5px; color: var(--secondary-foreground); font-weight: 550; }
.input, textarea.input, select.input {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm); background: var(--input);
  border: 1px solid var(--border-strong); color: var(--foreground); outline: none; transition: .12s;
}
.input:focus, textarea.input:focus, select.input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 90px; font-family: var(--mono); font-size: 13px; }
.input::placeholder { color: var(--muted-foreground); opacity: .8; }
select.input { cursor: pointer; }

/* ---------- Stat-Tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px 19px; position: relative; overflow: hidden; box-shadow: var(--shadow-xs);
}
.stat .k { font-size: 11.5px; color: var(--muted-foreground); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; gap: 7px; }
.stat .k svg { width: 14px; height: 14px; }
.stat .v { font-size: 30px; font-weight: 720; letter-spacing: -0.8px; margin-top: 6px; line-height: 1; }
.stat .v small { font-size: 13px; color: var(--muted-foreground); font-weight: 500; letter-spacing: 0; }
.stat.accent .v { color: var(--primary); }
.stat.green .v { color: var(--success); }
.stat.red .v { color: var(--destructive); }
.stat .glow { position: absolute; right: -24px; top: -24px; width: 96px; height: 96px; border-radius: 50%; opacity: .10; filter: blur(4px); background: var(--primary); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 9px; background: var(--card); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 0 13px; height: 40px; flex: 1; min-width: 220px; max-width: 440px; transition: .12s;
}
.search:focus-within { border-color: var(--ring); box-shadow: 0 0 0 3px var(--primary-soft); }
.search svg { width: 17px; height: 17px; color: var(--muted-foreground); flex: none; }
.search input { flex: 1; background: none; border: none; outline: none; height: 100%; }
.chips { display: flex; gap: 7px; }
.chip {
  padding: 8px 14px; border-radius: 9999px; border: 1px solid var(--border-strong); background: var(--card);
  color: var(--muted-foreground); cursor: pointer; font-weight: 550; font-size: 13px; transition: .12s;
}
.chip:hover { background: var(--accent); color: var(--accent-foreground); }
.chip.active { background: var(--primary); border-color: transparent; color: var(--primary-foreground); }
.chip .n { opacity: .75; margin-left: 5px; }

/* ---------- Postfach-Kacheln ---------- */
.mailbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.mbx {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 17px; cursor: pointer; transition: .15s cubic-bezier(.2,.7,.3,1); position: relative; overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.mbx:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.mbx.unread { border-color: color-mix(in oklch, var(--primary) 45%, var(--border)); }
.mbx.unread::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, var(--primary-soft), transparent 45%); pointer-events: none; }
.mbx .row1 { display: flex; align-items: center; gap: 11px; position: relative; }
.mbx .dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.mbx .name { font-weight: 620; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.2px; }
.mbx .email { color: var(--muted-foreground); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.mbx .row2 { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; position: relative; }
.mbx .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); }
.mbx .meta svg { width: 13px; height: 13px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.status-ok { background: var(--success); }
.status-fehler { background: var(--destructive); }
.status-neu { background: var(--muted-foreground); }
.unread-badge {
  min-width: 28px; height: 28px; padding: 0 9px; border-radius: 9999px; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 720; font-size: 13px;
  background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-sm);
}
.unread-badge.zero { background: var(--muted); color: var(--muted-foreground); font-weight: 600; box-shadow: none; }
.new-pulse { position: relative; }
.new-pulse::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  box-shadow: 0 0 0 0 color-mix(in oklch, var(--primary) 60%, transparent); animation: pulse 2s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 8px oklch(0.55 0.22 265 / 0); } 100% { box-shadow: 0 0 0 0 oklch(0.55 0.22 265 / 0); } }

/* ---------- Ansicht-Umschalter (Kacheln/Liste) ---------- */
.viewtoggle { display: inline-flex; background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; height: 40px; }
.vbtn { width: 40px; display: grid; place-items: center; background: transparent; border: none; color: var(--muted-foreground); cursor: pointer; transition: .12s; }
.vbtn:hover { background: var(--accent); color: var(--accent-foreground); }
.vbtn.active { background: var(--primary); color: var(--primary-foreground); }
.vbtn svg { width: 17px; height: 17px; }

/* ---------- Auswahl (Mehrfach) ---------- */
.sel { opacity: 0; transition: opacity .12s; cursor: pointer; display: inline-flex; }
.sel input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; display: block; margin: 0; }
.mbx .sel { position: absolute; top: 11px; left: 11px; z-index: 3; background: var(--card); border-radius: 6px; padding: 3px; box-shadow: var(--shadow-xs); }
.mbx:hover .sel, .mbx.selected .sel, .mailbox-grid.selecting .sel { opacity: 1; }
.mbx.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft), var(--shadow-md); }

.selbar-wrap:empty { display: none; }
.selbar { display: flex; align-items: center; gap: 10px; background: var(--primary-soft); border: 1px solid color-mix(in oklch, var(--primary) 30%, transparent); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; animation: slidein .18s ease; }
.selbar .selcount { display: inline-flex; align-items: center; gap: 8px; color: var(--primary); font-size: 13.5px; }
.selbar .selcount svg { width: 16px; height: 16px; }
.selbar .grow { flex: 1; }

/* ---------- Listen-Ansicht der Postfaecher ---------- */
.mailbox-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.lrow { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: .1s; position: relative; }
.lrow:last-child { border-bottom: none; }
.lrow:hover { background: var(--accent); }
.lrow.selected { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.lrow.unread .lname { font-weight: 700; }
.lrow .lname { font-weight: 600; width: 220px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.2px; }
.lrow .lemail { color: var(--muted-foreground); font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.lrow .lstatus { display: flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: 12.5px; width: 130px; flex: none; }
.lrow .ltime { display: flex; align-items: center; gap: 5px; color: var(--muted-foreground); font-size: 12px; width: 100px; flex: none; justify-content: flex-end; }
.lrow .ltime svg { width: 13px; height: 13px; }
.lrow .unread-badge { min-width: 26px; height: 24px; font-size: 12px; }
.lrow .sel { opacity: 0; }
.lrow:hover .sel, .lrow.selected .sel, .mailbox-list.selecting .sel { opacity: 1; }
@media (max-width: 1100px) { .lrow .lemail, .lrow .lstatus { display: none; } }
@media (max-width: 560px) { .hide-narrow { display: none; } }

/* ---------- Tabelle ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; padding: 13px 16px; font-size: 11.5px; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); font-weight: 650; background: var(--card-2); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td { background: var(--accent); }
.tbl .mono { font-family: var(--mono); font-size: 12px; color: var(--muted-foreground); }

/* ---------- Postfach-Ansicht ---------- */
.mailview { display: grid; grid-template-columns: 400px 1fr; height: 100%; }
.msglist { border-right: 1px solid var(--border); overflow: auto; background: var(--sidebar); }
.msglist-head { padding: 13px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: var(--sidebar); z-index: 1; }
.msglist-head b { font-weight: 620; letter-spacing: -0.2px; }
.msg-row { padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: .1s; }
.msg-row:hover { background: var(--accent); }
.msg-row.active { background: var(--card); box-shadow: inset 3px 0 0 var(--primary); }
.msg-row.unread .msg-from, .msg-row.unread .msg-subj { font-weight: 700; color: var(--foreground); }
.msg-row .msg-top { display: flex; align-items: center; gap: 8px; }
.msg-row .msg-from { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--secondary-foreground); font-weight: 550; }
.msg-row .msg-date { font-size: 11.5px; color: var(--muted-foreground); flex: none; }
.msg-row .msg-subj { color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.msg-row .udot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }

.reader { overflow: hidden; display: flex; flex-direction: column; background: var(--background); }
.reader-empty { flex: 1; display: grid; place-items: center; color: var(--muted-foreground); text-align: center; }
.reader-empty svg { width: 52px; height: 52px; opacity: .35; }
.reader-head { padding: 22px 28px; border-bottom: 1px solid var(--border); background: var(--card); }
.reader-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 14px; }
.reader-meta { display: flex; align-items: center; gap: 11px; color: var(--muted-foreground); font-size: 13px; }
.reader-meta .av { width: 40px; height: 40px; border-radius: 11px; background: var(--primary); display: grid; place-items: center; font-weight: 680; color: var(--primary-foreground); flex: none; }
.reader-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.reader-body { flex: 1; overflow: hidden; display: flex; }
.reader-body iframe { width: 100%; height: 100%; border: none; background: #fff; }
.reader-text { padding: 24px 28px; white-space: pre-wrap; font-size: 14px; color: var(--secondary-foreground); overflow: auto; flex: 1; }
.attachments { padding: 14px 28px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px; background: var(--card); }
.attachment { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; }
.attachment svg { width: 15px; height: 15px; color: var(--muted-foreground); }

/* ---------- Wichtig: Detailansicht, Anhaenge, Verlauf ---------- */
.imp-detail { overflow-y: auto; }
.imp-detail .reader-body { flex: none; }
.imp-detail .reader-body iframe { height: auto; min-height: 460px; }
.important-btn { color: var(--warning); border-color: color-mix(in oklch, var(--warning) 35%, transparent); }
.important-btn:hover { background: color-mix(in oklch, var(--warning) 16%, transparent); color: var(--warning); }
a.attachment { color: inherit; cursor: pointer; }
a.attachment:hover { border-color: var(--primary); background: var(--accent); }
a.attachment svg:last-child { color: var(--primary); margin-left: 2px; }

.thread-container { border-top: 1px solid var(--border); }
.thread-head { display: flex; align-items: center; gap: 8px; padding: 16px 26px 10px; font-size: 13px; color: var(--muted-foreground); }
.thread-head svg { width: 15px; height: 15px; }
.thread-item { border-top: 1px solid var(--border); }
.thread-item:first-of-type { border-top: none; }
.thread-line { display: flex; align-items: center; gap: 11px; padding: 12px 26px; cursor: pointer; transition: .1s; }
.thread-line:hover { background: var(--accent); }
.thread-dir { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--muted); color: var(--muted-foreground); flex: none; }
.thread-dir svg { width: 15px; height: 15px; }
.thread-item.outgoing .thread-dir { background: var(--primary-soft); color: var(--primary); }
.thread-chev { color: var(--muted-foreground); display: inline-flex; transition: transform .18s; flex: none; }
.thread-chev svg { width: 16px; height: 16px; }
.thread-item.open .thread-chev { transform: rotate(90deg); }
.thread-msg-body { padding: 0 26px; }
.thread-item.open .thread-msg-body { padding: 4px 26px 18px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 9999px; font-size: 11.5px; font-weight: 620; background: var(--muted); color: var(--muted-foreground); }
.badge svg { width: 12px; height: 12px; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--destructive-soft); color: var(--destructive); }
.badge.accent { background: var(--primary-soft); color: var(--primary); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: oklch(0.13 0.02 270 / 0.55); backdrop-filter: blur(5px); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 18px; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; box-shadow: var(--shadow-lg); animation: pop .17s cubic-bezier(.2,.7,.3,1); }
.modal.wide { max-width: 740px; }
@keyframes pop { from { transform: scale(.96) translateY(8px); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16.5px; font-weight: 680; letter-spacing: -0.3px; }
.modal-head .grow { flex: 1; }
.modal-body { padding: 22px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--card-2); }

/* ---------- Compose ---------- */
.compose-body { min-height: 240px; padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--input); outline: none; overflow: auto; max-height: 45vh; }
.compose-body:focus { border-color: var(--ring); box-shadow: 0 0 0 3px var(--primary-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- Signaturen ---------- */
.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.sig-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.sig-card .sig-head { padding: 14px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.sig-card .sig-head b { flex: 1; font-weight: 620; }
.sig-preview { padding: 16px; background: #fff; color: #222; min-height: 120px; font-size: 13px; overflow: auto; border-radius: var(--radius-sm); }

/* ---------- Diverses ---------- */
.empty-state { text-align: center; padding: 74px 20px; color: var(--muted-foreground); }
.empty-state svg { width: 48px; height: 48px; opacity: .4; margin-bottom: 14px; }
.empty-state h3 { color: var(--secondary-foreground); font-weight: 620; margin-bottom: 6px; font-size: 16px; }
.muted { color: var(--muted-foreground); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: grid; place-items: center; padding: 64px; }
.hint { font-size: 12px; color: var(--muted-foreground); margin-top: 4px; }
.section-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 26px; margin-bottom: 18px; max-width: 740px; box-shadow: var(--shadow-xs); }
.section-card h3 { font-size: 15.5px; font-weight: 680; margin-bottom: 4px; letter-spacing: -0.3px; }
.section-card p.desc { color: var(--muted-foreground); font-size: 13px; margin-bottom: 18px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: var(--card); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 13px 16px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; min-width: 260px; animation: slidein .2s ease; }
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } }
.toast.ok { border-left: 3px solid var(--success); }
.toast.err { border-left: 3px solid var(--destructive); }
.toast.ok svg { color: var(--success); }
.toast.err svg { color: var(--destructive); }
.toast svg { width: 18px; height: 18px; flex: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mailview { grid-template-columns: 1fr; }
  .msglist { border-right: none; border-bottom: 1px solid var(--border); max-height: 45vh; }
  .grid-2 { grid-template-columns: 1fr; }
}
