/* ── Theme-Tokens ── */
:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --ink: #1a1a2e;
    --muted: #555;
    --faint: #888;
    --line: #e0e0e0;
    --line-soft: #f0f0f0;
    --accent: #4361ee;
    --accent-strong: #3451d1;
    --accent-tint: #e9edfd;
    --accent-ring: rgba(67, 97, 238, .12);
    --thead-bg: #1a1a2e;
    --thead-ink: #fff;
    --thead-hover: #2d2d4e;
    --row-hover: #f7f8ff;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, .06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, .07);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, .09);
    --success-bg: #edfaf1;
    --success-ink: #1a7a3a;
    --success-line: #b2dfcc;
    --danger-bg: #fff0f0;
    --danger-ink: #c0392b;
    --danger-line: #f5c6c6;
    --ok: #2e7d32;
    --warn: #e6a700;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141c;
        --surface: #1a1e2b;
        --surface-2: #161927;
        --ink: #e6e9f4;
        --muted: #a7aec2;
        --faint: #7d8498;
        --line: #2a2f42;
        --line-soft: #232838;
        --accent: #7189f5;
        --accent-strong: #8ea1ff;
        --accent-tint: #242c4d;
        --accent-ring: rgba(113, 137, 245, .22);
        --thead-bg: #0e1017;
        --thead-ink: #cdd3e6;
        --thead-hover: #1c2030;
        --row-hover: #20253a;
        --shadow-sm: 0 1px 4px rgba(0, 0, 0, .35);
        --shadow-md: 0 2px 8px rgba(0, 0, 0, .4);
        --shadow-lg: 0 4px 24px rgba(0, 0, 0, .5);
        --success-bg: #14291c;
        --success-ink: #6fce93;
        --success-line: #245939;
        --danger-bg: #2d1a1a;
        --danger-ink: #ef8b7e;
        --danger-line: #5c2b26;
        --ok: #5fbf77;
        --warn: #e0b34f;
        color-scheme: dark;
    }
}

:root[data-theme="light"] {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --ink: #1a1a2e;
    --muted: #555;
    --faint: #888;
    --line: #e0e0e0;
    --line-soft: #f0f0f0;
    --accent: #4361ee;
    --accent-strong: #3451d1;
    --accent-tint: #e9edfd;
    --accent-ring: rgba(67, 97, 238, .12);
    --thead-bg: #1a1a2e;
    --thead-ink: #fff;
    --thead-hover: #2d2d4e;
    --row-hover: #f7f8ff;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, .06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, .07);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, .09);
    --success-bg: #edfaf1;
    --success-ink: #1a7a3a;
    --success-line: #b2dfcc;
    --danger-bg: #fff0f0;
    --danger-ink: #c0392b;
    --danger-line: #f5c6c6;
    --ok: #2e7d32;
    --warn: #e6a700;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #12141c;
    --surface: #1a1e2b;
    --surface-2: #161927;
    --ink: #e6e9f4;
    --muted: #a7aec2;
    --faint: #7d8498;
    --line: #2a2f42;
    --line-soft: #232838;
    --accent: #7189f5;
    --accent-strong: #8ea1ff;
    --accent-tint: #242c4d;
    --accent-ring: rgba(113, 137, 245, .22);
    --thead-bg: #0e1017;
    --thead-ink: #cdd3e6;
    --thead-hover: #1c2030;
    --row-hover: #20253a;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, .35);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, .4);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, .5);
    --success-bg: #14291c;
    --success-ink: #6fce93;
    --success-line: #245939;
    --danger-bg: #2d1a1a;
    --danger-ink: #ef8b7e;
    --danger-line: #5c2b26;
    --ok: #5fbf77;
    --warn: #e0b34f;
    color-scheme: dark;
}

