/* ==========================================
   IDENTIDADE VISUAL (cores do logo)
   ========================================== */
:root {
    --brand: #0E3A66;
    --brand-hover: #0A2D50;
    --brand-soft: #E8EFF7;
    --accent: #F5B014;
    --accent-soft: #FEF5DC;

    --bg: #F3F5F8;
    --surface: #FFFFFF;
    --surface-2: #F8FAFC;
    --border: #E2E7EE;
    --border-strong: #CBD3DE;
    --text: #0F1B2D;
    --text-2: #475569;
    --muted: #7A8699;

    --success: #157A3F;
    --success-soft: #E6F4EC;
    --danger: #C62828;
    --danger-soft: #FDECEC;
    --whats: #1FA855;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 27, 45, .04), 0 1px 3px rgba(15, 27, 45, .06);
    --shadow-lg: 0 10px 30px rgba(15, 27, 45, .12);

    --header-h: 64px;
    --nav-h: 64px;

    /* Ajustes do Bootstrap */
    --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-body-color: var(--text);
    --bs-body-bg: var(--bg);
    --bs-border-color: var(--border);
    --bs-primary: var(--brand);
    --bs-primary-rgb: 14, 58, 102;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 14, 58, 102;
}

/* A página ocupa no mínimo a tela inteira. Sem isso, no iPhone (app na tela inicial)
   a barra de navegação fixa "flutua" acima do fundo quando a tela tem pouco conteúdo. */
html {
    min-height: 100%;
    background: var(--bg);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    font-family: var(--bs-body-font-family);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

/* Evita zoom automático no iOS ao tocar em campos */
input, select, textarea, button {
    font-size: 16px !important;
}

.d-none {
    display: none !important;
}

/* ==========================================
   TELA DE ACESSO (login, cadastro, oficina)
   Enquanto não há sessão, só ela aparece.
   ========================================== */
body.sem-sessao .app-header,
body.sem-sessao .app-nav,
body.sem-sessao .app-main {
    display: none !important;
}

body.sem-sessao {
    padding-bottom: 0;
}

.acesso {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
    background:
        radial-gradient(1200px 500px at 50% -10%, #1B5089 0%, transparent 60%),
        var(--brand);
}

.acesso-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
    padding: 28px 24px;
}

.acesso-marca {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 24px;
}

.acesso-marca img {
    border-radius: 14px;
}

.acesso-nome {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--brand);
    line-height: 1;
    margin-top: 6px;
}

.acesso-slogan {
    font-size: .85rem;
    color: var(--muted);
}

