:root {
    --mesas-bg: #161a22;
    --mesas-main: rgba(27, 31, 40, 0.98);
    --mesas-card: rgba(255, 255, 255, 0.04);
    --mesas-border: rgba(255, 255, 255, 0.08);
    --mesas-text: #f5f7fb;
    --mesas-muted: #9ba3b4;
    --mesas-shadow: 0 24px 44px rgba(9, 9, 18, 0.34);
    --mesas-primary: #34c759;
    --mesas-primary-soft: rgba(52, 199, 89, 0.16);
    --mesas-primary-start: #46d96f;
    --mesas-primary-end: #2ea958;
    --mesas-button-soft: #f4f2ee;
    --mesas-button-soft-text: #252736;
    --mesas-warm: #ef8b67;
    --mesas-danger: #ff6b4a;
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: var(--meseros-font-family);
    color: var(--mesas-text);
    background:
        radial-gradient(circle at top left, rgba(52, 199, 89, 0.1), transparent 22rem),
        radial-gradient(circle at bottom right, rgba(52, 199, 89, 0.07), transparent 26rem),
        var(--mesas-bg);
}

.mesas-shell {
    min-height: 100vh;
    display: flex;
    gap: 1.4rem;
    padding: 1rem;
}

.mesas-main {
    flex: 1;
    min-width: 0;
    padding: 1.6rem;
    border-radius: 32px;
    background: linear-gradient(180deg, rgba(31, 35, 45, 0.98), rgba(24, 27, 36, 0.98));
    box-shadow: var(--mesas-shadow);
}

.mesas-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.2rem;
    margin-bottom: 1.35rem;
}

.mesas-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #8f97a8;
}

.mesas-title {
    font-size: clamp(1.85rem, 2.8vw, 2.45rem);
    font-weight: 800;
}

.mesas-subtitle {
    max-width: 42rem;
    font-size: 0.95rem;
    color: var(--mesas-muted);
}

.mesas-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.mesas-search,
.mesas-select {
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid var(--mesas-border);
    background: rgba(255, 255, 255, 0.04);
}

.mesas-search {
    min-width: 270px;
    padding: 0.35rem 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.mesas-search input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--mesas-text);
    font-size: 0.92rem;
}

.mesas-search input::placeholder {
    color: var(--mesas-muted);
}

.mesas-search-icon svg {
    width: 18px;
    height: 18px;
    color: var(--mesas-muted);
}

.mesas-select {
    min-width: 148px;
    padding: 0 2.2rem 0 0.9rem;
    color: var(--mesas-text);
    outline: 0;
    appearance: none;
    -webkit-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, #d8dbe6 50%),
        linear-gradient(135deg, #d8dbe6 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(1.05rem), calc(100% - 12px) calc(1.05rem);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    cursor: pointer;
}

.mesas-select option {
    color: #252736;
    background: #ffffff;
}

.mesas-select:focus,
.mesas-search:focus-within {
    border-color: rgba(52, 199, 89, 0.35);
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.12);
}

.layout-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-layout-primary,
.btn-layout-secondary,
.btn-layout-link {
    min-height: 48px;
    padding: 0.72rem 1.05rem;
    border-radius: 14px;
    font-size: 0.92rem;
    font-weight: 700;
}

.btn-layout-primary {
    color: #fff;
    background: #FF6709;
    border: 0;
    box-shadow: 0 12px 24px rgba(255, 103, 9, 0.22);
}

.btn-layout-secondary {
    color: var(--mesas-button-soft-text);
    background: var(--mesas-button-soft);
    border: 1px solid rgba(37, 39, 54, 0.12);
}

.btn-layout-link {
    color: var(--mesas-warm);
    background: transparent;
    border: 0;
}

.btn-layout-primary:hover,
.btn-layout-primary:focus {
    color: #fff;
    background: #ff7a22;
}

.btn-layout-secondary:hover,
.btn-layout-secondary:focus {
    color: #1f2230;
    background: #ffffff;
}

.btn-layout-link:hover,
.btn-layout-link:focus {
    color: #ff9f7e;
}

.mesas-board {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 1rem;
    min-height: 680px;
}

