:root {
    --navy-dark: #071521;
    --navy-blue: #0A1E2D;
    --navy-light: #132738;
    --navy-border: #1C354B;
    --space-mint: #00C3CD;
    --space-mint-hover: #1ee3ed;
    --pumpkin: #FF7D00;
    --text-main: #FFFFFF;
    --text-dim: #94A3B8;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { background: var(--navy-dark); color: var(--text-main); display: flex; height: 100vh; overflow: hidden; }

.icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: inline-flex;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Sidebar */
aside {
    width: 270px;
    background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy-blue) 100%);
    border-right: 1px solid var(--navy-border);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    user-select: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 30px;
    padding: 6px 8px 20px 8px;
    border-bottom: 1px solid var(--navy-border);
}

.brand-square-logo {
    width: 52px;
    height: 52px;
    border-radius: 4px;
    display: block;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.brand-text-block {
    display: flex;
    flex-direction: column;
}

.brand-app-name {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #FFFFFF;
}

.brand-app-sub {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--space-mint);
    text-transform: uppercase;
    margin-top: 2px;
}

nav { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 6px;
    color: var(--text-dim);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text-main); transform: translateX(3px); }
.nav-item.active { background: rgba(0, 195, 205, 0.12); color: var(--space-mint); border-left-color: var(--space-mint); }

/* Main Area */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: radial-gradient(circle at 90% 10%, rgba(0, 195, 205, 0.06), transparent 45%); }

header {
    padding: 20px 36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--navy-border);
    background: rgba(10, 30, 45, 0.6);
    backdrop-filter: blur(10px);
}
.header-title h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.header-title p { font-size: 13px; color: var(--text-dim); margin-top: 3px; }

.security-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--space-mint);
    background: rgba(0, 195, 205, 0.1);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(0, 195, 205, 0.3);
    font-weight: 600;
}

.content-area { flex: 1; overflow-y: auto; padding: 32px 36px; }

.card {
    background: var(--navy-blue);
    border: 1px solid var(--navy-border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.3s var(--ease);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-group { margin-bottom: 18px; }
label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 8px; }

input, select, textarea {
    width: 100%;
    background: #06131D;
    border: 1px solid var(--navy-border);
    border-radius: 6px;
    color: #fff;
    padding: 11px 14px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s var(--ease);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--space-mint);
    box-shadow: 0 0 0 2px rgba(0, 195, 205, 0.25);
    background: #091a27;
}

.btn {
    height: 42px;
    box-sizing: border-box;
    background: var(--navy-light);
    color: var(--text-main);
    font-weight: 700;
    font-size: 13px;
    border: 1px solid var(--navy-border);
    padding: 0 18px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}
