:root {
    /* --- VISTA AERO PALETTE --- */
    --aero-base: #256bb3; 
    --aero-bg: #eef3f8;
    
    --win-border-active: #38769f;
    --win-border-inner: #94cce8;
    
    --header-grad-top: #fbfdfe;
    --header-grad-mid: #dbebf9;
    --header-grad-bot: #c0dcf2;
    
    --btn-default-top: #f2f2f2;
    --btn-default-bot: #cfcfcf;
    --btn-primary-top: #eaf6fd;
    --btn-primary-mid: #d9f0fc;
    --btn-primary-bot: #a7d9f5;
    
    --text-main: #202020;
    --input-border: #7f9db9; 
    
    --radius: 3px;
    --header-height: 40px; 
    --sidebar-width: max(20vw, 260px);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(at top left, #294e6b 0%, #152c40 100%);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    font-size: 12px;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.header {
    height: var(--header-height);
    background: linear-gradient(to bottom, #1e3c54 0%, #102434 100%);
    border-bottom: 1px solid #000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 100;
    color: #fff;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 0 5px rgba(255,255,255,0.3);
}

.header h1 {
    font-size: 14px;
    margin: 0;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.config-group {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbdcea;
}

.config-group label {
    font-size: 11px;
}

.config-group input {
    height: 22px;
    background: #0b1a26;
    border: 1px solid #3e5a70;
    color: #fff;
    border-radius: 2px;
    padding: 0 6px;
    font-size: 11px;
    width: 160px;
}
.config-group input:focus {
    border-color: #6dacd6;
    outline: none;
    background: #152d40;
}

.burger-btn { display: none; }

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */
.dashboard-layout {
    display: flex;
    height: calc(100vh - var(--header-height));
    width: 100vw;
}

/* SIDEBAR */
.endpoint-nav {
    width: var(--sidebar-width);
    background: linear-gradient(to right, #f0f4fa 0%, #dce4f2 100%);
    border-right: 1px solid #99aabb;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 10px 0;
}

.endpoint-nav h2 {
    padding: 12px 15px 4px 15px;
    margin: 0;
    font-size: 11px;
    color: #1e395b; 
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.8;
}

.endpoint-nav ul { list-style: none; padding: 0; margin: 0 0 10px 0; }

.endpoint-nav li {
    padding: 5px 15px;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    border: 1px solid transparent;
    margin: 0 2px;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.endpoint-nav li:hover {
    background: linear-gradient(to bottom, #fcfefe 0%, #ebf3fd 100%);
    border-color: #b8d6fb;
}

.endpoint-nav li.active {
    background: linear-gradient(to bottom, #eaf6fd 0%, #d9f0fc 45%, #bee6fd 50%, #a7d9f5 100%);
    border-color: #3c7fb1;
    color: #000;
    box-shadow: inset 0 0 2px #fff;
    font-weight: 600;
}

/* MAIN CONTENT */
.main-content {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background: transparent; 
    display: block; 
    min-height: 0; 
    /* Verhindert horizontales Scrollen des gesamten Bereichs wenn möglich */
    max-width: 100%; 
}

/* ==========================================================================
   WINDOW FRAME STYLE
   ========================================================================== */
.window-frame {
    border: 1px solid #6c869f;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    background: #fff;
    overflow: visible; 
    display: flex;
    flex-direction: column;
    min-height: 300px; 
    height: auto;
    width: 100%;
    margin-bottom: 30px; 
    flex-shrink: 0; 
}

.window-header {
    background: linear-gradient(to bottom, var(--header-grad-top) 0%, var(--header-grad-mid) 45%, var(--header-grad-bot) 100%);
    border-bottom: 1px solid #9dbcd4;
    padding: 8px 15px;
    color: #1e395b;
    font-size: 13px;
    font-weight: bold;
    display: flex;
    align-items: center;
    box-shadow: inset 0 1px 0 #fff;
    border-radius: 4px 4px 0 0;
    flex-shrink: 0;
}

.window-body {
    padding: 20px;
    background: linear-gradient(to bottom, #fff 0%, #f4f8fc 100%);
    flex-grow: 1; 
    border-radius: 0 0 4px 4px;
}

.placeholder {
    text-align: center;
    color: #888;
    padding: 40px;
    font-style: italic;
}

/* ==========================================================================
   FORM LAYOUT & GRIDS
   ========================================================================== */
form[data-endpoint-name] {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 30px; 
    align-items: start;
}

.form-group {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.form-group label {
    margin-bottom: 5px;
    color: #1e395b;
    font-size: 11px;
    font-weight: 600;
}

.full-width { grid-column: 1 / -1; }

.columns-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    width: 100%;
    margin-bottom: 15px;
}

/* ==========================================================================
   INPUTS & CONTROLS
   ========================================================================== */
input[type="text"], 
input[type="password"],
input[type="number"], 
input[type="date"],
input[type="file"],
select, 
textarea {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid var(--input-border);
    border-top-color: #586e85;
    background-color: #fff;
    border-radius: 2px;
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
    color: #000;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05); 
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 28px; 
    box-sizing: border-box; /* Wichtig für Breitenberechnung */
}

input:focus, select:focus, textarea:focus {
    border-color: #3399ff;
    box-shadow: 0 0 0 2px rgba(51, 153, 255, 0.3), inset 0 1px 2px rgba(0,0,0,0.1);
    outline: none;
}

textarea {
    resize: vertical;
    min-height: 120px;
    font-family: Consolas, 'Courier New', monospace;
    line-height: 1.4;
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3e%3cpath fill='%23333' d='M0 0l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 8px;
    padding-right: 25px;
}

.date-range-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* ==========================================================================
   CONTROL BARS (Toolbars) - LOGIC FIX
   ========================================================================== */

/* STANDARD CONTROL BAR (für innere Bereiche) */
/* Flexibel: Darf umbrechen, Elemente dürfen kleiner sein */
.control-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap; /* Erlaubt Umbruch wenn Platz fehlt */
    gap: 8px;
    margin-bottom: 15px;
    padding: 8px;
    background: #eef3f8;
    border: 1px solid #d0dbe5;
    border-radius: 3px;
    width: 100%;
}

.control-bar input,
.control-bar select,
.control-bar button {
    height: 28px !important;
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Innere Elemente dürfen schrumpfen */
.control-bar input[type="text"] {
    flex-grow: 1;
    min-width: 80px; /* Kleinere Mindestbreite */
}
.control-bar select {
    min-width: 100px; /* Kleinere Mindestbreite */
}

/* MAIN TOOLBAR (Oben - Starr, eine Zeile) */
.control-bar.main-toolbar {
    flex-wrap: nowrap; /* Erzwingt eine Zeile */
    gap: 10px;
    padding: 10px;
    margin-bottom: 20px;
    white-space: nowrap;
}

.control-bar.main-toolbar input,
.control-bar.main-toolbar select,
.control-bar.main-toolbar button {
    height: 32px !important;
}

/* Große Mindestbreiten nur für die Hauptleiste */
.control-bar.main-toolbar select { min-width: 200px; }
.control-bar.main-toolbar input[type="text"] { min-width: 150px; }


/* ==========================================================================
   BUTTONS
   ========================================================================== */
button {
    font-family: 'Segoe UI', sans-serif;
    font-size: 12px;
    border-radius: 2px;
    cursor: pointer;
    text-align: center;
}

.btn-secondary, .clear-multiselect-btn {
    background: linear-gradient(to bottom, #f2f2f2 0%, #ebebeb 50%, #dddddd 50%, #cfcfcf 100%);
    border: 1px solid #707070;
    color: #000;
    height: 28px;
    padding: 0 12px;
    font-weight: 400;
    box-shadow: inset 0 1px 0 #fff;
}
.btn-secondary:hover {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 0 3px rgba(60,127,177,0.5);
    border-color: #3c7fb1;
    background: linear-gradient(to bottom, #fff 0%, #f0f0f0 100%);
}

.btn-primary {
    /* Standard Position */
    grid-column: 2 / 3;
    justify-self: end;
    
    min-width: 120px;
    height: 30px;
    padding: 0 20px;
    margin-top: 15px; 
    
    background: linear-gradient(to bottom, #f0f9ff 0%, #cbebff 45%, #a1dbff 50%, #88cfff 100%);
    border: 1px solid #2c628b;
    border-radius: 3px;
    color: #1e395b;
    font-weight: bold;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 2px rgba(0,0,0,0.1);
}

.btn-primary:hover {
    background: linear-gradient(to bottom, #eaf6fd 0%, #d9f0fc 45%, #bee6fd 50%, #a7d9f5 100%);
    box-shadow: 0 0 5px rgba(60, 127, 177, 0.8);
}

.btn-primary:disabled {
    filter: grayscale(100%);
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   RESULTS & STATUS
   ========================================================================== */
#job-status-container {
    display: none;
    background: #fdfdfd;
    border: 1px solid #8e9bb3;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    clear: both;
    width: 100%;
}
#job-status-text { margin: 0 0 5px 0; font-weight: bold; color: #444; }

.progress-bar {
    height: 16px;
    background: #e6e6e6;
    border: 1px solid #bcbcbc;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}
.progress-bar-inner {
    height: 100%;
    width: 0%;
    background: linear-gradient(to bottom, #d2ff52 0%, #91e842 50%, #74da24 51%, #74da24 100%);
    border-right: 1px solid #408612;
    transition: width 0.3s ease-out;
    text-align: center;
    line-height: 14px;
    font-size: 10px;
    color: #1a4405;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.result-display {
    border: 1px solid #8e9bb3;
    background: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    clear: both; 
    width: 100%;
    margin-bottom: 20px;
}
.result-display h4 {
    background: #e9e9e9;
    padding: 6px 10px;
    margin: 0;
    font-size: 11px;
    border-bottom: 1px solid #ccc;
    color: #333;
}
#result-pre {
    margin: 0;
    padding: 10px;
    background: #fefefe;
    font-family: Consolas, monospace;
    font-size: 11px;
    max-height: 300px;
    overflow: auto;
    border: none;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ==========================================================================
   MOBILE & BREAKPOINTS
   ========================================================================== */
@media (max-width: 1100px) {
    .columns-3 {
        grid-template-columns: 1fr; 
        gap: 20px;
    }
}

@media (max-width: 900px) {
    .dashboard-layout { flex-direction: column; }
    
    .endpoint-nav {
        position: fixed; 
        top: var(--header-height); 
        bottom: 0; 
        left: 0;
        z-index: 200;
        width: 85%;
        transform: translateX(-100%);
        transition: transform 0.3s;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    }
    .endpoint-nav.nav-open { transform: translateX(0); }
    
    .burger-btn {
        display: block;
        background: transparent;
        border: 1px solid rgba(255,255,255,0.3);
        color: #fff;
        padding: 4px 10px;
        border-radius: 3px;
        cursor: pointer;
        font-size: 16px;
    }
    
    .main-content { padding: 10px; }
    
    form[data-endpoint-name] {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .date-range-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .btn-primary { 
        grid-column: 1; 
        justify-self: stretch; 
        width: 100%;
    }
    
    .header-controls { display: none; }
    
    /* Mobile: Alles darf umbrechen */
    .control-bar, .control-bar.main-toolbar {
        flex-wrap: wrap; 
        white-space: normal;
    }
    .control-bar > * {
        width: 100%;
        margin-bottom: 5px !important;
    }
}