.tables-sidebar,
.layout-panel {
    border-radius: 26px;
    border: 1px solid var(--mesas-border);
    background: var(--mesas-card);
}

.tables-sidebar {
    padding: 0.8rem;
}

.tables-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 100%;
    overflow: auto;
    padding-right: 0.2rem;
}

.table-list-item {
    width: 100%;
    padding: 0.92rem 0.95rem;
    border: 1px solid transparent;
    border-radius: 18px;
    background: transparent;
    color: inherit;
    text-align: left;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.table-list-item:hover,
.table-list-item.is-selected {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(52, 199, 89, 0.22);
    transform: translateY(-1px);
}

.table-list-top,
.table-list-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.table-list-top {
    margin-bottom: 0.38rem;
}

.table-list-name {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 700;
}

.table-state-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--mesas-primary);
}

.table-state-dot.is-used {
    background: var(--mesas-danger);
}

.table-list-amount {
    font-weight: 800;
}

.table-list-meta {
    color: var(--mesas-muted);
    font-size: 0.76rem;
}

.table-list-empty {
    padding: 1.15rem;
    border-radius: 18px;
    border: 1px dashed var(--mesas-border);
    color: var(--mesas-muted);
    text-align: center;
}

.layout-panel {
    padding: 1rem;
}

.layout-legend {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    color: var(--mesas-muted);
    font-size: 0.84rem;
}

.layout-legend span {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.dot-available {
    background: var(--mesas-primary);
}

.dot-used {
    background: var(--mesas-danger);
}

.dot-selected {
    background: #1dcf90;
}

.floor-canvas {
    position: relative;
    min-height: 595px;
    border-radius: 22px;
    border: 1px solid var(--mesas-border);
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.1) 1px, transparent 1px) 0 0 / 18px 18px,
        rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.cashier-block {
    position: absolute;
    left: 10%;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 168px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.07);
    color: #818899;
    display: grid;
    place-items: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.layout-table {
    position: absolute;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--mesas-text);
    display: grid;
    place-items: center;
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.16);
    font-size: 1.12rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.layout-table:hover {
    transform: translate(-50%, -50%) scale(1.02);
}

.layout-table::before {
    content: attr(data-id);
}

.layout-table.round {
    width: 62px;
    height: 62px;
    border-radius: 999px;
}

.layout-table.square {
    width: 58px;
    height: 58px;
    border-radius: 12px;
}

.layout-table.rect {
    width: 114px;
    height: 58px;
    border-radius: 14px;
}

.layout-table.is-used {
    background:
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08) 4px, rgba(255, 255, 255, 0.01) 4px, rgba(255, 255, 255, 0.01) 10px),
        rgba(255, 255, 255, 0.03);
}

.layout-table.is-selected {
    border-color: #1dcf90;
    box-shadow: 0 0 0 4px rgba(29, 207, 144, 0.16), 0 18px 28px rgba(0, 0, 0, 0.2);
}

.layout-table.is-editing {
    cursor: move;
}

.layout-table.is-rotated.rect {
    width: 58px;
    height: 114px;
}

.table-capacity {
    position: absolute;
    top: -8px;
    right: -8px;
    min-width: 24px;
    height: 24px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #232733;
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 800;
}

.table-action-bar {
    position: absolute;
    padding: 0.38rem;
    border-radius: 14px;
    background: rgba(26, 29, 37, 0.96);
    box-shadow: 0 18px 32px rgba(0, 0, 0, 0.28);
    display: flex;
    gap: 0.3rem;
    z-index: 15;
}

.table-action-bar button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.table-action-bar svg {
    width: 18px;
    height: 18px;
}

.mesas-modal-content {
    border: 0;
    border-radius: 24px;
    overflow: hidden;
    background: #f7f5f1;
    color: #222432;
}

.mesas-modal {
    display: none;
    padding: 1rem !important;
    background: rgba(12, 14, 18, 0.52);
}

.mesas-modal.is-open {
    display: block;
}

.mesas-modal.fade {
    opacity: 0;
    transition: opacity 0.18s ease;
}

.mesas-modal.fade.show,
.mesas-modal.is-open {
    opacity: 1;
}

.mesas-modal .modal-dialog {
    max-width: 560px;
    margin: 1.75rem auto;
    pointer-events: none;
}

