/* Tables / Floor runtime view. Owned by the service-modes track.
   B60 OS tokens only - no new hex values, no page-local palette. */

.tbl-page {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
    min-height: calc(100vh - 120px);
    padding-block-end: var(--ds-space-4);
}

.tbl-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    flex-wrap: wrap;
}

.tbl-floors {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    flex-wrap: wrap;
}

.tbl-floor-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-1);
    padding: var(--ds-space-2) var(--ds-space-3);
    border-radius: var(--ds-radius-pill, 999px);
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    color: var(--ds-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.tbl-floor-tab.is-active {
    background: var(--ds-primary);
    border-color: var(--ds-primary);
    color: var(--ds-sidebar-pill);
}

.tbl-floor-add {
    border: none;
    background: transparent;
    color: var(--ds-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
    padding: var(--ds-space-2);
}

.tbl-view-controls {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
}

.tbl-filter-btn,
.tbl-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--ds-space-2) var(--ds-space-3);
    border-radius: var(--ds-radius-pill, 999px);
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    color: var(--ds-text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.tbl-view-toggle {
    display: inline-flex;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-pill, 999px);
    overflow: hidden;
    background: var(--ds-surface);
}

.tbl-view-toggle .tbl-view-btn {
    border: none;
    border-radius: 0;
}

.tbl-view-toggle .tbl-view-btn.is-active {
    background: var(--ds-primary-tint);
    color: var(--ds-primary);
}

.tbl-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: var(--ds-space-4);
    align-items: start;
    flex: 1;
    min-height: 0;
}

.tbl-canvas-col {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-3);
    min-width: 0;
}

.tbl-canvas-wrap {
    position: relative;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg, 18px);
    background: var(--ds-surface);
    overflow: hidden;
    min-height: 420px;
    height: min(56vh, 520px);
}

.tbl-canvas-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}

.tbl-canvas-viewport.is-dragging {
    cursor: grabbing;
}

.tbl-canvas-stage {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.tbl-canvas-bg {
    position: absolute;
    inset: 0;
    background-color: var(--ds-surface);
    background-image:
        radial-gradient(circle, var(--ds-border-strong) 1px, transparent 1.5px);
    background-size: 24px 24px;
}

.tbl-canvas-bg.has-image {
    background-image: none;
    background-color: var(--ds-surface-alt);
}

.tbl-canvas-bg img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    user-select: none;
    pointer-events: none;
}

.tbl-hotspots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.tbl-shape {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: center center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
    border: 2px solid transparent;
    background: var(--ds-surface);
    color: var(--ds-text-primary);
    box-shadow: var(--shadow-md, 0 4px 14px rgba(15, 23, 42, 0.08));
    pointer-events: all;
    cursor: pointer;
    font-family: inherit;
    transition: box-shadow 0.15s ease;
    overflow: hidden;
    text-align: center;
}

.tbl-shape:hover {
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(15, 23, 42, 0.12));
}

.tbl-shape.is-round,
.tbl-shape.is-bar_stool {
    border-radius: 50%;
}

.tbl-shape.is-square,
.tbl-shape.is-rectangle {
    border-radius: var(--ds-radius-md, 12px);
}

.tbl-shape.is-booth {
    border-radius: var(--ds-radius-lg, 16px) var(--ds-radius-lg, 16px) var(--ds-radius-sm, 8px) var(--ds-radius-sm, 8px);
}

.tbl-shape-label {
    font-size: 12px;
    font-weight: 800;
    line-height: 1.1;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tbl-shape-meta {
    font-size: 9px;
    font-weight: 600;
    opacity: 0.9;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Subtle table open time — floor map, grid, detail panel */
.table-open-meta,
.tbl-shape-time,
.tbl-open-meta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    color: var(--ds-text-tertiary);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    line-height: 1.2;
}

.tbl-shape-time {
    font-size: 9px;
    color: inherit;
    opacity: 0.85;
}

.tbl-shape.is-occupied .tbl-shape-time,
.tbl-shape.is-selected .tbl-shape-time {
    color: var(--ds-text-secondary);
}

.tbl-shape.is-selected .tbl-shape-time {
    color: rgba(255, 255, 255, 0.82);
}

.table-open-dot {
    opacity: 0.45;
    font-weight: 400;
}

.tbl-grid-open-meta {
    margin-top: 6px;
}

.tbl-meta-open .table-open-meta,
.tbl-meta-open .tbl-open-meta {
    font-size: 12px;
    color: var(--ds-text-secondary);
}

.tbl-meta-open.is-empty {
    color: var(--ds-text-tertiary);
    font-variant-numeric: tabular-nums;
}

.tbl-shape.is-available {
    background: var(--ds-surface);
    border-color: var(--ds-success);
}

.tbl-shape.is-occupied {
    border-color: var(--ds-danger);
    background: var(--ds-danger-tint);
}

.tbl-shape.is-reserved {
    border-color: var(--ds-warning);
    background: var(--ds-warning-tint);
}

.tbl-shape.is-cleaning {
    border-color: var(--ds-info);
    background: var(--ds-info-tint);
}

.tbl-shape.is-out_of_service {
    border-color: var(--ds-border-strong);
    background: var(--ds-surface-alt);
    color: var(--ds-text-tertiary);
}

.tbl-shape.is-selected {
    background: var(--ds-primary);
    border-color: var(--ds-primary);
    color: var(--ds-sidebar-pill);
}

.tbl-shape.is-selected .tbl-shape-meta {
    color: var(--ds-sidebar-pill);
}

.tbl-zoom-controls {
    position: absolute;
    top: var(--ds-space-3);
    left: var(--ds-space-3);
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tbl-zoom-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    color: var(--ds-text-primary);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(15, 23, 42, 0.06));
}

