body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #111827;
    color: #fff;
}

* {
    box-sizing: border-box;
}

header {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: #0f172a;
    flex-wrap: wrap;
}

h1 {
    font-size: 22px;
    margin: 0;
    flex: 1;
}

h2, h3 {
    margin-top: 0;
}

button {
    padding: 10px 14px;
    border: 0;
    border-radius: 8px;
    background: #14b8a6;
    color: white;
    font-weight: 700;
    cursor: pointer;
}

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

.tab {
    background: #334155;
}

.tab.active {
    background: #14b8a6;
}

main {
    display: grid;
    grid-template-columns: 1fr 320px;
    height: calc(100vh - 64px);
    overflow: hidden;
}

.layoutWorkspace {
    background: #e5e7eb;
    overflow: auto;
    padding: 12px;
}

.layoutToolbar {
    min-width: 1600px;
    display: grid;
    grid-template-columns: 220px 110px 1fr 100px 100px 140px 140px;
    gap: 10px;
    align-items: end;
    margin-bottom: 10px;
    color: #111827;
}

.layoutToolbar label {
    margin: 0;
    color: #334155;
    font-size: 13px;
}

.layoutToolbar input,
.layoutToolbar select {
    background: white;
    color: #111827;
    border: 1px solid #cbd5e1;
}

.hidden {
    display: none !important;
}

.canvas {
    position: relative;
    width: 1600px;
    height: 900px;
    min-height: 900px;
    background: #f8fafc;
    background-size: 100% 100%;
    background-position: center;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
    overflow: hidden;
}

.table-card {
    position: absolute;
    color: white;
    text-align: center;
    border-radius: 16px;
    font-weight: 800;
    cursor: move;
    user-select: none;
    touch-action: none;
    z-index: 5;
    transform-origin: center center;
}

.table-card .table-label {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-shadow: 0 1px 2px rgba(0,0,0,.5);
    pointer-events: none;
}

.table-type-label {
    font-size: 11px;
    opacity: .85;
}

.furniture {
    position: absolute;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .32);
}

.furniture-table {
    left: 28%;
    top: 30%;
    width: 44%;
    height: 40%;
    background: #d8c48a;
    border: 2px solid #5b4630;
    z-index: 3;
}

.furniture-a, .furniture-b, .furniture-c {
    background: #334155;
    border: 2px solid #94a3b8;
    z-index: 2;
}

.table-type-sofa_3 .furniture-a { left: 8%; top: 8%; width: 84%; height: 22%; }
.table-type-sofa_3 .furniture-b { left: 8%; bottom: 8%; width: 84%; height: 22%; }
.table-type-sofa_3 .furniture-c { left: 4%; top: 30%; width: 22%; height: 40%; }

.table-type-sofa_2 .furniture-a { left: 8%; top: 8%; width: 84%; height: 24%; }
.table-type-sofa_2 .furniture-b { left: 8%; bottom: 8%; width: 84%; height: 24%; }
.table-type-sofa_2 .furniture-c { display: none; }

.table-type-armchairs_2 .furniture-a { left: 4%; top: 30%; width: 26%; height: 40%; border-radius: 18px; }
.table-type-armchairs_2 .furniture-b { right: 4%; top: 30%; width: 26%; height: 40%; border-radius: 18px; }
.table-type-armchairs_2 .furniture-c { display: none; }
.table-type-armchairs_2 .furniture-table { left: 34%; width: 32%; }

.table-type-sofa_corner .furniture-a { left: 8%; top: 8%; width: 80%; height: 22%; }
.table-type-sofa_corner .furniture-b { left: 8%; top: 8%; width: 22%; height: 80%; }
.table-type-sofa_corner .furniture-c { display: none; }

.table-type-round .furniture-table,
.table-card.round .furniture-table { border-radius: 999px; }
.table-type-round .furniture-a { left: 38%; top: 2%; width: 24%; height: 20%; border-radius: 999px; }
.table-type-round .furniture-b { left: 38%; bottom: 2%; width: 24%; height: 20%; border-radius: 999px; }
.table-type-round .furniture-c { left: 2%; top: 38%; width: 20%; height: 24%; border-radius: 999px; }

.table-type-square .furniture-a { left: 38%; top: 2%; width: 24%; height: 20%; }
.table-type-square .furniture-b { left: 38%; bottom: 2%; width: 24%; height: 20%; }
.table-type-square .furniture-c { left: 2%; top: 38%; width: 20%; height: 24%; }

.table-type-bar .furniture-table { left: 10%; top: 38%; width: 80%; height: 24%; }
.table-type-bar .furniture-a { left: 16%; bottom: 4%; width: 18%; height: 24%; border-radius: 999px; }
.table-type-bar .furniture-b { left: 42%; bottom: 4%; width: 18%; height: 24%; border-radius: 999px; }
.table-type-bar .furniture-c { left: 68%; bottom: 4%; width: 18%; height: 24%; border-radius: 999px; }

.table-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 4px solid rgba(22, 163, 74, .85);
    border-radius: 16px;
    pointer-events: none;
}

.table-card:hover {
    filter: brightness(1.05);
}

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

.table-card.selected {
    outline: 6px solid #f59e0b;
    z-index: 50;
}

.table-card.dragging {
    opacity: 0.85;
    z-index: 100;
}

aside {
    background: #1f2937;
    padding: 18px;
    overflow: auto;
}

aside h2 {
    margin-top: 0;
}

label {
    display: block;
    margin: 12px 0;
    color: #cbd5e1;
}

