* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f0f2f5;
    color: #111827;
}

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

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: #111827;
    color: white;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: white;
    color: #111827;
    display: grid;
    place-items: center;
    font-weight: 800;
}

.brand span {
    display: block;
    margin-top: 2px;
    color: #9ca3af;
    font-size: 13px;
}

nav {
    display: grid;
    gap: 8px;
}

nav a,
.logout {
    padding: 11px 13px;
    border-radius: 12px;
    color: #d1d5db;
    font-size: 15px;
    transition: background .15s, color .15s;
}

nav a:hover,
nav a.active,
.logout:hover {
    background: rgba(255,255,255,.1);
    color: white;
}

nav a.active {
    background: rgba(255,255,255,.12);
    font-weight: 600;
}

.logout {
    margin-top: auto;
}

.main {
    padding: 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 26px;
}

.page-header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -.4px;
}

.page-header p {
    margin: 6px 0 0;
    color: #6b7280;
    font-size: 15px;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    background: #111827;
    color: white;
    font-weight: 700;
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .1s, box-shadow .15s;
}

.button:hover  { background: #1f2937; }
.button:active { transform: scale(.98); }

.button.secondary {
    background: white;
    color: #111827;
    border: 1.5px solid #e5e7eb;
}

.button.secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.grid {
    display: grid;
    gap: 18px;
}

.stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 22px;
}

.card {
    background: white;
    border-radius: 22px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .04);
}

.card-label {
    color: #6b7280;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.card-value {
    margin-top: 10px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.5px;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
}

.content-grid {
    grid-template-columns: 2fr 1fr;
}

.list {
    display: grid;
    gap: 12px;
}

.task-item {
    display: block;
    border: 1.5px solid #f1f3f5;
    border-radius: 16px;
    padding: 15px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.task-item:hover {
    background: #fafafa;
    border-color: #e5e7eb;
    box-shadow: 0 2px 10px rgba(15,23,42,.06);
}

.task-title {
    font-weight: 750;
}

.meta {
    margin-top: 6px;
    color: #6b7280;
    font-size: 14px;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .01em;
    background: #eef2ff;
    color: #3730a3;
}

.badge.prio-hoch,
.badge.prio-dringend {
    background: #fee2e2;
    color: #991b1b;
}

.badge.status-erledigt {
    background: #dcfce7;
    color: #166534;
}

.badge.status-in_bearbeitung {
    background: #f3e8ff;
    color: #6b21a8;
}

.empty {
    color: #9ca3af;
    padding: 20px;
    background: #f9fafb;
    border-radius: 14px;
    border: 1.5px dashed #e5e7eb;
    text-align: center;
    font-size: 14px;
}

/* ── Login ── */
.login-body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: #111827;
    overflow: hidden;
}

.login-hero {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 32px 40px;
    gap: 16px;
    background: linear-gradient(160deg, #1e293b 0%, #111827 60%, #0f172a 100%);
}

.login-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border-radius: 22px;
    background: rgba(255,255,255,.07);
    padding: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.4);
}

.login-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -.5px;
}

.login-subtitle {
    margin: 0;
    font-size: 15px;
    color: #6b7280;
}

.login-sheet {
    flex: 1 1 auto;
    background: #ffffff;
    border-radius: 28px 28px 0 0;
    padding: 32px 24px max(24px, env(safe-area-inset-bottom));
    box-shadow: 0 -12px 50px rgba(0,0,0,.25);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 400px;
    margin: 0 auto;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group input {
    width: 100%;
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    padding: 15px 48px 15px 46px;
    font: inherit;
    font-size: 16px;
    background: #f9fafb;
    color: #111827;
    transition: border-color .15s, background .15s;
    -webkit-appearance: none;
}

.input-group input:focus {
    outline: none;
    border-color: #111827;
    background: #ffffff;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: #9ca3af;
    display: flex;
    pointer-events: none;
}

.pw-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    display: flex;
    padding: 4px;
    margin: 0;
    width: auto;
    min-width: unset;
}

.pw-toggle:hover { color: #374151; }

.remember-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #4b5563;
    cursor: pointer;
    margin: 2px 0 6px;
}

.remember-label input[type="checkbox"] {
    display: none;
}

.remember-toggle {
    width: 42px;
    height: 24px;
    border-radius: 12px;
    background: #d1d5db;
    flex-shrink: 0;
    position: relative;
    transition: background .2s;
}

.remember-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,.25);
    transition: transform .2s;
}

.remember-label input:checked ~ .remember-toggle {
    background: #111827;
}

.remember-label input:checked ~ .remember-toggle::after {
    transform: translateX(18px);
}

.login-btn {
    width: 100%;
    padding: 16px;
    background: #111827;
    color: white;
    border: none;
    border-radius: 14px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .1s;
    margin-top: 4px;
    -webkit-appearance: none;
}

