/* ============================================
   FEBG Aufgabenverwaltung - Styles
   Mobile-First Design mit modernem Look
   ============================================ */

:root {
    /* Farben - Modernes, professionelles Schema */
    --color-primary: #2563eb;
    --color-primary-dark: #1e40af;
    --color-primary-light: #dbeafe;
    
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    
    /* Schatten */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    
    /* Abstände */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    /* Typografie */
    --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ============================================
   RESET & BASE
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

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

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   APP CONTAINER
   ============================================ */

.app-container {
    min-height: 100vh;
    padding-bottom: env(safe-area-inset-bottom);
}

.screen {
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   AUTHENTICATION SCREENS
   ============================================ */

.auth-container {
    max-width: 420px;
    margin: 0 auto;
    padding: var(--spacing-xl) var(--spacing-lg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--spacing-xl);
}

.auth-header {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.auth-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text);
}

.auth-header p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* Login Options */
.login-options {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.login-option-card {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.login-option-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.login-option-card .icon {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
}

.login-option-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text);
}

.login-option-card p {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* ============================================
   FORMS
   ============================================ */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-body);
    transition: all 0.2s ease;
    background: var(--color-surface);
    color: var(--color-text);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    font-weight: 400;
}

input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    background: var(--color-surface);
    color: var(--color-text);
    border: 2px solid var(--color-border);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-full {
    width: 100%;
}

