/* SE Branding */
:root {
    --se-life-green: #3DCD58;
    --se-dark-green: #009530;
    --se-white: #FFFFFF;
    --se-gray-50: #F7F8F9;
    --se-gray-100: #EBEDEF;
    --se-gray-200: #D6DADF;
    --se-gray-300: #B8BFC7;
    --se-gray-600: #586574;
    --se-gray-800: #2C3640;
    --se-gray-900: #1A2028;
    --se-blue: #0087CD;
    --se-amber: #F5A623;
    --se-red: #E53935;

    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;

    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: var(--font-sans);
    background: var(--se-gray-50);
    color: var(--se-gray-900);
    font-size: 14px;
    line-height: 1.5;
}

/* ========== Header ========== */
.header {
    background: var(--se-gray-900);
    color: var(--se-white);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-brand { display: flex; align-items: center; gap: 12px; }
.header-logo {
    background: var(--se-life-green);
    color: var(--se-white);
    font-weight: 700;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
}
.header h1 { font-size: 16px; font-weight: 600; }
.header-badge {
    font-size: 11px;
    background: rgba(255,255,255,0.12);
    padding: 4px 10px;
    border-radius: 12px;
    color: var(--se-gray-300);
}

/* ========== Global Bar ========== */
.global-bar {
    display: flex; align-items: center; gap: 24px;
    padding: 10px 24px; background: var(--se-white);
    border-bottom: 1px solid var(--se-gray-100);
    max-width: 1440px; margin: 0 auto;
    flex-wrap: wrap;
}
.global-group { display: flex; align-items: center; gap: 8px; }
.global-group > label {
    font-size: 12px; font-weight: 600; color: var(--se-gray-600);
    text-transform: uppercase; letter-spacing: 0.3px;
    display: flex; align-items: center; gap: 4px; white-space: nowrap;
}
.global-group .segmented-control { padding: 2px; gap: 2px; }
.global-group .seg-btn { padding: 6px 12px; font-size: 12px; }
.global-group select { width: auto; min-width: 180px; padding: 6px 28px 6px 10px; font-size: 12px; }

/* ========== Layout ========== */
.main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    padding: 20px 24px;
    max-width: 1440px;
    margin: 0 auto;
    align-items: start;
}

/* Tooltip */
.tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--se-gray-100);
    color: var(--se-gray-600);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    position: relative;
    flex-shrink: 0;
}
.tooltip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--se-gray-900);
    color: var(--se-white);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    width: max-content;
    max-width: 260px;
    z-index: 50;
    white-space: normal;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.tooltip:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--se-gray-900);
    z-index: 50;
}
/* Touch: tap toggles tooltip via focus */
@media (hover: none) {
    .tooltip { cursor: pointer; }
    .tooltip:focus::after {
        content: attr(data-tip);
        position: absolute; bottom: calc(100% + 6px); left: 50%;
        transform: translateX(-50%); background: var(--se-gray-900);
        color: var(--se-white); padding: 8px 12px; border-radius: 6px;
        font-size: 12px; font-weight: 400; line-height: 1.4;
        width: max-content; max-width: 260px; z-index: 50;
        white-space: normal; box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }
    .tooltip:focus::before {
        content: ''; position: absolute; bottom: calc(100% + 2px);
        left: 50%; transform: translateX(-50%);
        border: 4px solid transparent; border-top-color: var(--se-gray-900); z-index: 50;
    }
}

/* ========== Segmented Control (global bar) ========== */
.segmented-control {
    display: flex;
    background: var(--se-gray-100);
    border-radius: var(--radius);
    padding: 3px;
    gap: 3px;
}
.seg-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--se-gray-600);
    cursor: pointer;
    transition: all 0.2s;
}
.seg-btn.active {
    background: var(--se-white);
    color: var(--se-dark-green);
    box-shadow: var(--shadow);
    font-weight: 600;
}
.seg-btn:hover:not(.active) { color: var(--se-gray-800); }
.seg-btn:focus-visible {
    outline: 2px solid var(--se-life-green);
    outline-offset: 2px;
}