.login-btn:hover  { background: #1f2937; }
.login-btn:active { transform: scale(.98); }

/* Desktop */
@media (min-width: 640px) {
    .login-body {
        min-height: 100vh;
        align-items: center;
        justify-content: center;
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
        padding: 40px 24px;
    }

    .login-hero {
        width: 100%;
        max-width: 420px;
        background: #ffffff;
        border-radius: 28px 28px 0 0;
        padding: 48px 40px 28px;
        gap: 12px;
    }

    .login-title { color: #111827; }

    .login-logo {
        background: #f3f4f6;
        box-shadow: 0 4px 16px rgba(0,0,0,.1);
    }

    .login-sheet {
        width: 100%;
        max-width: 420px;
        flex: 0 0 auto;
        border-radius: 0 0 28px 28px;
        padding: 28px 40px 40px;
        box-shadow: 0 32px 80px rgba(0,0,0,.45);
    }
}

label {
    display: block;
    margin: 16px 0 7px;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    margin: 16px 0 4px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

input,
select,
textarea {
    width: 100%;
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    padding: 13px 14px;
    font: inherit;
    font-size: 15px;
    background: #f9fafb;
    color: #111827;
    transition: border-color .15s, background .15s;
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    cursor: pointer;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #111827;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(17,24,39,.06);
}

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

form button {
    margin-top: 20px;
    width: 100%;
}

/* ── Mängel ── */
.defect-status-offen          { background: #fef3c7; color: #92400e; }
.defect-status-in_bearbeitung { background: #f3e8ff; color: #6b21a8; }
.defect-status-behoben        { background: #dcfce7; color: #166534; }
.badge-fixed                  { background: #dcfce7; color: #166534; }
.badge-photo                  { background: #f0f9ff; color: #0369a1; }

.defect-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 4px;
}

.defect-photo-wrap {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    background: #f1f3f5;
    aspect-ratio: 1;
}

.defect-photo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .2s;
}

.defect-photo-wrap:hover img {
    transform: scale(1.04);
}

.defect-photo-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 100%);
    color: white;
    font-size: 11px;
    padding: 16px 8px 6px;
}

.defect-photo-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    margin: 0;
}

.defect-delete-btn {
    width: 26px !important;
    height: 26px;
    min-width: unset;
    padding: 0 !important;
    border-radius: 999px !important;
    background: rgba(0,0,0,.55) !important;
    color: white !important;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    margin-top: 0 !important;
}

/* ── Push-Banner ── */
.push-banner {
    background: #1d4ed8;
    color: white;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.push-banner span {
    flex: 1;
}

.push-banner button {
    background: white;
    color: #1d4ed8;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.push-banner button:hover {
    background: #eff6ff;
}

.alert {
    border-radius: 14px;
    padding: 13px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    border: 1.5px solid transparent;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert.success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill,minmax(180px,1fr));
    gap: 12px;
}

.gallery img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    transition: .2s;
}

.gallery img:hover {
    transform: scale(1.02);
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        padding: 16px;
        gap: 16px;
        border-radius: 0 0 24px 24px;
    }

    .brand {
        justify-content: space-between;
    }

    nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    nav a,
    .logout {
        white-space: nowrap;
        flex: 0 0 auto;
        padding: 10px 12px;
        font-size: 14px;
    }

    .logout {
        margin-top: 0;
        display: inline-flex;
        width: fit-content;
    }

    .main {
        padding: 18px;
    }

    .page-header {
        flex-direction: column;
        gap: 14px;
        margin-bottom: 18px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .page-header .button,
    .page-header a.button {
        width: 100%;
    }

    .stats,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .card {
        border-radius: 18px;
        padding: 16px;
    }

    .card-value {
        font-size: 26px;
    }

    .task-item {
        padding: 14px;
    }

    input,
    select,
    textarea,
    .button,
    button {
        font-size: 16px;
    }

    form button {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        padding: 14px;
        gap: 14px;
        border-radius: 0 0 22px 22px;
        overflow: hidden;
    }

    .brand {
        justify-content: flex-start;
        gap: 12px;
    }

    .brand-icon {
        width: 40px;
        height: 40px;
        border-radius: 13px;
        flex: 0 0 auto;
    }

    nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        max-width: 100%;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    nav a {
        flex: 0 0 auto;
        white-space: nowrap;
        padding: 9px 12px;
        font-size: 14px;
        border-radius: 12px;
    }

    .logout {
        margin-top: 0;
        width: fit-content;
        padding: 9px 12px;
        font-size: 14px;
    }

    .main {
        padding: 18px 14px;
    }

    .page-header {
        flex-direction: column;
        gap: 14px;
        margin-bottom: 18px;
    }

    .page-header h1 {
        font-size: 25px;
    }

    .page-header p {
        font-size: 15px;
        line-height: 1.4;
    }

    .page-header > div:last-child {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr;
    }

    .page-header .button,
    .page-header a.button {
        width: 100%;
        min-height: 48px;
    }

    .stats,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .card {
        border-radius: 18px;
        padding: 16px;
    }

    .card-value {
        font-size: 28px;
    }

    input,
    select,
    textarea,
    .button,
    button {
        font-size: 16px;
    }

    form button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .sidebar {
        margin: 0;
        border-radius: 0 0 20px 20px;
    }

    .brand strong {
        font-size: 17px;
    }

    .brand span {
        font-size: 13px;
    }

    .main {
        padding: 16px 12px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .stats {
        gap: 12px;
    }

    .card {
        padding: 15px;
        border-radius: 17px;
    }

    .task-item {
        padding: 13px;
    }

    .grid[style*="grid-template-columns:1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

.mobile-topbar,
.sidebar-backdrop {
    display: none;
}

.burger-button {
    border: 0;
    background: white;
    color: #111827;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 24px;
    font-weight: 800;
    cursor: pointer;
}

@media (max-width: 900px) {
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        background: #111827;
        color: white;
        padding: 14px;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .mobile-topbar .brand span {
        color: #9ca3af;
    }

    .mobile-topbar .brand-icon {
        background: white;
        color: #111827;
    }

    .app-shell {
        display: block;
    }

    .desktop-brand {
        display: none;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 270px;
        height: 100vh;
        z-index: 80;
        border-radius: 0;
        transition: left .25s ease;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar nav {
        display: grid;
        gap: 8px;
        overflow: visible;
    }

    .sidebar nav a,
    .sidebar .logout {
        width: 100%;
        white-space: normal;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.45);
        z-index: 70;
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .main {
        padding: 18px 14px;
    }
}