:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-surface-alt: #eef0f5;
    --color-sidebar: #ffffff;
    --color-sidebar-text: #5a6072;
    --color-sidebar-text-active: #1f2430;
    --color-sidebar-overlay-rgb: 31, 36, 48;
    --color-tooltip-bg: #1e2433;
    --color-tooltip-text: #ffffff;
    --color-tooltip-text-muted: #c3c8d4;
    --color-primary: #4f6df5;
    --color-primary-hover: #3c56dd;
    --color-primary-soft: rgba(79, 109, 245, 0.12);
    --color-border: #e4e6eb;
    --color-text: #1f2430;
    --color-text-muted: #6b7280;
    --color-danger: #d64545;
    --color-success: #1a9c53;
    --color-warning: #c9820a;
    --color-accent2: #7c5cff;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --series-5: #e87ba4;
    --series-6: #4a3aa7;
    --series-7: #e34948;
    --series-other: #898781;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05), 0 1px 1px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.1), 0 2px 4px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.16), 0 4px 10px rgba(15, 23, 42, 0.06);
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.18s;
}

:root[data-theme="dark"] {
    --color-bg: #12141c;
    --color-surface: #1b1e29;
    --color-surface-alt: #232735;
    --color-sidebar: #0d0f16;
    --color-sidebar-text: #9aa1b3;
    --color-sidebar-text-active: #ffffff;
    --color-sidebar-overlay-rgb: 255, 255, 255;
    --color-tooltip-bg: #05060a;
    --color-tooltip-text: #ffffff;
    --color-tooltip-text-muted: #9aa1b3;
    --color-primary: #7c93ff;
    --color-primary-hover: #97a8ff;
    --color-primary-soft: rgba(124, 147, 255, 0.16);
    --color-border: #2a2e3d;
    --color-text: #e6e8ef;
    --color-text-muted: #9198ab;
    --color-danger: #ef6a6a;
    --color-success: #2fbf6a;
    --color-warning: #e0a030;
    --color-accent2: #9085e9;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #9085e9;
    --series-7: #e66767;
    --series-other: #9198ab;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --color-bg: #12141c;
        --color-surface: #1b1e29;
        --color-surface-alt: #232735;
        --color-sidebar: #0d0f16;
        --color-sidebar-text: #9aa1b3;
        --color-sidebar-text-active: #ffffff;
        --color-sidebar-overlay-rgb: 255, 255, 255;
        --color-tooltip-bg: #05060a;
        --color-tooltip-text: #ffffff;
        --color-tooltip-text-muted: #9aa1b3;
        --color-primary: #7c93ff;
        --color-primary-hover: #97a8ff;
        --color-primary-soft: rgba(124, 147, 255, 0.16);
        --color-border: #2a2e3d;
        --color-text: #e6e8ef;
        --color-text-muted: #9198ab;
        --color-danger: #ef6a6a;
        --color-success: #2fbf6a;
        --color-warning: #e0a030;
        --color-accent2: #9085e9;
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --series-5: #d55181;
        --series-6: #9085e9;
        --series-7: #e66767;
        --series-other: #9198ab;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
        --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
        --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.55);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
    transition: background-color 0.15s ease, color 0.15s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ---------- Scrollbars ---------- */

html {
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.sidebar {
    scrollbar-color: rgba(var(--color-sidebar-overlay-rgb), 0.2) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 999px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(var(--color-sidebar-overlay-rgb), 0.2);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--color-sidebar-overlay-rgb), 0.32);
}

/* ---------- App shell ---------- */

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--color-sidebar);
    color: var(--color-sidebar-text);
    padding: 0.75rem 0 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-right: 1px solid var(--color-border);
    transition: width 0.15s ease, background-color var(--duration) var(--ease);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 1.5rem 1.5rem;
}

.sidebar-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--color-sidebar-text);
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: rgba(var(--color-sidebar-overlay-rgb), 0.08);
    color: var(--color-sidebar-text-active);
}

.sidebar-toggle .icon {
    width: 15px;
    height: 15px;
    transition: transform 0.15s ease;
}

.sidebar nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    font-size: 0.72rem;
    color: var(--color-sidebar-text);
    opacity: 0.9;
    border-top: 1px solid rgba(var(--color-sidebar-overlay-rgb), 0.08);
    flex-shrink: 0;
    text-align: center;
}

.sidebar-footer a,
.auth-footer span a {
    color: inherit;
    text-decoration: underline;
}

.sidebar-footer a:hover,
.auth-footer span a:hover {
    opacity: 0.8;
}

