/* ==========================================================================
   CORPORATE DESIGN – aus „E-Mail-Vorlage 01 – Brief von Daniel“ (freigegeben 25.10.2026)
   und der CI Daniel Otmar (freigegeben 14.10.2026). Alles andere in dieser Datei
   greift nur auf diese Variablen zu.
   ========================================================================== */
:root {
  --brand: #1D2F4A;          /* Deep Royal Navy */
  --brand-strong: #142238;
  --brand-soft: #EDE6DC;     /* aus Sand #D6C7B5 aufgehellt */
  --accent: #B89B5E;         /* Matt Gold – Linien, Akzente */
  --accent-strong: #9C8344;  /* dunkles Gold für kleine Schrift auf hell */
  --accent-soft: #F6DED2;    /* Warm Cream – weiche Flächen */

  --bg: #F3EFE9;             /* Off White */
  --surface: #FFFFFF;
  --text: #1D2F4A;
  --muted: #6B6258;
  --line: #E4DACD;
  --danger: #C1392D;
  --ok: #2e7d4f;

  --font-body: "Montserrat", Arial, Helvetica, sans-serif;
  --font-head: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(29,47,74,.04), 0 6px 20px rgba(29,47,74,.05);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface);
  padding: 8px 14px; border-radius: 5px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* ---------------------------------------------------------------- Layout */
