/* ── Reset & Grundlagen ────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:           #f5f6fa;
    --surface:      #ffffff;
    --border:       #e2e5ed;
    --text:         #1a1d23;
    --text-muted:   #6b7280;
    --primary:      #4f6ef7;
    --primary-dark: #3a57e8;
    --danger:       #ef4444;
    --danger-dark:  #dc2626;
    --success:      #22c55e;
    --warning:      #f59e0b;
    --overdue:      #fee2e2;
    --overdue-text: #b91c1c;
    --today:        #fef9c3;
    --today-text:   #92400e;
    --radius:       8px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}

/* ── Login ─────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
}

.login-logo {
    width: 180px;
    height: auto;
    margin-bottom: .5rem;
    display: block;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    font-size: .9rem;
}

.form-group-check {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .88rem;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ── Header ────────────────────────────────────────────────── */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: .625rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-logo {
    height: 36px;
    width: auto;
    display: block;
}

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

/* ── Mobile / Desktop Sichtbarkeit ─────────────────────────── */
.mobile-only  { display: none !important; }
.desktop-only { display: inline-flex; }

@media (max-width: 600px) {
    .mobile-only  { display: inline-flex !important; }
    .desktop-only { display: none !important; }
}

/* ── Mobile Dropdown-Menü ───────────────────────────────────── */
.mobile-menu-wrap {
    position: relative;
}

#btnMobileMenu {
    font-size: 1.3rem;
    padding: .4rem .7rem;
    line-height: 1;
    border-radius: var(--radius);
}

.mobile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + .5rem);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 150;
    overflow: hidden;
}

.mobile-dropdown.open {
    display: block;
}

.mobile-dropdown-item {
    display: block;
    width: 100%;
    padding: .75rem 1rem;
    font-size: .92rem;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    color: var(--text);
    text-decoration: none;
    font-family: inherit;
}

.mobile-dropdown-item:last-child {
    border-bottom: none;
}

.mobile-dropdown-item:hover {
    background: var(--bg);
}

/* ── Main ──────────────────────────────────────────────────── */
.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* ── Stats ─────────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card.stat-overdue { background: var(--overdue); border-color: #fca5a5; }
.stat-card.stat-today   { background: var(--today);   border-color: #fcd34d; }

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card.stat-overdue .stat-number { color: var(--overdue-text); }
.stat-card.stat-today   .stat-number { color: var(--today-text); }
.stat-card.stat-open    .stat-number { color: var(--primary); }
.stat-card.stat-done    .stat-number { color: var(--success); }

.stat-label {
    display: block;
    font-size: .78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: .25rem;
}

/* ── Filter ────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: .625rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-search {
    flex: 1;
    min-width: 160px;
}

.filter-select {
    min-width: 130px;
}

.filter-search,
.filter-select {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
    font-size: .9rem;
    background: var(--surface);
    color: var(--text);
    height: 38px;
}

.filter-search:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

/* ── Sections ──────────────────────────────────────────────── */
.tasks-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-bottom: .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

.section-title--inprogress { color: #15803d; }
.section-title--overdue    { color: var(--overdue-text); }
.section-title--today      { color: var(--today-text); }

/* ── Task Card ─────────────────────────────────────────────── */
.task-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: .875rem 1rem;
    cursor: pointer;
    transition: box-shadow .15s, border-color .15s;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .25rem .75rem;
    align-items: start;
    box-shadow: var(--shadow);
}

.task-card:hover { box-shadow: var(--shadow-md); border-color: #c5cad6; }

.task-card.priority-hoch    { border-left-color: var(--danger); }
.task-card.priority-mittel  { border-left-color: var(--warning); }
.task-card.priority-niedrig { border-left-color: var(--success); }

.task-card.status-erledigt {
    opacity: .6;
}

.task-card.overdue { background: #fff8f8; }
.task-card.today   { background: #fffef5; }

.task-title {
    font-weight: 600;
    font-size: .95rem;
    grid-column: 1;
}

.task-card.status-erledigt .task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
    align-items: center;
    grid-column: 1;
    margin-top: .25rem;
}

.task-date {
    font-size: .8rem;
    color: var(--text-muted);
}

.task-date.overdue { color: var(--overdue-text); font-weight: 600; }
.task-date.today   { color: var(--today-text);   font-weight: 600; }

.task-notes-preview {
    font-size: .82rem;
    color: var(--text-muted);
    grid-column: 1;
    margin-top: .25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.task-badges {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: .3rem;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
}

.badge-status-offen    { background: #eff6ff; color: #1d4ed8; }
.badge-status-in_arbeit{ background: #f0fdf4; color: #15803d; }
.badge-status-erledigt { background: #f1f5f9; color: #475569; }

.badge-priority-hoch    { background: #fee2e2; color: #b91c1c; }
.badge-priority-mittel  { background: #fef9c3; color: #92400e; }
.badge-priority-niedrig { background: #f0fdf4; color: #15803d; }

.tag {
    display: inline-block;
    padding: .15rem .5rem;
    border-radius: var(--radius);
    font-size: .75rem;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem;
    font-size: .9rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .5rem 1rem;
    border-radius: var(--radius);
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }

.btn-full { width: 100%; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: .375rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--text);
}

.hint {
    font-weight: 400;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
}

@media (max-width: 540px) {
    .form-row { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .5rem .75rem;
    font-size: .9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

textarea { resize: vertical; }

/* ── Alert ─────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .88rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: var(--overdue);
    color: var(--overdue-text);
    border: 1px solid #fca5a5;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 1.5rem 1.25rem;
    font-size: .78rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ── Divider ────────────────────────────────────────────────── */
.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

/* ── Tag Autocomplete ──────────────────────────────────────── */
.tag-autocomplete-wrap {
    position: relative;
}

.tag-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md);
    list-style: none;
    max-height: 180px;
    overflow-y: auto;
    z-index: 300;
    margin-top: -1px;
}

.tag-suggestion-item {
    padding: .45rem .75rem;
    cursor: pointer;
    font-size: .88rem;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
    background: var(--bg);
    color: var(--primary);
}

/* ── Current User ──────────────────────────────────────────── */
.current-user {
    font-size: .85rem;
    color: var(--text-muted);
    padding: .5rem .25rem;
    align-self: center;
}

/* ── User Table ────────────────────────────────────────────── */
.modal--wide {
    max-width: 680px;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

.user-table th {
    text-align: left;
    padding: .5rem .75rem;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.user-table td {
    padding: .625rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.btn-sm {
    padding: .25rem .625rem;
    font-size: .8rem;
}

/* ── Alert success ─────────────────────────────────────────── */
.alert-success {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #86efac;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}

.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0,0,0,.15);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: .25rem;
}
.modal-close:hover { color: var(--text); }

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}
