:root {
    --brand-blue: #3c50e0;
    --brand-blue-hover: #2563eb;
    --nebula-bg: #0f172a;
    --nebula-bg-darker: #0b1120;
    --nebula-bg-light: #1e293b;
    --nebula-border: #334155;
    --nebula-text: #e2e8f0;
    --nebula-text-muted: #94a3b8;
    --state-ok: #10b981;
    --state-warn: #f59e0b;
    --state-error: #ef4444;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body.app-body {
    font-family: 'Outfit', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--nebula-text);
    background:
        radial-gradient(1100px 680px at 8% -10%, rgba(60, 80, 224, 0.15), transparent 60%),
        radial-gradient(900px 620px at 94% 112%, rgba(56, 189, 248, 0.08), transparent 62%),
        linear-gradient(180deg, var(--nebula-bg) 0%, var(--nebula-bg-darker) 100%);
}

.app-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    width: 20.5rem;
    min-width: 20.5rem;
    border-right: 1px solid rgba(51, 65, 85, 0.92);
    background: linear-gradient(180deg, rgba(11, 17, 32, 0.96) 0%, rgba(8, 13, 25, 0.96) 100%);
    padding: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0.25rem 0.25rem;
}

.sidebar-brand__icon {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 0.7rem;
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(30, 58, 138, 0.26);
    color: #93c5fd;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-brand__title {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 700;
    color: #f8fafc;
}

.sidebar-brand__subtitle {
    margin: 0.1rem 0 0;
    font-size: 0.7rem;
    color: #94a3b8;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0.15rem 0;
}

.sidebar-nav__link {
    display: inline-flex;
    align-items: center;
    min-height: 2.45rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(51, 65, 85, 0.85);
    background: rgba(15, 23, 42, 0.65);
    color: #cbd5e1;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.55rem 0.8rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.sidebar-nav__link:hover {
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.9);
    background: rgba(30, 41, 59, 0.74);
}

.sidebar-nav__link--active {
    color: #f8fafc;
    border-color: rgba(96, 165, 250, 0.5);
    background: rgba(30, 58, 138, 0.36);
}

.sidebar-panel {
    padding: 1rem;
}

.sidebar-panel--grow {
    margin-top: auto;
}

#sidebar-stats-panel .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-main-frame {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 4rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.88);
    background: rgba(11, 17, 32, 0.86);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 1.15rem;
    gap: 1rem;
}

.app-header__title {
    font-size: 0.98rem;
    color: #f1f5f9;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.app-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.62rem;
    border: 1px solid rgba(100, 116, 139, 0.82);
    background: rgba(15, 23, 42, 0.66);
    color: #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.icon-btn:hover {
    color: #ffffff;
    border-color: rgba(148, 163, 184, 0.96);
    background: rgba(30, 41, 59, 0.78);
}

.icon-btn--active {
    color: #ffffff;
    border-color: rgba(96, 165, 250, 0.58);
    background: rgba(30, 58, 138, 0.4);
}

.app-content {
    flex: 1;
    overflow: auto;
    padding: 1rem 1.15rem;
}

.results-stage {
    position: relative;
    min-height: calc(100vh - 5.6rem);
    width: 100%;
    max-width: 1680px;
    margin: 0 auto;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
    gap: 0.9rem;
    align-items: start;
}

.empty-results {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #cbd5e1;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 1rem;
}

.panel-card {
    border: 1px solid rgba(51, 65, 85, 0.95);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.9) 0%, rgba(11, 17, 32, 0.95) 100%);
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.32);
}