.btn:hover { background: #1C354B; border-color: rgba(0, 195, 205, 0.4); color: #fff; }

.btn-corporate {
    background: linear-gradient(135deg, #132E43 0%, #0A1E2D 100%);
    color: var(--space-mint);
    border: 1.5px solid var(--space-mint);
    box-shadow: 0 4px 14px rgba(0, 195, 205, 0.15);
    font-weight: 800;
}
.btn-corporate:hover {
    background: var(--space-mint);
    color: var(--navy-blue);
    box-shadow: 0 6px 20px rgba(0, 195, 205, 0.35);
    transform: translateY(-1px);
}

.btn-danger {
    background: rgba(255, 5, 85, 0.15);
    border: 1px solid rgba(255, 5, 85, 0.4);
    color: #FF5277;
}
.btn-danger:hover { background: #FF0555; color: #fff; }

.btn-toggle-group {
    display: flex;
    background: #06131D;
    padding: 4px;
    border-radius: 6px;
    border: 1px solid var(--navy-border);
    margin-bottom: 18px;
}
.btn-toggle {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-toggle.active {
    background: var(--navy-light);
    color: var(--space-mint);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.counter-badge { text-align: right; font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.counter-warn { color: var(--pumpkin) !important; font-weight: bold; }

/* Item Listen */
.item-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 540px; overflow-y: auto; padding-right: 4px; }
.list-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--navy-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}
.list-entry:hover { background: rgba(0, 195, 205, 0.06); border-color: rgba(0, 195, 205, 0.3); transform: translateX(3px); }

.tag {
    background: rgba(0, 195, 205, 0.12);
    color: var(--space-mint);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 3px;
    margin-right: 4px;
}

.group-checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 2px;
}
.pill-check {
    background: #06131D;
    border: 1px solid var(--navy-border);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: all 0.2s;
}
.pill-check.checked {
    background: rgba(0, 195, 205, 0.18);
    border-color: var(--space-mint);
    color: var(--space-mint);
}

/* Modal Popups */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 14, 22, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s var(--ease);
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background: var(--navy-blue);
    border: 1.5px solid var(--navy-border);
    border-radius: 10px;
    width: 520px;
    max-width: 90vw;
    padding: 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    transform: scale(0.95);
    transition: transform 0.25s var(--ease);
}
.modal-overlay.active .modal-content {
    transform: scale(1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--navy-border);
}

#status-msg { margin-top: 16px; font-weight: 600; font-size: 14px; min-height: 20px; }

/* ---- Ergänzungen für die Server-Version ---- */
.header-right { display: flex; align-items: center; gap: 12px; }
.user-chip { font-size: 13px; color: var(--text-dim); }
.user-chip strong { color: var(--text-main); }
.inline-form { display: inline; }
.btn-small { height: 34px; padding: 0 12px; font-size: 12px; }
.tenant-switch { width: auto; min-width: 180px; padding: 7px 10px; font-size: 13px; }
.dry-run-banner { background: rgba(255,125,0,0.15); border-bottom: 1px solid rgba(255,125,0,0.5); color: var(--pumpkin); text-align: center; font-size: 12px; font-weight: 700; padding: 6px; }
.empty-hint { color: var(--text-dim); text-align: center; padding: 30px; font-size: 14px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.toolbar > input { flex: 2; min-width: 200px; }
.toolbar > select { flex: 1; min-width: 160px; }
.muted { color: var(--text-dim); font-size: 12px; }
.edit-hint { color: var(--space-mint); font-size: 12px; font-weight: 600; white-space: nowrap; }
.list-entry > div { min-width: 0; }
.truncate { max-width: 650px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn-corporate { flex: 1; }
.btn-close { height: 32px; width: 32px; padding: 0; }
.status-ok { color: var(--space-mint); }
.status-warn { color: var(--pumpkin); }
.status-err { color: #FF5277; }
.history-entry { cursor: default; flex-direction: column; align-items: stretch; gap: 6px; }
.history-entry:hover { transform: none; }
.history-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.history-body { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.history-fail { font-size: 12px; color: #FF5277; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 3px; }
.badge-ok { background: rgba(0,195,205,0.12); color: var(--space-mint); }
.badge-warn { background: rgba(255,125,0,0.15); color: var(--pumpkin); }
.badge-err { background: rgba(255,5,85,0.15); color: #FF5277; }
.sidebar-tenant { font-size: 12px; color: var(--text-dim); margin: -16px 8px 20px; }
.sidebar-tenant strong { display: block; color: var(--text-main); font-size: 14px; margin-top: 2px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Login / Auswahl / Fehler */
body.page-center { align-items: center; justify-content: center; overflow: auto; background: radial-gradient(circle at 80% 10%, rgba(0,195,205,0.08), transparent 50%), var(--navy-dark); }
.auth-card { width: 420px; max-width: calc(100vw - 32px); }
.auth-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-brand img { width: 52px; height: 52px; border-radius: 4px; }
.auth-error { background: rgba(255,5,85,0.12); border: 1px solid rgba(255,5,85,0.4); color: #FF5277; padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.auth-hint { font-size: 12px; color: var(--text-dim); margin-top: 16px; line-height: 1.5; }
.tenant-link { display: block; text-decoration: none; color: inherit; }
.tenant-link + .tenant-link { margin-top: 8px; }

@media (max-width: 800px) {
    body { flex-direction: column; height: auto; min-height: 100vh; overflow: auto; }
    aside { width: 100%; padding: 12px 16px; }
    .sidebar-brand { margin-bottom: 10px; padding-bottom: 10px; }
    .sidebar-tenant { margin: 0 8px 10px; }
    nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .nav-item { padding: 8px 10px; font-size: 13px; }
    .nav-item:hover { transform: none; }
    aside > .sidebar-footer { display: none; }
    header { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
    .content-area { padding: 16px; overflow: visible; }
    .card { padding: 16px; }
}

[hidden] { display: none !important; }

/* ---- Eigene Auswahlfelder ---- */
header { position: relative; z-index: 20; }
.cselect { position: relative; width: 100%; }
.cselect-native { display: none !important; }
.cselect-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background: #06131D; border: 1px solid var(--navy-border); border-radius: 6px;
    color: #fff; padding: 11px 14px; font-size: 14px; cursor: pointer; text-align: left;
    transition: all 0.2s var(--ease);
}
.cselect-btn:hover { border-color: rgba(0, 195, 205, 0.4); }
.cselect-btn:focus-visible, .cselect.open .cselect-btn {
    outline: none; border-color: var(--space-mint);
    box-shadow: 0 0 0 2px rgba(0, 195, 205, 0.25); background: #091a27;
}
.cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-label.placeholder { color: var(--text-dim); }
.cselect-chevron {
    width: 8px; height: 8px; flex-shrink: 0; margin-right: 2px;
    border-right: 2px solid var(--space-mint); border-bottom: 2px solid var(--space-mint);
    transform: translateY(-2px) rotate(45deg); transition: transform 0.2s var(--ease);
}
.cselect.open .cselect-chevron { transform: translateY(2px) rotate(-135deg); }
.cselect-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 500;
    background: var(--navy-blue); border: 1px solid var(--navy-border); border-radius: 8px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55); padding: 6px;
    animation: fadeIn 0.15s var(--ease);
}
.cselect-search { margin-bottom: 6px; padding: 8px 12px; font-size: 13px; }
.cselect-list { list-style: none; max-height: 264px; overflow-y: auto; }
.cselect-opt {
    padding: 9px 12px; border-radius: 5px; font-size: 14px; cursor: pointer;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.12s;
}
.cselect-opt.placeholder { color: var(--text-dim); }
.cselect-opt.active { background: rgba(255, 255, 255, 0.06); }
.cselect-opt.selected { color: var(--space-mint); background: rgba(0, 195, 205, 0.12); font-weight: 600; }
.cselect-empty { padding: 9px 12px; color: var(--text-dim); font-size: 13px; }
.cselect-compact { width: auto; min-width: 210px; }
.cselect-compact .cselect-btn { padding: 7px 12px; font-size: 13px; }
.cselect-compact .cselect-panel { left: auto; min-width: 100%; }
.toolbar > .cselect { flex: 1; min-width: 160px; }

.settings-current { font-size: 14px; color: var(--text-dim); }
.settings-current strong { color: var(--space-mint); font-size: 15px; }