.acesso-titulo {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.acesso-texto {
    color: var(--text-2);
    font-size: .92rem;
    margin-bottom: 16px;
}

.acesso-link {
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
    font-size: .9rem;
}

.acesso-rodape {
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    margin: 18px 0 0;
}

.acesso-msg:not(:empty) {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
}

.acesso-msg.erro {
    background: var(--danger-soft);
    color: var(--danger);
}

.acesso-msg.ok {
    background: var(--success-soft);
    color: var(--success);
}

/* ==========================================
   CONTA (modal)
   ========================================== */
.conta-usuario {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.conta-usuario i {
    font-size: 2rem;
    color: var(--brand);
}

.conta-usuario div {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.conta-usuario strong {
    overflow: hidden;
    text-overflow: ellipsis;
}

.conta-usuario span {
    color: var(--muted);
    font-size: .85rem;
}

.acesso-lista {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
}

.acesso-linha {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.acesso-linha:last-child {
    border-bottom: 0;
}

.acesso-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.acesso-info strong {
    font-weight: 600;
    font-size: .92rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acesso-info span {
    color: var(--muted);
    font-size: .8rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acesso-papel {
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
}

.conta-acoes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

/* ==========================================
   CABEÇALHO
   ========================================== */
.app-header {
    background: var(--brand);
    color: #fff;
    padding-top: env(safe-area-inset-top);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.app-header-inner {
    max-width: 960px;
    margin: 0 auto;
    height: var(--header-h);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.brand-name {
    font-weight: 800;
    font-size: 1.08rem;
    letter-spacing: -.02em;
}

.brand-sub {
    font-size: .78rem;
    color: rgba(255, 255, 255, .7);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 0;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem !important;
    transition: background .15s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, .2);
}

/* ==========================================
   NAVEGAÇÃO
   Celular: barra fixa embaixo. Computador: abas abaixo do cabeçalho.
   ========================================== */
.app-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}

.app-nav-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    height: var(--nav-h);
}

.nav-tab {
    flex: 1;
    border: 0;
    background: none;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-weight: 500;
    font-size: .75rem !important;
    position: relative;
    transition: color .15s;
}

.nav-tab i {
    font-size: 1.35rem;
    line-height: 1;
}

.nav-tab.active {
    color: var(--brand);
    font-weight: 600;
}

.nav-tab.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--accent);
}

@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .app-nav {
        position: sticky;
        top: calc(var(--header-h) + env(safe-area-inset-top));
        bottom: auto;
        border-top: 0;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0;
    }

    .app-nav-inner {
        height: 52px;
        padding: 0 16px;
        gap: 4px;
        justify-content: flex-start;
    }

    .nav-tab {
        flex: none;
        flex-direction: row;
        gap: 8px;
        padding: 0 16px;
        font-size: .95rem !important;
    }

    .nav-tab i {
        font-size: 1.1rem;
    }

    .nav-tab.active::before {
        top: auto;
        bottom: 0;
        left: 12px;
        right: 12px;
        border-radius: 3px 3px 0 0;
    }
}

/* ==========================================
   ESTRUTURA DA PÁGINA
   ========================================== */
.app-main {
    max-width: 760px;
    margin: 0 auto;
    padding: 20px 16px 32px;
}

.page-head {
    margin-bottom: 16px;
}

.page-head h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 0;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.panel-title {
    font-size: 1.02rem;
    font-weight: 600;
    margin: 0;
}

.panel-hint {
    color: var(--muted);
    font-size: .875rem;
    margin: 2px 0 0;
}

.section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.section-num {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
    font-size: .82rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 24px 0 12px;
}

.subsection-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 4px 0 10px;
}

/* ==========================================
   FORMULÁRIOS E BOTÕES
   ========================================== */
.form-label {
    font-size: .85rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 6px;
}

.form-control,
.form-select {
    background-color: var(--surface);
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    padding: .6rem .8rem;
    color: var(--text);
}

/* Campos em maiúsculas (placa, marca) não deixam o texto de exemplo gritando */
.form-control::placeholder {
    text-transform: none;
    letter-spacing: normal;
    color: #9AA5B5;
}

.form-control-lg {
    border-radius: var(--radius-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(14, 58, 102, .14);
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--surface-2);
    color: var(--muted);
}

.form-text {
    color: var(--muted);
    font-size: .8rem;
}

.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: .55rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-link {
    text-decoration: none;
}

.btn-lg {
    padding: .7rem 1.2rem;
    border-radius: var(--radius-sm);
}

.btn-sm {
    padding: .35rem .7rem;
    font-size: .85rem !important;
}

.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-hover);
    --bs-btn-hover-border-color: var(--brand-hover);
    --bs-btn-active-bg: var(--brand-hover);
    --bs-btn-active-border-color: var(--brand-hover);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
}

.btn-light {
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-color: var(--text);
    --bs-btn-hover-bg: var(--surface-2);
    --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-bg: var(--brand-soft);
    --bs-btn-active-border-color: var(--border-strong);
    --bs-btn-disabled-bg: var(--surface);
    --bs-btn-disabled-border-color: var(--border);
}

.btn-whats {
    white-space: normal;
    text-align: center;
    background: var(--whats);
    border-color: var(--whats);
    color: #fff;
}

.btn-whats:hover,
.btn-whats:active {
    background: #188F47;
    border-color: #188F47;
    color: #fff;
}

/* Campos com prefixo/sufixo (R$ / km) */
.input-prefix,
.input-suffix {
    position: relative;
}

.input-prefix > span,
.input-suffix > span {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: .9rem;
    pointer-events: none;
}

.input-prefix > span {
    left: 12px;
}

.input-prefix > .form-control {
    padding-left: 38px;
}

.input-suffix > span {
    right: 12px;
}

.input-suffix > .form-control {
    padding-right: 40px;
}

/* ==========================================
   NOVA OS
   ========================================== */
.panel-ai {
    border-color: #D6E1EE;
    background: linear-gradient(180deg, #F5F9FD 0%, var(--surface) 70%);
}

.panel-ai-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 14px;
}

.ai-badge {
    flex-shrink: 0;
    background: var(--accent-soft);
    color: #8A5F00;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    padding: 4px 10px;
    margin-top: 1px;
}

.ai-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.ai-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 12px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s, transform .05s;
}

.ai-tile:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(14, 58, 102, .08);
}

