:root {
    --mesas-primary: #463075;
    --mesas-primary-dark: color-mix(in srgb, var(--mesas-primary) 82%, #111827);
    --mesas-primary-soft: color-mix(in srgb, var(--mesas-primary) 15%, #ffffff);
    --mesas-border: #e5e7eb;
    --mesas-titulos: var(--mesas-primary-dark);
    /*--mesas-muted:color-mix(in srgb, var(--mesas-primary) 24%, #667085);*/
     --mesas-text: #172033;
    --mesas-muted: #667085;
    --mesas-surface: #ffffff;
    --mesas-bg: #f6f5f8;
    --mesas-shadow: 0 14px 36px rgba(31, 24, 48, 0.08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    background: var(--mesas-bg);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--mesas-text);
    background:
        radial-gradient(circle at 8% 4%, color-mix(in srgb, var(--mesas-primary) 13%, transparent), transparent 28rem),
        var(--mesas-bg);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mesas-page {
    width: calc(100% - 24px);
    margin: 12px auto 32px;
}

.mesas-hero,
.mesas-board,
.convidados-panel {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--mesas-border);
    border-radius: 22px;
    box-shadow: var(--mesas-shadow);
}

.mesas-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 22px;
    margin-bottom: 12px;
}

.mesas-brand,
.mesas-eyebrow {
    display: block;
    color: var(--mesas-primary);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.mesas-hero h1,
.mesas-section-heading h2,
.mover-dialog h2,
.mesas-invalid-card h1 {
    margin: 5px 0 0;
    color: var(--mesas-titulos);
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.mesas-hero h1 {
    font-size: clamp(1.5rem, 3vw, 2.15rem);
}

.mesas-hero p {
    margin: 7px 0 0;
    color: var(--mesas-muted);
}

.mesas-hero-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.mesas-btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 11px;
    border: 1px solid transparent;
    font-weight: 700;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.mesas-btn:hover {
    transform: translateY(-1px);
}

.mesas-btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
.sem-mesa-dropzone:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--mesas-primary) 28%, transparent);
    outline-offset: 2px;
}

.mesas-btn-primary {
    color: #fff;
    background: var(--mesas-primary);
    border-color: var(--mesas-primary);
}

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

.mesas-btn-primary:disabled {
    cursor: wait;
    opacity: 0.65;
    transform: none;
}

.mesas-btn-secondary {
    color: var(--mesas-text);
    background: #fff;
    border-color: #d7dce4;
}

.mesas-dirty-status {
    color: var(--mesas-muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.mesas-dirty-status.is-dirty {
    color: #9a6700;
}

.mesas-message {
    position: sticky;
    top: 12px;
    z-index: 20;
    padding: 13px 16px;
    margin: 0 0 14px;
    border-radius: 12px;
    border: 1px solid #b7dfc5;
    color: #17633a;
    background: #edf9f1;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
    font-weight: 600;
}

.mesas-message.is-error {
    border-color: #f0b9b9;
    color: #9d2525;
    background: #fff0f0;
}

.mesas-board,
.convidados-panel {
    padding: 24px;
}

.mesas-board {
    min-height: 260px;
    margin-bottom: 18px;
}

.mesas-workspace {
    display: block;
}

.mesas-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.mesas-section-heading h2 {
    font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.mesas-section-heading p {
    max-width: 480px;
    margin: 0;
    color: var(--mesas-muted);
    font-size: 0.9rem;
    text-align: right;
}

.mesas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 14px;
    align-items: stretch;
}

.mesa-card {
    min-height: 210px;
    display: flex;
    flex-direction: column;
    border: 1px solid #dce0e7;
    border-radius: 16px;
    background: #fbfbfc;
    overflow: hidden;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.mesa-card.is-drag-over {
    border-color: var(--mesas-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--mesas-primary) 12%, transparent);
    transform: translateY(-2px);
}

.mesa-card-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid #e8eaf0;
    background: #fff;
}

.mesa-name-input {
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--mesas-text);
    background: transparent;
    font-weight: 700;
}

.mesa-name-input:hover,
.mesa-name-input:focus {
    border-color: #d7dce4;
    background: #fff;
    outline: none;
}

.mesa-count {
    min-width: 30px;
    padding: 5px 8px;
    border-radius: 999px;
    color: var(--mesas-primary);
    background: var(--mesas-primary-soft);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}

.mesa-delete {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 9px;
    color: #9b2c2c;
    background: transparent;
    font-size: 1.2rem;
}

.mesa-delete:hover {
    background: #fff0f0;
}

.mesa-guests {
    min-height: 150px;
    flex: 1;
    display: flex;
    align-content: flex-start;
    gap: 7px;
    flex-wrap: wrap;
    padding: 12px;
}

.guest-chip {
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid #d8dce5;
    border-radius: 999px;
    color: var(--mesas-text);
    background: #fff;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.04);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: grab;
}

.guest-chip::before {
    content: "••";
    color: var(--mesas-muted);
    letter-spacing: -2px;
}

.guest-chip:active {
    cursor: grabbing;
}