/* eMind-Logo hat einen weißen Hintergrund (JPG) — eigene kleine weiße Badge-Fläche,
   damit es nicht als hartkantiges weißes Rechteck auf der dunklen Sidebar wirkt. */
.sidebar-footer-emind {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    background: #ffffff;
    border-radius: 3px;
    padding: 0.1rem 0.35rem;
    text-decoration: none !important;
}

.sidebar-footer-emind img {
    display: block;
    height: 12px;
    width: auto;
}

.sidebar-footer-version {
    margin-top: 0.3rem;
    opacity: 0.7;
    font-size: 0.68rem;
}

.auth-footer .sidebar-footer-version {
    margin-top: 0;
}

.menu-group {
    margin-bottom: 0.6rem;
}

.menu-group summary {
    cursor: pointer;
    padding: 0.6rem 1.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--color-sidebar-text);
    list-style: none;
}

.menu-group summary::-webkit-details-marker {
    display: none;
}

.menu-group ul {
    list-style: none;
    margin: 0;
    padding: 0 0 0.5rem;
}

.menu-group li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem 0.65rem 1.75rem;
    font-size: 0.9rem;
    color: var(--color-sidebar-text);
    border-radius: 0;
    transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.menu-group li a .icon {
    width: 15px;
    height: 15px;
    vertical-align: 0;
}

.menu-group li a:hover {
    background: rgba(var(--color-sidebar-overlay-rgb), 0.08);
    color: var(--color-sidebar-text-active);
}

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

.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 0.75rem 2rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

/* Reisebüro-Combo (system-menu.php) ist der erste .topbar-agency-menu-Eintrag.
   margin-right:auto MUSS auf dem direkten Flex-Kind sitzen (dieser Wrapper-Div),
   nicht auf dem verschachtelten Button — nur so absorbiert es den Leerraum und
   schiebt Agentur/Sprache/Hell-Dunkel/Abmelden tatsächlich nach rechts, statt
   dass alles bei justify-content:flex-end als eine Gruppe zusammenklebt. Der
   negative margin-left zieht sie zusätzlich über das Innenpolster hinaus bis an
   den Rand. :first-of-type (nicht :first-child): der mobile Menü-Button
   (.topbar-menu-toggle, ein <button>) darf vor diesem Div stehen, ohne dass er
   als "erstes Kind" mitzählt — :first-of-type matched nur gleiche Tags (div). */
.topbar > .topbar-agency-menu:first-of-type {
    margin-left: -8px;
    margin-right: auto;
}

.topbar-customer {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: none;
    background: none;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--color-text);
    cursor: pointer;
}

.topbar-agency-popup-stammdaten-last {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.topbar-agency-menu {
    position: relative;
}

.topbar-agency-button {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 220px;
    padding: 0.45rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease);
}

.topbar-agency-button:hover {
    background: var(--color-surface);
}

.topbar-agency-button span {
    flex: 1;
    text-align: left;
}

.topbar-agency-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.topbar-agency-popup {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 280px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 0.85rem 1rem;
    z-index: 50;
}

.topbar-agency-popup.visible {
    display: block;
}

.topbar-agency-popup-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.6rem;
}

.topbar-agency-popup-stammdaten {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-bottom: 0.65rem;
    margin-bottom: 0.65rem;
    border-bottom: 1px solid var(--color-border);
}

.topbar-agency-popup-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
}

.topbar-agency-popup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.topbar-agency-popup-label {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.topbar-agency-popup-value-sm {
    font-size: 0.82rem;
    color: var(--color-text);
    text-align: left;
}

.topbar-agency-popup-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-success);
}

.topbar-agency-popup-item-highlight {
    margin-top: 0.5rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
}

.topbar-agency-popup-item-highlight .topbar-agency-popup-value {
    font-size: 1.4rem;
    color: inherit;
}

.topbar-agency-popup-item-positive {
    background: rgba(45, 165, 105, 0.14);
    color: var(--color-success);
}

.topbar-agency-popup-item-negative {
    background: rgba(214, 69, 69, 0.14);
    color: var(--color-danger);
}

.topbar-agency-popup-item-zero {
    background: rgba(201, 130, 10, 0.14);
    color: var(--color-warning);
}

.topbar-agency-popup-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.topbar-agency-popup-button:hover {
    background: var(--color-primary-hover);
}

.topbar-agency-popup-button:active {
    transform: scale(0.98);
}

.topbar-agency-popup-button .icon {
    width: 15px;
    height: 15px;
}

