:root {
    --navy: #354052;
    --navy-light: #3d4a5e;
    --navy-dark: #2a3342;
    --orange: #F7931A;
    --orange-hover: #e8850f;
    --bg: #1a1f2e;
    --bg-card: #242b3d;
    --bg-input: #2d3548;
    --text: #e8eaf0;
    --text-muted: #8b92a5;
    --text-dim: #5a6278;
    --border: #3a4259;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --info: #2196f3;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-hover); }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--navy-dark);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.sidebar-logo {
    padding: 0 20px 20px;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--orange);
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.sidebar-nav { flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: var(--navy);
    color: var(--text);
    border-left-color: var(--orange);
}

.nav-item .icon { font-size: 1.2em; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85em;
}

.main { flex: 1; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--navy-dark);
    border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.3em; font-weight: 600; }

.topbar-actions { display: flex; gap: 12px; align-items: center; }

.content { flex: 1; padding: 30px; overflow-y: auto; }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h2 { font-size: 1.1em; font-weight: 600; }

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-value { font-size: 2em; font-weight: 700; color: var(--orange); }
.stat-label { color: var(--text-muted); margin-top: 4px; font-size: 0.9em; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-hover); }
.btn-secondary { background: var(--navy); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--navy-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 12px; font-size: 0.82em; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9em; color: var(--text-muted); }

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95em;
    transition: border-color 0.2s;
}

.form-control:focus { outline: none; border-color: var(--orange); }

textarea.form-control { min-height: 100px; resize: vertical; }

select.form-control { cursor: pointer; }

/* Tables */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

th { text-align: left; padding: 12px; font-weight: 600; font-size: 0.85em; color: var(--text-muted); border-bottom: 2px solid var(--border); text-transform: uppercase; letter-spacing: 0.5px; }

td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 0.92em; }

tr:hover td { background: rgba(247, 147, 26, 0.04); }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78em;
    font-weight: 600;
}

.badge-offen { background: var(--info); color: #fff; }
.badge-in_arbeit { background: var(--warning); color: #000; }
.badge-review { background: #9c27b0; color: #fff; }
.badge-erledigt { background: var(--success); color: #fff; }
.badge-kritisch { background: var(--danger); color: #fff; }
.badge-hoch { background: var(--warning); color: #000; }
.badge-mittel { background: var(--info); color: #fff; }
.badge-niedrig { background: var(--text-dim); color: var(--text); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal h2 { margin-bottom: 20px; }

.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.9em;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-card h1 { color: var(--orange); margin-bottom: 8px; font-size: 1.8em; }
.login-card p { color: var(--text-muted); margin-bottom: 30px; }

/* Loading */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--orange);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .topbar { padding: 12px 16px; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 3em; margin-bottom: 16px; }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }

/* News */
.news-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.news-item:last-child { border-bottom: none; }
.news-item h3 { font-size: 1em; margin-bottom: 4px; }
.news-item .meta { font-size: 0.82em; color: var(--text-muted); }
.news-item p { margin-top: 8px; font-size: 0.9em; color: var(--text-muted); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
    padding: 10px 20px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* System Health Bars */
.sys-bar-group { display: flex; flex-direction: column; gap: 8px; }
.sys-bar-label { font-size: 0.85em; color: var(--text-muted); }
.sys-bar { height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.sys-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }

/* Cron Status Badges */
.badge-cron-active { background: var(--success); color: #fff; }
.badge-cron-paused { background: var(--warning); color: #000; }
.badge-cron-error { background: var(--danger); color: #fff; }

/* Toggle Switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg-input); border-radius: 22px; transition: 0.3s;
}
.toggle-slider::before {
    content: ''; position: absolute; height: 16px; width: 16px;
    left: 3px; bottom: 3px; background: var(--text-muted);
    border-radius: 50%; transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--orange); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); background: #fff; }

/* Doc Viewer */
.doc-rendered { line-height: 1.7; font-size: 0.95em; }
.doc-rendered h1, .doc-rendered h2, .doc-rendered h3 { color: var(--orange); margin: 20px 0 10px; }
.doc-rendered code { background: var(--bg-input); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
.doc-rendered pre { background: var(--bg-input); padding: 16px; border-radius: var(--radius); overflow-x: auto; margin: 12px 0; }
.doc-rendered pre code { background: none; padding: 0; }
.doc-rendered table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.doc-rendered th, .doc-rendered td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.doc-rendered th { background: var(--bg-input); }
.doc-rendered blockquote { border-left: 3px solid var(--orange); padding-left: 16px; margin: 12px 0; color: var(--text-muted); }
.doc-rendered a { color: var(--orange); }
.doc-rendered img { max-width: 100%; border-radius: var(--radius); }

/* Nav Group (Brain sub-navigation) */
.nav-group .nav-sub-items { display: none; }
.nav-group.expanded .nav-sub-items { display: block; }
.nav-sub { padding-left: 36px !important; font-size: 0.88em; opacity: 0.85; }
.nav-sub:hover { opacity: 1; }
.nav-group-header::after { content: '▸'; float: right; transition: transform 0.2s; }
.nav-group.expanded .nav-group-header::after { transform: rotate(90deg); }

/* Persona Cards */
.persona-card { transition: transform 0.15s, box-shadow 0.15s; }
.persona-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }

/* Brain Module Cards */
.brain-module-card { transition: transform 0.15s; }
.brain-module-card:hover { transform: translateY(-2px); }

/* Journey Phases */
.journey-container { display: flex; gap: 0; overflow-x: auto; padding-bottom: 16px; }
.journey-phase { flex: 0 0 220px; position: relative; }
.journey-phase-header { background: var(--orange); color: #fff; padding: 16px; border-radius: var(--radius) var(--radius) 0 0; text-align: center; }
.journey-phase-header h4 { margin: 0; font-size: 1em; }
.journey-phase-body { background: var(--bg-card); border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); padding: 12px; min-height: 250px; }
.journey-section { margin-bottom: 12px; font-size: 0.85em; }
.journey-section strong { display: block; color: var(--text-muted); font-size: 0.8em; text-transform: uppercase; margin-bottom: 4px; }
.journey-arrow { position: absolute; right: -14px; top: 50px; font-size: 1.5em; color: var(--orange); z-index: 1; }

/* Lead Magnet Cards */
.lm-card { transition: transform 0.15s; }
.lm-card:hover { transform: translateY(-2px); }

/* Content Plan inline editing */
.cp-editable { cursor: pointer; }
.cp-editable:hover { background: rgba(247,147,26,0.1); }

@media (max-width: 768px) {
    .journey-container { flex-direction: column; }
    .journey-phase { flex: none; width: 100%; }
    .journey-arrow { display: none; }
}