.mesa-empty-hint {
    width: 100%;
    align-self: center;
    color: var(--mesas-muted);
    font-size: 0.83rem;
    text-align: center;
}

.mesas-empty {
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px dashed #cfd4de;
    border-radius: 16px;
    color: var(--mesas-muted);
    text-align: center;
}

.mesas-empty strong {
    color: var(--mesas-text);
}

.contador-distribuicao {
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--mesas-primary);
    background: var(--mesas-primary-soft);
    font-size: 0.88rem;
}

.sem-mesa-dropzone {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 62px;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 1px dashed #c9ced8;
    border-radius: 13px;
    color: var(--mesas-muted);
    background: #fafafa;
    transition: border-color 150ms ease, background 150ms ease;
}

.sem-mesa-dropzone strong {
    color: var(--mesas-text);
}

.sem-mesa-dropzone span {
    font-size: 0.85rem;
}

.sem-mesa-dropzone.is-drag-over {
    border-color: var(--mesas-primary);
    background: var(--mesas-primary-soft);
}

.convidados-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.busca-convidado {
    flex: 1;
}

.busca-convidado input {
    width: 100%;
    min-height: 44px;
    padding: 10px 13px;
    border: 1px solid #d8dde6;
    border-radius: 11px;
    color: var(--mesas-text);
    background: #fff;
}

.filtros-convidados {
    display: flex;
    gap: 5px;
    padding: 4px;
    border: 1px solid #e1e4e9;
    border-radius: 11px;
    background: #f7f7f8;
}

.filtros-convidados button {
    min-height: 34px;
    padding: 7px 11px;
    border: 0;
    border-radius: 8px;
    color: var(--mesas-muted);
    background: transparent;
    font-size: 0.8rem;
    font-weight: 700;
}

.filtros-convidados button.filtro-ativo {
    color: var(--mesas-primary);
    background: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.07);
}

.convidados-table-wrap {
    overflow: hidden;
    border: 1px solid var(--mesas-border);
    border-radius: 14px;
}

.convidados-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.convidados-table th,
.convidados-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #eceef2;
    text-align: left;
}

.convidados-table th {
    color: var(--mesas-muted);
    background: #f9fafb;
    font-size: 0.72rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.convidados-table th:nth-child(2),
.convidados-table td:nth-child(2) {
    width: 28%;
}

.convidados-table th:last-child,
.convidados-table td:last-child {
    width: 100px;
    text-align: right;
}

.convidado-row {
    transition: background 120ms ease;
}

.convidado-row:hover {
    background: #fbfbfd;
}

.convidado-drag-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    cursor: grab;
}

.convidado-drag-handle {
    color: var(--mesas-muted);
    font-size: 0.8rem;
    letter-spacing: -2px;
}

.convidado-mesa-badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--mesas-text);
    background: #f1f3f6;
    font-size: 0.78rem;
    font-weight: 600;
}

.convidado-mesa-badge.is-unassigned {
    color: #8a5a00;
    background: #fff7dc;
}

.convidado-move {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid #d8dde6;
    border-radius: 9px;
    color: var(--mesas-primary);
    background: #fff;
    font-weight: 700;
}

.convidados-empty {
    padding: 28px;
    color: var(--mesas-muted);
    text-align: center;
}

.mover-dialog {
    width: min(460px, calc(100% - 28px));
    padding: 0;
    border: 0;
    border-radius: 18px;
    color: var(--mesas-text);
    box-shadow: 0 26px 80px rgba(15, 23, 42, 0.28);
}

.mover-dialog::backdrop {
    background: rgba(18, 24, 38, 0.48);
    backdrop-filter: blur(3px);
}

.mover-dialog form {
    padding: 22px;
}

.mover-dialog-header {
    margin-bottom: 19px;
}

.mover-dialog-header p {
    margin: 8px 0 0;
    color: var(--mesas-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

.mover-dialog h2 {
    font-size: 1.45rem;
}

.mover-dialog label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.85rem;
    font-weight: 700;
}

.mover-dialog select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid #d8dde6;
    border-radius: 10px;
    background: #fff;
}

.adicionar-dialog-fields {
    display: grid;
    gap: 7px;
}

.adicionar-dialog-fields label {
    margin: 5px 0 0;
}

.adicionar-dialog-fields input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #d8dde6;
    border-radius: 10px;
    color: var(--mesas-text);
    background: #fff;
}

.mover-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
}

.mesas-invalid-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.mesas-invalid-card {
    width: min(520px, 100%);
    padding: 36px;
    border: 1px solid var(--mesas-border);
    border-radius: 22px;
    background: #fff;
    box-shadow: var(--mesas-shadow);
    text-align: center;
}

.mesas-invalid-card h1 {
    margin-top: 12px;
}

.mesas-invalid-card p {
    color: var(--mesas-muted);
}

.mesas-noscript {
    position: fixed;
    inset: auto 16px 16px;
    padding: 14px;
    border-radius: 10px;
    color: #fff;
    background: #9d2525;
    text-align: center;
}

.rodape {
color: #463075;
color: #463075;
font-size: 0.8rem;
text-align: center;
}