.app {
  display: grid;
  grid-template-columns: 220px 340px minmax(0, 1fr);
  height: 100vh;
}
.main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; min-height: 0; min-width: 0; }
.main:has(.customer[hidden]) { grid-template-columns: minmax(0, 1fr); }
.sidebar {
  background: var(--brand); color: #fff;
  display: flex; flex-direction: column; padding: 20px 14px;
}
.logo { padding: 4px 8px 4px; }
.logo small { display: block; font-size: 10px; font-weight: 600; color: var(--accent); letter-spacing: .18em; text-transform: uppercase; margin-top: 10px; }
.logo img { display: block; width: 100%; max-width: 170px; height: auto; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .6; margin: 28px 8px 8px; }
.mailbox {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; color: #fff;
  padding: 9px 10px; border-radius: 5px; cursor: pointer; opacity: .85;
}
.mailbox small { display: block; opacity: .65; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.mailbox:hover { background: rgba(255,255,255,.08); opacity: 1; }
.mailbox.active { background: rgba(255,255,255,.16); opacity: 1; }
.sidebar .spacer { flex: 1; }
.user { font-size: 12px; opacity: .8; padding: 8px; }
.user button { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 0; opacity: .8; }

.list { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 18px 16px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.list-head h2 { font-size: 24px; }
.search { margin: 10px 16px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; width: calc(100% - 32px); background: var(--bg); }
.messages { overflow-y: auto; flex: 1; }
.msg { padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; position: relative; }
.msg:hover { background: var(--bg); }
.msg.active { background: var(--brand-soft); }
.msg.unread::before { content: ""; position: absolute; left: 6px; top: 18px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.msg .row { display: flex; justify-content: space-between; gap: 8px; }
.msg .from { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .subject { font-weight: 600; }
.msg .date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg .subject { color: var(--text); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.reader { overflow-y: auto; padding: 24px 32px 48px; min-width: 0; }
.empty { color: var(--muted); text-align: center; margin-top: 30vh; }
.mail-head h1 { font-size: 32px; line-height: 1.15; }
.mail-meta { color: var(--muted); margin: 8px 0 18px; }
.mail-meta strong { color: var(--text); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { font-weight: 600; font-family: var(--font-body); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.summary { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.summary .text { white-space: pre-wrap; line-height: 1.55; }
/* Kundennachricht: feste Höhe, scrollbar, unten rechts größer ziehbar */
.mail-box {
  height: 180px; min-height: 90px; max-height: 85vh; overflow-y: auto; resize: vertical;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: #fff;
}
.mail-box:has(.mail-html:not([hidden])) { padding: 0; overflow: hidden; }
.mail-body { white-space: pre-wrap; line-height: 1.6; word-wrap: break-word; }
.mail-html { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.mail-preview { width: 100%; height: 620px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.toggle { font-size: 12px; color: var(--brand); background: none; border: 0; cursor: pointer; padding: 0; }
.attachments { margin-top: 10px; color: var(--muted); font-size: 12px; }

.composer textarea {
  width: 100%; min-height: 260px; border: 1px solid var(--line); border-radius: 5px;
  padding: 12px; line-height: 1.55; resize: vertical; background: #fff;
}
.composer input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; margin-bottom: 10px; }
.composer .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.composer .actions .grow { flex: 1; }
.composer label.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.hint-row { display: flex; gap: 8px; margin-bottom: 10px; }
.hint-row input { margin: 0 !important; }
.hint-row .btn { white-space: nowrap; }

.customer { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; padding: 20px 18px; }
.customer h2 { font-size: 24px; margin-bottom: 2px; }
.customer .email { color: var(--muted); font-size: 12px; margin-bottom: 18px; word-break: break-all; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; display: flex; justify-content: space-between; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; background: var(--brand-soft); color: var(--brand); }
.badge.buyer { background: var(--accent-soft); color: var(--brand); }
.badge.none { background: var(--bg); color: var(--muted); }
.purchase { border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; margin-bottom: 8px; }
.purchase .name { font-weight: 600; }
.purchase .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.activity { border-left: 2px solid var(--line); padding: 2px 0 10px 12px; margin-left: 4px; }
.activity .meta { font-size: 11px; color: var(--muted); }
.activity .type { font-weight: 600; color: var(--brand); }
.activity .text { white-space: pre-wrap; font-size: 13px; margin-top: 2px; max-height: 7.5em; overflow: hidden; }
.note { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; }
a { color: var(--brand); }

.loading { color: var(--muted); font-size: 13px; display: inline-flex; gap: 8px; align-items: center; }
.loading::before { content: ""; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 5px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 10;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }
.demo-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 5; background: var(--accent); color: #fff; text-align: center; font-size: 11px; padding: 2px; pointer-events: none; opacity: .9; }

/* ---------------------------------------------------------------- Responsiv */
@media (max-width: 1280px) {
  .app { grid-template-columns: 200px 300px minmax(0, 1fr); }
  .main { display: block; overflow-y: auto; }
  .reader { overflow: visible; padding-bottom: 8px; }
  .customer { border-left: 0; padding: 0 32px 32px; background: transparent; overflow: visible; }
}
@media (max-width: 860px) {
  .app { display: block; height: auto; }
  .main { overflow: visible; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px; padding: 10px 16px; }
  .nav-title, .sidebar .spacer { display: none; }
  .mailbox { width: auto; }
  .mailbox small { display: none; }
  .list { max-height: 45vh; }
  .reader, .customer { padding: 16px; }
}

/* ---------------------------------------------------------------- Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 32px; border-top: 3px solid var(--accent); }
.login-logo { display: block; width: 190px; margin: 0 auto 22px; }
.login-card h1 { font-size: 30px; margin-bottom: 4px; text-align: center; }
.login-card p { color: var(--muted); margin: 0 0 24px; text-align: center; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }

/* ---------------------------------------------------------------- Ordner & Löschen */
.folders { margin: 2px 0 8px 10px; border-left: 1px solid rgba(255,255,255,.15); padding-left: 6px; }
.folder {
  display: block; width: 100%; text-align: left; border: 0; background: transparent; color: #fff;
  padding: 6px 10px; border-radius: 5px; cursor: pointer; opacity: .7; font-size: 13px;
}
.folder:hover { background: rgba(255,255,255,.08); opacity: 1; }
.folder.active { opacity: 1; color: var(--accent); font-weight: 600; }
.mail-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.mail-title .btn { flex-shrink: 0; margin-top: 6px; }
.title-actions { display: flex; gap: 6px; flex-shrink: 0; }
.mail-title .btn.danger:hover { border-color: var(--danger); color: var(--danger); }
@media (max-width: 860px) {
  .folders { display: flex; flex-wrap: wrap; margin: 0; border: 0; padding: 0; width: 100%; }
  .folder { width: auto; }
}
.more-toggle::after { content: " ▸"; opacity: .7; }
.more-toggle[aria-expanded="true"]::after { content: " ▾"; }
.more-folders .folder { font-size: 12.5px; }
.more-folders span.folder { cursor: default; opacity: .5; }
.custom-folders:not(:empty) { border-top: 1px solid rgba(255,255,255,.12); margin-top: 4px; padding-top: 4px; }

/* ---------------------------------------------------------------- Live-Vorschlag & Team-Hinweis */
.team-note {
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: var(--radius);
  padding: 10px 12px; margin-bottom: 10px; font-size: 13px; line-height: 1.5;
}
.team-note strong { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-strong); margin-bottom: 2px; }
.composer textarea.writing { background: #fdfbf8; border-color: var(--accent); }

/* ---------------------------------------------------------------- Auswahl, Ziehen, Rechtsklick */
.msg.selected { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--accent); }
.msg.active.selected { background: #E3DACB; }
.folder.drop-target { background: var(--accent) !important; color: #fff; opacity: 1; }
.drag-ghost {
  position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 5px; max-width: 260px;
  background: var(--brand); color: #fff; font: 600 12px var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ctx-menu {
  position: fixed; z-index: 20; min-width: 210px; padding: 4px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(29,47,74,.18); font-size: 13px;
}
.ctx-head { padding: 6px 10px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.ctx-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%;
  padding: 7px 12px; border: 0; background: none; border-radius: 4px; text-align: left; cursor: pointer; color: var(--text);
}
.ctx-item:hover, .ctx-item:focus-within { background: var(--brand-soft); }
.ctx-item.muted { color: var(--muted); cursor: default; }
.ctx-item.danger:hover { background: #F7E3E1; color: var(--danger); }
.ctx-item kbd { font: inherit; color: var(--muted); }
.has-sub { position: relative; }
.has-sub::after { content: "▸"; color: var(--muted); }
.ctx-sub {
  display: none; position: absolute; left: 100%; top: -5px; min-width: 220px; max-height: 60vh; overflow-y: auto;
  padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(29,47,74,.18);
}
.ctx-menu.flip .ctx-sub { left: auto; right: 100%; }
.has-sub:hover > .ctx-sub, .has-sub:focus-within > .ctx-sub { display: block; }

/* ---------------------------------------------------------------- Produkte im Kundenpanel */
.purchase .name { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.purchase .source { flex-shrink: 0; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.purchase.status-won { border-left: 3px solid var(--accent); }
.purchase.status-active { border-left: 3px solid #97A4B1; }
.purchase.status-lost { opacity: .55; }
.purchase.status-info { border-left: 3px solid var(--line); }

/* ---------------------------------------------------------------- Weiterleiten */
dialog.forward {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 18px 60px rgba(29,47,74,.28);
}
dialog.forward::backdrop { background: rgba(20,34,56,.35); }
.fw-form { display: flex; flex-direction: column; }
.fw-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.fw-head h2 { font-size: 24px; }
.fw-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.fw-close { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.fw-close:hover { color: var(--text); }
dialog.forward section { padding: 14px 20px 6px; }
dialog.forward section + section { border-top: 1px solid var(--line); }
dialog.forward h3 { font-family: var(--font-body); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-strong); margin-bottom: 10px; }
dialog.forward input[type=text], dialog.forward textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 8px 10px; margin-bottom: 10px; background: #fff;
}
dialog.forward textarea { resize: vertical; line-height: 1.5; }
dialog.forward textarea[readonly] { color: var(--muted); background: #fdfbf8; }
dialog.forward label.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-bottom: 10px; cursor: pointer; }
.bang { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
dialog.forward details { margin-bottom: 10px; font-size: 13px; }
dialog.forward summary { cursor: pointer; color: var(--muted); }
.fw-original { white-space: pre-wrap; font: 12px/1.5 var(--font-body); background: var(--bg); border-radius: 5px; padding: 10px; max-height: 220px; overflow-y: auto; margin: 8px 0 0; }
.fw-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 20px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.fw-actions .grow { flex: 1; }
.fw-actions label.check { margin: 0 !important; color: var(--muted); }
.suggest-wrap { position: relative; }
.suggest {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% - 8px); max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(29,47,74,.18);
}
.suggest-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.suggest-item:hover, .suggest-item.active { background: var(--brand-soft); }
.suggest-item .who { display: flex; flex-direction: column; min-width: 0; }
.suggest-item .who span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.suggest-item .who strong + span { font-size: 12px; }
.suggest-item .kind { flex-shrink: 0; font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-strong); }

/* ---------------------------------------------------------------- Memberspot im Kundenpanel */
.course { margin-bottom: 10px; font-size: 13px; }
.course .name { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.course .name span { color: var(--muted); flex-shrink: 0; font-size: 12px; }
.course.off .name span { color: var(--danger); }
.course .bar { height: 6px; border-radius: 3px; background: var(--brand-soft); overflow: hidden; }
.course .bar span { display: block; height: 100%; background: var(--accent); }
.course.off { opacity: .6; }

/* ---------------------------------------------------------------- Spam & Anhänge */
.spam-warning { border: 1px solid #E8B4AE; background: #FBEDEB; color: #7A231B; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; }
.spam-warning.verdaechtig { border-color: #E7CF9B; background: #FBF4E4; color: #6B4E12; }
.spam-warning strong { display: block; font-size: 14px; margin-bottom: 4px; }
.spam-warning ul { margin: 4px 0 6px; padding-left: 18px; }
.spam-warning p { margin: 0; font-weight: 600; }
.spam-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 3px; font-size: 10px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; background: var(--danger); color: #fff; vertical-align: 1px; }
.spam-tag.warn { background: #C48A1C; }
.msg.is-spam .from, .msg.is-spam .subject { color: var(--muted); }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.attachment { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); border-radius: 5px;
  padding: 5px 10px; font-size: 12px; cursor: pointer; }
.attachment:hover { border-color: var(--brand); }
.attachment .dl { color: var(--muted); }
.attachment.danger { border-color: #E8B4AE; background: #FBEDEB; color: #7A231B; }
.links-locked { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted);
  background: var(--bg); border-radius: 5px; padding: 6px 10px; margin-bottom: 8px; }

/* ---------------------------------------------------------------- Zuordnung */
.msg .stamp { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; line-height: 1.25; }
.assignee { color: var(--danger); font-size: 11px; font-weight: 600; margin-top: 1px; }
.mail-assignee { color: var(--danger); font-size: 12px; font-weight: 600; margin-top: 4px; }
.ctx-item.muted-action { color: var(--muted); border-top: 1px solid var(--line); border-radius: 0 0 4px 4px; }