.back-btn {
    background: transparent;
    border: none;
    color: var(--color-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: var(--spacing-sm) 0;
    margin-bottom: var(--spacing-md);
    align-self: flex-start;
}

/* ============================================
   APP HEADER
   ============================================ */

.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--spacing-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

/* ============================================
   CONTENT
   ============================================ */

.content {
    padding: var(--spacing-lg);
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.card-header h2 {
    margin: 0;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.search-input {
    width: 200px;
}

/* ============================================
   STATS
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* ============================================
   EVENT LIST
   ============================================ */

.event-list,
.groups-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.event-item,
.group-item {
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.event-item:hover,
.group-item:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
}

.event-item h3,
.group-item h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.event-item p,
.group-item p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.group-item .group-code {
    font-family: var(--font-mono);
    background: var(--color-primary-light);
    color: var(--color-primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    display: inline-block;
    margin-top: var(--spacing-sm);
}

/* ============================================
   TASKS
   ============================================ */

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.task-item {
    background: var(--color-bg);
    border-left: 4px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.task-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.task-item.priority-urgent {
    border-left-color: var(--color-danger);
}

.task-item.priority-high {
    border-left-color: var(--color-warning);
}

.task-item.priority-medium {
    border-left-color: var(--color-info);
}

.task-item.priority-low {
    border-left-color: var(--color-border);
}

.task-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: var(--spacing-sm);
}

.task-title {
    font-weight: 600;
    font-size: 1.05rem;
}

.task-status {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-sm);
}

.task-meta-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-lg);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--color-text-muted);
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal-actions {
    display: flex;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
}

.modal-actions .btn {
    flex: 1;
}

/* ============================================
   TOAST
   ============================================ */

.toast {
    position: fixed;
    bottom: var(--spacing-lg);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: white;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 2000;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { transform: translate(-50%, 100px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.toast.success {
    background: var(--color-success);
}

.toast.error {
    background: var(--color-danger);
}

/* ============================================
   IMPORT/EXPORT
   ============================================ */

.import-info {
    background: var(--color-bg);
    padding: var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.import-info h3 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
}

.import-info h4 {
    font-size: 0.95rem;
    margin-top: var(--spacing-md);
    margin-bottom: var(--spacing-xs);
}

.import-info ol {
    margin-left: var(--spacing-lg);
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.import-info p {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

#import-result {
    margin-top: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

#import-result.success {
    background: #d1fae5;
    color: #065f46;
}

#import-result.error {
    background: #fee2e2;
    color: #991b1b;
}

input[type="file"] {
    padding: var(--spacing-sm);
    border: 2px dashed var(--color-border);
    background: var(--color-bg);
}

input[type="file"]:hover {
    border-color: var(--color-primary);
}

/* ============================================
   LOGIN LINKS & QR CODES - PHASE 4
   ============================================ */

.login-links-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.link-box {
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
}

.link-box h3 {
    font-size: 1rem;
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.link-display {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.link-input {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.link-input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.copy-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.2s;
    min-width: 50px;
}

.copy-btn:hover {
    background: var(--color-primary-dark);
}

.copy-btn.copied {
    background: var(--color-success);
}

.qr-container {
    display: flex;
    gap: var(--spacing-lg);
    margin-top: var(--spacing-md);
}

.qr-box {
    flex: 1;
    text-align: center;
    background: var(--color-surface);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
}

.qr-box h4 {
    font-size: 0.875rem;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-muted);
}

.qr-code {
    margin: var(--spacing-md) auto;
    padding: var(--spacing-sm);
    background: white;
    border-radius: var(--radius-sm);
    display: inline-block;
}

.link-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}

.link-expires {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    text-align: center;
}

.group-item-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.btn-icon {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 0.875rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .search-input {
        width: 100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        padding: var(--spacing-lg);
    }
}

@media (min-width: 768px) {
    .content {
        padding: var(--spacing-xl);
    }
}

/* ============================================
   V5: Kompakte Aufgabenliste, Status-Kacheln,
   Inline-Detailbearbeitung ohne Popup
   ============================================ */

.admin-footer-link{
    margin-top:40px;
    text-align:center;
}
.admin-footer-link a{
    font-size:12px;
    color:#94a3b8;
    text-decoration:none;
    opacity:.55;
    transition:all .2s ease;
}
.admin-footer-link a:hover{ opacity:1; }

.status-summary{
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(120px, 1fr));
    gap:.75rem;
    margin-top:.75rem;
}
.status-card{
    display:flex;
    align-items:center;
    gap:.5rem;
    padding:.7rem .85rem;
    background:var(--color-bg);
    border:1px solid var(--color-border);
    border-radius:var(--radius-md);
    cursor:pointer;
    font-family:var(--font-body);
    color:var(--color-text);
    transition:all .15s ease;
}
.status-card:hover{
    border-color:var(--color-primary);
    box-shadow:var(--shadow-sm);
    transform:translateY(-1px);
}
.status-card strong{ font-size:1.15rem; }
.status-dot{
    width:10px;
    height:10px;
    border-radius:999px;
    display:inline-block;
    flex:0 0 10px;
}

.task-item.compact-task{
    display:flex;
    align-items:center;
    gap:.75rem;
    padding:10px 14px;
    min-height:auto;
    border-left:0;
    border:1px solid transparent;
    border-radius:var(--radius-md);
    background:var(--color-bg);
}
.task-item.compact-task:hover{
    border-color:var(--color-primary-light);
    transform:none;
    box-shadow:var(--shadow-sm);
}
.task-main{ flex:1; min-width:0; }
.task-line{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:.75rem;
}
.task-title{
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}
.task-status.compact{
    padding:.15rem .55rem;
    font-size:.78rem;
    border-radius:999px;
}
.task-meta.compact-meta{
    font-size:12px;
    margin-top:4px;
    gap:.75rem;
}
.task-meta.compact-meta span{
    white-space:nowrap;
}

.task-detail-form{
    display:flex;
    flex-direction:column;
    gap:1rem;
}
.task-detail-header{
    display:flex;
    align-items:center;
    gap:.75rem;
}
.task-title-input{
    flex:1;
    font-size:1.35rem !important;
    font-weight:700;
}
.detail-grid{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:.9rem 1rem;
}
.detail-grid label{
    display:flex;
    flex-direction:column;
    gap:.35rem;
}
.detail-full{ grid-column:1 / -1; }
.task-detail-form input:disabled,
.task-detail-form textarea:disabled,
.task-detail-form select:disabled{
    background:#f3f4f6;
    border-color:transparent;
    color:var(--color-text);
    opacity:1;
    cursor:default;
}
.task-detail-form input:not(:disabled),
.task-detail-form textarea:not(:disabled),
.task-detail-form select:not(:disabled){
    background:#fff;
    border-color:var(--color-primary);
}
.task-actions{
    display:flex;
    gap:.75rem;
    flex-wrap:wrap;
}
.comments-section{
    margin-top:1.25rem;
    padding-top:1rem;
    border-top:1px solid var(--color-border);
}
.comment-item{
    background:var(--color-bg);
    border:1px solid var(--color-border);
    border-radius:var(--radius-md);
    padding:.65rem .8rem;
    margin:.5rem 0;
}
.comment-form{
    display:flex;
    flex-direction:column;
    gap:.5rem;
    margin-top:.75rem;
}

@media (max-width:640px){
    .detail-grid{ grid-template-columns:1fr; }
    .task-detail-header{ align-items:flex-start; flex-direction:column; }
}


/* v6: Admin-Bereich direkt öffnen */
.group-open-item {
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:1rem;
}
.group-open-hint {
    color:var(--color-primary);
    font-size:.875rem;
    font-weight:600;
    white-space:nowrap;
}
.group-open-item:hover .group-open-hint { text-decoration:underline; }

/* Admin Bereichsverwaltung */
.admin-group-card {
    cursor: default;
}

.admin-group-card .group-item-main {
    cursor: pointer;
}

.group-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem;
}

.credential-box {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.credential-box input[readonly] {
    font-family: var(--font-mono);
    background: white;
    cursor: pointer;
}

.modal-wide {
    max-width: 760px;
}

.helper-create-form {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1rem;
}

.helper-create-grid,
.helper-edit-grid {
    display: grid;
    grid-template-columns: 1.2fr 1.4fr 1fr 1fr auto;
    gap: .5rem;
    align-items: center;
}

.helpers-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.helper-row {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: center;
    padding: .65rem .75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.helper-main {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.helper-main span {
    font-size: .85rem;
    color: var(--color-primary);
}

.helper-main small {
    color: var(--color-text-muted);
}

.helper-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

@media (max-width: 760px) {
    .helper-create-grid,
    .helper-edit-grid {
        grid-template-columns: 1fr;
    }
    .helper-row {
        align-items: stretch;
        flex-direction: column;
    }
}

/* v9 Nacharbeit: Navigation, mobile Aufgabenliste, Kommentare */
.group-code.inline{display:inline-block;margin:0 .5rem 0 0;vertical-align:middle;font-size:.8rem;}
.group-header-actions{flex-wrap:wrap;justify-content:flex-end;}
.task-title{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25;word-break:break-word;}
.compact-task{align-items:flex-start;}
.compact-task .task-line{align-items:flex-start;gap:.5rem;}
.comment-head{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start;}
.comment-actions{display:flex;gap:.4rem;flex-wrap:wrap;}
.btn-mini{font-size:.75rem;padding:.25rem .5rem;}
.comment-item textarea{width:100%;}

@media (max-width: 640px){
  .app-header{align-items:flex-start;gap:1rem;}
  .group-header-actions{width:auto;display:flex;flex-direction:row;gap:.4rem;}
  .card-header{align-items:center;gap:.75rem;}
  .card-header .header-actions{display:grid;grid-template-columns:1fr auto;align-items:center;width:100%;}
  .card-header h2{margin:0;}
  .search-input{grid-column:1 / 2;width:100%;min-width:0;}
  #create-task-btn{grid-column:2 / 3;width:44px;height:44px;padding:0;font-size:1.4rem;border-radius:.75rem;}
  .compact-task{padding:10px 12px;min-height:58px;}
  .compact-task .task-line{display:flex;align-items:flex-start;}
  .task-status.compact{flex:0 0 auto;}
  .compact-meta{font-size:12px;gap:.45rem;}
  .task-detail-header{align-items:flex-start;}
  .task-title-input{font-size:1.15rem;line-height:1.25;}
  .detail-grid{grid-template-columns:1fr;}
}

/* Version 10: Rechteverwaltung / Sichtbarkeit */
.field-hint{font-size:.8rem;color:var(--color-text-muted);margin-top:.25rem;}
.admin-create-grid{display:grid;grid-template-columns:1fr 1fr 1fr 160px 1fr auto;gap:.75rem;align-items:center;}
.role-badge{display:inline-block;margin-left:.35rem;padding:.15rem .45rem;border-radius:.5rem;background:var(--color-primary-light);color:var(--color-primary);font-size:.75rem;font-weight:600;}
@media (max-width: 800px){.admin-create-grid{grid-template-columns:1fr;}.admin-create-grid .btn{width:100%;}.field-hint{line-height:1.3;}}

/* V11 Feinschliff: Event-Auswahl, Admin-Formular, mobile Aufgabenleiste */
.event-select{
    width:100%;
    max-width:100%;
    margin-top:.75rem;
}

.admin-create-form{
    background:var(--color-bg);
    border:1px solid var(--color-border);
    border-radius:var(--radius-md);
    padding:var(--spacing-md);
    margin-bottom:var(--spacing-md);
}

.admin-create-grid{
    display:grid;
    grid-template-columns:repeat(3, minmax(160px,1fr));
    gap:var(--spacing-md);
    align-items:end;
}

.admin-create-submit .btn{
    width:100%;
    white-space:nowrap;
}

.admin-filtered-tasks{
    margin-top:var(--spacing-lg);
    border-top:1px solid var(--color-border);
    padding-top:var(--spacing-md);
}

.admin-filter-head{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:var(--spacing-sm);
    gap:var(--spacing-sm);
}

.admin-filter-list .task-item{
    margin-bottom:.4rem;
}

.group-header-actions{
    flex-wrap:wrap;
    justify-content:flex-end;
}

@media (max-width: 640px){
    .card-header{
        align-items:center;
        gap:.6rem;
    }

    .card-header > h2{
        flex:0 0 auto;
        margin:0;
    }

    .card-header .header-actions{
        flex:1 1 auto;
        display:grid;
        grid-template-columns:minmax(0,1fr) auto;
        gap:.5rem;
        align-items:center;
        width:auto;
    }

    #task-search{
        min-width:0;
        width:100%;
    }

    #create-task-btn{
        width:44px;
        min-width:44px;
        height:44px;
        padding:0;
        font-size:1.35rem;
        border-radius:12px;
    }

    .compact-task{
        align-items:flex-start;
    }

    .task-line{
        align-items:flex-start;
        gap:.5rem;
    }

    .task-title{
        white-space:normal !important;
        overflow:visible !important;
        text-overflow:clip !important;
        line-height:1.25;
    }

    .compact-meta{
        display:flex;
        flex-wrap:wrap;
        gap:.35rem .75rem;
    }

    .admin-create-grid{
        grid-template-columns:1fr;
    }
}


/* v12: Event-IDs und Direktlinks sichtbarer */
.current-event-info{
    margin-top: 0.85rem;
    padding: 0.85rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.event-id-help{
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:0.6rem;
    font-size:0.92rem;
}
.event-id-reference{
    margin: 0.8rem 0 1rem;
    padding: 0.85rem 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}
.event-id-reference div{
    margin-top: 0.35rem;
}
.group-admin-actions .btn{
    white-space: nowrap;
}
@media (max-width: 640px){
    .event-id-help{align-items:flex-start; flex-direction:column; gap:0.4rem;}
}

/* ============================================
   V16: kompakte Aufgaben-Toolbar, Suche, Filter, Sortierung
   ============================================ */
.task-toolbar-v16 {
    align-items: flex-start;
    gap: .75rem;
    flex-wrap: wrap;
}
.task-title-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex: 1 1 auto;
    min-width: 220px;
}
.task-title-row h2 {
    margin: 0;
}
.btn-new-task {
    min-width: 74px;
    padding-inline: .9rem;
    font-weight: 700;
    letter-spacing: .02em;
}
.task-tools-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
    flex: 1 1 520px;
    min-width: 280px;
}
.sort-select {
    max-width: 190px;
    height: 44px;
    padding: .55rem .75rem;
    font-size: .9rem;
}
.btn-filter {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 1.2rem;
}
.task-tools-row .search-input {
    min-width: 180px;
    max-width: 300px;
    height: 44px;
}
.task-filter-panel {
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin: -.5rem 0 1rem 0;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: .75rem;
}
.filter-grid label {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    font-size: .82rem;
    color: var(--color-text-muted);
}
.filter-grid select {
    font-size: .92rem;
    padding: .6rem .75rem;
}
.filter-actions {
    margin-top: .75rem;
    display: flex;
    justify-content: flex-end;
}
.task-result-info {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin: 0 0 .75rem 0;
    padding: .65rem .85rem;
    background: #f8fafc;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: .9rem;
}
.active-filter-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .35rem;
}
.active-filter-tags span {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-radius: 999px;
    padding: .15rem .5rem;
    font-size: .78rem;
}
.compact-task {
    padding: 10px 14px !important;
    min-height: auto !important;
}
.compact-task .task-title {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: initial !important;
    line-height: 1.25;
}
.compact-task .task-line {
    align-items: flex-start;
    gap: .5rem;
}
.compact-task .compact-meta {
    font-size: 12px !important;
    margin-top: 4px !important;
    row-gap: .25rem;
}

@media (max-width: 760px) {
    .task-toolbar-v16 {
        display: block;
    }
    .task-title-row {
        width: 100%;
        justify-content: space-between;
        min-width: 0;
        margin-bottom: .75rem;
    }
    .btn-new-task {
        min-width: 64px;
        padding: .55rem .7rem;
    }
    .task-tools-row {
        width: 100%;
        min-width: 0;
        display: grid;
        grid-template-columns: 1fr 44px;
        gap: .5rem;
    }
    .sort-select {
        grid-column: 1 / 2;
        max-width: none;
        width: 100%;
    }
    .btn-filter {
        grid-column: 2 / 3;
        grid-row: 1 / 2;
    }
    .task-tools-row .search-input {
        grid-column: 1 / 3;
        width: 100%;
        max-width: none;
        min-width: 0;
    }
    .filter-grid {
        grid-template-columns: 1fr;
    }
    .task-result-info {
        align-items: flex-start;
        flex-direction: column;
    }
    .compact-task .task-line {
        display: grid;
        grid-template-columns: 1fr auto;
    }
}

/* V18: optische Korrekturen Aufgabenfelder / Kommentare / Mobile */
.task-title-input,
.task-detail-form textarea[name="responsible_person"],
.task-detail-form textarea[name="helper_person"],
#create-task-form textarea[name="title"],
#create-task-form textarea[name="responsible_person"],
#create-task-form textarea[name="helper_person"]{
    width:100%;
    min-height:44px;
    border:2px solid var(--color-border);
    border-radius:var(--radius-md);
    padding:.75rem 1rem;
    font-family:var(--font-body);
    font-size:1rem;
    line-height:1.35;
    resize:vertical;
    overflow-wrap:anywhere;
    word-break:break-word;
    box-sizing:border-box;
}
.task-title-input:disabled,
.task-detail-form textarea:disabled{
    background:#f3f4f6;
    border:0;
    color:var(--color-text);
    opacity:1;
}
.task-detail-header{align-items:flex-start; gap:.75rem;}
.task-detail-header .task-title-input{font-weight:700;font-size:1.25rem;min-height:48px;}
.change-marker{display:inline-flex;margin-right:.35rem;color:#f59e0b;font-weight:800;}
.comment-meta-preview{font-size:.8rem;color:var(--color-text-muted);background:#f8fafc;border:1px solid var(--color-border);border-radius:var(--radius-sm);padding:.35rem .5rem;margin-bottom:.35rem;}
.file-input-label{display:block;margin:.5rem 0;font-size:.875rem;color:var(--color-text-muted);}
.file-input-label input{display:block;margin-top:.35rem;width:100%;}
.comment-meta-line{font-size:.8rem;color:var(--color-text-muted);font-weight:400;}
.comment-attachment{margin-top:.5rem;}
.comment-attachment a{color:var(--color-primary);text-decoration:none;font-weight:600;}
.comment-item.system-comment{background:#fff7ed;border-left:4px solid #f59e0b;}
.btn-new-task{font-size:1.4rem;line-height:1;min-width:44px;padding:.45rem .9rem;}
@media (max-width: 640px){
    .task-toolbar-v16{gap:.75rem;align-items:stretch;}
    .task-title-row{display:flex;align-items:center;justify-content:space-between;width:100%;}
    .task-tools-row{display:grid;grid-template-columns:1fr auto;gap:.5rem;width:100%;}
    .task-tools-row .sort-select{grid-column:1 / -1;width:100%;}
    .task-tools-row .search-input{width:100%;min-width:0;}
    .task-title{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.25;}
    .task-line{align-items:flex-start;}
    .detail-grid{grid-template-columns:1fr;}
    .task-detail-header{display:block;}
    .task-detail-header .task-status{margin-top:.5rem;display:inline-flex;}
    .comment-head{align-items:flex-start;gap:.5rem;}
}


/* V20 Korrekturen */
.btn-plus-only,
.btn-new-task{
    width:56px!important; min-width:56px!important; height:48px!important;
    padding:0!important; justify-content:center!important; align-items:center!important;
    font-size:1.55rem!important; font-weight:800!important; line-height:1!important;
}
.card-header.stacked-mobile{display:flex;align-items:center;justify-content:space-between;gap:1rem;flex-wrap:wrap;}
#admin-dashboard-screen .card-header{align-items:flex-start;}
#admin-dashboard-screen .card-header .header-actions{display:flex;gap:.6rem;flex-wrap:wrap;justify-content:flex-end;}
#import-export-card:not(.open) .header-actions button:not(:first-child){display:none!important;}
#import-export-card.open .header-actions{display:flex!important;}
.task-title-input,
.task-detail-form textarea[name="responsible_person"],
.task-detail-form textarea[name="helper_person"],
#create-task-form textarea[name="title"],
#create-task-form textarea[name="responsible_person"],
#create-task-form textarea[name="helper_person"]{
    width:100%; box-sizing:border-box; border:1px solid var(--color-border,#d9e1ec); border-radius:12px!important;
    min-height:52px; padding:12px 14px; resize:vertical; white-space:pre-wrap; overflow-wrap:anywhere; word-break:break-word;
    font:inherit; line-height:1.35;
}
.task-title-input{font-weight:700;font-size:1.25rem;min-height:60px;}
.task-detail-header{display:flex;gap:.75rem;align-items:flex-start;}
.task-detail-header .task-status{flex:0 0 auto;}
.comment-form input[name="author_name"], .comment-form select[name="attachment_visibility"]{width:100%;box-sizing:border-box;border:1px solid var(--color-border,#d9e1ec);border-radius:12px;min-height:44px;padding:10px 12px;font:inherit;}
.comment-attachment a{display:flex;gap:.35rem;align-items:flex-start;max-width:100%;white-space:normal;overflow-wrap:anywhere;word-break:break-word;}
.status-reset{font-weight:700;justify-content:center;border-style:dashed;}
.bl-extra-row{margin-top:.25rem;}
@media (max-width: 720px){
    .app-header{align-items:flex-start!important;}
    #admin-dashboard-screen .card-header,
    #admin-dashboard-screen .card-header.stacked-mobile{display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:1rem!important;}
    #admin-dashboard-screen .card-header .header-actions{width:100%;justify-content:flex-start!important;display:flex!important;flex-wrap:wrap!important;}
    #admin-dashboard-screen .event-select{width:100%!important;max-width:100%!important;}
    #import-export-card .header-actions{display:flex;flex-direction:column;width:100%;align-items:stretch!important;}
    #import-export-card .header-actions .btn{width:100%!important;min-width:0!important;}
    .task-title-row{display:flex;align-items:center;justify-content:space-between;width:100%;}
    .task-tools-row{display:grid!important;grid-template-columns:1fr 48px;gap:.5rem;width:100%;}
    .task-tools-row .search-input{grid-column:1 / -1;width:100%!important;}
    .task-tools-row .sort-select{width:100%;min-width:0;}
    .task-toolbar-v16{display:flex!important;flex-direction:column!important;align-items:stretch!important;}
    .task-detail-header{flex-direction:column;}
    .task-title-input{font-size:1.1rem;}
    .detail-grid{grid-template-columns:1fr!important;}
    .task-actions{display:flex;flex-direction:column;gap:.75rem;}
    .task-actions .btn{width:100%;}
}



/* ============================================
   V20.1 FIX: Aufgaben-Toolbar mobil kompakt
   ============================================ */

.card-header.task-toolbar-fixed,
.card-header.task-toolbar-v16.task-toolbar-fixed {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.75rem !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 0 1rem 0 !important;
    padding: 0 !important;
}

.task-toolbar-fixed .task-title-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.75rem !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.task-toolbar-fixed .task-title-row h2 {
    margin: 0 !important;
    line-height: 1.2 !important;
}

.task-toolbar-fixed .btn-new-task,
.task-toolbar-fixed #create-task-btn {
    width: 56px !important;
    min-width: 56px !important;
    max-width: 56px !important;
    height: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.6rem !important;
    line-height: 1 !important;
    font-weight: 800 !important;
    flex: 0 0 56px !important;
}

.task-toolbar-fixed .task-tools-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 48px !important;
    gap: 0.5rem !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: stretch !important;
    flex: none !important;
}

.task-toolbar-fixed .sort-select {
    grid-column: 1 / 2 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
}

.task-toolbar-fixed .btn-filter {
    grid-column: 2 / 3 !important;
    width: 48px !important;
    min-width: 48px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.task-toolbar-fixed .search-input,
.task-toolbar-fixed #task-search {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
}

#task-filter-panel {
    margin: 0 0 1rem 0 !important;
}

#task-result-info {
    margin-top: 0 !important;
}

@media (max-width: 720px) {
    .card-header.task-toolbar-fixed,
    .card-header.task-toolbar-v16.task-toolbar-fixed {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        gap: 0.75rem !important;
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
    }

    .task-toolbar-fixed .task-title-row,
    .task-toolbar-fixed .task-tools-row {
        transform: none !important;
        position: static !important;
    }
}

@media (min-width: 721px) {
    .card-header.task-toolbar-fixed,
    .card-header.task-toolbar-v16.task-toolbar-fixed {
        display: grid !important;
        grid-template-columns: auto minmax(360px, 1fr) !important;
        align-items: center !important;
        gap: 1rem !important;
    }

    .task-toolbar-fixed .task-title-row {
        width: auto !important;
        min-width: 180px !important;
    }

    .task-toolbar-fixed .task-tools-row {
        grid-template-columns: 190px 48px minmax(180px, 300px) !important;
        justify-content: end !important;
    }

    .task-toolbar-fixed .search-input,
    .task-toolbar-fixed #task-search {
        grid-column: 3 / 4 !important;
    }
}
