:root {
    --bg: #f2f4f7;
    --card-bg: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1e4fc7;
    --text: #1f2937;
    --text-light: #6b7280;
    --radius: 10px;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

:root.dark {
    --bg: #0f1115;
    --card-bg: #1a1d23;
    --text: #e5e7eb;
    --text-light: #9ca3af;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --shadow: 0 4px 12px rgba(255,255,255,0.05);
}

@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        --bg: #0f1115;
        --card-bg: #1a1d23;
        --text: #e5e7eb;
        --text-light: #9ca3af;
        --primary: #3b82f6;
        --primary-hover: #60a5fa;
        --shadow: 0 4px 12px rgba(255,255,255,0.05);
    }
}

body {
    margin: 0;
    font-family: "Inter", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    -webkit-text-size-adjust: 100%;
}

.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 1rem;
}

header {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}

nav a {
    margin-left: 1rem;
    text-decoration: none;
    color: var(--primary);
    font-weight: 500;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
}

.main-nav a {
    margin-left: 0;
    padding: .45rem .65rem;
    border-radius: var(--radius);
}

.main-nav a:hover {
    background: rgba(37, 99, 235, 0.08);
}

.card {
    background: var(--card-bg);
    padding: 1.5rem 1.75rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

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

.card.stat {
    text-align: center;
    padding: 2rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 120px;
    border: 1px solid transparent;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.card.stat:hover,
.card.stat:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    border-color: var(--primary);
    outline: none;
}

.card.stat.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.16);
}

form label {
    display: block;
    margin-bottom: .45rem;
    font-weight: 600;
}

input[type="text"],
input[type="date"],
input[type="password"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: .75rem .8rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text);
    box-sizing: border-box;
}

button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: .7rem 1.2rem;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    margin-top: .5rem;
    transition: background .2s;
}

.ticket-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.ticket-line {
    display: block;
    margin-top: .2rem;
    overflow-wrap: anywhere;
}

button:hover {
    background: var(--primary-hover);
}

.ticket-list {
    list-style: none;
    padding: 0;
}

.ticket-list li {
    margin-bottom: .8rem;
}

.ticket-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    padding: 1rem 1.1rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow);
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.ticket-card:hover,
.ticket-card:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
    outline: none;
}

.ticket-card-title {
    font-weight: 600;
    margin-bottom: .2rem;
}

.ticket-card-date {
    color: var(--text-light);
    font-size: .9rem;
}

.ticket-card-compact {
    display: block;
}

.ticket-card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.badge {
    display: inline-block;
    padding: .3rem .7rem;
    border-radius: var(--radius);
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.badge.offen { background: #ef4444; color: #fff; }
.badge.bearbeitung { background: #f59e0b; color: #fff; }
.badge.wartet { background: #3b82f6; color: #fff; }
.badge.erledigt { background: #10b981; color: #fff; }

.gallery-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
}

.gallery-thumbs img.thumb {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: var(--radius);
    cursor: pointer;
}

.ticket-image-thumb {
    width: 200px;
    max-width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius);
}

.gallery-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.85);
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.gallery-modal img {
    max-width: 90%;
    max-height: 90%;
    border-radius: var(--radius);
}

.gallery-modal .close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2.5rem;
    color: #fff;
    cursor: pointer;
}

.comment-list,
.log-list {
    list-style: none;
    padding: 0;
}

.comment-list li,
.log-list li {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: .8rem;
}

.filter-form {
    display: flex;
    gap: .7rem;
    flex-wrap: wrap;
}

.dark-btn {
    background: var(--card-bg);
    border: 1px solid var(--text-light);
    padding: .4rem .7rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text);
}

.install-btn {
    background: var(--primary);
    border: none;
    padding: .4rem .7rem;
    border-radius: var(--radius);
    cursor: pointer;
    color: #fff;
}

.status-form {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.status-form button {
    margin-top: 0;
}

.status-form .status-btn {
    color: #fff;
    border: none;
}

.status-form .status-offen {
    background: #ef4444;
}

.status-form .status-bearbeitung {
    background: #f59e0b;
}

.status-form .status-wartet {
    background: #3b82f6;
}

.status-form .status-erledigt {
    background: #10b981;
}

.status-form .status-btn:hover {
    filter: brightness(0.92);
}

.ticket-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 820px;
    margin-right: auto;
    padding: .25rem .25rem .25rem 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.form-field small {
    color: var(--text-light);
    line-height: 1.4;
}

@media (max-width: 768px) {
    .container {
        margin: 1rem auto;
        padding: .75rem;
    }

    header {
        padding: .9rem;
        flex-direction: column;
        align-items: flex-start;
    }

    header h1 {
        margin: 0;
        font-size: 1.2rem;
    }

    .main-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .main-nav a,
    .dark-btn {
        min-height: 42px;
        display: inline-flex;
        align-items: center;
    }

    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card-grid {
        grid-template-columns: 1fr 1fr;
        gap: .75rem;
    }

    .card.stat {
        padding: 1rem;
        min-height: 104px;
        text-align: left;
    }

    .card.stat h2 {
        font-size: 1.35rem;
        margin: 0 0 .25rem 0;
    }

    .card.stat p {
        margin: 0;
        font-size: .95rem;
    }

    input[type="text"],
    input[type="date"],
    input[type="password"],
    input[type="file"],
    textarea,
    select,
    button {
        font-size: 16px;
    }

    button {
        width: 100%;
        min-height: 44px;
    }

    .filter-form {
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .status-form {
        flex-direction: column;
    }

    .status-form button {
        width: 100%;
    }

    .ticket-list li {
        padding: .9rem;
    }

    .ticket-list li a {
        display: inline-block;
        margin-bottom: .25rem;
    }

    .ticket-image-thumb {
        width: 100%;
        height: auto;
        max-height: 280px;
    }
}

@media (max-width: 480px) {
    .card-grid {
        grid-template-columns: 1fr;
    }

    .card.stat {
        min-height: 92px;
        padding: .9rem;
    }

    .card.stat h2 {
        font-size: 1.2rem;
    }

    .card.stat p {
        font-size: .9rem;
    }

    .ticket-list li {
        padding: .8rem;
    }
}
