:root {
    --ink: #1a120b;
    --ink-soft: #3d2e22;
    --ember: #e85d04;
    --ember-deep: #c2410c;
    --gold: #f0a202;
    --cream: #f7f0e6;
    --cream-dim: rgba(247, 240, 230, 0.72);
    --glass: rgba(247, 240, 230, 0.08);
    --glass-border: rgba(247, 240, 230, 0.14);
    --livre: #3d9b6a;
    --ocupada: #e85d04;
    --reservada: #5b7cfa;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Outfit', system-ui, sans-serif;
    --radius: 18px;
    --max: 960px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.mesas-page {
    font-family: var(--font-body);
    color: var(--cream);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.page-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 80% 50% at 10% -10%, rgba(232, 93, 4, 0.28), transparent 55%),
        radial-gradient(ellipse 60% 40% at 90% 20%, rgba(240, 162, 2, 0.12), transparent 50%),
        radial-gradient(ellipse 50% 60% at 50% 100%, rgba(61, 46, 34, 0.9), transparent 60%),
        linear-gradient(165deg, #1a120b 0%, #2a1a10 45%, #1a120b 100%);
}

.page-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
}

/* Header */
.page-header {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.25rem 1.25rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    animation: fadeDown 0.6s ease both;
}

.page-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--cream);
}

.logo-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(145deg, var(--ember), var(--ember-deep));
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(232, 93, 4, 0.35);
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.logo-text em {
    font-style: normal;
    color: var(--gold);
}

.btn-entrar {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--cream);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: 10px;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.btn-entrar:hover {
    background: rgba(247, 240, 230, 0.14);
    border-color: rgba(247, 240, 230, 0.28);
    color: white;
    transform: translateY(-1px);
}

/* Hero */
.hero {
    max-width: var(--max);
    margin: 0 auto;
    padding: clamp(2.5rem, 8vh, 4.5rem) 1.25rem 2.5rem;
    text-align: center;
    animation: fadeUp 0.7s 0.1s ease both;
}

.hero-place {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 1.25rem;
}

.hero-brand {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 9vw, 4.75rem);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
    color: var(--cream);
}

.hero-brand span {
    background: linear-gradient(120deg, var(--gold) 0%, var(--ember) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-lead {
    max-width: 28rem;
    margin: 0 auto 2rem;
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    line-height: 1.55;
    color: var(--cream-dim);
    font-weight: 400;
}

.hero-cta {
    max-width: 420px;
    margin: 0 auto;
    text-align: left;
    animation: fadeUp 0.7s 0.25s ease both;
}

.cta-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cream-dim);
    margin-bottom: 0.5rem;
}

.mesa-input-row {
    display: flex;
    gap: 0.5rem;
}

.mesa-input-row input {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.1rem;
    border: 1.5px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--cream);
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.08em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.mesa-input-row input::placeholder {
    color: rgba(247, 240, 230, 0.25);
    letter-spacing: 0.08em;
}

.mesa-input-row input:focus {
    outline: none;
    border-color: var(--ember);
    box-shadow: 0 0 0 4px rgba(232, 93, 4, 0.2);
}

.btn-ir {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 1.35rem;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: white;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(232, 93, 4, 0.35);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-ir:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(232, 93, 4, 0.45);
}

.cta-hint {
    margin-top: 0.85rem;
    font-size: 0.85rem;
    color: var(--cream-dim);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cta-hint i { color: var(--gold); }

/* Mesas section */
.mesas-section {
    max-width: var(--max);
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
    animation: fadeUp 0.7s 0.35s ease both;
}

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.section-head h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.section-head p {
    font-size: 0.9rem;
    color: var(--cream-dim);
}

.mesas-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    font-size: 0.8rem;
    color: var(--cream-dim);
}

.legenda-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.legenda-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.legenda-dot.livre { background: var(--livre); }
.legenda-dot.ocupada { background: var(--ocupada); }
.legenda-dot.reservada { background: var(--reservada); }
.legenda-dot.pedido { background: var(--gold); }

.mesas-resumo {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.75rem;
}

.resumo-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 0.9rem 0.5rem;
    text-align: center;
}

.resumo-item .num {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    display: block;
    line-height: 1.1;
}