/* ── Theme-Fade ─ nur während des Wechsels aktiv (Klasse setzt theme.js) ── */
html.theme-fading,
html.theme-fading *,
html.theme-fading *::before,
html.theme-fading *::after {
    transition: background-color .3s ease, color .3s ease,
                border-color .3s ease, box-shadow .3s ease !important;
}

@media (prefers-reduced-motion: reduce) {
    html.theme-fading,
    html.theme-fading *,
    html.theme-fading *::before,
    html.theme-fading *::after {
        transition: none !important;
    }
}

/* ── Reset ── */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: var(--ink);
    background-color: var(--bg);
}

body {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ── */
#header {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    background-color: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
}

#header img.logo {
    height: 40px;
    width: auto;
}

#header .user-info,
#header .mb-3 {
    font-size: .875rem;
    color: var(--muted);
    margin: 0;
}

#header .user-info a,
#header .mb-3 a {
    color: var(--accent);
    text-decoration: none;
}

#header select {
    font-size: .9rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ── Theme-Toggle ── */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    transition: background-color .15s, color .15s, border-color .15s;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ── Layout ── */
#layout {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
}

#page {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 2rem;
}

/* Status + Requests: normal vertical scroll */
#view-status,
#view-requests {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
}

/* Queue: internal structure, no outer scroll */
#view-queue {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#q-filter-card {
    flex-shrink: 0;
    margin-bottom: 0;
}

#q-table-card {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

.queue-table-wrap {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
}

#queue-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--thead-bg);
}

.queue-pagination {
    flex-shrink: 0;
}

#content {
    width: 100%;
    max-width: 1100px;
}

/* ── Login ── */
.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    margin: 3rem auto 0;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo img {
    height: 48px;
    width: auto;
}

.login-title {
    font-size: 1.4rem;
    font-weight: 600;
    text-align: center;
    margin: 0 0 1.5rem;
    color: var(--ink);
}

.login-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-line);
    color: var(--danger-ink);
    border-radius: 6px;
    padding: .65rem 1rem;
    font-size: .875rem;
    margin-bottom: 1.25rem;
}

.login-form .form-group {
    margin-bottom: 1.1rem;
}

.login-form label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: .35rem;
}

.login-form input[type="email"],
.login-form input[type="password"] {
    width: 100%;
    padding: .6rem .9rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-size: .95rem;
    color: var(--ink);
    background: var(--surface-2);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.login-form input[type="email"]:focus,
.login-form input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
    background: var(--surface);
}

.login-submit {
    width: 100%;
    padding: .7rem;
    font-size: 1rem;
    margin-top: .5rem;
    border-radius: 7px;
    justify-content: center;
}

/* ── Button ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem 1.1rem;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}

.btn-primary {
    background-color: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-strong);
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* ── Loading badge ── */
.loading-badge {
    display: none;
    align-items: center;
    gap: .4rem;
    font-size: .8rem;
    color: var(--faint);
    padding: .3rem .7rem;
    background: var(--bg);
    border-radius: 20px;
}

.loading-badge.visible {
    display: inline-flex;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Utility / Status ── */
.last-loaded {
    font-size: .8rem;
    color: var(--faint);
}

.push-right {
    margin-left: auto;
}

.hint-text {
    font-size: .85rem;
    color: var(--muted);
    margin: .25rem 0 1rem;
}

.bulk-info {
    font-size: .875rem;
    color: var(--muted);
}

.status-ok {
    color: var(--ok);
    font-weight: 600;
}

.status-warn {
    color: var(--warn);
    font-weight: 600;
}

.status-off {
    color: var(--faint);
}

.td-empty {
    text-align: center;
    color: var(--faint);
}

.td-error {
    text-align: center;
    color: var(--danger-ink);
}

.spinner-accent {
    border-color: var(--accent-ring);
    border-top-color: var(--accent);
}

/* ── Toggle switch ── */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--line);
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #fff;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

input:disabled + .slider {
    opacity: .5;
    cursor: not-allowed;
}