/* ========== Stepper (used by panel-stepper-row) ========== */
.stepper-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--se-gray-200); background: var(--se-white);
    border-radius: 6px; font-size: 18px; font-weight: 500;
    color: var(--se-gray-800); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s; font-family: var(--font-sans);
}
.stepper-btn:hover:not(:disabled) { border-color: var(--se-life-green); color: var(--se-dark-green); }
.stepper-btn:active:not(:disabled) { background: var(--se-gray-50); }
.stepper-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.stepper-btn:focus-visible { outline: 2px solid var(--se-life-green); outline-offset: 2px; }
.stepper-value {
    font-family: var(--font-mono); font-size: 16px;
    font-weight: 600; min-width: 32px; text-align: center;
}
/* ========== Dropdown ========== */
select {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--se-gray-200); border-radius: 6px;
    font-family: var(--font-sans); font-size: 13px;
    color: var(--se-gray-900); background: var(--se-white);
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23586574' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 32px;
}
select:focus {
    outline: none; border-color: var(--se-life-green);
    box-shadow: 0 0 0 2px rgba(61,205,88,0.2);
}

/* ========== Recommendation Card ========== */
.recommendation {
    position: sticky; top: 60px;
    background: var(--se-white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden;
    max-height: calc(100vh - 80px); overflow-y: auto;
    border: 1px solid var(--se-gray-100);
}
.rec-header {
    background: linear-gradient(135deg, var(--se-dark-green), #007A28);
    color: var(--se-white); padding: 20px;
    transition: box-shadow 0.3s ease;
}
.rec-header.pulse { box-shadow: inset 0 0 0 3px rgba(61,205,88,0.6); }
.rec-title { font-size: 18px; font-weight: 700; }
.rec-subtitle { font-size: 13px; opacity: 0.9; margin-top: 4px; font-family: var(--font-mono); }
.rec-section { padding: 16px 20px; border-bottom: 1px solid var(--se-gray-100); }
.rec-section:last-child { border-bottom: none; }
.rec-section h3 {
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--se-gray-600); margin-bottom: 10px;
    display: flex; align-items: center; gap: 6px;
}

/* Sizing grid */
.rec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rec-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.rec-item { background: var(--se-gray-50); border-radius: 6px; padding: 10px; }
.rec-item-label { font-size: 11px; color: var(--se-gray-600); margin-bottom: 2px; }
.rec-item-value { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--se-gray-900); }

/* Hints */
.hint {
    display: flex; align-items: flex-start; gap: 8px;
    padding: 8px 10px; border-radius: 6px; font-size: 12px;
    line-height: 1.4; margin-bottom: 6px;
}
.hint:last-child { margin-bottom: 0; }
.hint-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 3px; }
.hint-info { background: rgba(0,135,205,0.06); color: var(--se-gray-800); }
.hint-info .hint-dot { background: var(--se-blue); }
.hint-warning { background: rgba(245,166,35,0.08); color: var(--se-gray-800); }
.hint-warning .hint-dot { background: var(--se-amber); }
.hint-critical { background: rgba(229,57,53,0.08); color: var(--se-gray-800); }
.hint-critical .hint-dot { background: var(--se-red); }

/* Komponentenliste */
.rec-komponentenliste { list-style: none; font-size: 12px; font-family: var(--font-mono); }
.rec-komponentenliste li {
    padding: 4px 0; color: var(--se-gray-800); display: flex;
    justify-content: space-between; border-bottom: 1px solid var(--se-gray-50);
}
.rec-komponentenliste li:last-child { border-bottom: none; }
.komp-ref { color: var(--se-gray-600); font-size: 11px; }