.result-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.btn-primary,
.btn-brand {
    background: linear-gradient(180deg, rgba(66, 90, 232, 1) 0%, rgba(60, 80, 224, 1) 100%);
    border: 1px solid rgba(96, 165, 250, 0.4);
    color: #ffffff;
    min-height: 2.75rem;
    border-radius: 0.7rem;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-primary:hover,
.btn-brand:hover {
    box-shadow: 0 10px 22px rgba(60, 80, 224, 0.35);
    filter: brightness(1.04);
}

.btn-primary:active,
.btn-brand:active {
    transform: translateY(1px) scale(0.99);
}

.btn-secondary,
.btn-muted {
    border: 1px solid rgba(100, 116, 139, 0.8);
    background: rgba(15, 23, 42, 0.55);
    color: #cbd5e1;
    min-height: 2.75rem;
    border-radius: 0.7rem;
    font-weight: 600;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.btn-secondary:hover,
.btn-muted:hover {
    border-color: rgba(148, 163, 184, 0.95);
    color: #f8fafc;
    background: rgba(30, 41, 59, 0.75);
}

.stat-chip {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(51, 65, 85, 0.82);
    border-radius: 12px;
    padding: 0.7rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-chip--ok {
    border-color: rgba(16, 185, 129, 0.45);
}

.stat-chip--warn {
    border-color: rgba(245, 158, 11, 0.45);
}

.stat-chip--error {
    border-color: rgba(239, 68, 68, 0.5);
}

.stat-label {
    font-size: 0.72rem;
    color: var(--nebula-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.stat-value {
    font-size: 1.1rem;
    line-height: 1.1;
    color: #f8fafc;
    font-weight: 700;
}

.mapping-status {
    font-weight: 600;
    letter-spacing: 0.01em;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge--primary {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.28);
    background: rgba(30, 58, 138, 0.18);
}

.badge--success {
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.32);
    background: rgba(6, 78, 59, 0.22);
}

.badge--warning {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(120, 53, 15, 0.2);
}

.badge--error {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(127, 29, 29, 0.2);
}

.result-card__header {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.result-card__title {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.35;
    font-weight: 700;
    color: #f8fafc;
    word-break: break-word;
}

.result-card__meta {
    text-align: right;
    color: var(--nebula-text-muted);
    font-size: 0.78rem;
    flex-shrink: 0;
}

.result-card__status {
    display: inline-flex;
    margin-bottom: 0.25rem;
    font-size: 0.69rem;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.16rem 0.45rem;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.status-badge--pending {
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.22);
    background: rgba(71, 85, 105, 0.18);
}

.status-badge--info {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.26);
    background: rgba(30, 58, 138, 0.18);
}

.status-badge--ok {
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.28);
    background: rgba(6, 78, 59, 0.2);
}

.status-badge--warn {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.26);
    background: rgba(120, 53, 15, 0.2);
}

.status-badge--error {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.26);
    background: rgba(127, 29, 29, 0.22);
}

.result-card__content {
    padding: 0.6rem 0.7rem 0.75rem;
    max-height: 380px;
    min-height: 0;
    overflow-y: auto;
}

.result-card__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-card__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.68rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(51, 65, 85, 0.82);
    background: rgba(15, 23, 42, 0.62);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.result-card__item:hover {
    border-color: rgba(96, 165, 250, 0.55);
    background: rgba(15, 23, 42, 0.78);
}

.result-card__filename {
    font-size: 0.8rem;
    color: #e2e8f0;
    line-height: 1.3;
    word-break: break-word;
}

.result-card__meta-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
}

.result-card__profile {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.69rem;
    line-height: 1.25;
    font-weight: 700;
}

.result-card__profile--pending {
    color: var(--nebula-text-muted);
}

.result-card__profile--ok {
    color: #6ee7b7;
}

.result-card__profile--warn {
    color: #fcd34d;
}

.result-card__profile--error {
    color: #fca5a5;
}

.result-card__druckerei {
    margin-top: 0.2rem;
    font-size: 0.63rem;
    line-height: 1.2;
}

.result-card__druckerei--default {
    color: #94a3b8;
}

.result-card__druckerei--warn {
    color: #fcd34d;
    font-weight: 700;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.settings-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
    font-weight: 700;
    color: #f8fafc;
}

.settings-subtitle {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
    color: #94a3b8;
}

.settings-header-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    align-items: center;
}

.settings-status-wrap {
    margin-top: 0.85rem;
}

.settings-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.24rem 0.6rem;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.settings-status--info {
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.26);
    background: rgba(30, 58, 138, 0.18);
}

.settings-status--ok {
    color: #86efac;
    border-color: rgba(16, 185, 129, 0.28);
    background: rgba(6, 78, 59, 0.2);
}

.settings-status--warning {
    color: #fcd34d;
    border-color: rgba(245, 158, 11, 0.27);
    background: rgba(120, 53, 15, 0.2);
}

.settings-status--error {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.27);
    background: rgba(127, 29, 29, 0.2);
}

.settings-grid {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.settings-block {
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.5);
    padding: 0.9rem;
}

.settings-block--full {
    grid-column: 1 / -1;
}

.settings-block-title {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    line-height: 1.25;
    font-weight: 700;
    color: #f1f5f9;
}

.settings-form {
    display: grid;
    gap: 0.45rem;
    margin-bottom: 0.9rem;
}

.settings-label {
    font-size: 0.73rem;
    color: #94a3b8;
    font-weight: 600;
}