@media (min-width: 960px) {
    .mesas-page {
        height: calc(100vh - 24px);
        height: calc(100dvh - 24px);
        display: flex;
        flex-direction: column;
        margin-top: 12px;
        margin-bottom: 12px;
        overflow: hidden;
    }

    .mesas-workspace {
        min-height: 0;
        flex: 1;
        display: grid;
        grid-template-columns: minmax(250px, 292px) minmax(0, 1fr);
        grid-template-areas: "convidados mesas";
        gap: 12px;
        align-items: stretch;
    }

    .mesas-board {
        grid-area: mesas;
        min-width: 0;
        min-height: 0;
        height: 100%;
        margin-bottom: 0;
        padding: 18px;
        overflow-y: auto;
    }

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

    .convidados-panel {
        grid-area: convidados;
        position: static;
        display: flex;
        flex-direction: column;
        height: 100%;
        max-height: none;
        min-width: 0;
        overflow: hidden;
        padding: 13px;
        border-radius: 16px;
        box-shadow: 0 8px 22px rgba(31, 24, 48, 0.06);
    }

    .convidados-heading {
        display: flex;
        align-items: stretch;
        flex-direction: column;
        gap: 8px;
        margin-bottom: 10px;
    }

    .convidados-heading h2 {
        margin-top: 3px;
        font-size: 1.2rem;
    }

    .contador-distribuicao {
        align-self: flex-start;
        padding: 6px 9px;
        font-size: 0.76rem;
    }

    .sem-mesa-dropzone {
        min-height: 44px;
        padding: 8px 10px;
        margin-bottom: 9px;
        border-radius: 10px;
    }

    .sem-mesa-dropzone span {
        display: none;
    }

    .convidados-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 7px;
        margin-bottom: 9px;
    }

    .busca-convidado input {
        min-height: 38px;
        padding: 8px 10px;
        border-radius: 9px;
        font-size: 0.82rem;
    }

    .filtros-convidados {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 2px;
        padding: 3px;
        border-radius: 9px;
    }

    .filtros-convidados button {
        min-width: 0;
        min-height: 30px;
        padding: 5px 3px;
        font-size: 0.66rem;
        line-height: 1.1;
    }

    .convidados-table-wrap {
        min-height: 0;
        flex: 1;
        overflow-x: hidden;
        overflow-y: auto;
        border-radius: 10px;
    }

    .convidados-table,
    .convidados-table tbody {
        display: block;
        width: 100%;
    }

    .convidados-table thead {
        display: none;
    }

    .convidado-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "nome acao"
            "mesa acao";
        align-items: center;
        width: 100%;
        border-bottom: 1px solid #eceef2;
    }

    .convidados-table td {
        width: auto !important;
        border-bottom: 0;
    }

    .convidados-table td:first-child {
        grid-area: nome;
        min-width: 0;
        padding: 7px 4px 1px 8px;
    }

    .convidados-table td:nth-child(2) {
        grid-area: mesa;
        padding: 2px 4px 7px 25px;
    }

    .convidados-table td:last-child {
        grid-area: acao;
        padding: 7px 7px 7px 3px;
    }

    .convidado-drag-name {
        min-width: 0;
        gap: 6px;
        font-size: 0.8rem;
    }

    .convidado-drag-name span:last-child {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .convidado-drag-handle {
        font-size: 0.7rem;
    }

    .convidado-mesa-badge {
        max-width: 150px;
        padding: 3px 7px;
        overflow: hidden;
        font-size: 0.66rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .convidado-move {
        min-height: 30px;
        padding: 5px 7px;
        border-radius: 7px;
        font-size: 0.68rem;
    }

    .convidados-empty {
        padding: 18px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 760px) {
    .mesas-page {
        width: min(100% - 20px, 1440px);
        margin-top: 10px;
    }

    .mesas-hero,
    .mesas-section-heading,
    .convidados-controls {
        align-items: stretch;
        flex-direction: column;
    }

    .mesas-hero,
    .mesas-board,
    .convidados-panel {
        padding: 17px;
        border-radius: 16px;
    }

    .convidados-panel {
        margin-top: 18px;
    }

    .mesas-hero-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        justify-content: stretch;
    }

    .mesas-hero-actions #salvar-distribuicao {
        grid-column: 1 / -1;
    }

    .mesas-dirty-status {
        grid-column: 1 / -1;
    }

    .mesas-section-heading p {
        text-align: left;
    }

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

    .guest-chip,
    .convidado-drag-handle {
        cursor: default;
    }

    .sem-mesa-dropzone {
        display: none;
    }

    .filtros-convidados {
        overflow-x: auto;
    }

    .filtros-convidados button {
        flex: 0 0 auto;
    }

    .convidados-table th:nth-child(2),
    .convidados-table td:nth-child(2) {
        width: auto;
    }

    .convidados-table th,
    .convidados-table td {
        padding: 11px 9px;
    }

    .convidado-drag-name {
        gap: 5px;
    }

    .convidado-drag-handle {
        display: none;
    }

    .convidado-mesa-badge {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mover-dialog-actions {
        flex-direction: column-reverse;
    }

    .mover-dialog-actions .mesas-btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