/* Warnings empty state */
.rec-warnungen-list:empty::after {
    content: 'Keine Warnungen'; color: var(--se-gray-300); font-size: 12px;
}

/* ========== Energy Flow Diagram ========== */
.diagram-container {
    background: var(--se-white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); padding: 16px; position: relative;
}
.diagram-hint {
    position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
    font-size: 12px; color: var(--se-gray-600); pointer-events: none;
    transition: opacity 0.5s ease;
    background: var(--se-gray-50); padding: 4px 14px; border-radius: 12px;
    border: 1px solid var(--se-gray-200);
    animation: hint-pulse 2s ease-in-out 3;
}
.diagram-hint.hidden { opacity: 0; animation: none; }
@keyframes hint-pulse {
    0%, 100% { border-color: var(--se-gray-200); }
    50% { border-color: var(--se-life-green); }
}
.energy-diagram { width: 100%; height: auto; }
.energy-diagram .node { transition: opacity 300ms ease, filter 200ms ease; }
.energy-diagram .node:hover { filter: brightness(0.95) drop-shadow(0 0 4px rgba(0,0,0,0.12)); cursor: pointer; }
.energy-diagram .node:focus { outline: none; }
.energy-diagram .node:focus-visible { outline: 2px solid var(--se-life-green); outline-offset: 4px; }
.energy-diagram .node.active-node { filter: drop-shadow(0 0 8px rgba(61,205,88,0.5)); }
.energy-diagram .flow-line { stroke-linecap: round; transition: opacity 300ms ease, stroke-width 300ms ease; }

@keyframes dash-flow { to { stroke-dashoffset: -24; } }
.energy-diagram .flow-line.active { animation: dash-flow 1s linear infinite; }
.energy-diagram .flow-line.reverse { animation: dash-flow 1s linear infinite reverse; }

/* ========== Backdrop ========== */
.panel-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.15);
    z-index: 190; opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.panel-backdrop.visible { opacity: 1; pointer-events: auto; }

/* ========== Detail Panel ========== */
.detail-panel {
    position: fixed; top: 52px; right: -400px; width: 360px;
    max-height: calc(100vh - 60px); background: var(--se-white);
    box-shadow: -4px 0 20px rgba(0,0,0,0.12);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    overflow-y: auto; transition: right 0.3s ease; z-index: 200;
}
.detail-panel.open { right: 0; }
.detail-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-left: 4px solid var(--se-life-green);
    border-bottom: 1px solid var(--se-gray-100);
}
.detail-header h3 { font-size: 16px; font-weight: 600; color: var(--se-gray-900); }
.detail-close {
    background: none; border: none; font-size: 22px; color: var(--se-gray-600);
    cursor: pointer; padding: 4px 8px; border-radius: 4px; line-height: 1;
}
.detail-close:hover { background: var(--se-gray-100); }
.detail-close:focus-visible { outline: 2px solid var(--se-life-green); outline-offset: 2px; }
.detail-body { padding: 16px 20px; }
.detail-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--se-gray-50); font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--se-gray-600); }
.detail-value { font-family: var(--font-mono); font-weight: 500; color: var(--se-gray-900); }
.detail-critical .detail-value { color: var(--se-red); font-weight: 600; }
.detail-warning .detail-value { color: var(--se-amber); font-weight: 600; }
.detail-info .detail-value { color: var(--se-blue); }

