* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    background: #f4f4f4;
    color: #111;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 18px;
    background: #111;
    color: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
}

.topbar h1 {
    margin: 0;
    font-size: 22px;
    line-height: 1.1;
}

.topbar p {
    margin: 4px 0 0;
    color: #bbb;
}

.topbar nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

button.button {
    font-family: inherit;
    font-size: 14px;
}

.button,
.submit-button {
    display: inline-block;
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: #ff2b2b;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    cursor: pointer;
}

.button.secondary {
    background: #333;
}

.tablewrap {
    height: calc(100vh - 78px);
    overflow: auto;
    background: #fff;
}

.gear-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
}

.gear-table th,
.gear-table td {
    border-right: 1px solid #222;
    border-bottom: 1px solid #222;
    white-space: nowrap;
}

.gear-table thead th {
    position: sticky;
    top: 0;
    z-index: 30;
    background: #fff;
    height: 240px;
    vertical-align: middle;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 20;
    background: #fff;
    border-left: 1px solid #222;
}

.gear-table thead .sticky-col {
    z-index: 40;
    background: #111;
    color: #fff;
}

.date-head {
    min-width: 112px;
    height: 240px;
    padding: 10px;
    text-align: left;
    vertical-align: bottom !important;
}

.item-head {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    padding: 0;
    overflow: visible;
    position: relative;
}

.item-head span {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 220px;
    transform: translate(-50%, -50%) rotate(-90deg);
    transform-origin: center center;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.1;
}

.date-cell {
    min-width: 112px;
    padding: 5px 8px;
    background: #fff;
}

.date-cell strong {
    display: inline-block;
    min-width: 62px;
}

.date-cell span {
    color: #666;
}

.booking-cell {
    width: 64px;
    min-width: 64px;
    height: 30px;
    padding: 4px;
    text-align: center;
    vertical-align: middle;
    background: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 700;
}

tr.weekend td {
    background: #e9e9e9;
}

.month-toggle {
    cursor: pointer;
}

.month-cell {
    height: 34px;
    padding: 8px 10px;
    background: #111 !important;
    color: #fff;
    font-size: 15px;
    border-top: 3px solid #111;
    border-bottom: 3px solid #111 !important;
}

.month-arrow {
    display: inline-block;
    width: 20px;
    margin-right: 4px;
}

.day-row.is-collapsed {
    display: none;
}

.booking-cell.booked {
    background: #ff1f1f !important;
    color: #000;
    cursor: pointer;
}

.booking-cell.free {
    cursor: pointer;
}

.booking-cell.free:hover {
    background: #f1f1f1;
}

.today-highlight td {
    outline: 3px solid #ff1f1f;
    outline-offset: -3px;
}

.booking-list {
    margin: 18px;
    padding: 18px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.booking-list h2 {
    margin: 0 0 12px;
    font-size: 18px;
}

.booking-row,
.item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.booking-row:last-child,
.item-row:last-child {
    border-bottom: 0;
}

.booking-row span,
.booking-row small {
    display: block;
    color: #666;
    margin-top: 3px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 200;
}

.modal.show {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}

.modal-box h3 {
    margin-top: 0;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

.danger-button {
    border: 0;
    border-radius: 8px;
    padding: 8px 10px;
    background: #222;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.card-form {
    max-width: 760px;
    margin: 18px auto;
    padding: 18px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.card-form.compact {
    max-width: 520px;
}

.card-form label {
    display: block;
    font-weight: 700;
    margin-bottom: 14px;
}

.card-form input[type="text"],
.card-form input[type="date"],
.card-form input:not([type]) {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 10px;
    font-size: 16px;
}

.date-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.card-form h2 {
    margin: 20px 0 12px;
    font-size: 18px;
}

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

.check-card {
    display: flex !important;
    align-items: center;
    gap: 8px;
    margin: 0 !important;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fafafa;
}

.check-card input {
    width: 20px;
    height: 20px;
}

.submit-button {
    margin-top: 18px;
    width: 100%;
    font-size: 16px;
}

.item-list {
    max-width: 520px;
    margin: 18px auto;
    padding: 0 18px 24px;
}

.item-list .item-row {
    padding: 10px 12px;
    margin-bottom: 6px;
    background: #fff;
    border-radius: 10px;
}

@media (max-width: 700px) {
    .booking-row,
    .item-row {
        align-items: flex-start;
    }

    .danger-button {
        padding: 8px 9px;
        font-size: 12px;
    }

    body {
        font-size: 13px;
    }

    .topbar {
        align-items: flex-start;
        padding: 12px;
    }

    .topbar h1 {
        font-size: 18px;
    }

    .button {
        padding: 9px 11px;
        font-size: 13px;
    }

    .tablewrap {
        height: calc(100vh - 70px);
    }

    .date-head,
    .date-cell {
        min-width: 88px;
    }

    .date-cell {
        padding: 4px 6px;
    }

    .date-cell strong {
        display: block;
        min-width: 0;
    }

    .gear-table thead th {
        height: 210px;
    }

    .item-head {
        width: 52px;
        min-width: 52px;
        max-width: 52px;
    }

    .item-head span {
        width: 200px;
        transform: translate(-50%, -50%) rotate(-90deg);
        font-size: 12px;
    }

    .booking-cell {
        width: 52px;
        min-width: 52px;
        height: 28px;
        padding: 3px;
        font-size: 12px;
    }

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

    .card-form {
        margin: 12px;
        padding: 14px;
    }
}