/* ============================================================
   Sistema Aplicadora de Película - Design System
   Paleta base (sobrescrita por personalização): fundo #F5F5F5,
   sidebar #1A1A1A, destaque #F00404
   ============================================================ */

:root {
    --bg: #F5F5F5;
    --sidebar-bg: #1A1A1A;
    --sidebar-bg-hover: #2A2A2A;
    --primary: #F00404;
    --primary-hover: #C40303;
    --text: #1A1A1A;
    --text-muted: #6B6B6B;
    --card-bg: #FFFFFF;
    --border: #E0E0E0;
    --success: #2E7D32;
    --success-bg: #E8F5E9;
    --alerta: #E65100;
    --alerta-bg: #FFF3E0;
    --erro: #B71C1C;
    --erro-bg: #FFEBEE;
    --info: #1565C0;
    --info-bg: #E3F2FD;
    --sidebar-width: 240px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { max-width: 100%; }

/* ---------- Layout ---------- */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icone {
    width: 100%;
    max-width: 144px;
    height: auto;
    display: block;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.sidebar-signature {
    padding: 14px 20px;
    font-size: 11px;
    color: #6B6B6B;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-signature a {
    color: #6B6B6B;
    text-decoration: underline;
}

.sidebar-signature a:hover {
    color: #C9C9C9;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #C9C9C9;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-bg-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--sidebar-bg-hover);
    color: #fff;
    border-left-color: var(--primary);
}

.sidebar-grupo:first-of-type .sidebar-grupo-titulo {
    padding-top: 8px;
}

.sidebar-grupo-titulo {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
    padding: 16px 20px 6px;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6B6B6B;
}

.sidebar-grupo-titulo:hover { color: #C9C9C9; }

.sidebar-grupo-chevron {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.sidebar-grupo-titulo.fechado .sidebar-grupo-chevron {
    transform: rotate(-90deg);
}

.sidebar-grupo-itens {
    overflow: hidden;
    transition: max-height 0.25s ease;
}

.sidebar-toggle {
    display: none;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

/* Evita que a topbar fixa esconda o topo da seção quando a página pula direto
   pra uma âncora (ex: #materiais, #servicos) depois de salvar um item. */
#materiais, #servicos { scroll-margin-top: 70px; }

.topbar-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text);
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.topbar-user > a { color: var(--primary); font-weight: 600; }

/* Sino de avisos */
.sino { position: relative; }
.sino-btn { position: relative; background: none; border: none; cursor: pointer; color: var(--text); padding: 6px; border-radius: 8px; display: flex; }
.sino-btn:hover { background: var(--bg); }
.sino-num { position: absolute; top: 0; right: -2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 100px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--card-bg); }
.sino-painel { position: absolute; right: -8px; top: calc(100% + 10px); width: 400px; max-height: min(70vh, 560px); display: flex; flex-direction: column; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.18); z-index: 120; overflow: hidden; color: var(--text); }
.sino-topo { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sino-topo strong { font-size: 15px; }
.sino-abas { display: flex; background: var(--bg); border-radius: 100px; padding: 3px; }
.sino-abas button { border: none; background: none; padding: 6px 12px; border-radius: 100px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); cursor: pointer; font-family: inherit; }
.sino-abas button.ativa { background: var(--card-bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.sino-lista { overflow-y: auto; padding: 4px 0 8px; }
.sino-vazio { text-align: center; color: var(--text-muted); padding: 28px 16px; margin: 0; font-size: 14px; }
.sino-grupo h4 { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 16px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.sino-grupo-num { background: var(--bg); border-radius: 100px; padding: 0 7px; font-size: 11px; }
.sino-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 16px; border-left: 3px solid transparent; }
.sino-item:hover { background: var(--bg); }
.sino-item.atrasado { border-left-color: var(--erro); }
.sino-item-link { grid-column: 1; grid-row: 1 / span 2; color: inherit; text-decoration: none; min-width: 0; }
.sino-item-titulo { display: block; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sino-item-detalhe { display: block; font-size: 12.5px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sino-item-quando { grid-column: 2; font-size: 12px; font-weight: 700; color: var(--text-muted); white-space: nowrap; text-align: right; }
.sino-item.atrasado .sino-item-quando { color: var(--erro); }
.sino-item-whats { grid-column: 2; font-size: 12px; font-weight: 700; color: #1a9e4b; text-decoration: none; text-align: right; }

.content { padding: 24px; }

.sidebar-overlay {
    display: none;
}

/* ---------- Cards ---------- */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* ---------- Sanfona genérica (cards de lista do Dashboard etc.) ---------- */

.sanfona-cabecalho {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-align: left;
    font: inherit;
    color: inherit;
}
.sanfona-cabecalho .card-title { margin-bottom: 0; }
.sanfona-seta {
    flex-shrink: 0;
    margin-left: 8px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.sanfona-cabecalho.aberto .sanfona-seta { transform: rotate(180deg); }
.sanfona-corpo {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease;
}
.sanfona-corpo.aberto { grid-template-rows: 1fr; }
.sanfona-corpo-inner { overflow: hidden; padding-top: 16px; }

/* ---------- Olho de mostrar/ocultar senha (genérico) ---------- */

.campo-senha-wrapper { position: relative; }
.campo-senha-wrapper input[type="password"],
.campo-senha-wrapper input[type="text"] { padding-right: 42px; }
.campo-senha-olho {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    opacity: 0.55;
    display: flex;
    align-items: center;
    color: inherit;
}
.campo-senha-olho:hover { opacity: 1; }

.grid { display: grid; gap: 16px; align-items: stretch; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card.warn .stat-value { color: var(--alerta); }
.stat-card.danger .stat-value { color: var(--erro); }
.stat-card.success .stat-value { color: var(--success); }

/* Cards de conteúdo dentro de um .grid também ficam com altura igual */
.grid > .card { display: flex; flex-direction: column; margin-bottom: 0; }

/* Formulários: centralizados na área de conteúdo, não colados à esquerda */
.card-form { margin: 0 auto; }

/* ---------- Botões ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

label, .modal-box label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 14px 0 6px;
}

/* Sem exigir ancestral <form> - evita bug recorrente de campo de busca "encolhido"
   quando o input fica fora de um <form> (ex: telas com autocomplete solto na página). */
input[type="text"], input[type="number"], input[type="email"], input[type="password"],
input[type="date"], input[type="datetime-local"], input[type="tel"], input[type="search"], input[type="url"],
select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13.5px;
    background: #fff;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="tel"]:focus, input[type="search"]:focus, input[type="url"]:focus,
select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

input[type="checkbox"], input[type="radio"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    padding: 0;
    accent-color: var(--primary);
}

.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; }

.checkbox-linha {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    font-size: 13px;
    margin: 0;
}

.telefone-grupo { display: flex; gap: 8px; }
.telefone-grupo .prefixo-pais {
    display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--bg); font-size: 13.5px; font-weight: 600; color: var(--text-muted);
}
.telefone-grupo input { flex: 1; }

/* ---------- Modal ---------- */

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 28px; width: 480px; max-width: 92vw; max-height: 90vh; overflow-y: auto; }

/* ---------- Sugestões de busca (produto/cliente) ---------- */

.produto-sugestoes {
    display: none; position: fixed; z-index: 150;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12); max-height: 340px; overflow-y: auto; margin-top: 2px;
}
.produto-sugestao-item { padding: 10px 12px; font-size: 13px; line-height: 1.4; cursor: pointer; }
.produto-sugestao-item:hover { background: var(--bg); }
.produto-sugestao-vazia { padding: 10px 12px; font-size: 13px; color: var(--text-muted); }

/* ---------- Leitor de código de barras (câmera) ---------- */

.btn-leitor-camera {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border: none; border-radius: 6px; background: var(--bg);
    color: var(--text-muted); font-size: 14px; cursor: pointer; z-index: 5;
    display: flex; align-items: center; justify-content: center;
}
.btn-leitor-camera:hover { background: var(--border); color: var(--text); }

/* ---------- Tabelas ---------- */

.tabela-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Barra de rolagem horizontal customizada (visível), pra telas com tabela/kanban que
   passam do limite da tela no celular. A barra nativa do iOS Safari some sozinha e o
   usuário não percebe que dá pra arrastar - essa fica sempre visível como indicador. */
.barra-scroll-custom {
    position: relative;
    height: 6px;
    background: var(--border);
    border-radius: 100px;
    margin: 4px 2px 12px;
    display: none;
}
.barra-scroll-thumb {
    position: absolute;
    top: 0;
    height: 100%;
    min-width: 30px;
    background: var(--primary);
    border-radius: 100px;
    cursor: grab;
}
.barra-scroll-thumb:active { cursor: grabbing; }
@media (max-width: 900px) {
    .barra-scroll-custom { display: block; }
}

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

tr:hover td { background: #FAFAFA; }

/* ---------- Badges / Status ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-alerta  { background: var(--alerta-bg); color: var(--alerta); }
.badge-erro    { background: var(--erro-bg); color: var(--erro); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-neutro  { background: #EEE; color: var(--text-muted); }

/* ---------- Alertas ---------- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 16px;
}

.alert-erro    { background: var(--erro-bg); color: var(--erro); }
.alert-sucesso { background: var(--success-bg); color: var(--success); }
.alert-info    { background: var(--info-bg); color: var(--info); }

/* ---------- Login ---------- */

.login-page {
    background: var(--sidebar-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 360px;
    max-width: 90vw;
}

.login-logo { display: block; max-width: 240px; max-height: 100px; margin: 0 auto 18px; }
.login-title { font-size: 20px; font-weight: 700; text-align: center; }
.login-subtitle { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 4px; margin-bottom: 10px; }
.login-form .btn { margin-top: 22px; }

/* ---------- Responsivo ---------- */

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content { margin-left: 0; }
    .topbar-menu-btn { display: block; }
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .sidebar-overlay.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 90;
    }
}

@media (max-width: 640px) {
    .content { padding: 14px; }
    .topbar { padding: 12px 16px; }
    .form-row { flex-direction: column; align-items: stretch !important; }
    .card { padding: 16px; }
    .card-form { max-width: 100% !important; }
    /* Barras de ação (título + botões) e linhas de botão viram coluna/quebram
       pra não espremer nem cortar nada em tela estreita - sem precisar editar
       cada tela que usa esse padrão de layout inline. */
    [style*="justify-content:space-between"] { flex-wrap: wrap; gap: 10px; }
    [style*="display:flex"] { flex-wrap: wrap; }
}

/* ============================================================
   App mobile (PWA): topo escuro, navegação inferior, toques grandes
   ============================================================ */

.nav-inferior { display: none; }
.banner-instalar { display: none; }

@media (max-width: 900px) {
    html { -webkit-tap-highlight-color: transparent; }
    body { overscroll-behavior-y: none; }

    .topbar {
        background: var(--sidebar-bg);
        border-bottom: none;
        padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
    }
    .topbar-menu-btn { display: none !important; }
    .topbar-title { color: #fff; font-size: 17px; font-weight: 700; }
    .topbar-user > span { display: none; }
    .topbar-user > a { color: rgba(255,255,255,0.7); font-weight: 500; }
    .sino-btn { color: #fff; }
    .sino-btn:hover { background: rgba(255,255,255,.1); }
    .sino-num { box-shadow: 0 0 0 2px var(--sidebar-bg); }
    .sino-painel { position: fixed; left: 10px; right: 10px; width: auto; top: calc(58px + env(safe-area-inset-top)); max-height: calc(100vh - 150px - env(safe-area-inset-top)); }

    .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
    .content { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }

    /* 16px evita o zoom automático do iPhone ao tocar num campo */
    input[type="text"], input[type="number"], input[type="email"], input[type="password"],
    input[type="date"], input[type="datetime-local"], input[type="tel"], input[type="search"], input[type="url"],
    select, textarea { font-size: 16px; padding: 12px; }
    .btn { min-height: 44px; }
    .btn-sm { min-height: 38px; padding: 8px 14px; font-size: 13.5px; }
    .card { border-radius: 14px; }

    .nav-inferior {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
        align-items: flex-end; justify-content: space-around;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        background: rgba(255,255,255,0.97); border-top: 1px solid var(--border);
        -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    }
    .nav-inferior-item {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
        padding: 6px 0 2px; color: var(--text-muted); font-size: 11px; font-weight: 600;
        background: none; border: none; font-family: inherit; cursor: pointer;
    }
    .nav-inferior-item svg { width: 24px; height: 24px; }
    .nav-inferior-item.ativo { color: var(--primary); }
    .nav-inferior-central {
        flex: 0 0 auto; width: 58px; height: 58px; margin: -26px 4px 2px; border-radius: 50%;
        background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
        border: 4px solid var(--bg); box-shadow: 0 6px 18px rgba(240,4,4,0.38);
        transition: transform .12s ease;
    }
    .nav-inferior-central svg { width: 28px; height: 28px; }
    .nav-inferior-central:active, .nav-inferior-item:active { transform: scale(0.92); }

    .banner-instalar:not([hidden]) {
        display: flex; align-items: center; gap: 12px;
        position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 85;
        background: #1A1A1A; color: #fff; border-radius: 16px; padding: 12px 12px 12px 14px;
        box-shadow: 0 12px 32px rgba(0,0,0,0.35); animation: bannerSobe .35s ease;
    }
    .banner-instalar img { width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0; }
    .banner-instalar-texto { flex: 1; min-width: 0; line-height: 1.3; }
    .banner-instalar-texto strong { display: block; font-size: 14px; }
    .banner-instalar-texto span { font-size: 12px; color: rgba(255,255,255,0.7); }
    .banner-instalar-btn {
        background: var(--primary); color: #fff; border: none; border-radius: 10px;
        padding: 10px 14px; font-weight: 700; font-size: 14px; font-family: inherit;
    }
    .banner-instalar-fechar { background: none; border: none; color: rgba(255,255,255,0.6); font-size: 22px; padding: 0 4px; }
}

@keyframes bannerSobe { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================================================
   Tela da OS (desktop e app)
   ============================================================ */

.os-cabecalho { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.os-cabecalho-topo { display: flex; align-items: center; gap: 10px; }
.os-numero { font-size: 20px; font-weight: 800; }
.os-placa {
    display: inline-block; margin-top: 8px; padding: 3px 10px; border: 2px solid var(--text); border-radius: 6px;
    font-family: 'Courier New', monospace; font-weight: 700; font-size: 15px; letter-spacing: 2px; background: #fff;
}
.os-cabecalho-sub { color: var(--text-muted); font-size: 13px; margin-top: 8px; line-height: 1.5; }
.os-cabecalho-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.os-atalhos { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.os-atalhos::-webkit-scrollbar { display: none; }
.os-atalhos a {
    flex-shrink: 0; padding: 8px 14px; border-radius: 100px; background: var(--card-bg); border: 1px solid var(--border);
    font-size: 13px; font-weight: 600; color: var(--text);
}
.os-atalhos a b { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 100px; background: var(--primary); color: #fff; font-size: 11px; text-align: center; }
html { scroll-behavior: smooth; }
#checklist, #fotos, #servicos, #materiais, #totais { scroll-margin-top: 80px; }

.secao-toggle {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
    background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: inherit; text-align: left;
}
.secao-toggle-titulo { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secao-toggle-seta { font-size: 18px; transition: transform .2s; }
.secao-toggle.aberto .secao-toggle-seta { transform: rotate(180deg); }
#checklistCorpo { margin-top: 14px; }
.secao-dica { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; line-height: 1.5; }

/* Checklist em cartões */
.chk-lista { display: flex; flex-direction: column; gap: 8px; }
.chk-item { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: #fff; transition: border-color .2s, background .2s; }
.chk-item.avaria { border-color: var(--erro); background: var(--erro-bg); }
.chk-item.salvando { opacity: .7; }
.chk-item.salvo { box-shadow: 0 0 0 2px var(--success); }
.chk-linha { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chk-nome { font-weight: 600; font-size: 14px; }
.chk-seletor { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; flex-shrink: 0; }
.chk-opcao { margin: 0; cursor: pointer; }
.chk-opcao input { position: absolute; opacity: 0; pointer-events: none; }
.chk-opcao span { display: block; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--text-muted); transition: background .15s, color .15s; }
.chk-ok input:checked + span { background: var(--success); color: #fff; }
.chk-avaria input:checked + span { background: var(--erro); color: #fff; }
.chk-detalhe { display: none; margin-top: 10px; }
.chk-item.avaria .chk-detalhe { display: block; }
.chk-obs { background: #fff; }
.chk-fotos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }
.chk-foto-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 64px; padding: 0 14px; border-radius: 10px;
    border: 2px dashed var(--erro); background: #fff; color: var(--erro); font-weight: 700; font-size: 13px; font-family: inherit; cursor: pointer;
}
.chk-foto-btn svg { width: 22px; height: 22px; }
.chk-fotos .foto-mini { width: 64px; height: 64px; }

/* Galeria de fotos */
.foto-abas { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.foto-aba { flex: 1; padding: 10px; border: none; background: none; border-radius: 9px; font-family: inherit; font-size: 14px; font-weight: 700; color: var(--text-muted); cursor: pointer; }
.foto-aba b { font-weight: 700; opacity: .6; margin-left: 2px; }
.foto-aba.ativa { background: #fff; color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.foto-acoes { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-bottom: 14px; }
.foto-btn-camera, .foto-btn-galeria {
    display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; border-radius: 12px;
    font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.foto-btn-camera { background: var(--primary); color: #fff; border: none; box-shadow: 0 4px 12px rgba(240,4,4,.25); }
.foto-btn-galeria { background: #fff; color: var(--text); border: 1px solid var(--border); }
.foto-btn-camera svg, .foto-btn-galeria svg { width: 22px; height: 22px; }
.foto-btn-camera:active, .foto-btn-galeria:active, .chk-foto-btn:active { transform: scale(.97); }
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.foto-mini {
    position: relative; aspect-ratio: 1; padding: 0; border: none; border-radius: 10px; overflow: hidden;
    background: var(--bg); cursor: zoom-in; display: block;
}
.foto-mini img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto-mini.enviando img { opacity: .45; }
.foto-mini.enviando::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
    border: 3px solid #fff; border-top-color: var(--primary); border-radius: 50%; animation: girar .8s linear infinite;
}
.foto-mini.erro { outline: 3px solid var(--erro); }
.foto-etiqueta {
    position: absolute; left: 4px; right: 4px; bottom: 4px; padding: 2px 5px; border-radius: 5px;
    background: rgba(183,28,28,.9); color: #fff; font-size: 10px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.foto-vazio { color: var(--text-muted); font-size: 13px; text-align: center; padding: 18px 0 6px; }
@keyframes girar { to { transform: rotate(360deg); } }

/* Visualizador em tela cheia */
.lightbox:not([hidden]) {
    position: fixed; inset: 0; z-index: 300; background: #000; display: flex; flex-direction: column;
    animation: lbEntra .18s ease;
}
.lightbox-topo {
    display: flex; align-items: center; gap: 12px; color: #fff; font-size: 14px; font-weight: 600;
    padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
}
.lightbox-topo #lightboxLegenda { flex: 1; }
.lightbox-topo #lightboxContador { color: rgba(255,255,255,.6); font-weight: 500; }
.lightbox-fechar { background: rgba(255,255,255,.12); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 24px; cursor: pointer; }
.lightbox-palco { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; }
.lightbox-palco img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; }
.lightbox-rodape {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
}
.lightbox-rodape button { background: rgba(255,255,255,.12); color: #fff; border: none; border-radius: 12px; min-height: 46px; min-width: 56px; font-size: 26px; font-family: inherit; cursor: pointer; }
.lightbox-rodape .lightbox-excluir { font-size: 14px; font-weight: 700; padding: 0 18px; color: #FF8A8A; }
@keyframes lbEntra { from { opacity: 0; } to { opacity: 1; } }

/* Aviso rápido */
.toast:not([hidden]) {
    position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 310;
    display: flex; align-items: center; gap: 14px; background: #1A1A1A; color: #fff; padding: 12px 16px; border-radius: 12px;
    font-size: 14px; font-weight: 600; box-shadow: 0 10px 28px rgba(0,0,0,.3); max-width: calc(100vw - 24px);
    animation: bannerSobe .25s ease;
}
.toast button { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 8px 12px; font-weight: 700; font-family: inherit; font-size: 13px; white-space: nowrap; }

@media (max-width: 900px) {
    .os-cabecalho { flex-direction: column; background: var(--sidebar-bg); color: #fff; margin: -14px -14px 12px; padding: 16px 16px 18px; border-radius: 0 0 20px 20px; }
    .os-cabecalho-sub { color: rgba(255,255,255,.7); }
    .os-placa { background: #fff; color: #1A1A1A; border-color: #fff; font-size: 18px; }
    .os-cabecalho-acoes { width: 100%; justify-content: stretch; }
    .os-cabecalho-acoes .btn { flex: 1; background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.18); font-size: 13px; padding: 10px 8px; }
    .os-cabecalho-acoes .btn-primary { background: var(--primary); border-color: var(--primary); }
    .os-atalhos { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 40; margin: 0 -14px 14px; padding: 8px 14px; background: var(--bg); }
    .toast:not([hidden]) { bottom: calc(92px + env(safe-area-inset-bottom)); }
    .chk-opcao span { padding: 10px 16px; font-size: 14px; }
    .foto-grid { grid-template-columns: repeat(3, 1fr); }
    #checklist, #fotos, #servicos, #materiais, #totais { scroll-margin-top: 120px; }
}

@media (max-width: 900px) {
    .kanban-board { scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
    .kanban-board .kanban-coluna { min-width: 84vw; scroll-snap-align: center; max-height: none; }
}

.btn-whats { background: #25D366; color: #fff; border: none; font-weight: 700; }
.btn-whats:hover { background: #1EB857; }
@media (max-width: 900px) {
    .os-cabecalho-acoes .btn-whats { flex-basis: 100%; background: #25D366; border-color: #25D366; color: #fff; font-size: 15px; }
}
