:root {
    --brand-50: #fff7ed;
    --brand-100: #ffedd5;
    --brand-500: #f97316;
    --brand-600: #ea580c;
    --brand-700: #c2410c;
    --bg: #fafafa;
    --card-bg: #ffffff;
    --text: #18181b;
    --muted: #71717a;
    --border: #e4e4e7;
    --border-soft: #f4f4f5;
    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --warn: #d97706;
    --warn-bg: #fef3c7;
    --bad: #dc2626;
    --bad-bg: #fee2e2;
    --info: #0284c7;
    --info-bg: #e0f2fe;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .75rem; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.main { padding-top: 1.5rem; padding-bottom: 3rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.95); border-bottom: 1px solid var(--border); backdrop-filter: blur(8px); }
.topbar-row { display: flex; align-items: center; height: 56px; gap: .75rem; }
.brand { display: flex; align-items: center; gap: .5rem; margin-right: 1rem; }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-600); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.brand-name { font-weight: 600; color: #27272a; }
.nav { display: flex; align-items: center; gap: .25rem; flex: 1; overflow-x: auto; }
.nav-item { padding: .375rem .75rem; border-radius: 8px; font-weight: 500; color: #52525b; white-space: nowrap; }
.nav-item:hover { background: #f4f4f5; text-decoration: none; }
.nav-item.active { background: var(--brand-50); color: var(--brand-700); }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.user-info { display: none; align-items: center; gap: .5rem; font-size: .85rem; color: #52525b; }
@media (min-width: 768px) { .user-info { display: flex; } }
.badge-rest { font-size: .85rem; font-weight: 500; color: var(--brand-700); padding: .25rem .5rem; }

/* Sub-nav */
.subnav { background: var(--bg); border-bottom: 1px solid var(--border); }
.subnav .container { display: flex; align-items: center; gap: .25rem; overflow-x: auto; padding-top: .25rem; padding-bottom: .25rem; }
.subnav-item { padding: .375rem .75rem; border-radius: 6px; font-weight: 500; color: #71717a; white-space: nowrap; font-size: .9rem; }
.subnav-item:hover { background: #fff; color: #27272a; text-decoration: none; }
.subnav-item.active { background: #fff; color: var(--brand-700); box-shadow: 0 1px 2px rgba(0,0,0,.04); }

/* Cards */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.section { padding: 1.25rem; margin-bottom: 1.25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; gap: 1rem; flex-wrap: wrap; }
.p-6 { padding: 1.5rem; }

/* Page head */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { color: #18181b; }
.page-head p { margin: 0; }
.page-actions { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }

/* Stat cards */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card { padding: 1rem; }
.stat-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: .25rem; }
.stat-sub { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.tone-ok { color: var(--ok); }
.tone-warn { color: var(--warn); }
.tone-bad { color: var(--bad); }
.tone-muted { color: var(--muted); }
.tone-brand { color: var(--brand-700); }

/* Inputs */
.input { width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); font-size: .9rem; transition: border-color .15s, box-shadow .15s; }
.input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(249,115,22,.15); }
.input-sm { padding: .35rem .5rem; font-size: .85rem; max-width: 180px; }
.label { display: block; font-size: .8rem; font-weight: 500; margin-bottom: .25rem; color: #3f3f46; }
textarea.input { resize: vertical; min-height: 60px; font-family: inherit; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%2371717a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 1.25em; padding-right: 2rem; appearance: none; }
.checkbox { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .375rem; padding: .55rem 1rem; border-radius: 8px; font-weight: 500; font-size: .9rem; border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s, transform .05s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand-600); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-secondary { background: #fff; color: #3f3f46; border-color: var(--border); }
.btn-secondary:hover { background: #fafafa; }
.btn-ghost { background: transparent; color: #52525b; }
.btn-ghost:hover { background: #f4f4f5; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: .35rem .65rem; font-size: .8rem; }
.btn-block { width: 100%; }

.link { color: var(--brand-700); cursor: pointer; background: none; border: none; padding: 0; font: inherit; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link-danger { color: var(--bad); cursor: pointer; background: none; border: none; padding: 0; font: inherit; font-size: .85rem; }
.link-danger:hover { text-decoration: underline; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th { padding: .65rem .75rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; border-bottom: 1px solid var(--border); }
td { padding: .65rem .75rem; border-bottom: 1px solid var(--border-soft); font-size: .9rem; vertical-align: middle; }
tbody tr:hover { background: var(--bg); }
tfoot td { background: var(--bg); border-top: 1px solid var(--border); border-bottom: none; }

/* Badges */
.badge-ok, .badge-warn, .badge-bad, .badge-muted { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 500; }
.badge-ok { background: var(--ok-bg); color: #166534; }
.badge-warn { background: var(--warn-bg); color: #92400e; }
.badge-bad { background: var(--bad-bg); color: #991b1b; }
.badge-muted { background: #f4f4f5; color: #52525b; }

/* Alerts */
.alert-ok, .alert-error, .alert-warn, .alert-info { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; border: 1px solid; }
.alert-ok { background: var(--ok-bg); color: #166534; border-color: #86efac; }
.alert-error { background: var(--bad-bg); color: #991b1b; border-color: #fca5a5; }
.alert-warn { background: var(--warn-bg); color: #92400e; border-color: #fcd34d; }
.alert-info { background: var(--info-bg); color: #075985; border-color: #7dd3fc; }

/* Restaurant banner */
.restaurant-banner { margin-bottom: 1.25rem; font-size: .9rem; color: var(--muted); }
.restaurant-banner strong { color: var(--brand-700); }

/* Login */
.login-bg { min-height: 100vh; background: linear-gradient(135deg, #fafafa, #f4f4f5); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-wrap { width: 100%; max-width: 360px; }
.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-logo { display: inline-flex; height: 48px; width: 48px; align-items: center; justify-content: center; border-radius: 16px; background: var(--brand-600); color: #fff; font-weight: 700; font-size: 1.25rem; box-shadow: 0 4px 12px rgba(234,88,12,.25); margin-bottom: 1rem; }
.login-brand h1 { font-size: 1.5rem; font-weight: 600; }
.login-brand p { margin: .25rem 0 0; }
.login-card { padding: 1.5rem; display: flex; flex-direction: column; gap: .75rem; }
.login-card .label { margin-top: .5rem; }
.login-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 1.5rem; }

/* Forms grid */
.grid-form { display: grid; grid-template-columns: repeat(12, 1fr); gap: .75rem; }
.grid-mens { grid-column: span 12; }
.grid-comanda { grid-column: span 12; }
.grid-valor { grid-column: span 12; }
.grid-submit { grid-column: span 12; display: flex; align-items: flex-end; }
.grid-obs { grid-column: span 12; }
@media (min-width: 768px) {
    .grid-mens { grid-column: span 5; }
    .grid-comanda { grid-column: span 3; }
    .grid-valor { grid-column: span 2; }
    .grid-submit { grid-column: span 2; }
    .grid-obs { grid-column: span 12; }
}

.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.row-2 { display: grid; grid-template-columns: 1.5fr 1fr auto; gap: .5rem; margin-bottom: .5rem; align-items: center; }

/* Filters */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters .input { flex: 1; min-width: 200px; }
.filters select.input { flex: 0 0 180px; }

.inline-form { display: flex; flex-direction: column; gap: .15rem; }

.form-actions { margin-top: 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* Tabs */
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab { padding: .55rem .9rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; }
.tab:hover { text-decoration: none; color: #27272a; }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand-600); }

.empty { text-align: center; padding: 2rem 0; color: var(--muted); font-size: .9rem; }

.footer { border-top: 1px solid var(--border); background: #fff; padding: .9rem 0; text-align: center; color: #a1a1aa; font-size: .75rem; margin-top: auto; }

/* Disabled */
fieldset { border: none; padding: 0; margin: 0; }
fieldset[disabled] .input, fieldset[disabled] .btn { opacity: .6; pointer-events: none; }

/* ========================================================== */
/* MOBILE — só afeta telas <= 640px, desktop fica intocado    */
/* ========================================================== */
@media (max-width: 640px) {
    body { font-size: 15px; }

    .container { padding: 0 .75rem; }
    .main { padding-top: 1rem; padding-bottom: 2rem; }

    h1 { font-size: 1.25rem; }
    h2 { font-size: 1rem; }

    /* Topbar quebra em duas linhas: linha 1 (brand + actions), linha 2 (nav) */
    .topbar-row {
        flex-wrap: wrap;
        height: auto;
        min-height: 56px;
        padding: .5rem 0;
        gap: .5rem;
        row-gap: .5rem;
    }
    .brand { margin-right: 0; }
    .brand-name { display: none; } /* só logo VR no mobile */
    .topbar-right {
        margin-left: auto;
        gap: .35rem;
    }
    .topbar-right .input-sm { max-width: 130px; font-size: .85rem; }

    /* Nav vai pra segunda linha, ocupa toda largura */
    .nav {
        order: 2;
        width: 100%;
        flex: 0 0 100%;
        gap: .15rem;
        padding-top: .25rem;
        border-top: 1px solid var(--border-soft);
        -webkit-overflow-scrolling: touch;
    }
    .nav-item {
        padding: .6rem .85rem;
        font-size: .9rem;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }

    /* Subnav: tap targets maiores e melhor scroll */
    .subnav .container {
        padding-top: .35rem;
        padding-bottom: .35rem;
    }
    .subnav-item {
        padding: .55rem .85rem;
        min-height: 38px;
        display: inline-flex;
        align-items: center;
    }

    /* Page head empilhado */
    .page-head h1 { font-size: 1.35rem; }
    .page-actions { width: 100%; flex-wrap: wrap; }
    .page-actions .btn { flex: 1 1 auto; }

    /* Cards e tabelas */
    .section { padding: 1rem; }
    .stat-card { padding: .85rem; }
    .stat-value { font-size: 1.25rem; }

    th, td { padding: .55rem .5rem; font-size: .85rem; }

    /* Botões e inputs com altura mínima de toque (44px iOS) */
    .btn { min-height: 42px; padding: .6rem 1rem; }
    .btn-sm { min-height: 36px; }
    .input { padding: .6rem .75rem; font-size: 16px; /* evita zoom no iOS */ }

    /* Filtros empilham */
    .filters { flex-direction: column; }
    .filters .input, .filters select.input, .filters .btn { width: 100%; min-width: 0; flex: none; }

    /* Form actions */
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; }
    .form-actions .input { width: 100%; }

    /* Login */
    .login-wrap { max-width: 100%; }
    .login-card { padding: 1.25rem; }

    /* Row-2 do fechamento: empilha em mobile */
    .row-2 { grid-template-columns: 1fr auto; }
    .row-2 .input:nth-child(1) { grid-column: 1 / -1; }
    .row-2 .input:nth-child(2) { grid-column: 1; }
    .row-2 button { grid-column: 2; grid-row: 2; }
}

/* ─── Home: 2 cards grandes ─── */
.grid-home {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-top: 1rem;
}
@media (min-width: 900px) {
    .grid-home { grid-template-columns: 1fr 1fr; }
}

.home-card {
    display: flex;
    flex-direction: column;
    padding: 1.75rem;
    text-decoration: none;
    color: inherit;
    transition: transform .15s, box-shadow .15s, border-color .15s;
    cursor: pointer;
    min-height: 280px;
}
.home-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    border-color: var(--brand-500);
}

.home-card-head {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .5rem;
}
.home-card-head h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: var(--text);
}
.home-card-icon {
    font-size: 2.25rem;
    line-height: 1;
}

.home-card > p {
    margin: 0 0 1.25rem;
    font-size: .95rem;
}

.home-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: 8px;
}
.home-card-stats .stat-value { font-size: 1.15rem; }

.home-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: auto;
}
.home-card-actions .btn {
    flex: 1;
    min-width: 130px;
    cursor: pointer;
}

@media (max-width: 640px) {
    .home-card { padding: 1.25rem; min-height: 0; }
    .home-card-head h2 { font-size: 1.25rem; }
    .home-card-icon { font-size: 1.75rem; }
    .home-card-stats { grid-template-columns: 1fr; padding: .75rem; }
    .home-card-actions .btn { flex: 1 1 100%; }
}

/* Ocultar valores em R$ — toggle no header */
.valor {
    display: inline-block;
    transition: filter .15s ease;
}
body.values-hidden .valor {
    filter: blur(7px);
    user-select: none;
    cursor: default;
}
body.values-hidden .valor:hover {
    /* revela ao passar o mouse, atalho rápido sem precisar desativar o modo */
    filter: blur(0);
}

/* Telas muito pequenas (≤ 360px) — só ajustes finos */
@media (max-width: 360px) {
    .nav-item { padding: .55rem .65rem; font-size: .85rem; }
    .subnav-item { padding: .5rem .65rem; font-size: .85rem; }
    .topbar-right .badge-rest { display: none; }
}