.mesas-modal .modal-content {
    pointer-events: auto;
}

.mesas-modal-header {
    padding: 1.4rem 1.6rem 0.6rem;
    border-bottom: 0;
}

.mesas-modal-title {
    width: 100%;
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
}

.mesas-modal-close {
    background: transparent;
    border: 0;
    color: #88818f;
    font-size: 2rem;
    line-height: 1;
}

.mesas-modal-body {
    padding: 0 1.6rem 1.6rem;
}

.add-table-form {
    display: grid;
    gap: 1rem;
}

.add-table-form label {
    margin-bottom: 0.45rem;
    font-weight: 700;
}

.mesas-input {
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid rgba(34, 36, 50, 0.12);
    background: #fff;
}

.form-hint {
    display: block;
    margin-top: 0.45rem;
    color: #978f9b;
}

.type-note {
    padding: 1rem;
    border-radius: 16px;
    background: #eceae6;
    color: #5f5b67;
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    font-size: 0.9rem;
}

.type-note-badge {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    background: #34363e;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    flex: 0 0 auto;
}

.mesas-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.mesas-btn {
    min-height: 48px;
    border-radius: 14px;
    font-weight: 700;
}

.mesas-btn-muted {
    background: #fff;
    color: #433d4d;
    border: 1px solid rgba(67, 61, 77, 0.14);
}

.mesas-btn-primary {
    background: linear-gradient(135deg, var(--mesas-primary-start), var(--mesas-primary-end));
    color: #fff;
    border: 0;
}

body.theme-light {
    --mesas-bg: #f3eee6;
    --mesas-main: rgba(255, 255, 255, 0.96);
    --mesas-card: rgba(31, 35, 45, 0.04);
    --mesas-border: rgba(31, 35, 45, 0.08);
    --mesas-text: #242735;
    --mesas-muted: #6f7582;
    color-scheme: light;
}

body.theme-light .mesas-main {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 244, 238, 0.98));
}

body.theme-light .mesas-select {
    background-image:
        linear-gradient(45deg, transparent 50%, #656b79 50%),
        linear-gradient(135deg, #656b79 50%, transparent 50%);
}

body.theme-light .cashier-block,
body.theme-light .mesas-search,
body.theme-light .mesas-select,
body.theme-light .layout-table,
body.theme-light .table-list-item:hover,
body.theme-light .table-list-item.is-selected {
    background-color: rgba(31, 35, 45, 0.04);
}

body.theme-light .btn-layout-secondary {
    background: #ffffff;
    color: #252736;
}

body.theme-light .layout-table {
    border-color: rgba(31, 35, 45, 0.12);
}

body.theme-light .table-capacity {
    background: #262a33;
}

body.theme-light .table-action-bar {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(31, 35, 45, 0.08);
}

body.theme-light .table-action-bar button {
    background: rgba(31, 35, 45, 0.06);
    color: #242735;
}

@media (max-width: 1199.98px) {
    .mesas-toolbar {
        flex-direction: column;
    }

    .mesas-toolbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .mesas-board {
        grid-template-columns: 1fr;
    }

    .tables-sidebar {
        min-height: 220px;
    }

    .tables-list {
        max-height: 220px;
    }
}

@media (max-width: 767.98px) {
    .mesas-shell {
        flex-direction: column;
    }

    .mesas-main {
        padding: 1rem;
        border-radius: 24px;
    }

    .mesas-toolbar-actions,
    .layout-actions,
    .layout-actions .btn,
    .mesas-select,
    .mesas-search {
        width: 100%;
    }

    .floor-canvas {
        min-height: 520px;
        overflow: auto;
    }

    .cashier-block {
        left: 12%;
        width: 54px;
        height: 150px;
    }

    .mesas-modal-actions {
        grid-template-columns: 1fr;
    }

    .mesas-modal .modal-dialog {
        margin: 0.75rem auto;
    }
}

@media (max-width: 575.98px) {
    .mesas-toolbar {
        margin-bottom: 1rem;
    }

    .layout-legend {
        gap: 0.75rem;
    }

    .table-list-item {
        padding: 0.85rem;
    }
}
