@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;700&display=swap");

:root {
    --page-gutter: 20px;
    --site-header-offset: 160px;
    --bg: #f4f1ec;
    --card: #ffffff;
    --text: #1f2328;
    --muted: #5f5b57;
    --accent: #2563eb;
    --accent-weak: #e2ecff;
    --danger: #b3261e;
    --success: #0f7a3b;
    --border: rgba(45, 55, 72, 0.12);
    --shadow: 0 24px 60px rgba(31, 35, 40, 0.12);
    --radius-lg: 20px;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "DM Sans", "Space Grotesk", system-ui, sans-serif;
    background: radial-gradient(circle at top, #fff7ec 0%, #f4f1ec 55%, #ebe5dd 100%);
    color: var(--text);
}

.container {
    width: auto;
    margin: 0 var(--page-gutter);
}

.site-header {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: "Space Grotesk", "DM Sans", system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
    line-height: 1;
}

.brand__logo {
    height: 150px;
    width: auto;
    display: block;
}

.brand__text {
    line-height: 1;
}

.nav {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    font-weight: 600;
}

.nav__link,
.nav__user {
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
}

.nav__user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav__link {
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent-weak);
    color: var(--accent);
}

.menu-toggle {
    display: none;
}

.menu-button {
    display: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
}

.menu-button__line {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: var(--text);
    display: block;
}

.menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 9;
}

main {
    padding: 0;
}

.app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 24px;
    width: auto;
    margin: 0 var(--page-gutter);
    padding: 24px 0 60px;
}

.app-shell.app-shell--auth {
    grid-template-columns: 1fr;
    width: min(720px, calc(100vw - (2 * var(--page-gutter))));
    margin: 0 auto;
}

.app-shell--auth .main-content {
    padding-top: 0;
}

.side-menu {
    display: grid;
    gap: 10px;
    align-content: start;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
    position: sticky;
    top: calc(var(--site-header-offset) + var(--page-gutter));
    height: fit-content;
}

.side-menu a {
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 999px;
    background: transparent;
}

.side-menu a:hover {
    background: var(--accent-weak);
    color: var(--accent);
}

.side-menu a.is-active {
    background: var(--accent);
    color: white;
}

.main-content {
    width: 100%;
    min-width: 0;
    margin: 0;
    container-type: inline-size;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
    overflow-x: auto;
    max-width: 100%;
}

.auth-card {
    max-width: 560px;
    margin: 0 auto 22px;
    padding: 34px;
}

.form {
    display: grid;
    gap: 12px;
    margin-top: 18px;
}

.filter-form {
    display: grid;
    grid-template-columns: auto minmax(240px, 420px) auto auto;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
}

label {
    font-weight: 600;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 16px;
}

button {
    padding: 12px 18px;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.form button {
    justify-self: start;
}

button.link-button {
    background: none;
    color: var(--accent);
    padding: 0;
    font-weight: 600;
}

.button,
.button:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    font-weight: 600;
}

.button--icon {
    width: 40px;
    height: 40px;
    padding: 0;
    line-height: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
}

.button--icon .icon {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin: 0;
    display: block;
}

.button--disabled {
    background: var(--border);
    color: var(--muted);
    cursor: not-allowed;
}

.button--danger {
    background: var(--danger);
}

.button--success {
    background: var(--success);
}

.button--ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--accent);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.table {
    width: 100%;
    min-width: 1040px;
    border-collapse: collapse;
    margin-top: 16px;
    font-size: 15px;
    background: var(--card);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.table--list-items {
    min-width: 1180px;
}

.table--templates {
    min-width: 1040px;
}

.table .col-title {
    width: 24%;
}

.table .col-kita,
.table .col-list {
    width: 17%;
}

.table .col-group {
    width: 10%;
}

.table .col-time {
    width: 16%;
}

.table .col-status {
    width: 100px;
}

.table .col-number,
.table .col-state {
    width: 1%;
}

.table .col-actions {
    width: 104px;
}

@media (max-width: 720px) {
    .table {
        min-width: 0;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        margin-bottom: 12px;
        background: var(--card);
        box-shadow: var(--shadow);
    }

    .table td {
        padding: 8px 0;
        border: none;
        display: grid;
        grid-template-columns: minmax(120px, 40%) 1fr;
        gap: 12px;
        align-items: start;
    }

    .table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 600;
    }

    .table td[data-label="Aktionen"] {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        white-space: normal;
    }

    .table td[data-label="Aktionen"]::before {
        flex: 0 0 min(40%, 160px);
    }
}

