/* ============================================================
   TW-Utils Design System
   Shared styles for consistent UI across all views
   ============================================================ */

/* --- CSS Variables (Global) --- */
:root {
    --ds-primary: #3B82F6;
    --ds-primary-hover: #2563EB;
    --ds-black: #1f1f1f;
    --ds-black-hover: #000;
    --ds-text-dark: #2c2f33;
    --ds-text-muted: #595f66;
    --ds-border: #e9ecef;
    --ds-bg-light: #f8f9fa;
    --ds-bg-white: #ffffff;
    --ds-danger: #dc3545;
    --ds-danger-hover: #c82333;
    --ds-success: #28a745;
    --ds-radius: 8px;
    --ds-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --ds-shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --ds-font-heading: 'Outfit', sans-serif;
}

/* --- Buttons --- */
.btn-black {
    padding: 6px 16px;
    border-radius: var(--ds-radius);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--ds-black);
    color: white;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    line-height: 1.5;
    white-space: nowrap;
    text-decoration: none;
}
.btn-black:hover {
    background: var(--ds-black-hover);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    text-decoration: none;
}
.btn-black:disabled,
.btn-black[disabled] {
    background: #b0b3b8;
    color: #e4e6eb;
    cursor: not-allowed;
    box-shadow: none;
    pointer-events: none;
    opacity: 0.7;
}
.btn-black:disabled:hover,
.btn-black[disabled]:hover {
    background: #b0b3b8;
    transform: none;
    box-shadow: none;
}

.btn-neutral {
    padding: 6px 16px;
    border-radius: var(--ds-radius);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--ds-bg-light);
    color: #4b5563;
    border: 1px solid #d1d9e0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.5;
    white-space: nowrap;
    text-decoration: none;
}
.btn-neutral:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #212529;
    transform: translateY(-1px);
    text-decoration: none;
}

