:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #18202a;
    --muted: #657386;
    --line: #dce2ea;
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --danger: #b42318;
    --free: #f8fafc;
    --shadow: 0 18px 40px rgba(21, 31, 44, 0.10);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    overflow-x: hidden;
}

a {
    color: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px clamp(18px, 4vw, 48px);
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.topbar p,
.panel h2,
.toolbar p,
.table-header h2,
.table-header p,
.metric p {
    margin: 0;
}

.eyebrow {
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.topbar h1 {
    margin-top: 4px;
    font-size: clamp(24px, 4vw, 34px);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.menu-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
    place-items: center;
    padding: 10px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    margin: 3px 0;
    border-radius: 999px;
    background: var(--text);
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) {
    opacity: 0;
}

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.nav a,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.nav a.active,
.button.primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.ghost {
    background: #f8fafc;
}

.button.small {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
}

.button.danger {
    border-color: #f4c7c1;
    background: #fff5f3;
    color: var(--danger);
}

.page {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 26px clamp(14px, 3vw, 36px) 44px;
}

.page-full {
    width: 100%;
    max-width: none;
    padding-right: 0;
    padding-left: 0;
}

.page-full > :not(.salon-layout):not(.modal):not(.confirm-dialog) {
    width: min(1440px, calc(100% - 28px));
    margin-right: auto;
    margin-left: auto;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    margin-bottom: 16px;
}

.toolbar h2 {
    font-size: 20px;
}

.toolbar p,
.hint {
    color: var(--muted);
    line-height: 1.5;
}

.status-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
    text-align: center;
}

.metric {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.metric span {
    display: block;
    margin-bottom: 4px;
    color: var(--primary);
    font-size: 28px;
    font-weight: 800;
}

.metric p {
    color: var(--muted);
    font-size: 14px;
}

.metric-confirmed span {
    color: #15803d;
}

.metric-pending span {
    color: #ca8a04;
}

.metric-rejected span {
    color: #dc2626;
}

.salon-layout {
    position: relative;
    width: 100%;
    height: 80vh;
    overflow: hidden;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    cursor: grab;
    touch-action: none;
}

.layout-controls {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.grid-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 24px rgba(21, 31, 44, 0.12);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    touch-action: auto;
}

.grid-switch input {
    width: 16px;
    min-height: 16px;
    accent-color: var(--primary);
}

.salon-canvas {
    position: relative;
    min-width: 100%;
    min-height: 100%;
    transform-origin: 0 0;
    will-change: transform;
}

.salon-layout.show-grid .salon-canvas {
    background:
        linear-gradient(90deg, rgba(148, 163, 184, 0.22) 1px, transparent 1px),
        linear-gradient(rgba(148, 163, 184, 0.22) 1px, transparent 1px);
    background-size: 36px 36px;
}

.salon-layout.panning {
    cursor: grabbing;
}

.draggable-table {
    position: absolute;
    width: 280px;
    height: 280px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    user-select: none;
}

.draggable-table.dragging {
    z-index: 5;
}

.table-center {
    position: absolute;
    inset: 26%;
    z-index: 2;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 4px;
    padding: 10px;
    border: 2px solid #94a3b8;
    border-radius: 50%;
    background: #ffffff;
    color: var(--text);
    box-shadow: 0 14px 34px rgba(21, 31, 44, 0.16);
    cursor: default;
    font: inherit;
    text-align: center;
    touch-action: none;
    pointer-events: auto;
}

.draggable-table.cuadrada .table-center,
.table-center.cuadrada {
    border-radius: 8px;
}

.draggable-table.circular .table-center,
.table-center.circular {
    border-radius: 50%;
}

.salon-layout.can-move-tables .table-center {
    cursor: grab;
}

.salon-layout.can-move-tables .table-center:active,
.salon-layout.can-move-tables .draggable-table.dragging .table-center {
    cursor: grabbing;
}

.table-center strong,
.table-center small {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-center strong {
    color: var(--primary);
    font-size: 13px;
}

.table-center span {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.12;
    white-space: normal;
}

.table-center small {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
}

.table-header,
.table-footer,
.panel-title,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.table-header p {
    color: var(--primary);
    font-weight: 800;
}

.table-header h2 {
    margin-top: 2px;
    font-size: 20px;
}

.table-header span,
.table-footer span {
    border-radius: 999px;
    background: #eef7f6;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    padding: 7px 10px;
    white-space: nowrap;
}

.seat {
    --seat-color: var(--primary);
    --seat-size: 54px;
    --seat-number-size: 15px;
    --seat-name-size: 9px;
    position: absolute;
    width: var(--seat-size);
    height: var(--seat-size);
    transform: translate(-50%, -50%);
    border: 2px solid var(--line);
    border-radius: 50%;
    background: var(--free);
    color: var(--text);
    cursor: pointer;
    font-weight: 800;
    overflow: visible;
    pointer-events: auto;
}

.seat.occupied.status-confirmado {
    --seat-color: #16a34a;
    background: #ecfdf3;
    color: #14532d;
}

.seat.occupied.status-pendiente {
    --seat-color: #eab308;
    background: #fef9c3;
    color: #713f12;
}

.seat.occupied.status-parcial {
    --seat-color: #c2410c;
    background: #ffedd5;
    color: #7c2d12;
}

.seat.occupied.status-rechazado {
    --seat-color: #dc2626;
    background: #fef2f2;
    color: #7f1d1d;
}

.seat.free:hover {
    border-color: var(--primary);
    background: #e6f4f1;
}

.seat.occupied {
    border-color: var(--seat-color);
}

.seat span {
    display: block;
    font-size: var(--seat-number-size);
    line-height: 1;
}

.seat small {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--seat-name-size);
    line-height: 1.1;
}

.status-dot {
    position: absolute;
    top: 2px;
    right: 2px;
    z-index: 2;
    width: 12px;
    height: 12px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--seat-color);
    box-shadow: 0 2px 5px rgba(21, 31, 44, 0.18);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.confirmado {
    background: #dcfce7;
    color: #166534;
}

.status-pill.pendiente {
    background: #fef9c3;
    color: #854d0e;
}

.status-pill.rechazado {
    background: #fee2e2;
    color: #991b1b;
}

.guest-confirmation-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.table-footer {
    padding-top: 6px;
    color: var(--muted);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.content-grid > *,
.panel,
.form-panel,
.table-panel {
    min-width: 0;
}

.form-panel,
.table-panel {
    padding: 18px;
}

.panel-title {
    margin-bottom: 16px;
}

.panel-title h2 {
    font-size: 20px;
}

label {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

input,
select {
    width: 100%;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
}

input:focus,
select:focus {
    outline: 2px solid rgba(15, 118, 110, 0.22);
    border-color: var(--primary);
}

.copy-input {
    min-width: 260px;
    background: #f8fafc;
    font-size: 13px;
}

.table-wrap {
    overflow-x: visible;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.empty,
.empty-state {
    color: var(--muted);
    text-align: center;
}

.empty-state {
    padding: 34px;
}

.empty-state h2 {
    color: var(--text);
}

.alert {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #f4c7c1;
    border-radius: 8px;
    background: #fff5f3;
    color: var(--danger);
    font-weight: 700;
}

.notice {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #b7e4d8;
    border-radius: 8px;
    background: #ecfdf7;
    color: #047857;
    font-weight: 700;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 18px;
}

.login-page {
    width: min(420px, 100%);
}

.login-card {
    padding: 24px;
}

.login-card h1 {
    margin: 4px 0 20px;
    font-size: 30px;
}

.settings-grid {
    margin-bottom: 18px;
}

.inline-password-form {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(120px, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.inline-password-form input {
    min-height: 34px;
}

.backup-panel {
    padding: 18px;
}

.deadline-panel {
    margin-bottom: 18px;
    padding: 18px;
}

.deadline-form {
    display: grid;
    grid-template-columns: minmax(220px, 320px) auto;
    gap: 12px;
    align-items: end;
}

.deadline-form label {
    margin: 0;
}

.deadline-form .button {
    width: auto;
}

.backup-actions {
    display: grid;
    grid-template-columns: minmax(220px, 320px) 1fr;
    gap: 18px;
    align-items: start;
}

.checkbox-line {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
    color: var(--text);
    font-weight: 700;
}

.checkbox-line input {
    width: 18px;
    min-height: 18px;
}

.print-report {
    display: grid;
    gap: 16px;
}

.report-table {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.report-table-title h3,
.report-summary {
    margin: 0;
}

.report-summary {
    color: var(--muted);
}

.report-table-title {
    margin-bottom: 12px;
}

.report-table-title h3 {
    font-size: 20px;
}

.report-summary {
    margin-top: 10px;
    font-weight: 700;
}

.modal[hidden] {
    display: none;
}

@media print {
    @page {
        margin: 14mm;
    }

    body {
        background: #ffffff;
        color: #000000;
        font-size: 11px;
    }

    .topbar,
    .no-print {
        display: none;
    }

    .page {
        width: 100%;
        padding: 0;
    }

    .print-report {
        display: block;
    }

    .report-table {
        border: 0;
        border-bottom: 1px solid #999999;
        border-radius: 0;
        box-shadow: none;
        page-break-inside: avoid;
        margin-bottom: 8px;
        padding: 0 0 8px;
    }

    .report-table-title {
        margin-bottom: 4px;
    }

    .report-table-title h3 {
        font-size: 13px;
    }

    th,
    td {
        padding: 3px 0;
        border-bottom: 0;
    }

    th {
        display: none;
    }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
}

.confirm-dialog[hidden] {
    display: none;
}

.confirm-dialog {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 18px;
}

.confirm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.56);
}

.confirm-card {
    position: relative;
    z-index: 1;
    width: min(420px, 100%);
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.26);
}

.confirm-card h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.confirm-card p {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.dialog-open {
    overflow: hidden;
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    min-width: 0;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
}

.icon-button {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

@media (max-width: 1120px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 800px) {
    .toolbar {
        display: grid;
        align-items: start;
    }

    .topbar {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 14px;
        padding: 16px;
    }

    .menu-toggle {
        display: grid;
    }

    .nav {
        display: none;
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
        justify-content: stretch;
        width: 100%;
        padding-top: 4px;
    }

    .nav.open {
        display: grid;
    }

    .nav a {
        flex: none;
        min-width: 0;
        padding: 0 10px;
        text-align: center;
    }

    .inline-password-form,
    .backup-actions {
        grid-template-columns: 1fr;
    }

    .seat {
        width: 50px;
        height: 50px;
    }
}

@media screen and (max-width: 900px) {
    .page {
        padding: 16px 10px 32px;
    }

    .toolbar,
    .form-panel,
    .table-panel,
    .backup-panel,
    .modal-card {
        padding: 14px;
    }

    .panel-title,
    .table-header,
    .table-footer,
    .modal-actions {
        align-items: stretch;
        display: grid;
    }

    .button,
    .nav a {
        width: 100%;
    }

    .deadline-form {
        grid-template-columns: 1fr;
    }

    .deadline-form .button {
        width: 100%;
    }

    .status-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .metric {
        padding: 12px;
    }

    .metric span {
        font-size: 24px;
    }

    .salon-canvas {
        min-height: 100%;
    }

    .table-wrap {
        overflow: visible;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 12px;
    }

    tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #ffffff;
        overflow: hidden;
    }

    td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        min-height: 44px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--line);
        white-space: normal;
        text-align: right;
        word-break: break-word;
    }

    td:last-child {
        border-bottom: 0;
    }

    td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        color: var(--muted);
        font-size: 12px;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
    }

    td.empty {
        display: block;
        text-align: center;
    }

    td.empty::before {
        content: none;
    }

    td.actions {
        display: grid;
        grid-template-columns: 1fr;
        text-align: left;
    }

    td.actions::before {
        flex-basis: auto;
    }

    .actions form,
    .actions .button {
        width: 100%;
    }

    .inline-password-form {
        width: 100%;
    }

    .copy-input {
        min-width: 0;
        text-align: right;
    }

    .backup-actions {
        gap: 12px;
    }

    .modal {
        align-items: end;
        padding: 10px;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100vh - 20px);
        border-radius: 8px 8px 0 0;
    }

    .modal-card > *,
    .modal-card label,
    .modal-card select {
        min-width: 0;
        width: 100%;
    }

    .modal-card .panel-title {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 44px;
        align-items: start;
        gap: 12px;
        width: 100%;
    }

    .modal-card .panel-title > * {
        min-width: 0;
    }

    .modal-card .panel-title > div {
        grid-column: 1;
        grid-row: 1;
    }

    .modal-card .panel-title .icon-button {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
        align-self: start;
        width: 40px;
        height: 40px;
    }

    .modal-card .panel-title h2 {
        font-size: 18px;
    }

    .modal-card label,
    .modal-card .hint {
        margin-bottom: 12px;
    }

    .modal-card select {
        min-height: 48px;
        font-size: 16px;
    }

    .modal-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
    }

    .modal-actions .button {
        width: 100%;
        min-height: 46px;
    }

    .modal-actions .button.primary {
        order: 1;
    }

    .modal-actions .button.ghost {
        order: 2;
    }
}

@media screen and (max-width: 640px) {
    .page {
        padding: 14px 8px 28px;
    }

    .toolbar,
    .form-panel,
    .table-panel,
    .backup-panel,
    .modal-card {
        padding: 12px;
    }

    .modal {
        padding: 8px;
    }

    .modal-card {
        max-height: calc(92vh - 16px);
        border-radius: 12px 12px 0 0;
    }

    .modal-backdrop {
        background: rgba(15, 23, 42, 0.62);
    }

    .salon-canvas {
        min-height: 100%;
    }

    .confirm-dialog {
        align-items: end;
        padding: 8px;
    }

    .confirm-card {
        width: 100%;
        padding: 16px;
        border-radius: 12px;
    }

    .confirm-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .confirm-actions .button {
        width: 100%;
        min-height: 46px;
    }

    .confirm-actions .button.primary {
        order: 1;
    }

    .confirm-actions .button.ghost {
        order: 2;
    }
}

@media screen and (max-width: 380px) {
    .status-strip {
        grid-template-columns: 1fr;
    }
}
