/* ============ Base: reset, tokens, layout del shell ============ */

:root {
    color-scheme: light dark;

    --bg: #f4efe6;
    --surface: #fffdf8;
    --surface-2: #efe7d8;
    --ink: #2a2622;
    --muted: #8a7d69;
    --line: #e2d7c3;

    --accent: #c2410c;
    --accent-ink: #ffffff;
    --accent-soft: #f6e2d5;

    --green: #15803d;
    --amber: #b45309;
    --red: #b91c1c;
    --info: #1d4ed8;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(60, 40, 20, .12), 0 8px 24px rgba(60, 40, 20, .08);
    --tap: 46px;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --header-h: 52px;
    --tabbar-h: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1a1613;
        --surface: #241f1b;
        --surface-2: #2f2823;
        --ink: #ece5d8;
        --muted: #a1927b;
        --line: #3a322b;
        --accent: #e2632b;
        --accent-soft: #3a2117;
    }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); }

.boot {
    height: 100dvh;
    display: grid;
    place-items: center;
    color: var(--muted);
}

/* ---- Shell ---- */

.app {
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: calc(var(--header-h) + var(--safe-top));
    padding: var(--safe-top) 14px 0;
    background: var(--accent);
    color: var(--accent-ink);
}
.topbar-title { font-weight: 700; letter-spacing: .2px; }
.topbar-user {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 999px;
    background: rgba(255, 255, 255, .16);
    color: inherit; font-size: .85rem; font-weight: 600;
    max-width: 55vw; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.view {
    padding: 14px 14px calc(18px + var(--safe-bottom));
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
}

.tabbar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
}
.tabbar a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    min-height: var(--tabbar-h);
    color: var(--muted);
    text-decoration: none;
    font-size: .72rem; font-weight: 600;
}
.tabbar a .ico { height: 22px; }
.tabbar a.active { color: var(--accent); }

/* login oculta el shell */
body:not(.authed) .topbar,
body:not(.authed) .tabbar { display: none; }

/* con un bottom-sheet abierto, el shell no debe asomar por debajo */
body.sheet-open .tabbar,
body.sheet-open .order-bar { visibility: hidden; }

/* ---- utilidades ---- */
.muted { color: var(--muted); }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.center-empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.spin { text-align: center; color: var(--muted); padding: 32px; }
[hidden] { display: none !important; }