/* --- ZWC/Plan-Viewer Ergebnisbereich: Stat-Karten + Aktions-Buttons (gerendert von zwc_logic.js) --- */
.zwc-stat-card {
    flex: 1 1 110px;
    min-width: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 8px 12px;
}
.zwc-stat-card--dark {
    background: #495057;
    border-color: #495057;
}
.zwc-stat-label {
    font-size: 0.65rem;
    color: #868e96;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.zwc-stat-card--dark .zwc-stat-label { color: #adb5bd; }
.zwc-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.3;
}
.zwc-stat-card--dark .zwc-stat-value { color: #fff; }
.zwc-stat-total {
    font-size: 0.75rem;
    color: #adb5bd;
    font-weight: 500;
}
.zwc-stat-card--dark .zwc-stat-total { color: #868e96; }

.zwc-res-btncol {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    flex: 0 0 160px;
    width: 160px;
}
.zwc-res-btn-primary {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background: #212529;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.zwc-res-btn-primary:hover { background: #343a40; color: #fff; }
.zwc-res-btnrow {
    display: flex;
    gap: 5px;
    height: 26px;
}
.zwc-res-btn-secondary {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: #fff;
    color: #495057;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.zwc-res-btn-secondary:hover {
    border-color: var(--ds-primary, #3B82F6);
    color: var(--ds-primary, #3B82F6);
}
@media (max-width: 768px) {
    .zwc-res-btncol {
        flex: 1 1 100%;
        width: 100%;
    }
}

/* Ergebnis-Tabs als Pills (nur Desktop — der Mobile-Block weiter unten stapelt sie) */
@media (min-width: 769px) {
    #zwc-result-tabs,
    #off-result-tabs,
    #upv-tabs {
        display: inline-flex;
        flex-wrap: wrap;
        background: #e9ecef;
        border: 0;
        border-radius: 8px;
        padding: 3px;
        gap: 2px;
    }
    #zwc-result-tabs .nav-link,
    #off-result-tabs .nav-link,
    #upv-tabs .nav-link {
        border: none;
        margin-bottom: 0;
        background: transparent;
        padding: 6px 14px;
        border-radius: 6px;
        font-size: 0.85rem;
        color: #868e96;
    }
    #zwc-result-tabs .nav-link:hover:not(.active),
    #off-result-tabs .nav-link:hover:not(.active),
    #upv-tabs .nav-link:hover:not(.active) { color: #495057; }
    #zwc-result-tabs .nav-link.active,
    #off-result-tabs .nav-link.active,
    #upv-tabs .nav-link.active {
        background: #fff;
        color: #212529;
        font-weight: 600;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    }
}
#zwc-result-tabs .badge,
#off-result-tabs .badge,
#upv-tabs .badge { border-radius: 10px; }

.btn-secondary {
    padding: 6px 16px;
    border-radius: var(--ds-radius);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--ds-bg-white);
    color: var(--ds-text-dark);
    border: 1px solid var(--ds-border);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
}
.btn-secondary:hover {
    transform: translateY(-1px);
}

.btn-danger {
    padding: 6px 16px;
    border-radius: var(--ds-radius);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--ds-danger);
    color: white;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(220, 53, 69, 0.2);
    line-height: 1.5;
}
.btn-danger:hover {
    background: var(--ds-danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.btn-primary,
.btn-save {
    padding: 6px 16px;
    border-radius: var(--ds-radius);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    background: var(--ds-primary);
    color: white;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
    line-height: 1.5;
}
.btn-primary:hover,
.btn-save:hover {
    background: var(--ds-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Icon buttons (small, in tables) */
.btn-icon {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.85em;
    padding: 0;
}
.btn-icon:hover {
    background: var(--ds-bg-light);
    transform: scale(1.1);
}
.btn-icon.btn-edit,
.btn-icon-action { color: #0d6efd; }
.btn-icon.btn-edit:hover { background: rgba(13, 110, 253, 0.1); }
.btn-icon.btn-delete,
.btn-icon-danger { color: var(--ds-danger); }
.btn-icon.btn-delete:hover,
.btn-icon-danger:hover { color: var(--ds-danger-hover); background: rgba(220, 53, 69, 0.1); }

/* --- Tables --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    padding: 5px 10px;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    font-weight: 700;
    color: var(--ds-text-muted);
    background: var(--ds-bg-light);
    border-bottom: 2px solid var(--ds-border);
    text-align: left;
    white-space: nowrap;
}
.data-table td {
    padding: 5px 10px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
    color: var(--ds-text-dark);
}
.data-table tr:last-child td {
    border-bottom: none;
}
.data-table tr:hover td {
    background: #fafafa;
}
.data-table .table-actions {
    white-space: nowrap;
    text-align: right;
}

/* --- Toast notifications --- */
#toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* --- Empty states --- */
.empty-state {
    padding: 50px 20px;
    text-align: center;
}
.empty-state i {
    color: #e0e0e0;
    font-size: 3em;
    margin-bottom: 15px;
}
.empty-state p {
    font-size: 0.95em;
    color: var(--ds-text-muted);
    font-weight: 500;
}

/* --- Loading text --- */
.loading-text {
    padding: 30px;
    text-align: center;
    color: var(--ds-text-muted);
    font-weight: 500;
    font-size: 0.9em;
}

/* --- Modal Hybrid System (Bootstrap base + custom look) --- */
.modal-content {
    border-radius: 16px !important;
    overflow: hidden;
    border: none !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25) !important;
}
.modal-header {
    background: #1f1f1f;
    color: white;
    padding: 20px 24px;
    border-bottom: 2px solid #1f1f1f;
}
.modal-header .modal-title,
.modal-header h5 {
    font-family: var(--ds-font-heading, 'Outfit', sans-serif);
    font-weight: 700;
    font-size: 1.15rem;
    color: white;
}
.modal-header .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.7;
}
.modal-header .btn-close:hover {
    opacity: 1;
}
.modal-body {
    padding: 24px;
}
.modal-footer {
    padding: 16px 24px;
    background: var(--ds-bg-light, #f8f9fa);
    border-top: 1px solid var(--ds-border, #e9ecef);
}
.modal-backdrop.show {
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

/* --- Toolbar (reusable) --- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--ds-bg-light, #f8f9fa);
    padding: 8px 12px;
    border-radius: var(--ds-radius, 8px);
    border: 1px solid var(--ds-border, #e9ecef);
    margin-bottom: 15px;
}
.toolbar .action-group {
    display: flex;
    gap: 8px;
    align-items: center;
}
.toolbar .search-box {
    width: 250px;
}
.toolbar .search-box input {
    width: 100%;
}

/* --- Alert hints (info boxes) --- */
.alert-hint {
    margin: 0 20px 10px;
    background: #e8f4fd;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 10px 16px;
    border-radius: var(--ds-radius, 8px);
    font-size: 0.9em;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-hint i {
    font-size: 1em;
    margin-top: 3px;
    flex-shrink: 0;
}

/* --- Tab Links (underline style) --- */
.tab-link {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 5px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: color 0.2s, border-bottom 0.2s;
    font-size: 0.95rem;
}
.tab-link:hover {
    color: #000;
}
.tab-link.active {
    color: #000;
    border-bottom: 3px solid var(--ds-primary, #3B82F6);
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-family: var(--ds-font-heading, 'Outfit', sans-serif);
}

/* --- Form Controls (global override) --- */
.form-control {
    border: 2px solid var(--ds-border, #e9ecef);
    padding: 10px 12px;
    border-radius: var(--ds-radius, 8px);
    transition: all 0.2s;
    font-size: 0.9rem;
}
.form-control:focus {
    border-color: var(--ds-primary, #3B82F6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}
.form-select {
    border: 2px solid var(--ds-border, #e9ecef);
    padding: 8px 12px;
    border-radius: var(--ds-radius, 8px);
    transition: all 0.2s;
    font-size: 0.9rem;
}
.form-select:focus {
    border-color: var(--ds-primary, #3B82F6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    outline: none;
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    font-weight: 600;
    color: var(--ds-text-dark, #2c2f33);
    margin-bottom: 6px;
    display: block;
    font-size: 0.85rem;
}

/* --- Suchfeld (Lupe innen links, optionales Clear-x rechts) --- */
.zwc-search {
    position: relative;
    width: 300px;
    max-width: 100%;
}
.zwc-search-icon {
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    color: #6c757d;
    font-size: 0.9rem;
    pointer-events: none;
    transform: translateY(2px);
}
.zwc-search .zwc-search-input {
    padding: 0.35rem 34px;
    font-size: 0.85rem;
    height: auto;
}
.zwc-search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 2px 6px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
}
.zwc-search-clear:hover {
    color: #343a40;
    background: rgba(0, 0, 0, 0.05);
}

/* --- Dashboard Card (consolidated from 5 templates) --- */
.dashboard-card {
    background: #fff;
    border: 1px solid var(--ds-border, #e0e0e0);
    border-radius: 6px;
    box-shadow: var(--ds-shadow-sm);
    margin-bottom: 30px;
    width: 100%;
    padding: 25px;
}

/* --- Section Label (colored heading for card sections) --- */
.section-label {
    color: var(--ds-primary);
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

/* --- Section Header (card header with primary border) --- */
.section-header {
    border-bottom: 2px solid var(--ds-primary);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* --- Upload Drop Zone (consolidated from 4 templates) --- */
.upload-drop-zone {
    border: 2px dashed #ced4da;
    border-radius: var(--ds-radius);
    padding: 40px 20px;
    text-align: center;
    background-color: #fcfcfc;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    margin-bottom: 10px;
}
.upload-drop-zone:hover {
    border-color: #adb5bd;
    background-color: var(--ds-bg-light);
}
.upload-drop-zone.drag-over {
    border-color: var(--ds-primary);
    background-color: rgba(59, 130, 246, 0.04);
    color: var(--ds-primary);
}
.upload-drop-zone i {
    color: #adb5bd;
    transition: color 0.2s;
}
.upload-drop-zone.drag-over i {
    color: var(--ds-primary);
}

/* --- Info Box (left-border accent) --- */
.info-box-primary {
    border-left: 4px solid var(--ds-primary);
    background: var(--ds-bg-light);
    padding: 12px 16px;
    border-radius: 0 var(--ds-radius) var(--ds-radius) 0;
}

/* --- Loader Spinner --- */
.loader-spinner {
    border: 8px solid var(--ds-bg-light);
    border-top: 8px solid var(--ds-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --- Nav Link Pill Style (Off-Planner, AG-Planner tabs) --- */
.nav-pills-dark .nav-link {
    color: var(--ds-text-muted);
    font-weight: 500;
    border-radius: var(--ds-radius);
    transition: all 0.2s;
}
.nav-pills-dark .nav-link:hover {
    color: var(--ds-text-dark);
}
.nav-pills-dark .nav-link.active {
    background: var(--ds-text-dark) !important;
    color: white !important;
}

/* --- Autocomplete dropdown --- */
.autocomplete-items {
    border: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    border-radius: 0 0 var(--ds-radius, 8px) var(--ds-radius, 8px);
    overflow: hidden;
}
.autocomplete-items div {
    padding: 10px 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.1s;
}
.autocomplete-items div:hover {
    background: #f1f3f5;
}

/* --- Responsive utilities --- */
@media (max-width: 768px) {
    .toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }
    .toolbar .search-box {
        width: 100%;
    }
    .toolbar .action-group {
        width: 100%;
        flex-wrap: wrap;
    }

    /* Allow horizontal scroll on tab navigation on small screens */
    .tab-link-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        scrollbar-width: none;
    }
    .tab-link-container::-webkit-scrollbar {
        display: none;
    }

    /* Reduce card padding on mobile */
    .dashboard-card {
        padding: 15px;
        margin-bottom: 20px;
    }

    /* Stack modals better on mobile */
    .modal-body {
        padding: 16px;
    }
    .modal-header {
        padding: 16px;
    }

    /* =============================================
       Saved Plans & Actions — Mobile Card Layout
       ============================================= */

    /* --- Card header stacking (title + button) --- */
    #sp-tab-plans .dashboard-card > div:first-child,
    #sp-tab-actions .dashboard-card > div:first-child {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start !important;
    }

    /* --- Shared: table → card transformation --- */
    #sp-tab-plans .data-table thead,
    #sp-tab-actions .data-table thead {
        display: none;
    }

    /* --- Shared: card base styles --- */
    #sp-tab-plans .data-table tbody tr,
    #sp-tab-actions .data-table tbody tr {
        display: flex;
        flex-direction: column;
        position: relative;
        border: 1px solid var(--ds-border, #e9ecef);
        border-radius: var(--ds-radius, 8px);
        padding: 12px;
        margin-bottom: 10px;
        background: #fff;
    }

    #sp-tab-plans .data-table td,
    #sp-tab-actions .data-table td {
        display: block;
        padding: 2px 0;
        border: none;
        text-align: left !important;
        word-break: break-word;
    }

    /* Card labels via ::before */
    #sp-tab-plans .data-table td[data-label]::before,
    #sp-tab-actions .data-table td[data-label]::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        font-size: 0.75rem;
        color: var(--ds-text-muted, #595f66);
    }

    /* Hide labels on action/link cells (icons speak for themselves) */
    #sp-tab-plans .data-table td:last-child::before,
    #sp-tab-actions .data-table td[data-label="Links"]::before {
        display: none;
    }

    /* Hide # column on mobile */
    #sp-tab-plans .data-table td[data-label="#"],
    #sp-tab-actions .data-table td[data-label="#"] {
        display: none;
    }

    /* Hide Keys column on mobile (actions tab) */
    #sp-tab-actions .data-table td[data-label="Keys"] {
        display: none;
    }

    /* Actions cell: flex row for icon buttons */
    #sp-tab-plans .data-table td:last-child,
    #sp-tab-actions .data-table td[data-label="Links"] {
        margin-top: 6px;
        padding-top: 6px;
        border-top: 1px solid var(--ds-border, #e9ecef);
    }

    #sp-tab-plans .data-table td:last-child .d-flex,
    #sp-tab-actions .data-table td[data-label="Links"] .d-flex {
        justify-content: flex-start !important;
    }

    /* --- Plans tab: card ordering & layout --- */
    /* Order: Name(1) → Befehle(2) → Datum(3) → Aktionen(4), Typ absolute-positioned */
    /* Order: Name(1) → Befehle(2) → Datum(3) → Aktionen(4) */
    /* HTML order: #(1st), Datum(2nd), Name(3rd), Befehle(4th), Typ(5th), Aktionen(6th) */
    #sp-tab-plans .data-table td:nth-child(3) { order: 1; } /* Name */
    #sp-tab-plans .data-table td:nth-child(4) { order: 2; } /* Befehle */
    #sp-tab-plans .data-table td:nth-child(2) { order: 3; } /* Datum */
    #sp-tab-plans .data-table td:last-child   { order: 4; } /* Aktionen */

    /* Typ badge: top-right corner, no label */
    #sp-tab-plans .data-table td[data-label="Typ"] {
        position: absolute;
        top: 12px;
        right: 12px;
        padding: 0;
        order: 0;
    }
    #sp-tab-plans .data-table td[data-label="Typ"]::before {
        display: none;
    }

    /* Add right padding to Name so it doesn't overlap the badge */
    #sp-tab-plans .data-table td[data-label="Name"] {
        padding-right: 70px;
    }

    /* Hide Name label (Name is self-evident as first bold item) */
    #sp-tab-plans .data-table td[data-label="Name"]::before {
        display: none;
    }

    /* Bigger action icons for touch targets */
    #sp-tab-plans .data-table td:last-child .btn {
        font-size: 1.2rem !important;
        padding: 6px 10px !important;
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* --- Accordion header stacking --- */
    .accordion-header-content {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px;
    }

    /* Order: Name(1) → Badges(2) */
    .accordion-header-name    { order: 1; }
    .accordion-header-badges  { order: 2; margin-top: 4px; }

    /* --- Button bar: vertical stack --- */
    .manage-plans-bar {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
    }

    .manage-plans-bar > select {
        width: 100% !important;
        max-width: 100% !important;
        flex-grow: 0 !important;
        box-sizing: border-box;
    }

    /* Prevent overflow from manage-plans container */
    .manage-plans-bar {
        overflow: hidden;
        box-sizing: border-box;
    }

    .manage-plans-bar > button {
        font-size: 0.85rem;
        padding: 8px 12px;
        white-space: normal !important;
        width: 100%;
    }

    /* --- Actions tab: bigger icons (same as plans tab) --- */
    #sp-tab-actions .data-table td[data-label="Links"] .btn {
        font-size: 1.2rem !important;
        padding: 6px 10px !important;
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* --- Action footer: stack buttons vertically --- */
    #sp-tab-actions .accordion-body > .d-flex.justify-content-between {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start !important;
    }

    #sp-tab-actions .accordion-body > .d-flex.justify-content-between > * {
        text-align: left;
    }

    /* --- Modals: wider on mobile --- */
    #deletePlanModal .modal-dialog,
    #createEmptyActionModal .modal-dialog,
    #deleteActionModal .modal-dialog,
    #clearActionModal .modal-dialog,
    #deleteOutdatedModal .modal-dialog,
    #importExternalPlanModal .modal-dialog {
        width: 95vw;
        max-width: 95vw;
        margin: 10px auto;
    }

    /* Import modal: scroll on mobile */
    #importExternalPlanModal .modal-body {
        max-height: 70vh;
        overflow-y: auto;
    }

    /* Modal footer buttons: full width stacked */
    #deletePlanModal .modal-footer,
    #createEmptyActionModal .modal-footer,
    #deleteActionModal .modal-footer,
    #clearActionModal .modal-footer,
    #deleteOutdatedModal .modal-footer,
    #importExternalPlanModal .modal-footer {
        flex-direction: column;
        gap: 8px;
    }

    #deletePlanModal .modal-footer > button,
    #createEmptyActionModal .modal-footer > button,
    #deleteActionModal .modal-footer > button,
    #clearActionModal .modal-footer > button,
    #deleteOutdatedModal .modal-footer > button,
    #importExternalPlanModal .modal-footer > button {
        width: 100%;
        margin: 0;
    }

    /* --- Toast: prevent overflow --- */
    .toast-container,
    #toast-container {
        max-width: 90vw !important;
        right: 5vw !important;
    }

    /* --- Hide action created date in accordion header on mobile --- */
    .action-created-date {
        display: none;
    }

    /* =============================================
       Plan Viewer — Mobile Responsive (≤768px)
       ============================================= */

    /* --- 1. Hide sections --- */
    .plan-viewer-page #incomplete-targets-section {
        display: none !important;
    }
    .pv-attacked-players {
        display: none !important;
    }
    .pv-sending-players {
        display: none !important;
    }

    /* --- 2a. Hide table columns — Off/ZWC/External --- */
    /* Keep: Typ(2), Herkunft(3), Abschickzeit(7), Ankunftszeit(8) */
    #target-detail-table th:nth-child(1),
    #target-detail-table td:nth-child(1),
    #target-detail-table th:nth-child(4),
    #target-detail-table td:nth-child(4),
    #target-detail-table th:nth-child(5),
    #target-detail-table td:nth-child(5),
    #target-detail-table th:nth-child(6),
    #target-detail-table td:nth-child(6),
    #target-detail-table th:nth-child(9),
    #target-detail-table td:nth-child(9),
    #target-detail-table th:nth-child(10),
    #target-detail-table td:nth-child(10) {
        display: none !important;
    }

    /* Disable sort on time columns (ZWC detail table) */
    #target-detail-table th[data-sort] {
        pointer-events: none;
        cursor: default;
        color: inherit !important;
        background-color: transparent !important;
    }
    #target-detail-table th[data-sort] .sort-icon {
        display: none !important;
    }

    /* --- 2b. Hide table columns — AG Plan --- */
    /* Keep: Typ(2), Herkunft(3), Abschickzeit(7), Ankunftszeit(8) */
    #ag-train-section table th:nth-child(1),
    #ag-train-section table td:nth-child(1),
    #ag-train-section table th:nth-child(4),
    #ag-train-section table td:nth-child(4),
    #ag-train-section table th:nth-child(5),
    #ag-train-section table td:nth-child(5),
    #ag-train-section table th:nth-child(6),
    #ag-train-section table td:nth-child(6),
    #ag-train-section table th:nth-child(9),
    #ag-train-section table td:nth-child(9),
    #ag-train-section table th:nth-child(10),
    #ag-train-section table td:nth-child(10) {
        display: none !important;
    }

    /* --- 2d. Hide table columns — Unified Plan Viewer --- */
    /* Keep: Typ(2), Herkunft(3), Abschickzeit(7), Ankunftszeit(8) */
    #upv-cmd-table th:nth-child(1),
    #upv-cmd-table td:nth-child(1),
    #upv-cmd-table th:nth-child(4),
    #upv-cmd-table td:nth-child(4),
    #upv-cmd-table th:nth-child(5),
    #upv-cmd-table td:nth-child(5),
    #upv-cmd-table th:nth-child(6),
    #upv-cmd-table td:nth-child(6),
    #upv-cmd-table th:nth-child(9),
    #upv-cmd-table td:nth-child(9),
    #upv-cmd-table th:nth-child(10),
    #upv-cmd-table td:nth-child(10) {
        display: none !important;
    }
    #upv-cmd-table th:nth-child(7),
    #upv-cmd-table th:nth-child(8) {
        min-width: 0 !important;
    }

    /* Result viewer tabs as 2x2 grid on mobile */
    #upv-tabs,
    #zwc-result-tabs,
    #off-result-tabs {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        border-bottom: none;
        padding: 0;
    }
    #upv-tabs .nav-item,
    #zwc-result-tabs .nav-item,
    #off-result-tabs .nav-item {
        display: contents;
    }
    #upv-tabs .nav-link,
    #zwc-result-tabs .nav-link,
    #off-result-tabs .nav-link {
        width: 100%;
        border-radius: var(--ds-radius);
        border: 1px solid var(--ds-border, #e9ecef);
        background: var(--ds-bg-light, #f8f9fa);
        color: var(--ds-text-muted, #595f66);
        text-align: center;
        font-size: 0.8rem;
        font-weight: 500;
        padding: 10px 6px;
        transition: all 0.2s;
    }
    #upv-tabs .nav-link.active,
    #zwc-result-tabs .nav-link.active,
    #off-result-tabs .nav-link.active {
        background: var(--ds-text-dark, #2c2f33);
        color: #fff;
        border-color: var(--ds-text-dark, #2c2f33);
    }

    /* Alle drei Ergebnis-Tabs: aktiver Tab weiß auf grauem Track wie auf dem Desktop
       (statt schwarzer Pille); 2×2-Raster bleibt. */
    #zwc-result-tabs,
    #off-result-tabs,
    #upv-tabs {
        background: #e9ecef;
        border-radius: 8px;
        padding: 3px;
        gap: 4px;
    }
    #zwc-result-tabs .nav-link,
    #off-result-tabs .nav-link,
    #upv-tabs .nav-link {
        border: none;
        background: transparent;
        color: #868e96;
        border-radius: 6px;
        font-weight: 500;
    }
    #zwc-result-tabs .nav-link.active,
    #off-result-tabs .nav-link.active,
    #upv-tabs .nav-link.active {
        background: #fff;
        color: #212529;
        font-weight: 600;
        border: none;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    }

    /* --- Hide Bootstrap tooltips on mobile (unit composition not needed) --- */
    .tooltip {
        display: none !important;
    }

    /* --- 2c. Reset min-width on time columns for mobile --- */
    #ag-train-section table th:nth-child(9),
    #ag-train-section table th:nth-child(10) {
        min-width: 0 !important;
    }

    /* --- 3. Expandable detail rows --- */
    /* Override nth-child column hiding for detail row's single <td colspan> */
    #target-detail-table .pv-detail-row td,
    #ag-train-section table .pv-detail-row td,
    #upv-cmd-table .pv-detail-row td {
        display: table-cell !important;
    }
    .pv-detail-row {
        display: none !important;
    }
    .pv-detail-row.pv-expanded {
        display: table-row !important;
    }
    .pv-detail-row.pv-expanded td {
        background: var(--ds-bg-light, #f8f9fa);
        padding: 10px 14px !important;
        border-top: none !important;
    }
    .pv-detail-content {
        display: flex;
        flex-direction: column;
        gap: 4px;
        font-size: 0.85rem;
    }
    .pv-detail-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .pv-detail-label {
        font-weight: 600;
        color: var(--ds-text-muted, #595f66);
        font-size: 0.75rem;
    }
    /* Kompakte laufende Einheiten in der Detailzeile (Icon + Zahl, umbrechend, keine Tabelle) */
    .pv-unit-inline {
        display: inline-block;
        white-space: nowrap;
        margin-right: 8px;
    }
    .pv-unit-inline img {
        vertical-align: middle;
        margin-right: 2px;
    }
    #target-detail-table tbody tr:not(.pv-detail-row),
    #ag-train-tbody tr:not(.pv-detail-row) {
        cursor: pointer;
    }

    /* --- 4. Navigation header — mobile layout --- */
    .pv-nav-header {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px 8px !important;
        padding: 10px !important;
    }
    .pv-btn-text {
        display: none;
    }
    .pv-nav-header > button {
        min-width: 36px;
        min-height: 36px;
    }

    /* display:contents lets h6/small/input-group become direct flex items */
    .pv-nav-header > .text-center {
        display: contents;
    }

    /* Row 1: Search field (full width) */
    .pv-nav-header .input-group {
        order: 1;
        flex: 0 0 100%;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 4px 0 !important;
    }

    /* Row 2: [<] title [>] */
    .pv-nav-header > button:first-of-type { order: 2; }
    .pv-nav-header h6,
    .pv-nav-header h4 {
        order: 3;
        flex: 1 1 0;
        text-align: center;
        margin: 0 !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
    }
    .pv-nav-header > button:last-of-type { order: 4; }

    /* Row 3: Pagination (full width) */
    .pv-nav-header small {
        order: 5;
        flex: 0 0 100%;
        text-align: center;
    }

    /* Title split: coord prominent, player name smaller */
    .pv-nav-header .pv-title-label {
        display: none;
    }
    .pv-nav-header .pv-title-coord {
        order: -1;
        font-size: 1rem;
        font-weight: 700;
        color: var(--ds-text-dark, #2c2f33);
    }
    .pv-nav-header .pv-title-player {
        font-size: 0.8rem;
        color: var(--ds-text-muted, #595f66);
    }
    .pv-nav-header .pv-title-prio {
        font-size: 0.75rem;
    }


    /* --- Shortened timestamps on mobile (TT.MM.YY HH:MM) --- */
    .pv-time-full {
        display: none !important;
    }
    .pv-time-short {
        display: inline !important;
    }

    /* --- Shortened table headers on mobile --- */
    .pv-th-full {
        display: none !important;
    }
    .pv-th-short {
        display: inline !important;
    }

    /* =============================================
       ZWC Planner — Mobile Responsive (≤768px)
       ============================================= */

    /* --- 1. Card headers: stack title + buttons (Karten liegen jetzt in .zwc-step-panel) --- */
    #main-form .dashboard-card > div[style*="display: flex"]:first-child {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start !important;
    }

    /* --- 2. Remove vertical borders between stacked columns --- */
    #main-form .border-end {
        border-right: none !important;
    }
    #main-form .border-start {
        border-left: none !important;
        padding-left: 12px !important;
    }

    /* --- 3. Submit button full width + separators between sections --- */
    #btn-start-calc {
        width: 100%;
    }
    #main-form .col-md-6.border-start {
        border-top: 1px solid #bbb !important;
        padding-top: 1rem;
        margin-top: 0.5rem;
    }
    .zwc-btn-wrapper {
        border-top: 1px solid #bbb;
        padding-top: 1rem;
        margin-top: 0.5rem;
    }

    /* --- 5. Modals fullscreen --- */
    #zwcTroopsOverviewModal .modal-dialog,
    #wbCommandsOverviewModal .modal-dialog,
    #noble-modal .modal-dialog,
    #launch-modal .modal-dialog,
    #off-modal .modal-dialog,
    #all-reports-modal .modal-dialog {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    #zwcTroopsOverviewModal .modal-content,
    #wbCommandsOverviewModal .modal-content,
    #noble-modal .modal-content,
    #launch-modal .modal-content,
    #off-modal .modal-content,
    #all-reports-modal .modal-content {
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    #zwcTroopsOverviewModal .modal-body,
    #wbCommandsOverviewModal .modal-body,
    #noble-modal .modal-body,
    #launch-modal .modal-body,
    #off-modal .modal-body,
    #all-reports-modal .modal-body {
        max-height: calc(100vh - 130px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- 6. Modal footer: stacked buttons --- */
    #zwcTroopsOverviewModal .modal-footer,
    #wbCommandsOverviewModal .modal-footer,
    #noble-modal .modal-footer,
    #launch-modal .modal-footer,
    #off-modal .modal-footer,
    #all-reports-modal .modal-footer {
        flex-direction: column;
        gap: 8px;
    }
    #zwcTroopsOverviewModal .modal-footer > button,
    #wbCommandsOverviewModal .modal-footer > button,
    #noble-modal .modal-footer > button,
    #launch-modal .modal-footer > button,
    #off-modal .modal-footer > button,
    #all-reports-modal .modal-footer > button {
        width: 100%;
        margin: 0;
    }

    /* --- 7. Modal X-buttons hidden (backdrop click to close) --- */
    #zwcTroopsOverviewModal .btn-close,
    #wbCommandsOverviewModal .btn-close,
    #noble-modal .btn-close,
    #launch-modal .btn-close,
    #off-modal .btn-close,
    #all-reports-modal .btn-close {
        display: none;
    }

    /* --- 8. Modal table touch targets --- */
    #zwcTroopsOverviewModal .table td,
    #wbCommandsOverviewModal .table td {
        padding: 8px 6px;
        min-height: 44px;
    }

}

/* Plan viewer: detail rows always hidden on desktop */
.pv-detail-row {
    display: none;
}

/* Plan viewer: short timestamps and headers hidden on desktop */
.pv-time-short,
.pv-th-short {
    display: none;
}

/* Zeitspalten der Befehlstabellen (Off-Ergebnis, ZWC-Ergebnis, Plan-Viewer, AG):
   dicktengleiche Ziffern, damit Datum und Uhrzeit untereinander buendig stehen.
   Rezept von .lv-tabular-nums — bewusst eine eigene Klasse der pv-Familie, weil
   leader_view_container.css nur im Leader-View laedt.
   Die Groesse sitzt hier und nicht als Bootstrap-.small an der Zelle: so tragen alle
   vier Tabellen dieselbe Zeitspalten-Groesse. */
.pv-time-cell {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    font-size: 0.875em;
}
