:root {
    --bg: #f3f5f8;
    --ink: #172033;
    --muted: #667085;
    --line: #d8dee8;
    --panel: #ffffff;
    --soft: #eef4f3;
    --primary: #315c73;
    --primary-dark: #244457;
    --accent: #c47b61;
    --success: #157347;
    --danger: #b42318;
    --shadow: 0 16px 40px rgba(23, 32, 51, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

body.menu-open {
    overflow: hidden;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    width: 260px;
    background: #172033;
    color: #fff;
    padding: 22px;
}

.mobile-topbar {
    display: none;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(23, 32, 51, .48);
}

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

.brand {
    margin-bottom: 30px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
}

.brand small,
.auth-brand small,
.row span,
.card span,
.card small,
.page-header p,
.eyebrow {
    color: var(--muted);
}

.brand small,
.auth-brand small {
    display: block;
    color: #b9c0cc;
}

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

.sidebar nav a,
.sidebar-footer button {
    border-radius: 8px;
    padding: 12px;
    color: #dbe1ea;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar-footer {
    display: grid;
    gap: 10px;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-top: 18px;
}

.sidebar-footer span {
    color: #b9c0cc;
    font-size: 13px;
}

.sidebar-footer button {
    border: 0;
    background: rgba(255, 255, 255, .08);
    cursor: pointer;
    text-align: left;
}

.main {
    margin-left: 260px;
    padding: 34px;
}

.page-header,
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 6px;
    font-size: 34px;
}

h2 {
    margin-bottom: 16px;
    font-size: 20px;
}

.eyebrow {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

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

.button.secondary {
    background: #e6eaf0;
    color: var(--ink);
}

.link-danger {
    width: fit-content;
    border: 0;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff1f0;
    color: var(--danger);
    font-weight: 800;
    cursor: pointer;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stats article,
.panel,
.card,
.quick-actions a,
.auth-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.stats article {
    padding: 20px;
    border-top: 4px solid var(--accent);
}

.stats span {
    display: block;
    color: var(--muted);
}

.stats strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
}

.panel {
    margin-bottom: 20px;
    padding: 20px;
}

.table-list {
    display: grid;
    gap: 8px;
}

.row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(110px, auto));
    align-items: center;
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.row:hover {
    border-color: #b9c6d4;
}

.row strong,
.row span {
    display: block;
}

.split,
.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.quick-actions a {
    display: grid;
    gap: 6px;
    padding: 20px;
}

.quick-actions span {
    color: var(--muted);
}

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

.form-stack {
    display: grid;
    gap: 14px;
}

.wide {
    grid-column: 1 / -1;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(49, 92, 115, .16);
    border-color: var(--primary);
}

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

.card {
    display: grid;
    gap: 6px;
    padding: 16px;
}

.badge {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 10px;
    background: var(--soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.notice {
    margin-bottom: 18px;
    border-radius: 8px;
    padding: 12px 14px;
    background: #e7f7ee;
    color: var(--success);
}

.notice.error {
    background: #fff1f0;
    color: var(--danger);
}

.empty {
    margin: 0;
    color: var(--muted);
}

.search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-bottom: 20px;
}

.check-row {
    grid-template-columns: minmax(220px, 1fr) 130px 110px auto;
}

.provider-row {
    grid-template-columns: minmax(220px, 1fr) 120px minmax(120px, auto) minmax(120px, auto);
}

.finance-row {
    grid-template-columns: minmax(220px, 1fr) 120px 120px 140px 110px;
}

.layout-row {
    grid-template-columns: minmax(160px, 1fr) 130px 100px 80px 80px auto;
}

.simple-layout-row {
    grid-template-columns: minmax(180px, 1fr) 150px 120px;
}

.layout-tools {
    align-items: stretch;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(150px, 1.2fr) 130px minmax(150px, 1fr) 110px 110px 140px 120px auto;
    gap: 10px;
    margin-bottom: 18px;
}

.finance-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.finance-summary article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--soft);
}