@container (max-width: 1100px) {
    .table {
        min-width: 0;
    }

    .table thead {
        display: none;
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        padding: 12px 14px;
        margin-bottom: 12px;
        background: var(--card);
        box-shadow: var(--shadow);
    }

    .table td {
        padding: 8px 0;
        border: none;
        display: grid;
        grid-template-columns: minmax(120px, 28%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
    }

    .table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 600;
    }

    .table td[data-label="Kita"] {
        min-width: 0;
    }

    .table td[data-label="Aktionen"] {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
        white-space: normal;
    }

    .table td[data-label="Aktionen"]::before {
        flex: 0 0 min(28%, 160px);
    }
}

.table thead {
    background: #f5f6f8;
}

.table th,
.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    overflow-wrap: anywhere;
}

.table th {
    white-space: nowrap;
}

.table th a {
    white-space: nowrap;
}

.table td[data-label="Status"],
.table td[data-label="Minuten"],
.table td[data-label="Plätze"],
.table td[data-label="Aktiv"],
.table td[data-label="Standard Minuten"],
.table td[data-label="Standard Plätze"] {
    white-space: nowrap;
    overflow-wrap: normal;
}

.table td[data-label="Kita"] {
    min-width: 150px;
    overflow-wrap: break-word;
}

.table td[data-label="Aktionen"] {
    white-space: nowrap;
}

@media (max-width: 720px) {
    .table td[data-label="Kita"] {
        min-width: 0;
    }
}

@container (max-width: 1100px) {
    .table td[data-label="Kita"] {
        min-width: 0;
    }
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 0;
}

.action-stack {
    display: grid;
    gap: 8px;
}

.inline-form input[type="number"] {
    width: 110px;
}

button:hover {
    filter: brightness(0.95);
}

button:disabled {
    filter: none;
    opacity: 0.55;
    cursor: not-allowed;
}

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 12px;
    font-weight: 600;
}

.flash--error {
    background: #fde8e7;
    color: var(--danger);
}

.flash--success {
    background: #e5f5ec;
    color: var(--success);
}

.list {
    padding-left: 18px;
    margin: 12px 0 0;
}

.placeholder {
    padding: 16px;
    border-radius: 12px;
    background: var(--accent-weak);
    color: var(--muted);
}

.installer-page {
    width: min(760px, calc(100vw - (2 * var(--page-gutter))));
    margin: 0 auto;
    padding: 32px 0 60px;
}

.installer-card {
    overflow-x: visible;
}

.installer-section {
    border-top: 1px solid var(--border);
    margin-top: 22px;
    padding-top: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.muted {
    color: var(--muted);
    font-weight: 600;
}

.kita-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin: 16px 0 10px;
}

.kita-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    background: #faf8f4;
    display: grid;
    gap: 8px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.hidden {
    display: none;
}

.kita-card .small {
    font-size: 13px;
    color: var(--muted);
}

.stat-label {
    color: var(--muted);
    font-weight: 600;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

@media (max-width: 1100px) {
    :root {
        --site-header-offset: 160px;
    }

    .site-header .container {
        align-items: center;
        gap: 12px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .menu-button {
        display: inline-flex;
        margin-left: auto;
    }

    .nav {
        margin-left: auto;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .nav__user {
        max-width: min(260px, 36vw);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .side-menu {
        position: fixed;
        top: calc(var(--site-header-offset) + var(--page-gutter));
        left: var(--page-gutter);
        right: var(--page-gutter);
        max-height: calc(100vh - var(--site-header-offset) - (2 * var(--page-gutter)));
        overflow-y: auto;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-12px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
        visibility: hidden;
        z-index: 11;
    }

    .menu-toggle:checked ~ .menu-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .menu-toggle:checked ~ .app-shell .side-menu {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
        visibility: visible;
    }

    .table {
        overflow-x: visible;
    }
}

@media (max-width: 720px) {
    .filter-form {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .filter-form button,
    .filter-form .button {
        justify-self: start;
    }
}