.resumo-item .lbl {
    font-size: 0.65rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.resumo-item.livre .num { color: #6ee7a8; }
.resumo-item.ocupada .num { color: #ff9f5a; }
.resumo-item.pedido .num { color: var(--gold); }

.mesas-zona { margin-bottom: 1.75rem; }

.zona-titulo {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--cream-dim);
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zona-titulo i { color: var(--gold); }

.mesas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 0.75rem;
}

.mesa-card {
    background: var(--glass);
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: transform 0.25s ease, border-color 0.25s, box-shadow 0.25s;
}

.mesa-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.mesa-card.livre { border-color: rgba(61, 155, 106, 0.45); }
.mesa-card.livre:hover { border-color: rgba(61, 155, 106, 0.8); }

.mesa-card.ocupada {
    border-color: rgba(232, 93, 4, 0.45);
    background: rgba(232, 93, 4, 0.08);
}

.mesa-card.reservada {
    border-color: rgba(91, 124, 250, 0.45);
    background: rgba(91, 124, 250, 0.08);
}

.mesa-card.com-pedido::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--ember));
}

.mesa-card-link {
    display: block;
    padding: 1.15rem 0.85rem 1rem;
    text-align: center;
    text-decoration: none;
    color: var(--cream);
}

.mesa-numero {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.mesa-local {
    font-size: 0.7rem;
    color: var(--cream-dim);
    margin-bottom: 0.55rem;
    line-height: 1.3;
    min-height: 1.8em;
}

.mesa-estado {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mesa-estado.livre { background: rgba(61, 155, 106, 0.2); color: #6ee7a8; }
.mesa-estado.ocupada { background: rgba(232, 93, 4, 0.22); color: #ffb070; }
.mesa-estado.reservada { background: rgba(91, 124, 250, 0.22); color: #a5b8ff; }

.mesa-pedido-info {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--glass-border);
    font-size: 0.7rem;
}

.mesa-pedido-info .pedido-estado {
    color: var(--gold);
    font-weight: 600;
}

.mesa-pedido-info .pedido-total {
    font-weight: 700;
    margin-top: 0.15rem;
}

.mesa-qr-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem;
    background: rgba(240, 162, 2, 0.1);
    border-top: 1px solid var(--glass-border);
    color: var(--gold);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    transition: background 0.2s;
}

.mesa-qr-btn:hover {
    background: rgba(240, 162, 2, 0.2);
    color: var(--gold);
}

.mesas-loading {
    text-align: center;
    padding: 3rem;
    color: var(--cream-dim);
}

.mesas-loading .spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--ember);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

/* Footer */
.page-footer {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
    text-align: center;
    border-top: 1px solid var(--glass-border);
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--gold);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.footer-link:hover { text-decoration: underline; }

.page-footer p {
    font-size: 0.8rem;
    color: var(--cream-dim);
}

/* Menu page mesa info (shared) */
.mesa-info-card {
    max-width: 1200px;
    margin: 1rem auto 0;
    padding: 0 1rem;
}

.mesa-info-inner {
    background: linear-gradient(135deg, rgba(232, 93, 4, 0.12), rgba(194, 65, 12, 0.08));
    border: 2px solid rgba(232, 93, 4, 0.25);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.mesa-info-left { display: flex; align-items: center; gap: 1rem; }

.mesa-info-numero {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--ember), var(--ember-deep));
    color: white;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    flex-shrink: 0;
}

.mesa-info-detalhes h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.15rem;
}

.mesa-info-detalhes p {
    font-size: 0.85rem;
    color: var(--text-muted, #6c757d);
    margin: 0;
}

.mesa-info-detalhes .mesa-local-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--ember);
    font-weight: 600;
}

.mesa-pedido-ativo {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e9ecef);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.mesa-pedido-ativo i { color: var(--ember); font-size: 1.2rem; }
.mesa-pedido-ativo a { color: var(--ember); font-weight: 700; text-decoration: none; }

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
    .mesas-resumo { grid-template-columns: repeat(2, 1fr); }
    .mesas-grid { grid-template-columns: repeat(2, 1fr); }
    .mesa-input-row { flex-direction: column; }
    .btn-ir {
        justify-content: center;
        padding: 0.95rem 1.35rem;
        min-height: 48px;
        width: 100%;
    }
    .section-head { flex-direction: column; align-items: flex-start; }
    .mesa-info-inner { flex-direction: column; align-items: flex-start; }
}

