:root {
    --bg: #f5f1ea;
    --paper: #ffffff;
    --ink: #17151a;
    --muted: #726b62;
    --line: #e7ddd0;
    --brand: #1c1714;
    --gold: #c4944f;
    --gold-2: #f0d7a2;
    --danger: #c0392b;
    --success: #248a52;
    --warning: #b7791f;
    --info: #2563eb;
    --radius: 18px;
    --shadow: 0 16px 40px rgba(28, 23, 20, .10);
}

* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, rgba(196,148,79,.17), transparent 32rem), var(--bg);
    color: var(--ink);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; min-width: 0; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 10%, rgba(240,215,162,.3), transparent 22rem),
        linear-gradient(135deg, #151211 0%, #2b211a 48%, #111 100%);
}
.login-card {
    width: min(100%, 440px);
    background: rgba(255,255,255,.95);
    border-radius: 26px;
    padding: 32px;
    box-shadow: 0 28px 80px rgba(0,0,0,.28);
}
.login-logo {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 24px;
}
.logo-icon, .brand-icon {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand), #3c2a1d);
    color: var(--gold-2);
    font-size: 26px;
    box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.login-logo strong { display:block; font-size: 1.4rem; }
.login-logo small { color: var(--muted); }

.form-grid { display: grid; gap: 14px; }
.form-row { display: grid; gap: 8px; }
.form-row label { font-weight: 750; font-size: .92rem; }
.form-row input, .form-row select, .form-row textarea,
.input, .select, .textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 14px;
    padding: 12px 14px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.form-row textarea, .textarea { resize: vertical; min-height: 88px; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus,
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(196,148,79,.18);
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .2s, box-shadow .2s, background .2s;
    min-height: 44px;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: linear-gradient(135deg, var(--brand), #3d2a1f); box-shadow: 0 12px 25px rgba(28, 23, 20, .22); }
.btn-gold { color: #21160f; background: linear-gradient(135deg, #f4d58d, #c4944f); }
.btn-light { background: #f8f3ec; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color:#fff; }
.btn-success { background: var(--success); color:#fff; }
.btn-warning { background: #f59e0b; color:#28170a; }
.btn-sm { min-height: 34px; padding: 7px 11px; border-radius: 10px; font-size: .86rem; }
.btn-block { width: 100%; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 276px;
    position: fixed;
    inset: 0 auto 0 0;
    background: linear-gradient(180deg, #181310, #28201a);
    color: #fff;
    padding: 18px;
    z-index: 50;
    display: flex;
    flex-direction: column;
}
.brand-box { display:flex; align-items:center; justify-content:space-between; gap: 10px; margin-bottom: 18px; }
.brand-mark { display:flex; align-items:center; gap: 12px; }
.brand-mark strong { display:block; font-size: 1.15rem; }
.brand-mark small { display:block; color: var(--gold-2); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-close { display:none; background:transparent; border:0; color:#fff; font-size: 32px; }
.nav-menu { display:grid; gap: 7px; }
.nav-menu a {
    display:flex;
    align-items:center;
    gap: 10px;
    padding: 12px 12px;
    border-radius: 14px;
    color: rgba(255,255,255,.82);
    font-weight: 750;
}
.nav-menu a:hover, .nav-menu a.active { background: rgba(255,255,255,.10); color:#fff; }
.nav-menu span { width: 24px; text-align:center; }
.sidebar-footer { margin-top:auto; display:grid; gap: 12px; }
.mini-card { background: rgba(255,255,255,.09); border:1px solid rgba(255,255,255,.12); border-radius: 16px; padding:12px; display:flex; justify-content:space-between; gap: 12px; }
.mini-card span { color: rgba(255,255,255,.72); }
.logout-link { text-align:center; padding: 10px; color: var(--gold-2); }

.main-content { margin-left: 276px; width: calc(100% - 276px); min-width: 0; padding: 22px 26px 80px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap: 18px; margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: clamp(1.35rem, 2.5vw, 2rem); }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.menu-toggle { display:none; border:0; background: var(--paper); border-radius: 13px; padding:10px 12px; box-shadow: var(--shadow); }
.user-pill { display:flex; align-items:center; gap: 10px; background: var(--paper); border:1px solid var(--line); border-radius: 999px; padding: 8px 12px 8px 8px; box-shadow: 0 8px 22px rgba(28,23,20,.06); }
.user-pill > span { width: 38px; height: 38px; border-radius: 50%; background: #201711; color: var(--gold-2); display:grid; place-items:center; font-weight: 600; }
.user-pill strong { display:block; font-size: .92rem; }
.user-pill small { display:block; color: var(--muted); text-transform: capitalize; }

.card {
    min-width: 0;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.card-title { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin:0; }
.card-title p { margin: 3px 0 0; color: var(--muted); }
.grid { display:grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.actions { display:flex; flex-wrap:wrap; gap:10px; align-items:center; }
.actions-between { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap: wrap; }

.stat-card { padding: 18px; border-radius: var(--radius); background: var(--paper); border:1px solid var(--line); box-shadow: var(--shadow); }
.stat-card span { color: var(--muted); font-weight: 600; }
.stat-card strong { display:block; font-size: 1.7rem; margin-top: 7px; }
.stat-card small { color: var(--muted); }

.table-wrap { width:100%; overflow-x:auto; border-radius: 16px; border:1px solid var(--line); }
table { width:100%; border-collapse: collapse; background:#fff; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align:left; vertical-align: top; }
th { background: #fbf7f0; font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; color: #5c5045; }
tr:last-child td { border-bottom:0; }
.table-actions { display:flex; flex-wrap:wrap; gap: 7px; }

.alert { padding: 13px 15px; border-radius: 14px; margin-bottom: 16px; font-weight: 600; }
.alert-success { background: #e9f8ef; color: #155c35; border: 1px solid #bce9ca; }
.alert-danger, .alert-error { background:#fdecea; color:#8a241c; border:1px solid #f4bbb6; }
.alert-warning { background:#fff7df; color:#7a4b0d; border:1px solid #f5d287; }
.alert-info { background:#eaf1ff; color:#153f91; border:1px solid #c2d5ff; }

.badge { display:inline-flex; align-items:center; border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge-ativo, .badge-pago, .badge-finalizado, .badge-aberto, .badge-confirmado, .badge-entrada, .badge-reforco, .badge-venda { background:#e8f7ef; color:#14613a; }
.badge-inativo, .badge-cancelado, .badge-saida, .badge-sangria { background:#fdecea; color:#92251e; }
.badge-agendado, .badge-pendente { background:#fff5da; color:#8a540e; }
.badge-em_atendimento { background:#eaf1ff; color:#153f91; }
.badge-faltou { background:#f3edf9; color:#5c2f8e; }
.badge-servico { background:#f7eddf; color:#78501b; }
.badge-produto { background:#edf7f5; color:#176354; }
.badge-fechado { background:#f1f1f1; color:#555; }

.filter-bar { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items:end; margin-bottom: 16px; }
.inline-form { display:inline; }
.total-line { display:flex; justify-content:space-between; gap: 12px; padding: 9px 0; border-bottom:1px dashed var(--line); }
.total-line strong:last-child { text-align:right; }
.total-box { background:#fbf7f0; border:1px solid var(--line); border-radius:16px; padding:14px; }

.item-builder { display:grid; grid-template-columns: 1.2fr .9fr .45fr .55fr auto; gap:10px; align-items:end; }
.item-list { display:grid; gap: 10px; }
.item-row { display:grid; grid-template-columns: 1.3fr .4fr .5fr .5fr auto; gap:8px; align-items:center; background:#fbf7f0; border:1px solid var(--line); border-radius:14px; padding:10px; }
.empty-state { padding: 28px; border:1px dashed var(--line); background:rgba(255,255,255,.65); border-radius:18px; text-align:center; color:var(--muted); }

.mobile-bottom-nav { display:none; }

.print-ticket { background:#fff; color:#000; max-width: 320px; margin: 0 auto; padding: 10px; font-family: Arial, sans-serif; }
.print-ticket h1, .print-ticket h2, .print-ticket p { margin: 0; }
.print-ticket .center { text-align:center; }
.print-ticket .line { border-top:1px dashed #000; margin:8px 0; }
.print-ticket table { font-size:12px; }
.print-ticket th, .print-ticket td { border:0; padding: 3px 0; background:#fff; }
.print-actions { max-width: 320px; margin: 20px auto; display:flex; gap:8px; }

@media (max-width: 980px) {
    .sidebar { transform: translateX(-105%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close, .menu-toggle { display:block; }
    .main-content { margin-left:0; width:100%; padding: 16px 14px 96px; }
    .topbar { align-items:flex-start; }
    .user-pill { display:none; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
    .item-builder { grid-template-columns: 1fr; }
    .item-row { grid-template-columns: 1fr 1fr; }
    .mobile-bottom-nav {
        display:grid;
        grid-template-columns: repeat(4, 1fr);
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        z-index: 40;
        background: rgba(24,19,16,.96);
        color:#fff;
        border-radius: 22px;
        padding: 8px;
        box-shadow: 0 18px 45px rgba(0,0,0,.28);
    }
    .mobile-bottom-nav a { display:grid; place-items:center; gap:3px; font-size: 1.1rem; border-radius: 16px; padding: 7px 3px; }
    .mobile-bottom-nav span { font-size: .68rem; font-weight: 600; }
    .mobile-bottom-nav a.active { background: rgba(255,255,255,.12); color: var(--gold-2); }
    th, td { padding: 10px; }
}


@media (max-width: 640px) {
    body { overflow-x: hidden; }
    .main-content { padding-inline: 10px; }
    .topbar h1 { font-size: 1.22rem; line-height: 1.15; }
    .topbar p { font-size: .86rem; }
    .card { padding: 14px; border-radius: 16px; }
    .card-title { align-items: flex-start; flex-wrap: wrap; }
    .actions, .actions-between { align-items: stretch; }
    .actions .btn, .actions-between .btn { width: 100%; }
    .table-wrap {
        max-width: 100%;
        overflow: visible;
        border: 0;
        border-radius: 0;
    }
    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap tr,
    .table-wrap th,
    .table-wrap td {
        display: block;
        width: 100%;
        max-width: 100%;
    }
    .table-wrap thead { display: none; }
    .table-wrap tr {
        margin-bottom: 12px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 8px 20px rgba(28,23,20,.06);
    }
    .table-wrap td {
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    .table-wrap tr td:last-child { border-bottom: 0; }
    .table-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .table-actions .btn,
    .table-actions button,
    .table-actions form,
    .table-actions details,
    .table-actions summary {
        width: 100%;
        max-width: 100%;
    }
    .table-actions .inline-form { display: block; }
    details .form-grid,
    details form {
        width: 100% !important;
        min-width: 0 !important;
    }
    .cash-status-pill strong { font-size: .8rem; }
    .logout-top { font-size: .86rem; }
}

@media print {
    body { background:#fff; }
    .sidebar, .topbar, .mobile-bottom-nav, .print-actions { display:none !important; }
    .main-content { margin:0; width:100%; padding:0; }
    .card { box-shadow:none; border:0; }
    @page { size: 58mm auto; margin: 4mm; }
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-left: auto;
}
.cash-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.96);
    color: var(--ink);
    box-shadow: 0 10px 26px rgba(28,23,20,.10);
}
.cash-status-pill {
    padding: 8px 12px;
}
.cash-status-pill strong,
.cash-status-pill small {
    display: block;
    line-height: 1.1;
    white-space: nowrap;
}
.cash-status-pill strong { font-size: .86rem; }
.cash-status-pill small { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.cash-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 4px rgba(36,138,82,.13);
}
.is-open .cash-dot { background: var(--success); }
.is-closed .cash-dot {
    background: #9ca3af;
    box-shadow: 0 0 0 4px rgba(156,163,175,.16);
}
.logout-top {
    min-height: 40px;
    padding-inline: 13px;
    white-space: nowrap;
}
.logout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 14px;
    padding: 11px 12px;
    background: rgba(255,255,255,.11);
    border: 1px solid rgba(255,255,255,.16);
    color: var(--gold-2);
    font-weight: 600;
}
.logout-button:hover { background: rgba(255,255,255,.16); color: #fff; }
.mini-card-caixa {
    color: #fff;
    text-align: left;
    align-items: center;
}
.mini-card-caixa small {
    display: block;
    color: rgba(255,255,255,.62);
    font-size: .76rem;
    margin-left: auto;
    text-align: right;
}
.mobile-bottom-nav { grid-template-columns: repeat(5, 1fr); }

@media (max-width: 980px) {
    .topbar { flex-wrap: wrap; gap: 10px; }
    .topbar > div:not(.topbar-actions) { min-width: 0; flex: 1 1 calc(100% - 58px); }
    .topbar-actions { width: 100%; margin-left: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
    .cash-status-pill { padding: 8px 10px; max-width: 100%; }
    .cash-status-pill small { display: none; }
    .logout-top { min-height: 38px; padding: 8px 10px; }
    .mobile-bottom-nav { grid-template-columns: repeat(5, 1fr); }
}


/* Ajustes mobile v0.1.2: evita estouro horizontal e mantém o status do caixa no topo. */
@media (max-width: 640px) {
    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .cash-status-pill {
        flex: 0 1 auto;
        max-width: calc(100% - 112px);
        padding: 8px 10px;
    }
    .cash-status-pill strong {
        font-size: .8rem;
        max-width: 132px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .cash-status-pill small { display: none; }
    .logout-top {
        flex: 0 0 auto;
        font-size: .86rem;
        padding-inline: 10px;
    }
    .table-wrap {
        width: 100%;
        max-width: 100%;
        overflow: visible;
        border: 0;
        border-radius: 0;
    }
    .table-wrap table,
    .table-wrap thead,
    .table-wrap tbody,
    .table-wrap tr,
    .table-wrap th,
    .table-wrap td {
        display: block;
        width: 100%;
        max-width: 100%;
    }
    .table-wrap thead { display: none; }
    .table-wrap tr {
        margin-bottom: 12px;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 16px;
        overflow: hidden;
    }
    .table-wrap td {
        border-bottom: 1px solid var(--line);
        overflow-wrap: anywhere;
        word-break: break-word;
    }
    .table-wrap tr td:last-child { border-bottom: 0; }
    .table-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .table-actions .btn,
    .table-actions button,
    .table-actions form,
    .table-actions details,
    .table-actions summary {
        width: 100%;
        max-width: 100%;
    }
    .table-actions .inline-form { display: block; }
    .table-actions details form,
    details .form-grid {
        width: 100% !important;
        min-width: 0 !important;
    }
}
/* Ajuste Profissionais: remove rolagem da equipe ativa e compacta ações */
.profissionais-grid {
    align-items: start;
}

.profissionais-list-card {
    overflow: hidden;
}

.equipe-ativa-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
}

.equipe-ativa-table {
    table-layout: fixed;
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}

.equipe-ativa-table .col-profissional {
    width: 42%;
}

.equipe-ativa-table .col-comissao {
    width: 18%;
}

.equipe-ativa-table .col-atendimentos {
    width: 18%;
}

.equipe-ativa-table .col-acoes {
    width: 22%;
}

.equipe-ativa-table th,
.equipe-ativa-table td {
    padding: 9px 10px;
}

.profissionais-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.profissionais-actions .btn-xs,
.profissionais-actions button.btn-xs {
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 8px;
    font-size: .74rem;
    line-height: 1;
    font-weight: 750;
}

.profissionais-actions .inline-form {
    display: inline-flex;
}

@media (max-width: 640px) {
    .equipe-ativa-table {
        table-layout: auto;
        border: 0;
        border-radius: 0;
    }

    .profissionais-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .profissionais-actions .btn,
    .profissionais-actions button,
    .profissionais-actions form {
        width: auto;
        max-width: none;
    }
}