.finance-summary span,
.timeline span {
    color: var(--muted);
}

.finance-summary strong {
    display: block;
    margin-top: 6px;
    font-size: 22px;
}

.calendar-grid {
    display: grid;
    gap: 20px;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline a {
    display: grid;
    grid-template-columns: 62px 1fr;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.timeline time {
    display: grid;
    place-items: center;
    min-height: 46px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.floor-plan {
    position: relative;
    min-height: 520px;
    margin-bottom: 20px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(49, 92, 115, .08) 1px, transparent 1px),
        linear-gradient(rgba(49, 92, 115, .08) 1px, transparent 1px),
        #fff;
    background-size: 40px 40px;
    box-shadow: var(--shadow);
}

.map-mode {
    margin-bottom: 20px;
}

.map-add-button {
    position: absolute;
    right: 18px;
    top: 18px;
    z-index: 10;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 32px;
    font-weight: 800;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.map-add-button span {
    position: absolute;
    right: 62px;
    width: max-content;
    border-radius: 8px;
    padding: 8px 10px;
    background: #172033;
    color: #fff;
    font-size: 13px;
    opacity: 0;
    transform: translateX(6px);
    transition: .16s ease;
    pointer-events: none;
}

.map-add-button:hover span {
    opacity: 1;
    transform: translateX(0);
}

.map-popup {
    position: absolute;
    right: 18px;
    top: 82px;
    z-index: 20;
    width: min(360px, calc(100% - 36px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fff;
    box-shadow: var(--shadow);
}

.map-popup.anchored {
    position: absolute;
    right: auto;
}

.edit-popup {
    right: 18px;
    top: 82px;
}

.map-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.map-popup-header button {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: #e6eaf0;
    color: var(--ink);
    font-size: 22px;
    cursor: pointer;
}

.floor-table {
    position: absolute;
    display: grid;
    place-items: center;
    width: 122px;
    min-height: 122px;
    transform: translate(-50%, -50%);
    border: 2px solid var(--primary);
    background: #fff;
    box-shadow: var(--shadow);
    text-align: center;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.floor-table .table-edit-button {
    position: absolute;
    top: 18px;
    right: -74px;
    transform: none;
    border: 0;
    border-radius: 999px;
    padding: 6px 10px;
    background: #172033;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    opacity: 0;
    transition: .16s ease;
}

.floor-table .table-guests-button {
    position: absolute;
    right: -74px;
    top: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    padding: 0 10px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.floor-table:hover .table-edit-button,
.floor-table .table-edit-button:focus {
    opacity: 1;
}

.floor-table.dragging {
    z-index: 5;
    cursor: grabbing;
    border-color: var(--accent);
    transform: translate(-50%, -50%) scale(1.04);
}

.floor-table.round {
    border-radius: 999px;
}

.floor-table.rectangle {
    width: 150px;
    border-radius: 8px;
}

.floor-table span {
    color: var(--muted);
    font-size: 13px;
}

.seats {
    position: absolute;
    inset: -20px;
    pointer-events: none;
}

.seats i {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 16px;
    margin: -8px -7px;
    border-radius: 4px 4px 7px 7px;
    background: var(--accent);
    transform:
        rotate(calc(360deg / var(--seats) * var(--i)))
        translate(78px)
        rotate(calc(-360deg / var(--seats) * var(--i)));
}

.seats i::before {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    top: -5px;
    height: 6px;
    border-radius: 4px 4px 2px 2px;
    background: #a96750;
}

.seats i::after {
    content: "";
    position: absolute;
    left: 3px;
    right: 3px;
    bottom: -3px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: #a96750;
}

.seats i:nth-child(1) { --i: 1; }
.seats i:nth-child(2) { --i: 2; }
.seats i:nth-child(3) { --i: 3; }
.seats i:nth-child(4) { --i: 4; }
.seats i:nth-child(5) { --i: 5; }
.seats i:nth-child(6) { --i: 6; }
.seats i:nth-child(7) { --i: 7; }
.seats i:nth-child(8) { --i: 8; }
.seats i:nth-child(9) { --i: 9; }
.seats i:nth-child(10) { --i: 10; }
.seats i:nth-child(11) { --i: 11; }
.seats i:nth-child(12) { --i: 12; }
.seats i:nth-child(13) { --i: 13; }
.seats i:nth-child(14) { --i: 14; }
.seats i:nth-child(15) { --i: 15; }
.seats i:nth-child(16) { --i: 16; }

.guests-popup {
    left: 18px;
    right: auto;
    top: 18px;
}

.guest-arrival-summary {
    margin-bottom: 12px;
}

.guest-arrival-summary span {
    display: inline-flex;
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--soft);
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
}

.guest-arrival-list {
    display: grid;
    gap: 8px;
    max-height: 270px;
    overflow: auto;
}

.guest-arrival-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.guest-arrival-item.arrived {
    border-color: rgba(21, 115, 71, .28);
    background: #f1fbf5;
}

.guest-arrival-item span {
    color: var(--muted);
    font-size: 13px;
}

.auth-screen {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(49, 92, 115, .92), rgba(196, 123, 97, .82)),
        #172033;
}

.auth-card {
    width: min(440px, 100%);
    padding: 30px;
}

.auth-card h1 {
    margin-top: 28px;
}

.auth-brand small {
    color: var(--muted);
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.check-label input {
    width: auto;
}

.preview-band {
    display: grid;
    gap: 6px;
    border-radius: 8px;
    padding: 18px;
    background: linear-gradient(90deg, var(--preview-primary), var(--preview-accent));
    color: #fff;
}

.preview-band span {
    color: rgba(255, 255, 255, .78);
}

@media (max-width: 840px) {
    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 25;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        min-height: 64px;
        border-bottom: 1px solid var(--line);
        padding: 10px 16px;
        background: #fff;
        box-shadow: 0 8px 24px rgba(23, 32, 51, .08);
    }

    .mobile-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }

    .mobile-brand .brand-mark {
        width: 38px;
        height: 38px;
        font-size: 12px;
    }

    .menu-toggle {
        display: grid;
        gap: 5px;
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: 8px;
        padding: 11px;
        background: var(--primary);
        cursor: pointer;
    }

    .menu-toggle span {
        display: block;
        height: 3px;
        border-radius: 999px;
        background: #fff;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(82vw, 310px);
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    body.menu-open .sidebar {
        transform: translateX(0);
    }

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

    .stats,
    .split,
    .quick-actions,
    .finance-summary,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .page-header,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .actions,
    .actions .button {
        width: 100%;
    }

    .actions .button {
        justify-content: center;
    }

    .row,
    .check-row,
    .provider-row,
    .finance-row,
    .layout-row,
    .simple-layout-row,
    .inline-form,
    .search {
        grid-template-columns: 1fr;
    }

    .floor-plan {
        min-height: 560px;
        overflow: auto;
    }

    .floor-table {
        width: 106px;
        min-height: 106px;
    }

    .floor-table.rectangle {
        width: 128px;
    }

    .floor-table .table-edit-button {
        top: 10px;
        right: -64px;
        opacity: 1;
    }

    .floor-table .table-guests-button {
        right: -64px;
        top: 46px;
    }

    .map-add-button {
        position: sticky;
        left: calc(100% - 68px);
        top: 16px;
    }

    .map-add-button span {
        display: none;
    }

    .map-popup,
    .guests-popup {
        position: sticky;
        left: 12px;
        right: 12px;
        top: 76px;
        width: calc(100% - 24px);
        max-height: calc(100vh - 120px);
        overflow: auto;
    }

    .map-popup.anchored,
    .guests-popup.anchored {
        position: absolute;
        width: min(360px, calc(100% - 24px));
    }

    .guest-arrival-item {
        grid-template-columns: 1fr;
    }
}