.ai-tile:active {
    transform: scale(.98);
}

.ai-tile-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.ai-tile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.ai-tile-text strong {
    font-size: .95rem;
    font-weight: 600;
}

.ai-tile-text small {
    color: var(--muted);
    font-size: .78rem;
}

@media (max-width: 420px) {
    .ai-tile {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

.ditado {
    margin-top: 14px;
}

.ditado-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

/* "Fechar" vai para baixo, ocupando a linha toda */
#btnFecharDitado {
    grid-column: 1 / -1;
    order: 1;
}

#statusAssistente:not(:empty) {
    margin-top: 12px;
}

.placa-search {
    display: flex;
    gap: 8px;
}

.placa-input {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .12em;
    font-size: 1.15rem !important;
}

.busca-status:not(:empty) {
    margin-top: 10px;
    font-size: .9rem;
}

.busca-status .text-success,
.busca-status .text-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600 !important;
}

.busca-status .text-success {
    background: var(--success-soft);
    color: var(--success) !important;
}

.busca-status .text-primary {
    background: var(--brand-soft);
    color: var(--brand) !important;
}

/* Linhas de gastos dinâmicos */
.repasse-item {
    --bs-gutter-x: 8px;
}

/* Total */
.total-box {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: var(--success-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.total-box > span {
    font-size: .85rem;
    font-weight: 600;
    color: var(--success);
}

.total-value {
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--success);
}

.total-value small {
    font-weight: 600;
}

.total-value input {
    border: 0;
    background: transparent;
    color: var(--success);
    font-weight: 700;
    font-size: 1.5rem !important;
    width: 9ch;
    text-align: right;
    padding: 0;
    outline: none;
}

.total-value input::placeholder {
    color: var(--success);
    opacity: .5;
}

/* Barra de ações fixa */
.action-bar {
    position: sticky;
    bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    margin: 0 -16px;
    padding: 12px 16px;
    background: rgba(243, 245, 248, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
    .action-bar {
        bottom: 0;
        margin: 0;
        padding: 12px 0;
        background: rgba(243, 245, 248, .92);
        border-top: 0;
    }
}

/* ==========================================
   AVISOS (callouts, alerts e toasts)
   ========================================== */
.callout {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid;
    margin-bottom: 16px;
}

.callout-icon {
    font-size: 1.15rem;
    line-height: 1.3;
}

.callout-body {
    flex: 1;
    min-width: 0;
}

.callout-warning {
    background: var(--accent-soft);
    border-color: #F6DE9C;
    color: #6B4A00;
}

.callout-info {
    background: var(--brand-soft);
    border-color: #CBDBEC;
    color: var(--brand);
}

.alert {
    border-radius: var(--radius-sm);
    font-size: .9rem;
}

.toast-area {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: calc(var(--header-h) + env(safe-area-inset-top) + 12px);
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100% - 32px));
    pointer-events: none;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: #fff;
    font-weight: 500;
    font-size: .92rem;
    box-shadow: var(--shadow-lg);
    animation: toast-in .2s ease-out;
}

.app-toast i {
    font-size: 1.1rem;
}