input,
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    margin-top: 6px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #475569;
    background: #0f172a;
    color: #fff;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

.row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#hideButton {
    background: #dc2626;
    margin-top: 10px;
    width: 100%;
}

#saveButton {
    width: 100%;
    margin-top: 12px;
}

.warning {
    background: #f59e0b;
}

.danger {
    background: #dc2626;
}

/* ===== Common light pages ===== */
.reservationsPage,
#crmPage,
#analyticsPage,
#maintenancePage,
#eventsPage,
#notificationsPage,
#qrMenuPage,
#qrPage,
#cleaningPage,
#devicesPage {
    min-height: calc(100vh - 64px);
    background: #f8fafc;
    color: #111827;
    padding: 18px;
    box-sizing: border-box;
}

.reservationsPage h2,
.reservationsPage h3,
#crmPage h2,
#analyticsPage h2,
#maintenancePage h2,
#eventsPage h2,
#notificationsPage h2,
#qrMenuPage h2,
#qrPage h2,
#cleaningPage h2,
#devicesPage h2 {
    color: #111827;
}

.filters,
.crmFilters,
.analyticsFilters,
.qrFilters,
.eventsFilters,
.notificationsFilters,
.maintenanceFilters {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.filters label,
.crmFilters label,
.analyticsFilters label,
.qrFilters label,
.eventsFilters label,
.notificationsFilters label,
.maintenanceFilters label {
    color: #111827;
    margin: 0;
}

.reservationsPage input,
.reservationsPage select,
.reservationsPage textarea,
#crmPage input,
#crmPage select,
#crmPage textarea,
#analyticsPage input,
#analyticsPage select,
#analyticsPage textarea,
#maintenancePage input,
#maintenancePage select,
#maintenancePage textarea,
#eventsPage input,
#eventsPage select,
#eventsPage textarea,
#notificationsPage input,
#notificationsPage select,
#notificationsPage textarea,
#qrMenuPage input,
#qrMenuPage select,
#qrMenuPage textarea,
#qrPage input,
#qrPage select,
#qrPage textarea,
#cleaningPage input,
#cleaningPage select,
#cleaningPage textarea,
#devicesPage input,
#devicesPage select,
#devicesPage textarea {
    background: #ffffff;
    color: #111827;
    border: 1px solid #cbd5e1;
}

.reservationsPage input::placeholder,
#crmPage input::placeholder,
#analyticsPage input::placeholder,
#maintenancePage input::placeholder,
#eventsPage input::placeholder,
#notificationsPage input::placeholder,
#qrMenuPage input::placeholder,
#qrPage input::placeholder,
#cleaningPage input::placeholder,
#devicesPage input::placeholder {
    color: #64748b;
}

.tableWrap,
.card,
.panel,
.sectionCard,
.crmCard,
.analyticsCard,
.qrCard,
.eventCard,
.notificationCard,
.maintenanceCard {
    background: white;
    color: #111827;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.tableWrap {
    max-width: 100%;
    overflow: auto;
}

.reservationTable,
.dataTable,
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.reservationTable th,
.dataTable th,
.tableWrap th,
table th {
    position: sticky;
    top: 0;
    background: #0f172a;
    color: white;
    text-align: left;
    padding: 10px;
}

.reservationTable td,
.dataTable td,
.tableWrap td,
table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 9px;
    vertical-align: top;
    color: #111827;
    background: #ffffff;
}

.reservationTable tr:nth-child(even) td,
.dataTable tr:nth-child(even) td,
.tableWrap tr:nth-child(even) td,
table tr:nth-child(even) td {
    background: #f8fafc;
}

.reservationTable a,
.dataTable a,
.tableWrap a,
table a,
#crmPage a,
#analyticsPage a,
#eventsPage a,
#notificationsPage a,
#maintenancePage a,
#qrMenuPage a,
#qrPage a {
    color: #2563eb;
}

.status-new {
    color: #2563eb;
    font-weight: 700;
}

.status-confirmed {
    color: #0f766e;
    font-weight: 700;
}

.status-cancelled {
    color: #dc2626;
    font-weight: 700;
}

.status-seated {
    color: #16a34a;
    font-weight: 700;
}

.smallBtn {
    padding: 7px 10px;
    font-size: 12px;
    margin: 2px;
}

.cancelBtn {
    background: #dc2626;
}

.finishBtn {
    background: #64748b;
}

.seatBtn {
    background: #16a34a;
}

.muted,
.text-muted,
.help,
.small {
    color: #64748b !important;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #e2e8f0;
    color: #0f172a;
}

pre,
code {
    color: #111827;
}

@media (max-width: 1100px) {
    main {
        grid-template-columns: 1fr;
        height: auto;
    }

    aside {
        order: -1;
    }

    .filters,
    .crmFilters,
    .analyticsFilters,
    .qrFilters,
    .eventsFilters,
    .notificationsFilters,
    .maintenanceFilters {
        flex-direction: column;
        align-items: stretch;
    }
}


/* Visual schema fixes: overlap warning and readable labels on rotated tables */
.table-card.overlap::after {
    border-color: rgba(239, 68, 68, .96) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, .18), 0 0 22px rgba(239, 68, 68, .45);
}
.table-card.overlap .table-label::before {
    content: "НАЛОЖЕНИЕ";
    display: block;
    font-size: 10px;
    line-height: 1;
    padding: 2px 4px;
    margin-bottom: 2px;
    background: rgba(220, 38, 38, .92);
    border-radius: 6px;
    color: #fff;
}
.table-card .table-label {
    transform-origin: center center;
}