.settings-input,
.settings-textarea {
    width: 100%;
    border: 1px solid rgba(100, 116, 139, 0.75);
    background: rgba(15, 23, 42, 0.72);
    color: #e2e8f0;
    border-radius: 0.6rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-input:focus,
.settings-textarea:focus {
    border-color: rgba(96, 165, 250, 0.95);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
}

.settings-input:disabled,
.settings-textarea:disabled,
.btn-primary:disabled,
.btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.settings-form-actions {
    margin-top: 0.25rem;
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.settings-help {
    margin: 0.2rem 0 0;
    font-size: 0.74rem;
    line-height: 1.35;
    color: #94a3b8;
}

.printer-list {
    display: grid;
    gap: 0.6rem;
}

.printer-card {
    border: 1px solid rgba(51, 65, 85, 0.78);
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.62);
    padding: 0.62rem 0.68rem;
}

.printer-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.printer-card__title {
    margin: 0;
    font-size: 0.84rem;
    color: #f8fafc;
    line-height: 1.25;
    font-weight: 700;
}

.printer-card__actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.printer-card__body p {
    margin: 0.16rem 0;
    font-size: 0.74rem;
    color: #cbd5e1;
    line-height: 1.28;
}

.matrix-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 0.7rem;
}

.matrix-container {
    border: 1px solid rgba(51, 65, 85, 0.75);
    border-radius: 10px;
    overflow: auto;
    max-height: 520px;
    background: rgba(15, 23, 42, 0.65);
}

.matrix-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

.matrix-table th,
.matrix-table td {
    border-bottom: 1px solid rgba(51, 65, 85, 0.68);
    border-right: 1px solid rgba(51, 65, 85, 0.68);
    padding: 0.48rem 0.52rem;
    text-align: center;
    font-size: 0.74rem;
}

.matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(11, 17, 32, 0.95);
    color: #cbd5e1;
    font-weight: 700;
}

.matrix-table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    background: rgba(11, 17, 32, 0.94);
    color: #e2e8f0;
    text-align: left;
    min-width: 260px;
    font-weight: 600;
}

.matrix-table input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--brand-blue);
}

.settings-empty {
    padding: 0.75rem;
    border: 1px dashed rgba(100, 116, 139, 0.66);
    border-radius: 10px;
    color: #94a3b8;
    font-size: 0.82rem;
}

.nebula-grid-shape {
    position: fixed;
    pointer-events: none;
    opacity: 0.42;
    z-index: 0;
    width: 420px;
    height: 420px;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 52px 52px;
}

.nebula-grid-shape--top-right {
    top: -80px;
    right: -80px;
}

.nebula-grid-shape--bottom-left {
    bottom: -80px;
    left: -80px;
    transform: rotate(180deg);
}

.app-scrollbar::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.app-scrollbar::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.75);
    border-radius: 10px;
}

.app-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.85);
    border-radius: 10px;
}

.app-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.95);
}

@media (max-width: 1023px) {
    .app-shell {
        flex-direction: column;
    }

    .app-sidebar {
        width: 100%;
        min-width: 0;
        border-right: 0;
        border-bottom: 1px solid rgba(51, 65, 85, 0.92);
    }

    .sidebar-panel--grow {
        margin-top: 0;
    }

    .app-header {
        padding: 0.6rem 0.8rem;
    }

    .app-content {
        padding: 0.85rem;
    }

    .results-stage {
        min-height: 60vh;
        max-width: none;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    }
}

@media (max-width: 767px) {
    .sidebar-brand__title {
        font-size: 0.9rem;
    }

    .sidebar-brand__subtitle {
        font-size: 0.68rem;
    }

    .app-header__title {
        font-size: 0.9rem;
    }

    .icon-btn {
        width: 2.35rem;
        height: 2.35rem;
    }

    .results-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .empty-results {
        font-size: 0.95rem;
    }

    .result-card__header {
        padding: 0.85rem;
    }

    .result-card__title {
        font-size: 0.88rem;
    }

    .result-card__meta {
        font-size: 0.72rem;
    }

    .result-card__item {
        padding: 0.6rem 0.65rem;
    }

    .result-card__filename {
        font-size: 0.76rem;
    }

    .settings-header-actions {
        width: 100%;
    }

    .matrix-table {
        min-width: 620px;
    }
}

@media (min-width: 1120px) {
    .settings-grid {
        grid-template-columns: 0.9fr 1.1fr;
    }
}