.tbl-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    align-items: center;
    padding: var(--ds-space-2) var(--ds-space-1);
}

.tbl-legend-badge {
    font-size: 11px;
    font-weight: 600;
}

.tbl-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: var(--ds-space-2);
}

.tbl-stat-card {
    min-width: 0;
}

.tbl-stat-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ds-space-2);
}

.ds-stat-card-value.is-available { color: var(--ds-success); }
.ds-stat-card-value.is-occupied { color: var(--ds-danger); }
.ds-stat-card-value.is-reserved { color: var(--ds-warning); }
.ds-stat-card-value.is-cleaning { color: var(--ds-info); }
.ds-stat-card-value.is-out_of_service { color: var(--ds-text-tertiary); }

.tbl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--ds-space-3);
    padding: var(--ds-space-3);
}

.tbl-grid-card {
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md, 12px);
    background: var(--ds-surface);
    padding: var(--ds-space-3);
    cursor: pointer;
    font-family: inherit;
    text-align: start;
}

.tbl-grid-card.is-selected {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 1px var(--ds-primary);
}

.tbl-detail {
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg, 18px);
    background: var(--ds-surface);
    padding: var(--ds-space-4);
    min-height: 420px;
    max-height: calc(100vh - 140px);
    overflow: auto;
    position: sticky;
    top: var(--ds-space-3);
}

.tbl-detail-empty {
    min-height: 360px;
}

.tbl-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-2);
    margin-block-end: var(--ds-space-3);
}

.tbl-detail-title {
    margin: 0;
    font-size: 20px;
    font-weight: 800;
    color: var(--ds-text-primary);
}

.tbl-detail-actions-top {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
}

.tbl-status-select {
    min-width: 120px;
}

.tbl-overflow-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--ds-border);
    background: var(--ds-surface);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--ds-text-secondary);
}

.tbl-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-3);
    font-size: 13px;
    color: var(--ds-text-secondary);
    margin-block-end: var(--ds-space-4);
}

.tbl-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-block-end: var(--ds-space-2);
    font-size: 14px;
    font-weight: 700;
    color: var(--ds-text-primary);
}

.tbl-guest-card {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    padding: var(--ds-space-3);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md, 12px);
    margin-block-end: var(--ds-space-4);
}

.tbl-guest-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ds-primary-tint);
    color: var(--ds-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.tbl-guest-info {
    flex: 1;
    min-width: 0;
}

.tbl-guest-name {
    font-weight: 700;
    color: var(--ds-text-primary);
}

.tbl-guest-phone {
    font-size: 12px;
    color: var(--ds-text-secondary);
}

.tbl-order-lines {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    margin-block-end: var(--ds-space-4);
    max-height: 240px;
    overflow: auto;
}

.tbl-order-line {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: var(--ds-space-2);
    align-items: center;
    font-size: 13px;
}

.tbl-order-thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--ds-surface-alt);
    object-fit: cover;
}

.tbl-order-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--ds-surface-alt);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.tbl-order-name {
    font-weight: 600;
    color: var(--ds-text-primary);
}

.tbl-order-mod {
    font-size: 11px;
    color: var(--ds-text-tertiary);
}

.tbl-order-qty-price {
    text-align: end;
    font-variant-numeric: tabular-nums;
}

.tbl-order-qty-price .tbl-money {
    font-weight: 700;
    color: var(--ds-text-primary);
}

.tbl-summary-rows {
    border-top: 1px solid var(--ds-border);
    padding-block-start: var(--ds-space-3);
    margin-block-end: var(--ds-space-4);
}

.tbl-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--ds-text-secondary);
    margin-block-end: 6px;
}

.tbl-summary-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 14px;
    font-weight: 700;
    color: var(--ds-text-primary);
    margin-block-start: var(--ds-space-2);
}

.tbl-summary-total .tbl-money {
    font-size: 24px;
    font-weight: 800;
}

.tbl-detail-foot {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
}

.tbl-filter-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md, 12px);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(15, 23, 42, 0.12));
    padding: 6px;
    z-index: 20;
}

.tbl-filter-menu button {
    display: block;
    width: 100%;
    text-align: start;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    color: var(--ds-text-primary);
}

.tbl-filter-menu button.is-active,
.tbl-filter-menu button:hover {
    background: var(--ds-primary-tint);
    color: var(--ds-primary);
}

.tbl-filter-wrap {
    position: relative;
}

.tbl-overflow-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md, 12px);
    box-shadow: var(--shadow-lg, 0 8px 24px rgba(15, 23, 42, 0.12));
    padding: 6px;
    z-index: 20;
}

.tbl-overflow-menu button {
    display: block;
    width: 100%;
    text-align: start;
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    color: var(--ds-text-primary);
}

.tbl-overflow-menu button:hover {
    background: var(--ds-surface-alt);
}

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

    .tbl-detail {
        position: static;
        max-height: none;
    }

    .tbl-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .tbl-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