.app-toast.sucesso i { color: #5BD68E; }
.app-toast.erro { background: var(--danger); }

.app-toast.saindo {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .25s, transform .25s;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* ==========================================
   CONSULTA
   ========================================== */
.search-row {
    display: flex;
    gap: 8px;
}

.search-field {
    position: relative;
    flex: 1;
    min-width: 0;
}

.search-field i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.search-field .form-control {
    padding-left: 36px;
}

.os-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.os-group-date {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 10px 4px 2px;
}

.os-list > .os-group-date:first-child {
    margin-top: 0;
}

.os-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.os-card:hover {
    border-color: var(--border-strong);
    box-shadow: 0 4px 12px rgba(15, 27, 45, .08);
}

.os-card-main {
    flex: 1;
    min-width: 0;
}

.os-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.placa-tag {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-weight: 700;
    font-size: .85rem;
    letter-spacing: .06em;
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--brand-soft);
    color: var(--brand);
}

.os-card-car {
    font-weight: 600;
    font-size: .95rem;
}

.os-card-desc {
    color: var(--text-2);
    font-size: .875rem;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.os-card-client {
    color: var(--muted);
    font-size: .8rem;
    margin-top: 2px;
}

.os-card-value {
    text-align: right;
    flex-shrink: 0;
    font-weight: 700;
    color: var(--success);
    white-space: nowrap;
}

.os-card-value i {
    display: block;
    color: var(--muted);
    font-size: .9rem;
    margin-top: 4px;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 40px 16px;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}

.empty-state.erro {
    color: var(--danger);
    border-color: #F3B8B8;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.pager span {
    color: var(--muted);
    font-size: .875rem;
    font-weight: 500;
}

/* ==========================================
   DETALHES DA OS (modal)
   ========================================== */
.modal-content {
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.modal-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    gap: 8px;
}

.modal-footer > * {
    margin: 0;
}

/* Celular: as janelas abrem em tela cheia. Como a barra de status do iPhone é transparente
   (app na tela inicial), o topo da janela fica embaixo do relógio e da bateria, e o rodapé
   embaixo da barra de gestos. Reserva esse espaço, como o cabeçalho principal já faz. */
@media (max-width: 575.98px) {
    .modal-fullscreen-sm-down .modal-content {
        border-radius: 0;
    }

    .modal-fullscreen-sm-down .modal-header {
        padding-top: calc(16px + env(safe-area-inset-top));
    }

    .modal-fullscreen-sm-down .modal-footer {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

.detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.detail-car {
    font-size: 1.1rem;
    font-weight: 700;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 20px;
    margin-bottom: 18px;
}

@media (min-width: 576px) {
    .detail-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.detail-item span {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: 2px;
}

.detail-item strong {
    font-weight: 500;
    word-break: break-word;
}

.detail-desc {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    white-space: pre-wrap;
    margin-bottom: 18px;
}

.detail-values {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.detail-values > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .92rem;
}

.detail-values > div:last-child {
    border-bottom: 0;
}

.detail-values .sub {
    color: var(--text-2);
    padding-left: 26px;
}

.detail-values .total {
    background: var(--success-soft);
    color: var(--success);
    font-weight: 700;
    font-size: 1.05rem;
}

/* ==========================================
   FINANCEIRO
   ========================================== */
.fin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.fin-toolbar .form-control {
    width: auto;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.kpi-label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--muted);
}

.kpi-value {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Celular: faturamento ocupa a linha inteira, os outros dois dividem a de baixo */
@media (max-width: 560px) {
    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .kpi:first-child {
        grid-column: 1 / -1;
    }

    .kpi:first-child .kpi-value {
        font-size: 1.5rem;
    }
}

.split-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

@media (min-width: 640px) {
    .split-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

.split-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    border-top: 4px solid var(--split-color);
}

.split-oficina { --split-color: var(--brand); }

/* ==========================================
   EQUIPE
   ========================================== */
.team-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.team-list:empty::before {
    content: "Nenhum funcionário ativo. Toque em Adicionar.";
    display: block;
    padding: 24px 18px;
    color: var(--muted);
    text-align: center;
}

.team-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

.team-row:last-child {
    border-bottom: 0;
}

.avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--avatar-color, var(--brand));
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.team-row.inativo .avatar {
    background: var(--border-strong);
}

.team-name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.team-row.inativo .team-name {
    color: var(--muted);
    font-weight: 500;
}

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

.btn-square {
    width: 38px;
    height: 38px;
    padding: 0;
}

.split-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.split-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-2);
}

.split-name {
    font-weight: 600;
}

.split-name small {
    color: var(--muted);
    font-weight: 400;
}

.split-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.02em;
    margin: 12px 0 14px;
}

.split-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.data-table {
    --bs-table-bg: transparent;
    font-size: .92rem;
}

.data-table th {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    border-bottom-color: var(--border);
}

.data-table td {
    border-bottom-color: var(--border);
    vertical-align: middle;
}

.modal-total {
    margin-left: auto;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--success);
}

/* ==========================================
   ESTILOS DE IMPRESSÃO (RECIBO / NOTA FISCAL)
   ========================================== */
@media print {
    /* Esconde o sistema inteiro */
    body * {
        visibility: hidden;
    }

    body {
        padding: 0;
        background: #fff;
    }

    /* Mostra apenas o recibo e seus filhos */
    #reciboImpressao, #reciboImpressao * {
        visibility: visible;
    }

    /* Posiciona o recibo no topo da página A4 */
    #reciboImpressao {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        font-family: 'Courier New', Courier, monospace; /* Fonte clássica de nota fiscal */
        color: #000;
        padding: 20px;
    }

    /* Remove margens extras colocadas pelo navegador */
    @page {
        margin: 10mm;
    }
}