.topbar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}

.topbar-logout .icon {
    width: 16px;
    height: 16px;
}

.topbar-logout:hover {
    background: var(--color-danger);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}

.content {
    padding: 2rem;
}

/* Ein einfaches "<h1>Titel</h1>" (Listen/Agenturdaten/...) bekommt sonst den
   Browser-Standardabstand über der Überschrift — das Dashboard sitzt höher,
   weil sein h1 in .page-title-row liegt (margin:0). Gleiche Starthöhe für alle. */
.content > h1:first-child {
    margin-top: 0;
}

.page-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.page-title-row h1 {
    margin: 0;
}

.page-title-sub {
    margin: 0;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* ---------- Dashboard cards ---------- */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Flexbox instead of the auto-fill grid above: with only two cards, auto-fill can
   reserve extra empty column tracks on wide screens instead of letting the two
   real cards split the row evenly. */
.detail-info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-info-row .card {
    flex: 1 1 300px;
}

.detail-info-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1 1 300px;
}

.detail-info-col .card {
    flex: none;
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
}

.card h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.totp-secret {
    display: inline-block;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 1.3rem;
    letter-spacing: 0.1em;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    margin: 0.5rem 0 1.25rem;
}

.card ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.card ul a {
    font-size: 0.9rem;
    color: var(--color-primary);
}

.card ul a:hover {
    text-decoration: underline;
}

/* ---------- Auth (login) ---------- */

.auth-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 500px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
}