/* ===== RESPONSIVO COMPLETO ===== */

/* Telefones pequenos (320px – 479px) */
@media (max-width: 479px) {
    .page-header {
        padding: max(0.85rem, env(safe-area-inset-top)) 1rem 0;
    }

    .logo-text { font-size: 0.875rem; }
    .logo-mark { width: 36px; height: 36px; font-size: 1rem; }

    .btn-entrar {
        padding: 0.5rem 0.85rem;
        font-size: 0.8rem;
        min-height: 44px;
    }

    .hero {
        padding: 1.75rem 1rem 2rem;
    }

    .hero-brand {
        font-size: clamp(2.25rem, 12vw, 3rem);
    }

    .hero-lead {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }

    .hero-cta {
        max-width: 100%;
    }

    .mesa-input-row input {
        font-size: 1.35rem;
        padding: 0.9rem;
        min-height: 52px;
    }

    .cta-hint {
        font-size: 0.8rem;
        flex-wrap: wrap;
    }

    .mesas-section {
        padding: 0 1rem 2rem;
    }

    .section-head h2 { font-size: 1.25rem; }

    .mesas-legenda {
        gap: 0.5rem 0.85rem;
        font-size: 0.75rem;
    }

    .mesas-resumo {
        gap: 0.5rem;
    }

    .resumo-item {
        padding: 0.75rem 0.35rem;
    }

    .resumo-item .num { font-size: 1.35rem; }
    .resumo-item .lbl { font-size: 0.6rem; }

    .mesas-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
    }

    .mesa-numero { font-size: 1.85rem; }
    .mesa-local { font-size: 0.65rem; min-height: auto; }
    .mesa-card-link { padding: 1rem 0.65rem 0.85rem; }
    .mesa-qr-btn { padding: 0.55rem; font-size: 0.75rem; min-height: 44px; }

    .page-footer {
        padding: 1.25rem 1rem max(2rem, env(safe-area-inset-bottom));
    }

    .footer-link { font-size: 0.85rem; }
}

/* Telefones grandes (480px – 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .mesas-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .hero-cta { max-width: 460px; }
}

/* Tablets (768px – 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    :root { --max: 720px; }

    .mesas-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 0.85rem;
    }

    .hero-brand { font-size: clamp(3.25rem, 7vw, 4rem); }

    .mesa-input-row {
        flex-direction: row;
    }

    .btn-ir {
        min-height: 52px;
        padding: 0 1.75rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    :root { --max: 1040px; }

    .mesas-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }

    .mesas-resumo {
        gap: 0.85rem;
    }

    .resumo-item .num { font-size: 1.85rem; }

    .hero {
        padding: clamp(3rem, 10vh, 5rem) 1.5rem 3rem;
    }
}

/* Ecrãs largos (1280px+) */
@media (min-width: 1280px) {
    :root { --max: 1140px; }

    .mesas-grid {
        grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
    }
}

/* Orientação horizontal em telemóvel */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        padding: 1.25rem 1.25rem 1.5rem;
    }

    .hero-brand {
        font-size: clamp(2rem, 8vh, 2.75rem);
        margin-bottom: 0.5rem;
    }

    .hero-lead {
        margin-bottom: 1rem;
        font-size: 0.9rem;
    }

    .hero-place { margin-bottom: 0.75rem; }

    .mesa-input-row {
        flex-direction: row;
        max-width: 420px;
        margin: 0 auto;
    }

    .hero-cta { text-align: center; }
    .cta-label { text-align: center; }
    .cta-hint { justify-content: center; }
}

/* Toque — áreas clicáveis mínimas */
@media (hover: none) and (pointer: coarse) {
    .mesa-card:hover { transform: none; }
    .mesa-card:active { transform: scale(0.98); opacity: 0.92; }
    .btn-ir:hover { transform: none; }
    .btn-ir:active { transform: scale(0.98); }
    .btn-entrar:hover { transform: none; }

    .mesa-card-link,
    .mesa-qr-btn,
    .btn-entrar,
    .btn-ir,
    .footer-link {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Safe area — iPhone com notch */
@supports (padding: max(0px)) {
    body.mesas-page {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