/* Panel config zone */
.panel-config-zone { margin-bottom: 0; }
.panel-field { margin-bottom: 12px; }
.panel-field:last-child { margin-bottom: 0; }
.panel-field > label {
    display: block; font-size: 12px; font-weight: 500;
    color: var(--se-gray-600); margin-bottom: 4px;
}
.panel-slider-row { display: flex; align-items: center; gap: 10px; }
.panel-slider {
    flex: 1; height: 6px; -webkit-appearance: none; appearance: none;
    background: var(--se-gray-200); border-radius: 3px; outline: none;
}
.panel-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
    background: var(--se-life-green); cursor: pointer;
    border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.panel-slider::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: var(--se-life-green); cursor: pointer;
    border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.panel-slider-value {
    font-family: var(--font-mono); font-size: 13px; font-weight: 600;
    min-width: 70px; text-align: right; color: var(--se-gray-900);
}
.panel-select {
    width: 100%; padding: 6px 10px; border: 1px solid var(--se-gray-200);
    border-radius: 6px; font-family: var(--font-sans); font-size: 12px;
    color: var(--se-gray-900); background: var(--se-white);
    cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23586574' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}
.panel-toggle {
    display: flex; background: var(--se-gray-100); border-radius: 6px; padding: 2px; gap: 2px;
}
.panel-toggle-btn {
    flex: 1; padding: 6px 8px; border: none; background: transparent; border-radius: 4px;
    font-family: var(--font-sans); font-size: 12px; font-weight: 500;
    color: var(--se-gray-600); cursor: pointer; transition: all 0.15s;
}
.panel-toggle-btn.active {
    background: var(--se-white); color: var(--se-dark-green);
    box-shadow: var(--shadow); font-weight: 600;
}
.panel-stepper-row {
    display: flex; align-items: center; gap: 8px;
}
.panel-stepper-row .stepper-btn { width: 28px; height: 28px; font-size: 16px; }
.panel-stepper-row .stepper-value { font-size: 15px; min-width: 28px; }

/* Panel hint text */
.panel-hint { font-size: 11px; color: var(--se-gray-300); margin-top: 3px; }

/* Panel checkboxes */
.panel-checkbox-group { display: flex; flex-wrap: wrap; gap: 6px; }
.panel-checkbox {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 10px; font-size: 12px; border-radius: 4px;
    border: 1px solid var(--se-gray-200); background: var(--se-gray-50);
    cursor: pointer; user-select: none; transition: all 0.15s;
}
.panel-checkbox.checked {
    background: rgba(61,205,88,0.08); border-color: var(--se-life-green);
    color: var(--se-dark-green); font-weight: 500;
}
.panel-checkbox input[type="checkbox"] { accent-color: var(--se-life-green); width: 14px; height: 14px; }

/* Separator between config and results */
.panel-separator {
    display: flex; align-items: center; gap: 10px;
    margin: 16px 0 12px; color: var(--se-gray-300); font-size: 10px;
    text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
}
.panel-separator::before, .panel-separator::after {
    content: ''; flex: 1; height: 1px; background: var(--se-gray-100);
}

/* Override slider */
.detail-override { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--se-gray-100); }
.detail-override label {
    display: block; font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--se-gray-600); margin-bottom: 8px;
}
.override-slider {
    width: calc(100% - 50px); vertical-align: middle; height: 6px;
    -webkit-appearance: none; appearance: none;
    background: var(--se-gray-200); border-radius: 3px; outline: none;
}
.override-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
    background: var(--se-life-green); cursor: pointer;
    border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.override-value {
    display: inline-block; width: 40px; text-align: right;
    font-family: var(--font-mono); font-weight: 600; font-size: 14px; vertical-align: middle;
}
.override-hint { font-size: 12px; margin-top: 6px; min-height: 18px; }
.override-hint.warning { color: var(--se-amber); }
.override-hint.info { color: var(--se-blue); }
.override-hint.critical { color: var(--se-red); }
.override-row { display: flex; align-items: center; gap: 8px; }
.override-reg { margin-top: 8px; font-size: 12px; font-family: var(--font-mono); }
.override-reg-item { padding: 2px 0; color: var(--se-gray-600); }

/* ========== Responsive ========== */
@media (max-width: 1200px) {
    .main { grid-template-columns: 1fr; }
    .recommendation { position: static; }
    .detail-panel { width: 100%; right: -100%; }
    .global-bar { padding: 8px 16px; gap: 16px; }
}

/* ========== Utilities ========== */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