.auth-card h1 {
    margin: 0 0 1.5rem;
    font-size: 1.25rem;
    text-align: center;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-card label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.auth-card input {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.auth-card input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.otp-inputs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.otp-box {
    width: 2.6rem;
    height: 3rem;
    padding: 0 !important;
    text-align: center;
    font-size: 1.4rem !important;
    font-weight: 600;
}

.auth-card button {
    margin-top: 0.5rem;
    padding: 0.6rem;
    border: none;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.auth-card button:hover {
    background: var(--color-primary-hover);
}

.auth-card button:active {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.75;
    cursor: default;
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 0.5rem;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* Variante für Buttons/Links ohne farbigen Hintergrund (z. B. .row-action) —
   nutzt die aktuelle Textfarbe statt fest Weiß. */
.spinner-current {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: 0.8;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.password-field {
    position: relative;
    display: flex;
}

.password-field input {
    flex: 1;
    padding-right: 2.4rem;
}

.auth-card button.password-toggle {
    position: absolute;
    right: 0.3rem;
    top: 50%;
    transform: translateY(-50%);
    margin-top: 0;
    padding: 0.3rem;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.auth-card button.password-toggle:hover {
    opacity: 1;
    color: var(--color-text);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.auth-error {
    background: rgba(214, 69, 69, 0.1);
    color: var(--color-danger);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin: 0 0 1rem;
}

.auth-subtitle {
    margin: -1rem 0 1rem;
    font-size: 1rem;
    text-align: center;
    color: var(--color-text);
}

.auth-intro {
    margin: 0 0 1.25rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    text-align: center;
}

.auth-back {
    margin: 1rem 0 0;
    font-size: 0.85rem;
    text-align: center;
}

.debug-log {
    width: 100%;
    max-width: 500px;
    margin: 1rem auto 0;
    padding: 0.85rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-danger);
    border-radius: var(--radius);
    font-size: 0.78rem;
    color: var(--color-text);
}

.debug-log strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--color-danger);
}

.debug-log pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    max-height: 260px;
    overflow-y: auto;
}

/* ---------- Search form ---------- */

.search-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.search-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Primary search field (Buchungsnummer / Name-Vorname) grows to fill available
   space; the narrower date/status fields keep their natural width. */
.search-form label:first-of-type {
    flex: 2 1 260px;
}

.search-form label:first-of-type input {
    width: 100%;
}

.search-form label.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

/* Zahlungen-Suchleiste: feste Grid-Spalten statt frei umbrechendem Flex, damit
   Buchungsnummer/Datum von/Datum bis/Text/Zahlart sauber untereinander stehen. */
.search-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.search-form-grid label:nth-of-type(4) {
    grid-column: span 2;
}

.search-form input[type="text"],
.search-form input[type="date"],
.search-form select,
.totp-form input[type="text"] {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.search-form input[type="text"]:focus,
.search-form input[type="date"]:focus,
.search-form select:focus,
.totp-form input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.search-form button,
.totp-form button {
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.search-form button:hover,
.totp-form button:hover {
    background: var(--color-primary-hover);
}

.search-form button:active,
.totp-form button:active {
    transform: scale(0.98);
}

/* ---------- Authenticator-Setup: Bestätigungscode ---------- */

.totp-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 1rem;
    margin-top: 1rem;
}

.totp-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.totp-form input[type="text"] {
    width: 9rem;
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: 0.4em;
    text-align: center;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- Data table ---------- */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background-color var(--duration) var(--ease);
}

.data-table tbody tr:hover {
    background: var(--color-primary-soft);
}

/* ---------- Status badge ---------- */

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    vertical-align: middle;
}

.status-buchung {
    background: rgba(46, 160, 67, 0.14);
    color: var(--color-success);
}

.status-storno {
    background: rgba(214, 69, 69, 0.1);
    color: var(--color-danger);
}

.number-badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(79, 109, 245, 0.12);
    color: var(--color-primary);
}

/* ---------- Definition list (booking detail) ---------- */

dl {
    margin: 0;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

dt {
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

dd {
    margin: 0;
    font-size: 0.9rem;
}

/* ---------- Brand / logo ---------- */

.brand {
    display: inline-flex;
    align-items: center;
}

.brand-logo {
    flex-direction: column;
    gap: 0.25rem;
}

.brand-logo img {
    display: block;
    height: auto;
    width: auto;
    max-height: 128px;
    max-width: 100%;
}

.brand-tagline {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

/* eMind logo (login footer) has a real opaque white background in the source JPG,
   so it keeps a white badge behind it. The Ventus logo (transparent PNG) does not. */
.brand-logo-badge {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
    box-shadow: var(--shadow-sm);
}

.brand-logo-small img {
    height: 20px;
}

.auth-card .brand-logo img {
    height: auto;
    width: auto;
    max-height: 280px;
    max-width: 100%;
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-muted);
    border-radius: var(--radius);
    padding: 0.3rem 0.55rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: color var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

.theme-toggle:hover {
    color: var(--color-text);
    background: var(--color-surface-alt);
}

.theme-toggle-icon {
    line-height: 1;
}

/* ---------- Language switch ---------- */

.lang-switch {
    display: flex;
    gap: 0.35rem;
}

.lang-switch select {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    cursor: pointer;
}

/* ---------- Footer ---------- */

.app-footer {
    padding: 1rem 2rem;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}

.auth-footer {
    border-top: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0 1.5rem;
}

.auth-toolbar {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 0 0;
}

/* ---------- Stat tiles ---------- */

.stat-tiles {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    position: relative;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 600;
}

/* ---------- Sales chart ---------- */

.chart-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem 0.5rem;
    margin: 1.5rem 0;
}

.chart-card h2 {
    margin: 0 0 1rem;
    font-size: 1rem;
}

.chart-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.chart-tab {
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-muted);
    border-radius: var(--radius);
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.chart-tab:hover:not(.active) {
    background: var(--color-surface-alt);
    color: var(--color-text);
}

.chart-tab.active {
    color: #fff;
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.chart-panel {
    display: none;
}

.chart-panel.active {
    display: block;
}

.chart-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
}

.chart-mini {
    flex: 1 1 240px;
    min-width: 0;
    height: 260px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    padding: 0.85rem 1rem;
}

.chart-mini h3 {
    flex-shrink: 0;
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.chart-mini .chart-svg {
    flex-shrink: 0;
}

.chart-svg {
    width: 100%;
    height: auto;
    aspect-ratio: 720 / 220;
    display: block;
    overflow: visible;
}

.chart-bar {
    fill: var(--color-primary);
}

.chart-bar-group.chart-hover .chart-bar {
    opacity: 0.8;
}

.chart-hit {
    fill: transparent;
    cursor: pointer;
}

.chart-gridline {
    stroke: var(--color-border);
    stroke-width: 1;
}

.chart-baseline {
    stroke: var(--color-text-muted);
    stroke-width: 1;
}

.chart-axis-label {
    fill: var(--color-text-muted);
    font-size: 13px;
}

.chart-count-label {
    fill: var(--color-primary);
    font-size: 11px;
    font-weight: 600;
}

.chart-tooltip {
    position: fixed;
    z-index: 50;
    background: var(--color-tooltip-bg);
    color: var(--color-tooltip-text);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s ease;
    white-space: nowrap;
}

.chart-tooltip.visible {
    opacity: 1;
}

.chart-tooltip span {
    color: var(--color-tooltip-text-muted);
}

/* ---------- Icons ---------- */

.icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    vertical-align: -4px;
}

.reiseart-icon {
    width: 15px;
    height: 15px;
    color: var(--color-text-muted);
    vertical-align: -3px;
}

h2 .icon {
    width: 20px;
    height: 20px;
    vertical-align: -5px;
    margin-right: 0.3rem;
    color: var(--color-primary);
}

/* ---------- Sidebar: dashboard link + group icons ---------- */

.menu-dashboard-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-sidebar-text-active);
    transition: background-color var(--duration) var(--ease);
}

.menu-dashboard-link:hover {
    background: rgba(var(--color-sidebar-overlay-rgb), 0.08);
}

.menu-dashboard-link.active {
    background: var(--color-primary-soft);
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1.5rem - 3px);
}

.menu-group li a.active {
    background: var(--color-primary-soft);
    color: var(--color-sidebar-text-active);
    font-weight: 600;
    border-left: 3px solid var(--color-primary);
    padding-left: calc(1.75rem - 3px);
}

.menu-group.active > summary {
    color: var(--color-sidebar-text-active);
}

.menu-group summary {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.menu-chevron {
    width: 14px;
    height: 14px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0.6;
    transition: transform 0.15s ease;
}

.menu-group[open] > summary .menu-chevron {
    transform: rotate(90deg);
}

/* ---------- Collapsible sidebar (icon-only rail) ---------- */

html[data-sidebar="collapsed"] .sidebar {
    width: 64px;
}

html[data-sidebar="collapsed"] .sidebar-brand {
    justify-content: center;
    padding: 0 0 1.5rem;
}

html[data-sidebar="collapsed"] .sidebar-brand .brand-logo {
    display: none;
}

html[data-sidebar="collapsed"] .sidebar-toggle .icon {
    transform: rotate(180deg);
}

html[data-sidebar="collapsed"] .menu-label {
    display: none;
}

html[data-sidebar="collapsed"] .menu-dashboard-link,
html[data-sidebar="collapsed"] .menu-group summary {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
}

html[data-sidebar="collapsed"] .menu-group li a {
    justify-content: center;
    gap: 0;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

html[data-sidebar="collapsed"] .menu-chevron {
    display: none;
}

html[data-sidebar="collapsed"] .sidebar-footer {
    display: none;
}

/* Submenu becomes a flyout instead of pushing layout — the rail is too narrow
   to show group + children stacked. */
html[data-sidebar="collapsed"] .menu-group {
    position: relative;
}

html[data-sidebar="collapsed"] .menu-group[open] > ul {
    position: absolute;
    left: 64px;
    top: 0;
    min-width: 200px;
    background: var(--color-sidebar);
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    padding: 0.5rem 0;
    z-index: 40;
}

html[data-sidebar="collapsed"] .menu-group[open] > ul li a {
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.45rem 1.25rem;
}

html[data-sidebar="collapsed"] .menu-group[open] > ul .menu-label {
    display: inline;
}

/* ---------- Stat tile icons + color coding ---------- */

.stat-tile .stat-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 0.2rem;
}

.stat-tile-count .stat-icon,
.stat-tile-count .stat-value {
    color: var(--color-primary);
}

.stat-tile-total .stat-icon,
.stat-tile-total .stat-value {
    color: var(--color-accent2);
}

.stat-tile-paid .stat-icon,
.stat-tile-paid .stat-value {
    color: var(--color-success);
}

.stat-tile-open .stat-icon,
.stat-tile-open .stat-value {
    color: var(--color-danger);
}

/* ---------- Row action (open icon) ---------- */

.row-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius);
    color: var(--color-primary);
    transition: background-color var(--duration) var(--ease);
}

