* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f3ef;
    color: #2b2620;
}

header {
    background: #3a2a1a;
    color: #fff;
    padding: 0.6rem 1.5rem;
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    row-gap: 0.5rem;
}

.logo {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}

nav a {
    color: #f0c66e;
    text-decoration: none;
}

main {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    main {
        margin: 1rem auto;
        padding: 0 1rem;
    }

    header {
        padding: 0.6rem 1rem;
    }

    h1 {
        font-size: 1.4rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    h3 {
        font-size: 1rem;
    }

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

    .field-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    }

    /* Tabellen worden op mobiel gestapelde kaarten i.p.v. horizontaal
       scrollende tabellen, zodat alles gewoon binnen het scherm past. */
    .item-table,
    .item-table thead,
    .item-table tbody,
    .item-table th,
    .item-table td,
    .item-table tr {
        display: block;
    }

    .table-scroll {
        overflow-x: visible;
    }

    .item-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .item-table {
        border: 1px solid #eee;
    }

    .item-table tr {
        border-bottom: 6px solid #f5f3ef;
    }

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

    .item-table td {
        border-bottom: 1px solid #eee;
        padding: 0.5rem 0.7rem;
        font-size: 0.85rem;
    }

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

    .item-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 0.7rem;
        text-transform: uppercase;
        color: #998;
        margin-bottom: 0.25rem;
    }

    .item-table .naam-input,
    .item-table .aantal-input,
    .item-table .eenheid-input,
    .item-table select,
    .item-table .soort-select {
        width: 100%;
        max-width: 100%;
    }

    .heading-form .naam-input {
        min-width: 0;
        width: 100%;
        font-size: 1.2rem;
    }
}

h1 {
    margin-top: 0;
}

.flash-messages {
    margin-bottom: 1rem;
}

.flash {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #dff2e1;
    color: #1e5c2a;
}

.flash-error {
    background: #fbe0df;
    color: #8a1f1a;
}

/* Auth */
.auth-box {
    max-width: 360px;
    margin: 3rem auto;
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.auth-box form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-box label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.auth-box input {
    padding: 0.6rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.auth-box button {
    margin-top: 1rem;
}

.auth-switch {
    font-size: 0.85rem;
    text-align: center;
    margin-top: 1rem;
}

/* Buttons */
button {
    background: #a5672a;
    color: #fff;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

button:hover {
    background: #8a5321;
}

.btn-small {
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
}

.btn-delete-small {
    background: transparent;
    color: #a83a32;
    border: 1px solid #a83a32;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-delete-small:hover {
    background: #a83a32;
    color: #fff;
}

/* Category grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.category-card {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.6rem;
}

.delete-category-form {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
}

.btn-delete-icon {
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
}

.btn-delete-icon:hover {
    color: #fff;
    background: #a83a32;
}

.category-link {
    text-decoration: none;
    color: inherit;
}

.category-card h2 {
    margin: 0 0 0.3rem 0;
    font-size: 1.1rem;
}

.item-count {
    font-size: 0.8rem;
    color: #777;
}

.item-preview {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
}

.item-preview li {
    padding: 0.15rem 0;
}

.activity-feed {
    list-style: none;
    margin: 0 0 2rem 0;
    padding: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    overflow: hidden;
}

.activity-feed li {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.activity-feed li:last-child {
    border-bottom: none;
}

.new-category-box {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.new-category-box h3 {
    margin-top: 0;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.inline-form input,
.inline-form select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.stacked-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 500px;
}

.stacked-form input,
.stacked-form textarea {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}

.stacked-form button {
    align-self: flex-start;
}

.status-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: #eee;
    color: #777;
}

.status-ok {
    background: #dff2e1;
    color: #1e5c2a;
}

.status-tekort {
    background: #fbe0df;
    color: #8a1f1a;
}

.tekort-text {
    color: #a83a32;
    font-size: 0.8rem;
}

.opmerkingen-textarea {
    display: block;
    width: 100%;
    max-width: 500px;
    padding: 0.7rem 1rem;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    resize: vertical;
}

.delete-recipe-zone {
    margin-top: 1.5rem;
}

/* Item table */
.item-table {
    min-width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.item-table th, .item-table td {
    text-align: left;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.item-table th {
    background: #f0ece4;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: #665;
}

.aantal-input {
    width: 80px;
    padding: 0.35rem;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.naam-input {
    min-width: 140px;
    padding: 0.35rem;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.soort-select {
    padding: 0.35rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.8rem;
}

.eenheid-input {
    width: 90px;
    padding: 0.35rem;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.heading-form {
    margin-bottom: 1rem;
    align-items: center;
}

.heading-form .naam-input {
    font-size: 1.4rem;
    font-weight: 700;
    min-width: 240px;
}

.actions-cell {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.7rem;
    max-width: 600px;
    margin-bottom: 0.5rem;
}

.field-grid label {
    display: flex;
    flex-direction: column;
    font-size: 0.8rem;
    color: #665;
    gap: 0.25rem;
}

.field-grid input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.muted {
    color: #999;
    font-size: 0.8rem;
}

.back-link {
    display: inline-block;
    margin-bottom: 1rem;
    color: #a5672a;
    text-decoration: none;
    font-size: 0.9rem;
}

.empty-state {
    color: #999;
    font-style: italic;
}
