/* === Basis === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f0;
    color: #333;
    line-height: 1.5;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Navigation === */
.navbar {
    background: #1e293b;
    color: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand { color: #fff; font-size: 18px; font-weight: bold; }
.nav-brand:hover { text-decoration: none; opacity: 0.9; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: #cbd5e1; font-size: 14px; }
.nav-links a:hover { color: #fff; text-decoration: none; }

/* === Container === */
.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* === Footer === */
.footer { text-align: center; padding: 20px; color: #999; font-size: 13px; }

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-size: 24px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn:hover { background: #f3f4f6; text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* === Badge === */
.badge {
    background: #e2e8f0;
    color: #475569;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
}

/* === Flash Messages === */
.flash-messages { margin-bottom: 16px; }
.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 14px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* === Tables === */
.table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.table th, .table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}
.table th { background: #f8fafc; color: #64748b; font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table-compact th, .table-compact td { padding: 6px 10px; font-size: 13px; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }

/* === Forms === */
.form { max-width: 700px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 14px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}
.form-group input:focus, .form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; }
.form-check { display: flex; align-items: center; padding-top: 24px; }
.form-check label { display: flex; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 8px; margin-top: 24px; }
.search-form { display: flex; gap: 8px; margin-bottom: 24px; }
.search-form input { padding: 8px 14px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; width: 300px; }

/* === Info Card === */
.info-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.info-card h2 { font-size: 16px; margin-bottom: 12px; color: #1e293b; }

/* === DL horizontal === */
.dl-horizontal { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; }
.dl-horizontal dt { color: #64748b; font-size: 13px; }
.dl-horizontal dd { font-size: 14px; }

/* === Radix Layout === */
.radix-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}
.chart-container {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: sticky;
    top: 16px;
}
.chart-container svg { width: 100%; height: auto; }
.radix-tables { display: flex; flex-direction: column; gap: 0; }

/* === Planet Symbols === */
.planet-symbol { font-size: 16px; margin-right: 2px; }
.retro { color: #dc2626; font-weight: bold; font-size: 12px; }

/* === Aspect Colors === */
.aspect-konjunktion { color: #2563eb; font-weight: 600; }
.aspect-quadrat { color: #dc2626; font-weight: 600; }
.aspect-opposition { color: #dc2626; }
.aspect-spiegelpunkt { color: #8b5cf6; }

/* === Houses Grid === */
.houses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
}
.house-item { padding: 4px 8px; font-size: 13px; }
.house-item.highlight { background: #eff6ff; border-radius: 4px; font-weight: 500; }

/* === Journal === */
.journal-entries { margin-bottom: 16px; }
.journal-entry { padding: 10px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.journal-entry strong { color: #1e293b; font-size: 13px; }
.journal-entry p { margin-top: 4px; white-space: pre-wrap; }
.journal-time { color: #94a3b8; font-size: 11px; margin-left: 8px; }
.journal-form { margin-top: 12px; }

/* === Geocoding === */
.geocode-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
}
.geocode-item {
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}
.geocode-item:hover { background: #f8fafc; }
.geocode-item:last-child { border-bottom: none; }

/* === Empty State === */
.empty-state { color: #94a3b8; padding: 40px 0; text-align: center; }
.note { color: #64748b; font-style: italic; }

/* === MRL === */
.mrl-directions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}
.mrl-direction h2 { font-size: 18px; margin-bottom: 4px; }
.direction-desc { color: #64748b; font-size: 13px; margin-bottom: 16px; }

.mrl-phase {
    background: #fff;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border-left: 3px solid #e2e8f0;
}
.mrl-phase.phase-active {
    border-left-color: #2563eb;
    background: #f8faff;
}

.phase-header { margin-bottom: 8px; }
.phase-title { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.phase-house { font-weight: 700; font-size: 15px; }
.phase-age { color: #64748b; font-size: 13px; }
.badge-active { background: #2563eb; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }
.phase-ruler { font-size: 13px; color: #475569; }

.mrl-triggers { margin-top: 8px; }
.mrl-triggers td { font-size: 12px; padding: 4px 8px; }
.mrl-triggers th { font-size: 11px; padding: 4px 8px; }

.trigger-type {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}
.type-direct { background: #dbeafe; color: #1d4ed8; }
.type-rulership { background: #fef3c7; color: #92400e; }
.type-square { background: #fecaca; color: #991b1b; }
.type-opposition { background: #fecaca; color: #991b1b; }
.type-aspect { background: #e0e7ff; color: #3730a3; }
.type-gsp { background: #d1fae5; color: #065f46; }

.trigger-gsp td { color: #065f46; font-style: italic; }
.empty-state-small { color: #94a3b8; font-size: 12px; padding: 6px 0; }

/* === GSP === */
.gsp-activated { background: #f0fdf4; }
.gsp-activated td:first-child { color: #065f46; }
.gsp-desc { color: #64748b; font-size: 12px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* === Progression === */
.prog-dir {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}
.prog-fwd { background: #dbeafe; color: #1d4ed8; }
.prog-rev { background: #fef3c7; color: #92400e; }
.prog-past td { color: #94a3b8; }

/* === Transite === */
.transit-table td { vertical-align: middle; }
.transit-pos { color: #94a3b8; font-size: 11px; display: block; }
.transit-resonanz { background: #fffbeb; border-left: 3px solid #f59e0b; }
.badge-resonanz {
    display: inline-block;
    background: #f59e0b;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
}
.transit-form label { white-space: nowrap; }

/* === Events === */
.event-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.event-summary-item {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 6px; border: 1px solid #e2e8f0;
    background: #fff; text-decoration: none; font-size: 13px;
    transition: background 0.15s;
}
.event-summary-item:hover { background: #f8fafc; text-decoration: none; }
.event-summary-item.active { background: #eff6ff; border-color: #2563eb; }
.event-count { font-weight: 700; color: #1e293b; }
.event-typ-badge {
    display: inline-block; padding: 1px 6px; border-radius: 3px;
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    white-space: nowrap;
}
.evt-tra { background: #dbeafe; color: #1d4ed8; }
.evt-mrl { background: #fef3c7; color: #92400e; }
.evt-pro { background: #d1fae5; color: #065f46; }
.event-table td { font-size: 12px; padding: 5px 8px; }
.event-table th { font-size: 11px; padding: 5px 8px; }

/* === Ausgabe (Gesamtübersicht) === */
.ausgabe-chapter { page-break-inside: avoid; }
.chapter-title { border-bottom: 2px solid #2563eb; padding-bottom: 4px; }
.mrl-phase-compact {
    padding: 6px 10px;
    margin-bottom: 4px;
    border-left: 2px solid #e2e8f0;
    font-size: 13px;
}
.mrl-phase-compact.phase-active { border-left-color: #2563eb; background: #f8faff; }

/* === Chapter Toggle === */
.chapter-arrow {
    display: inline-block;
    width: 16px;
    font-size: 12px;
    color: #94a3b8;
    transition: transform 0.15s;
    margin-right: 4px;
}
.chapter-title:hover .chapter-arrow { color: #2563eb; }
.chapter-collapsed { opacity: 0.85; }
.chapter-collapsed .chapter-title { border-bottom-color: #e2e8f0; }
/* === Format Toggle === */
.format-toggle { display: flex; gap: 0; border: 1px solid #d1d5db; border-radius: 6px; overflow: hidden; }
.format-option {
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s;
}
.format-option:first-child { border-right: 1px solid #d1d5db; }
.format-option.active { background: #2563eb; color: #fff; }
.format-option input[type="radio"] { display: none; }

/* === Remedy / Mittel === */
.remedy-inline { display: flex; flex-wrap: wrap; gap: 3px; }
.remedy-pill {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}
.remedy-notice { background: #fffbeb; border: 1px solid #fde68a; }
.remedy-summary-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.remedy-hit-count { color: #2563eb; font-weight: 700; }

/* === Differentiation === */
.diff-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    align-items: start;
}
@media (max-width: 960px) {
    .diff-layout { grid-template-columns: 1fr; }
}
.diff-tier-a { border-left: 3px solid #16a34a; }
.diff-tier-b { border-left: 3px solid #f59e0b; }
.diff-tier-c { border-left: 3px solid #e2e8f0; }
.diff-remedy {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}
.diff-remedy:last-child { border-bottom: none; }
.diff-remedy-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.diff-score {
    font-size: 12px;
    color: #2563eb;
    font-weight: 600;
}
.diff-remedy-detail { margin-top: 2px; }
.diff-konstellationen {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
}
.pill-resonanz {
    background: #fffbeb !important;
    color: #92400e !important;
    border: 1px solid #fde68a;
}

/* === Chat === */
.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px 0;
    margin-bottom: 8px;
}
.chat-msg {
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}
.chat-user {
    background: #eff6ff;
    color: #1e293b;
    margin-left: 40px;
    text-align: right;
}
.chat-assistant {
    background: #f1f5f9;
    color: #1e293b;
    margin-right: 40px;
}
.chat-input-row {
    display: flex;
    gap: 6px;
}

/* === Query Tabs === */
.query-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
}
.query-tab {
    padding: 8px 16px;
    font-size: 14px;
    color: #64748b;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.query-tab:hover { color: #1e293b; text-decoration: none; }
.query-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}

/* === Chart Tooltip === */
.chart-tooltip {
    display: none;
    position: absolute;
    background: #1e293b;
    color: #f1f5f9;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre;
    pointer-events: none;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 250px;
}

/* === Statistics === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-number { font-size: 28px; font-weight: 700; color: #2563eb; }
.stat-label { font-size: 13px; color: #64748b; margin-top: 2px; }
.stats-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 768px) {
    .stats-two-col { grid-template-columns: 1fr; }
}

.print-only { display: none; }
.print-header { text-align: center; margin-bottom: 20px; }
.print-header h1 { font-size: 22px; margin-bottom: 4px; }
.print-header p { color: #64748b; font-size: 13px; margin: 2px 0; }

/* === Print === */
@media print {
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    .navbar, .footer { display: none !important; }
    .container { max-width: 100%; padding: 0; }
    .info-card { box-shadow: none; border: 1px solid #e2e8f0; break-inside: avoid; }
    body { background: #fff; font-size: 11px; }
    .table th, .table td { padding: 4px 6px; font-size: 10px; }
    .table th { font-size: 9px; }
    .chapter-body { display: block !important; }
    .chapter-arrow { display: none !important; }
}

/* === Responsive === */
@media (max-width: 960px) {
    .radix-layout { grid-template-columns: 1fr; }
    .chart-container { position: static; }
    .mrl-directions { grid-template-columns: 1fr; }
}