.row-action:hover {
    background: var(--color-primary-soft);
}

.row-action .icon {
    width: 18px;
    height: 18px;
    vertical-align: 0;
}

/* ---------- Agent form (read-only display) ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.form-grid input[readonly] {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.9rem;
}

/* ---------- Mail-Compose-Formular (Kunde per Mail kontaktieren) ---------- */

.mail-compose-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 640px;
}

.mail-compose-form label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.mail-compose-form input,
.mail-compose-form textarea {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.mail-compose-form input:focus,
.mail-compose-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.mail-compose-form input:disabled {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.mail-compose-form textarea {
    resize: vertical;
    line-height: 1.5;
}

.mail-compose-form button {
    align-self: flex-start;
    margin-top: 0.25rem;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    background: var(--color-primary);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.mail-compose-form button:hover {
    background: var(--color-primary-hover);
}

.mail-compose-form button:active {
    transform: scale(0.98);
}

/* ---------- Pagination ---------- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: -0.5rem 0 1.5rem;
}

.pagination a,
.pagination-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.pagination-disabled {
    opacity: 0.35;
}

.pagination a:hover {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ---------- Utility ---------- */

/* !important: this utility class must win over more specific contextual rules
   like ".data-table th/td { text-align: left }" (class+type beats a bare
   class), which would otherwise always override it regardless of source order. */
.text-right {
    text-align: right !important;
}

.text-danger {
    color: var(--color-danger);
}

/* ---------- List toolbar / export button ---------- */

.list-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: -0.75rem 0 1rem;
}

/* Stat-Kacheln bringen schon genug eigenen Abstand mit — der negative
   Toolbar-Margin (für den Fall direkt nach dem Suchformular) würde den
   Export-Button sonst über die Kacheln schieben. */
.stat-tiles + .list-toolbar {
    margin-top: 1rem;
}

.export-button {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.export-button:hover {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}

.export-button .icon {
    width: 16px;
    height: 16px;
}

/* ---------- Dokument ansehen: Mit/Ohne Preise ---------- */

.doc-view-menu {
    position: relative;
    display: inline-block;
}

.doc-view-popup {
    display: none;
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: 170px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 0.4rem;
    z-index: 50;
}

.doc-view-popup.visible {
    display: block;
}

.doc-view-popup-link {
    display: block;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: 0.85rem;
    text-decoration: none;
    transition: background-color var(--duration) var(--ease);
}

.doc-view-popup-link:hover {
    background: var(--color-primary-soft);
}

/* ---------- Passagier-Detailmaske: aufklappbare Unterzeile ---------- */

.guest-detail-row {
    display: none;
}

.guest-detail-row.visible {
    display: table-row;
}

.guest-detail-row td {
    background: var(--color-bg);
    padding: 1.25rem 1.5rem;
}

.guest-field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.85rem 1.5rem;
}

.guest-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.guest-field dt {
    margin: 0;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.guest-field dd {
    margin: 0;
    font-size: 0.88rem;
    word-break: break-word;
}

.row-action.guest-detail-toggle.is-open {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.guest-detail-chevron {
    transition: transform 0.15s ease;
}

.guest-detail-toggle.is-open .guest-detail-chevron {
    transform: rotate(90deg);
}

/* ---------- Sidebar footer links (copyright + legal) ---------- */

.sidebar-footer-links {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.sidebar-footer-links a {
    font-size: 0.7rem;
    color: var(--color-sidebar-text);
    opacity: 0.85;
}

.sidebar-footer-links a:hover {
    opacity: 1;
    text-decoration: underline;
}

.auth-footer .sidebar-footer-links a {
    color: var(--color-text-muted);
}

/* ---------- Legal pages (Impressum/Datenschutz) ---------- */

.legal-card {
    position: relative;
    width: 100%;
    max-width: 640px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    text-align: left;
}

.legal-close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color var(--duration) var(--ease);
}

.legal-close:hover {
    background: var(--color-border);
}

.legal-card h1 {
    margin-top: 0;
}

.legal-card h2 {
    font-size: 1rem;
    margin: 1.5rem 0 0.5rem;
}

.legal-placeholder-note {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.legal-license-note {
    margin-bottom: 1.5rem;
    padding: 0.85rem 1rem;
    background: var(--color-primary-soft);
    border-radius: var(--radius);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ---------- Detail page header ---------- */

.text-success {
    color: var(--color-success);
}

.detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
}

.detail-header-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
}

.detail-header-main h1 {
    margin: 0;
    font-size: 1.3rem;
}

.detail-header-main .status-badge {
    margin: 0;
}

.detail-header-sub {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.detail-header-amounts {
    display: flex;
    gap: 1.5rem;
}

.amount-pill {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: right;
}

.amount-label {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.amount-value {
    font-size: 1.05rem;
    font-weight: 600;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section .data-table {
    margin-bottom: 0;
    box-shadow: none;
    border: none;
}

.collapsible-section summary {
    cursor: pointer;
    list-style: none;
}

.collapsible-section summary::-webkit-details-marker {
    display: none;
}

.collapsible-section summary h2 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.section-chevron {
    width: 16px;
    height: 16px;
    margin-left: auto;
    color: var(--color-text-muted);
    transition: transform 0.15s ease;
}

.collapsible-section[open] summary .section-chevron {
    transform: rotate(90deg);
}

.collapsible-section .data-table {
    margin-top: 1rem;
}

.form-grid input.text-right {
    text-align: right;
}

/* ---------- Pie chart (Gesellschaft / Reiseart breakdowns) ---------- */

.pie-chart {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    min-height: 0;
    flex: 1 1 auto;
}

.pie-svg {
    width: auto;
    max-width: 65%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    overflow: visible;
    flex-shrink: 0;
}

.pie-slice {
    stroke: var(--color-surface);
    stroke-width: 2;
    cursor: pointer;
    transition: opacity 0.1s ease;
}

.pie-slice:hover,
.pie-slice.chart-hover {
    opacity: 0.82;
}

.pie-color-1 { fill: var(--series-1); background-color: var(--series-1); }
.pie-color-2 { fill: var(--series-2); background-color: var(--series-2); }
.pie-color-3 { fill: var(--series-3); background-color: var(--series-3); }
.pie-color-4 { fill: var(--series-4); background-color: var(--series-4); }
.pie-color-5 { fill: var(--series-5); background-color: var(--series-5); }
.pie-color-6 { fill: var(--series-6); background-color: var(--series-6); }
.pie-color-7 { fill: var(--series-7); background-color: var(--series-7); }
.pie-color-other { fill: var(--series-other); background-color: var(--series-other); }

.pie-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.3rem;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--color-text);
}

.pie-legend-count {
    color: var(--color-text-muted);
}

.pie-legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.pie-empty {
    padding: 2rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ---------- Detail page toolbar (back link + print button) ---------- */

.detail-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.detail-toolbar p {
    margin: 0;
}

/* ---------- Print (Buchungsdetail -> DIN A4) ---------- */

.only-print {
    display: none;
}

@media print {
    /* Force light values regardless of the viewer's dark-mode toggle — a printed
       document is always black-on-white, never dark-mode. */
    :root,
    :root[data-theme="dark"] {
        --color-bg: #ffffff;
        --color-surface: #ffffff;
        --color-text: #111111;
        --color-text-muted: #444444;
        --color-border: #999999;
        --color-primary: #111111;
        --color-danger: #111111;
        --color-success: #111111;
        --color-accent2: #111111;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
    }

    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .only-print {
        display: block;
    }

    .app {
        display: block;
        min-height: 0;
    }

    .main,
    .content {
        display: block;
        padding: 0;
    }

    body {
        background: #fff;
        color: #000;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

    .print-header {
        text-align: center;
        margin-bottom: 10mm;
        padding-bottom: 5mm;
        border-bottom: 2px solid #000;
    }

    .print-header-agent {
        font-size: 0.85rem;
        line-height: 1.5;
        margin-bottom: 6mm;
    }

    .print-header-title {
        font-size: 1.2rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
    }

    /* Document look: no cards/pills/shadows — plain sections with hairline rules. */
    .detail-header,
    .card,
    .detail-section {
        background: none !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin-bottom: 6mm;
        break-inside: avoid;
    }

    .detail-header {
        display: flex;
        border-bottom: 1px solid #000 !important;
        padding-bottom: 3mm !important;
    }

    .card h2,
    .detail-section h2 {
        font-size: 0.95rem;
        border-bottom: 1px solid #000;
        padding-bottom: 1.5mm;
        margin-bottom: 3mm;
    }

    .card h2 .icon,
    .detail-section h2 .icon,
    .amount-pill .icon {
        display: none;
    }

    .detail-info-row {
        display: block;
    }

    .detail-info-row .card {
        margin-bottom: 5mm;
    }

    .status-badge {
        background: none !important;
        color: #000 !important;
        font-weight: 700;
        padding: 0;
        border-radius: 0;
    }

    .amount-value,
    .text-danger,
    .text-success {
        color: #000 !important;
    }

    .data-table {
        border-collapse: collapse;
        width: 100%;
        box-shadow: none;
        border: none;
    }

    .data-table th,
    .data-table td {
        border: 1px solid #999;
        padding: 1.5mm 2mm;
    }

    .data-table th {
        background: #eee !important;
        color: #000;
    }

    @page {
        size: A4;
        margin: 18mm 15mm;
    }
}

/* ==================== Responsive / Mobile ==================== */

/* ---------- Data tables: horizontal scroll instead of squeezing columns ---------- */

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media print {
    .table-scroll {
        overflow: visible;
    }
}

/* ---------- Mobile menu button (hidden on desktop, shown ≤880px) ---------- */

.topbar-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background-color var(--duration) var(--ease);
}

.topbar-menu-toggle:hover {
    background: var(--color-surface-alt);
}

.topbar-menu-toggle .icon {
    width: 18px;
    height: 18px;
    vertical-align: 0;
}

.sidebar-backdrop {
    display: none;
}

/* ---------- Detail header amounts: allow wrapping on narrow screens ---------- */

.detail-header-amounts {
    flex-wrap: wrap;
}

/* ---------- OTP boxes: fluid width so all 6 boxes always fit ---------- */

.otp-inputs {
    gap: clamp(0.3rem, 1.6vw, 0.5rem);
}

.otp-box {
    width: clamp(2rem, 12vw, 2.6rem) !important;
    height: clamp(2.3rem, 13vw, 3rem);
    font-size: clamp(1.05rem, 5.5vw, 1.4rem) !important;
}

/* ==================== Breakpoint: tablet (≤880px) — off-canvas sidebar ==================== */

@media screen and (max-width: 880px) {
    .content {
        padding: 1.25rem;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 0.6rem;
        padding: 0.6rem 1rem;
    }

    .topbar-menu-toggle {
        display: inline-flex;
    }

    /* Off-canvas drawer instead of the sticky, always-visible desktop sidebar. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 240px;
        transform: translateX(-100%);
        z-index: 100;
        box-shadow: var(--shadow-lg);
        transition: transform 0.2s ease, background-color var(--duration) var(--ease);
    }

    html[data-sidebar-mobile="open"] .sidebar {
        transform: translateX(0);
    }

    html[data-sidebar-mobile="open"] .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(var(--color-sidebar-overlay-rgb), 0.45);
        z-index: 90;
    }

    html[data-sidebar-mobile="open"] body {
        overflow: hidden;
    }

    /* The icon-only "collapsed rail" is a desktop affordance — on the mobile
       drawer it must always show the full menu with labels, regardless of
       whatever collapse state was last saved during a desktop session
       (same selectors as the desktop collapse rules above, repeated here so
       they win on source order at this breakpoint — width is the only thing
       that changed, not specificity). */
    html[data-sidebar="collapsed"] .sidebar {
        width: 240px;
    }

    html[data-sidebar="collapsed"] .sidebar-brand {
        justify-content: space-between;
        padding: 0 1.5rem 1.5rem;
    }

    html[data-sidebar="collapsed"] .sidebar-brand .brand-logo {
        display: inline-flex;
    }

    html[data-sidebar="collapsed"] .menu-label {
        display: inline;
    }

    html[data-sidebar="collapsed"] .menu-dashboard-link,
    html[data-sidebar="collapsed"] .menu-group summary {
        justify-content: flex-start;
        gap: 0.6rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    html[data-sidebar="collapsed"] .menu-group li a {
        justify-content: flex-start;
        gap: 0.5rem;
        padding-left: 1.75rem;
        padding-right: 1.5rem;
    }

    html[data-sidebar="collapsed"] .menu-chevron {
        display: inline-block;
    }

    html[data-sidebar="collapsed"] .sidebar-footer {
        display: block;
    }

    html[data-sidebar="collapsed"] .menu-group[open] > ul {
        position: static;
        left: auto;
        top: auto;
        min-width: auto;
        background: none;
        border-radius: 0;
        box-shadow: none;
        padding: 0 0 0.5rem;
        z-index: auto;
    }

    html[data-sidebar="collapsed"] .menu-group[open] > ul li a {
        padding: 0.65rem 1.5rem 0.65rem 1.75rem;
    }

    /* Customer/agency names in the topbar can be long — truncate instead of
       pushing the theme/language/logout controls off-screen. */
    .topbar-customer {
        max-width: 45vw;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .topbar-agency-button {
        min-width: 0;
        max-width: 55vw;
    }

    .topbar-agency-button span {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

/* ==================== Breakpoint: phone (≤560px) ==================== */

@media screen and (max-width: 560px) {
    .content {
        padding: 1rem;
    }

    .auth-card,
    .legal-card {
        padding: 1.5rem;
    }

    .chart-mini {
        height: 220px;
    }

    /* Anchored dropdowns (Agentur/Reisebüro-Info, PDF-Ansicht) don't have
       enough room to hang off their button on a narrow screen — pin them as a
       small fixed sheet near the top instead of letting them overflow sideways. */
    .topbar-agency-popup,
    .doc-view-popup {
        position: fixed;
        top: 4.25rem;
        left: 1rem;
        right: 1rem;
        min-width: 0;
        width: auto;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-backdrop {
        padding: 0;
    }

    .modal {
        max-width: none;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }
}
