:root {
  --bg-dark: #0b0c0f;
  --bg-panel: #12141a;
  --bg-card: #181b24;
  --border-color: #242834;
  --border-light: rgba(255, 255, 255, 0.08);
  --gold-primary: #c5a059;
  --gold-light: #f5eccb;
  --gold-dim: rgba(197, 160, 89, 0.2);
  --text-main: #f3f4f6;
  --text-muted: #8e95a5;
  --font-display: 'Cinzel', serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  background: #0f1116;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
}
.brand-group { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-badge {
  width: 36px; height: 36px; border: 1px solid var(--gold-primary);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: var(--gold-light);
}
.brand-text h1 { font-family: var(--font-display); font-size: 14px; letter-spacing: 1px; color: var(--gold-light); display: flex; align-items: center; gap: 6px; }
.badge-suite { background: #262115; color: var(--gold-primary); font-size: 10px; padding: 1px 5px; border-radius: 3px; font-family: var(--font-sans); border: 1px solid var(--gold-primary); }
.brand-text p { font-size: 9.5px; color: var(--text-muted); letter-spacing: 0.5px; }

.nav-tabs { display: flex; gap: 4px; }
.nav-tab-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-muted);
  padding: 6px 12px; border-radius: 6px; font-size: 12.5px; cursor: pointer; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.nav-tab-btn:hover { background: #181b24; color: #fff; }
.nav-tab-btn.active { background: var(--gold-primary); color: #0b0f19; font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.status-pill {
  font-size: 11px; padding: 4px 8px; border-radius: 4px;
  background: #1a1e28; border: 1px solid var(--border-color); color: var(--text-muted);
}
.status-pill.error { border-color: #ef4444; color: #ef4444; }
.status-pill.ok { border-color: var(--gold-primary); color: var(--gold-light); }

.btn-gold {
  background: var(--gold-primary); color: #0b0f19; border: none; padding: 7px 14px;
  border-radius: 6px; font-weight: 700; font-size: 12.5px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.btn-gold:hover { background: #d8b368; }
.btn-secondary {
  background: #181b24; border: 1px solid var(--border-color); color: var(--gold-light);
  padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { background: #222633; }

.main-layout { flex: 1; display: flex; overflow: hidden; position: relative; }

/* MAIL LISTE */
.mail-list-panel {
  width: 390px; background: var(--bg-panel); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.list-topbar { padding: 10px 14px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.mail-cards-scroll { flex: 1; overflow-y: auto; }

.mail-item {
  padding: 12px 14px; border-bottom: 1px solid var(--border-light); cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
}
.mail-item:hover { background: #171a22; }
.mail-item.active { background: #1e222d; border-left: 3px solid var(--gold-primary); }
.mail-item.unread .mail-title { font-weight: 700; color: #fff; }
.mail-item-header { display: flex; justify-content: space-between; font-size: 12px; color: var(--gold-light); }
.mail-title { font-size: 13px; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* VIEWS */
.view-container { flex: 1; background: var(--bg-dark); display: none; flex-direction: column; overflow-y: auto; position: relative; }
.view-container.active { display: flex; }

/* KALENDER */
.cal-wrapper { padding: 20px; height: 100%; display: flex; flex-direction: column; gap: 12px; }
.cal-grid-header { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 11px; font-weight: 700; color: var(--gold-primary); text-transform: uppercase; padding-bottom: 4px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; flex: 1; }
.cal-day { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 6px; min-height: 80px; padding: 6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.cal-day:hover { border-color: rgba(197, 160, 89, 0.4); }
.cal-day.today { border-color: var(--gold-primary); background: #1e2330; }
.cal-day.other-month { opacity: 0.25; }
.event-tag { font-size: 10.5px; padding: 3px 5px; border-radius: 3px; background: var(--gold-dim); color: var(--gold-light); border-left: 2px solid var(--gold-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* KONTAKTE */
.contacts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; padding: 20px; }
.contact-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.contact-name { font-weight: 700; color: #fff; font-size: 14px; }
.contact-info { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 3px; }

/* SIGNATUR-STUDIO */
.sig-studio-wrapper { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.sig-sheet-preview {
  background: #ffffff; color: #111; width: 680px; max-width: 100%; margin: 0 auto;
  border-radius: 8px; padding: 40px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); position: relative;
}

/* MODALE */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.82); backdrop-filter: blur(5px);
  display: none; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal-bg.active { display: flex; }
.modal-window {
  background: #141720; border: 1px solid var(--border-color); border-radius: 8px;
  width: 900px; max-width: 96vw; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  background: #0f1117; padding: 12px 18px; border-bottom: 1px solid var(--border-color);
  display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; color: var(--gold-light);
}
.modal-body { padding: 18px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-footer {
  background: #0f1117; padding: 12px 18px; border-top: 1px solid var(--border-color);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* BRIEFBOGEN */
.letterhead-card {
  background: #ffffff; color: #1a1a1a; width: 720px; max-width: 100%; margin: 0 auto;
  border-radius: 4px; padding: 45px 50px; position: relative; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.photo-corner { position: absolute; width: 18px; height: 18px; border-color: var(--gold-primary); pointer-events: none; }
.photo-corner.tl { top: 16px; left: 16px; border-top: 2px solid var(--gold-primary); border-left: 2px solid var(--gold-primary); }
.photo-corner.tr { top: 16px; right: 16px; border-top: 2px solid var(--gold-primary); border-right: 2px solid var(--gold-primary); }
.photo-corner.bl { bottom: 16px; left: 16px; border-bottom: 2px solid var(--gold-primary); border-left: 2px solid var(--gold-primary); }
.photo-corner.br { bottom: 16px; right: 16px; border-bottom: 2px solid var(--gold-primary); border-right: 2px solid var(--gold-primary); }

.letterhead-header { text-align: center; margin-bottom: 24px; }
.letterhead-header h2 { font-family: var(--font-display); font-size: 19px; letter-spacing: 2px; color: #111; margin-bottom: 4px; }
.letterhead-header p { font-size: 9.5px; letter-spacing: 1.5px; color: #666; text-transform: uppercase; }

.editor-toolbar {
  display: flex; align-items: center; gap: 4px; background: #0c0e13; border: 1px solid var(--border-color);
  padding: 6px 10px; border-radius: 6px; margin-bottom: 12px; flex-wrap: wrap;
}
.editor-toolbar button, .editor-toolbar select {
  background: #181b24; border: 1px solid var(--border-color); color: #e2e8f0;
  padding: 4px 8px; border-radius: 4px; font-size: 12px; cursor: pointer;
}
.editor-toolbar button:hover { background: var(--gold-primary); color: #000; }

.mail-editable-content {
  min-height: 120px; outline: none; font-size: 13.5px; line-height: 1.65; color: #222;
  margin-bottom: 16px; font-family: inherit;
}
.mail-sig-separator { border: none; border-top: 1px dashed #ccc; margin: 16px 0; }

/* SIGNATUR-FLOW-BLOCK */
.signature-flow-block {
  position: relative;
  margin-top: 14px;
}
.stamp-draggable-box {
  position: absolute; cursor: grab; user-select: none; z-index: 10;
  display: inline-flex; align-items: center; justify-content: center;
}
.stamp-draggable-box:active { cursor: grabbing; }

.form-group-row { display: flex; gap: 10px; align-items: center; font-size: 12.5px; }
.form-group-row label { width: 65px; color: var(--gold-light); font-weight: 600; }
.form-control {
  flex: 1; background: #0f1117; border: 1px solid var(--border-color); color: #fff;
  padding: 7px 10px; border-radius: 5px; font-size: 13px; outline: none;
}
.form-control:focus { border-color: var(--gold-primary); }

@media (max-width: 900px) {
  .mail-list-panel { width: 100%; }
  .view-container { display: none; position: absolute; inset: 0; z-index: 50; }
  body.mobile-view-active .view-container { display: flex; }
  body.mobile-view-active .mail-list-panel { display: none; }
}