/* ==========================================================
   Sistema de Implantação — identidade visual
   Paleta: navy profundo + dourado (referência a custo/valor)
   Tipografia: Sora (display) + Inter (texto) + JetBrains Mono (dados)
   ========================================================== */

:root {
    --navy-900: #101a30;
    --navy-800: #16223f;
    --navy-700: #1c2c4d;
    --gold-500: #d6a756;
    --gold-400: #e3bd7c;
    --bg: #f5f6f9;
    --surface: #ffffff;
    --text: #171b26;
    --text-muted: #6b7280;
    --border: #e6e8ef;
    --success: #2f8f5b;
    --danger: #c0392b;
    --radius: 14px;
    --shadow: 0 10px 30px -12px rgba(16, 26, 48, 0.18);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    /* PWA em fullscreen ocupa até embaixo do notch/barra de status —
       esse padding empurra o conteúdo pra não ficar atrás deles. */
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

h1, h2, h3 {
    font-family: 'Sora', 'Inter', sans-serif;
    letter-spacing: -0.02em;
    margin: 0;
}

a { color: inherit; }

.mono { font-family: 'JetBrains Mono', monospace; }

/* ---------- LOGIN ---------- */
.login-wrap {
    display: flex;
    min-height: 100vh;
}

.login-hero {
    flex: 1.1;
    background: radial-gradient(circle at 20% 20%, var(--navy-700), var(--navy-900) 70%);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.login-hero .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 18px;
    letter-spacing: 0.02em;
}

.login-hero .brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gold-500);
}

.login-hero .pitch h1 {
    font-size: clamp(32px, 4vw, 44px);
    font-weight: 600;
    line-height: 1.15;
    max-width: 480px;
}

.login-hero .pitch p {
    color: #b9c2d6;
    margin-top: 16px;
    max-width: 420px;
    line-height: 1.6;
}

/* signature: sparkline representando a curva de custo de implantação */
.ledger-line {
    position: absolute;
    right: -40px;
    bottom: -20px;
    width: 520px;
    max-width: 70%;
    opacity: 0.9;
}

.ledger-line path.fill { fill: url(#goldFade); }
.ledger-line path.line {
    fill: none;
    stroke: var(--gold-500);
    stroke-width: 2.5;
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: draw 1.8s ease forwards 0.3s;
}

@keyframes draw {
    to { stroke-dashoffset: 0; }
}

.login-hero .foot {
    color: #7c88a3;
    font-size: 13px;
}

.login-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: var(--surface);
}

.login-card { width: 100%; max-width: 360px; }

.login-card .eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold-500);
    margin-bottom: 8px;
    display: block;
}

.login-card h2 {
    font-size: 26px;
    margin-bottom: 6px;
}

.login-card .sub {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.field input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fbfbfd;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus {
    outline: none;
    border-color: var(--gold-500);
    box-shadow: 0 0 0 3px rgba(214, 167, 86, 0.18);
    background: #fff;
}

.btn-primary {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: var(--navy-900);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s, transform .1s;
    margin-top: 6px;
}

.btn-primary:hover { background: var(--navy-700); }
.btn-primary:active { transform: scale(0.99); }

.alert {
    background: #fdecea;
    border: 1px solid #f5c6c0;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 18px;
}

.hint {
    margin-top: 22px;
    font-size: 12.5px;
    color: var(--text-muted);
    background: #f7f7fb;
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

/* ---------- APP SHELL (dashboard) ---------- */
.sidebar {
    width: 240px;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--navy-900);
    color: #fff;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 16px;
    padding: 6px 10px 26px;
}

.sidebar .brand .dot {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--gold-500);
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; min-height: 0; }

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #aab4cc;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.sidebar a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar a.active { background: var(--gold-500); color: var(--navy-900); }

.sidebar .logout {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 14px;
}

main {
    margin-left: 240px;
    padding: 32px 40px;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.topbar .eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--gold-500);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 4px;
}

.topbar h1 { font-size: 26px; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 14px 8px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
}

.user-chip .avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--gold-500);
    color: var(--navy-900);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

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

.card .label {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 26px;
    font-weight: 700;
    margin-top: 8px;
    color: var(--navy-900);
}

/* ---------- cards KPI com ícone (dashboard) ---------- */
.card-kpi {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold-500);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.card-kpi.kpi-gold { border-left-color: var(--gold-500); }
.card-kpi.kpi-navy { border-left-color: var(--navy-700); }
.card-kpi.kpi-green { border-left-color: var(--success); }
.card-kpi.kpi-red { border-left-color: var(--danger); }

.card-kpi .card-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}
.card-kpi.kpi-gold .card-icon { background: #fbf1de; }
.card-kpi.kpi-navy .card-icon { background: #eef1f8; }
.card-kpi.kpi-green .card-icon { background: #e7f5ee; }
.card-kpi.kpi-red .card-icon { background: #fdecea; }

.card-kpi .card-body { min-width: 0; flex: 1; }
.card-kpi .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-kpi .value {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 21px;
    color: var(--navy-900);
    margin-top: 3px;
    line-height: 1.15;
}

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

.panel h2 { font-size: 16.5px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.panel .sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 18px; }

/* ---------- título de seção do dashboard, com selo de ícone ---------- */
.dash-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Sora', sans-serif;
    font-size: 15.5px;
    font-weight: 700;
    color: var(--navy-900);
    margin: 30px 0 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}
.dash-section-title:first-of-type { margin-top: 4px; }
.dash-section-title .icone-secao {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.03em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 30px; margin-bottom: 10px; }

/* ---------- extras: módulo de Implantações ---------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 10px;
    background: var(--gold-500);
    color: var(--navy-900);
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.btn-secondary:hover { background: var(--gold-400); }
.btn-secondary:active { transform: scale(0.99); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #f5f6f9; border-color: #d3d7e2; }

.btn-danger-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid #f0cfc9;
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn-danger-ghost:hover { background: #fdecea; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    min-width: 260px;
}
.search-box input {
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    background: transparent;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: capitalize;
}
.badge.planejada { background: #eef1f8; color: #47506b; }
.badge.em_andamento { background: #fdf3e0; color: #92650f; }
.badge.concluida { background: #e7f5ee; color: var(--success); }
.badge.alta-recorrencia { background: #fdecea; color: var(--danger); }
.badge.aguardando { background: #eaf1fd; color: #2563eb; }

.actions-cell { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-cell .btn-primary { width: auto; padding: 8px 14px; margin-top: 0; font-size: 12.5px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }

.field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fbfbfd;
    resize: vertical;
    min-height: 90px;
}
.field textarea:focus { outline: none; border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(214,167,86,.18); background:#fff; }

.field select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fbfbfd;
}

.peca-row-completa {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fafbfd;
}
.peca-row {
    display: grid;
    grid-template-columns: 1fr 1fr 110px 40px;
    gap: 10px;
    margin-bottom: 8px;
    align-items: center;
}
.peca-origem-select { grid-column: span 2; }
.peca-serie-wrap { margin-bottom: 8px; }
.peca-serie-wrap select { border: 1px solid var(--gold-500); }
.peca-tipo-uso {
    display: flex;
    gap: 16px;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-muted);
}
.peca-tipo-uso label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.peca-comprovante {
    display: flex;
    align-items: center;
    gap: 6px;
}
.peca-comprovante input[type="file"] {
    font-size: 11.5px;
    padding: 6px 8px;
}

.equip-row {
    display: grid;
    grid-template-columns: 1fr 110px 40px;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}
.equip-row-4col {
    display: grid;
    grid-template-columns: 1fr 64px 110px 40px;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}
.equip-row input, .equip-row-4col input { margin: 0; }
.equip-remove {
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid #f0cfc9;
    background: #fff;
    color: var(--danger);
    cursor: pointer;
    font-weight: 700;
}
.equip-remove:hover { background: #fdecea; }

.add-row-btn {
    border: 1.5px dashed var(--border);
    background: transparent;
    color: var(--text-muted);
    padding: 10px;
    width: 100%;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
}
.add-row-btn:hover { border-color: var(--gold-500); color: var(--navy-900); }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}
.form-actions .btn-primary { width: auto; padding: 12px 26px; }

.install-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    border: none;
}
.install-card-icon { font-size: 30px; flex-shrink: 0; }
.install-card-texto { flex: 1; }
.install-card-texto h2 { color: #fff; }
.install-card-texto .sub { color: #b9c2d6; }
.install-card .btn-secondary { flex-shrink: 0; }

@media (max-width: 780px) {
    .install-card { flex-wrap: wrap; text-align: left; }
    .install-card .btn-secondary { width: 100%; justify-content: center; }
}

.hint-app {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    border-style: solid;
    border-color: var(--gold-500);
    background: #fdf8ef;
    transition: background .15s;
}
.hint-app:hover { background: #fbf0dc; }
.hint-app-icone { font-size: 22px; }

/* ---------- Configurações: cartões de app por plataforma ---------- */
.app-plataformas {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.app-plataforma-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.app-plataforma-desabilitada { background: #f9fafb; opacity: 0.85; }
.app-plataforma-head { display: flex; align-items: center; gap: 12px; }
.app-plataforma-icone { font-size: 26px; }
.app-atual {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    margin-top: 12px;
    font-size: 13.5px;
}

@media (max-width: 780px) {
    .app-plataformas { grid-template-columns: 1fr; }
}

.btn-ghost.active-filtro { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }

/* ---------- toast de chamado novo (canto superior direito) ---------- */
.toast-chamado-wrap {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top));
    right: 16px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}
.toast-chamado {
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    color: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(16,26,48,0.4);
    border-left: 4px solid var(--gold-500);
    padding: 14px 16px;
    cursor: pointer;
    animation: toastEntrar 0.35s ease;
    position: relative;
    overflow: hidden;
}
.toast-chamado.saindo { animation: toastSair 0.3s ease forwards; }
@keyframes toastEntrar {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastSair {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}
.toast-chamado-titulo { font-family:'Sora',sans-serif; font-weight:700; font-size:13.5px; display:flex; align-items:center; gap:6px; margin-bottom:4px; }
.toast-chamado-corpo { font-size:12.5px; color:#c6d0e2; }
.toast-chamado-barra { position:absolute; left:0; bottom:0; height:3px; background:var(--gold-500); animation: toastBarra 15s linear forwards; }
@keyframes toastBarra { from { width:100%; } to { width:0%; } }

/* ---------- leitor de QR code (dashboard) ---------- */
.qr-modal {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.qr-modal-topo {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px calc(12px + env(safe-area-inset-top));
    background: linear-gradient(rgba(0,0,0,0.6), transparent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    z-index: 1;
}
.qr-modal-fechar {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}
#qr-video {
    width: 100%;
    max-width: 480px;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    border-radius: 12px;
}
.qr-video-wrap {
    position: relative;
    width: 100%;
    max-width: 480px;
}
.qr-mira {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 62%;
    aspect-ratio: 1;
    border: 3px solid rgba(255,255,255,0.85);
    border-radius: 16px;
    box-shadow: 0 0 0 999px rgba(0,0,0,0.35);
    pointer-events: none;
}

/* ---------- feed de atividade recente ---------- */
.feed-list { display: flex; flex-direction: column; margin-top: 8px; }
.feed-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
}
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: #fbfbfd; }
.feed-titulo { font-size: 13.5px; font-weight: 600; }
.feed-meta { font-size: 11.5px; color: var(--text-muted); }

/* ---------- gráfico de pizza (CSS puro) ---------- */
.pie-wrap {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}
.pie-chart {
    width: 138px;
    height: 138px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 30px -12px rgba(16,26,48,0.35), inset 0 0 0 1px rgba(16,26,48,0.04);
}
.pie-centro {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(16,26,48,0.12);
}
.pie-centro .pie-total-num {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 19px;
    color: var(--navy-900);
    line-height: 1;
}
.pie-centro .pie-total-lbl {
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-top: 3px;
}
.pie-legend { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 180px; }
.pie-legend-item { display: flex; align-items: flex-start; gap: 10px; }
.pie-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; margin-top: 4px; }
.pie-legend-body { flex: 1; min-width: 0; }
.pie-legend-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.pie-label { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pie-valor { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-muted); flex-shrink: 0; }
.pie-legend-track { height: 5px; border-radius: 999px; background: #eef0f5; overflow: hidden; }
.pie-legend-fill { height: 100%; border-radius: 999px; }

@media (max-width: 780px) {
    .pie-wrap { justify-content: center; }
}

/* ---------- Downloads: arraste e solte + lista ---------- */
.dropzone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    background: #fbfbfd;
}
.dropzone:hover, .dropzone.dropzone-ativo {
    border-color: var(--gold-500);
    background: #fdf8ef;
}
.dropzone-icon { font-size: 32px; margin-bottom: 8px; }
.dropzone-texto { font-size: 14px; color: var(--text); margin: 0; }
.dropzone-texto span { color: var(--text-muted); font-size: 12.5px; }
.dropzone-arquivo {
    display: none;
    margin-top: 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy-900);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
}

.download-list { display: flex; flex-direction: column; gap: 10px; }
.download-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text);
    transition: border-color .15s, background .15s;
}
.download-item:hover { border-color: var(--gold-500); background: #fdfaf3; }
.download-icon { font-size: 26px; flex-shrink: 0; }
.download-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.download-info strong { font-size: 14.5px; }
.download-desc { font-size: 12.5px; color: var(--text-muted); }
.download-meta { font-size: 11.5px; color: var(--text-muted); }
.download-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

@media (max-width: 780px) {
    .download-item { flex-wrap: wrap; }
    .download-actions { width: 100%; justify-content: flex-end; }
}

/* ---------- seletor de foto: câmera / galeria com prévia ---------- */
.upload-picker-btns { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
    margin-top: 4px;
}
.upload-preview-thumb {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #f5f6f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    position: relative;
}
.upload-preview-thumb img, .upload-preview-thumb video { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-thumb .nome-arquivo {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(16,26,48,0.7); color:#fff; font-size: 8.5px;
    padding: 2px 3px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- geolocalização (RAT) ---------- */
.geo-box {
    border: 1.5px dashed var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13.5px;
}
.geo-box.geo-ok { border-style: solid; border-color: var(--success); background: #f2faf6; }
.geo-box.geo-erro { border-style: solid; border-color: #f0cfc9; background: #fdf6f4; }
.geo-status { color: var(--text-muted); }
.geo-box.geo-ok .geo-status { color: var(--success); font-weight: 600; }
.geo-box.geo-erro .geo-status { color: var(--danger); font-weight: 600; }

/* ---------- PWA: botão de instalar ---------- */
#btn-instalar-pwa {
    position: fixed;
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    z-index: 999;
    background: var(--navy-900);
    color: #fff;
    border: none;
    padding: 13px 20px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13.5px;
    box-shadow: 0 10px 24px -8px rgba(16,26,48,0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
#btn-instalar-pwa:hover { background: var(--navy-700); }

@media print {
    #btn-instalar-pwa { display: none !important; }
    .stat-mini-card, .pie-chart { box-shadow: none !important; }
    .chart-bar-row .qty { background: none !important; padding: 0 !important; }
}

/* ---------- tela de desbloqueio (biometria) ---------- */
.lock-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, var(--navy-700), var(--navy-900) 70%);
    padding: 24px;
}
.lock-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 36px 30px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 20px 50px -15px rgba(0,0,0,0.4);
    text-align: center;
}
.lock-card .brand { color: var(--navy-900); }
.lock-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
    color: var(--navy-900);
    font-size: 28px;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 16px;
}
.lock-card .btn-primary { width: 100%; }

/* ---------- notificações ---------- */
.notif-card {
    border: 1px solid var(--border);
    border-left: 4px solid var(--gold-500);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fbfbfd;
}
.notif-card.notif-tecnico { border-left-color: var(--navy-700); }
.notif-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.notif-msg { font-size: 14px; line-height: 1.5; margin: 0 0 8px; }
.notif-foot { font-size: 11.5px; color: var(--text-muted); }

.sidebar-badge {
    background: var(--gold-500);
    color: var(--navy-900);
    font-size: 10.5px;
    font-weight: 800;
    border-radius: 999px;
    padding: 1px 7px;
    margin-left: auto;
}

/* ---------- galeria de fotos / evidências ---------- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
}
.photo-thumb {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    aspect-ratio: 1;
}
.photo-thumb img, .photo-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove {
    position: absolute;
    top: 4px; right: 4px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(16,26,48,0.75);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    text-decoration: none;
    line-height: 1;
}
.photo-remove:hover { background: var(--danger); }

input[type="file"] {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px dashed var(--border);
    border-radius: 10px;
    font-size: 13.5px;
    background: #fbfbfd;
    font-family: inherit;
}

/* ---------- RAT: cupom térmico (recibo) ---------- */
.rat-toolbar {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.rat-preview-wrap {
    display: flex;
    justify-content: center;
}

.rat-print {
    width: 80mm;
    max-width: 100%;
    box-sizing: border-box;
    background: #fff;
    color: #000;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.45;
    padding: 14px 12px;
    border: 1px solid var(--border);
}
.rat-print * { box-sizing: border-box; }

.rat-print .center { text-align: center; }
.rat-print .bold { font-weight: 700; }
.rat-print .big { font-size: 15px; font-weight: 700; }
.rat-print .divider { border-top: 1px dashed #000; margin: 10px 0; }
.rat-print .row { display: flex; justify-content: space-between; gap: 8px; }
.rat-print .label-rat { font-weight: 700; text-transform: uppercase; font-size: 10.5px; margin-bottom: 2px; }
.rat-print .block { margin-bottom: 10px; }
.rat-print .sig-line {
    margin-top: 26px;
    border-top: 1px solid #000;
    padding-top: 4px;
    text-align: center;
    font-size: 10.5px;
}
.rat-print .sig-img { max-width: 100%; max-height: 60px; margin-top: 6px; }
.rat-print .via-tag { text-align:center; font-size: 10px; letter-spacing: .1em; margin-top: 14px; text-transform: uppercase; }
.rat-print .qr-cupom { display: flex; justify-content: center; }
.rat-print .qr-cupom img { image-rendering: pixelated; }

.rat-print.print-only { display: none; }

.sig-pad-wrap {
    border: 1.5px dashed var(--border);
    border-radius: 10px;
    padding: 10px;
    background: #fbfbfd;
}
.sig-pad-wrap canvas {
    width: 100%;
    height: 160px;
    background: #fff;
    border-radius: 8px;
    touch-action: none;
    border: 1px solid var(--border);
}
.sig-pad-actions { display:flex; justify-content: flex-end; margin-top: 8px; }

@media print {
    .rat-print.print-only { display: block !important; page-break-before: always; }
    .rat-preview-wrap { display: block !important; }
    .rat-print { border: none; }
}

/* ---------- relatório / impressão ---------- */
.report-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 32px 32px;
    box-shadow: var(--shadow);
    max-width: 780px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}
.report-card::before {
    content: '';
    display: block;
    height: 6px;
    margin: 0 -32px 26px;
    background: linear-gradient(90deg, var(--navy-900), var(--navy-700) 40%, var(--gold-500));
}
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid var(--navy-900);
    padding-bottom: 18px;
    margin-bottom: 22px;
}
.report-header .brand { font-family:'Sora',sans-serif; font-weight:700; font-size:18px; display:flex; align-items:center; gap:8px; }
.report-header .brand .dot { width:9px; height:9px; border-radius:50%; background: var(--gold-500); }
.report-header .meta { text-align:right; font-size:12.5px; color: var(--text-muted); }

.report-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 24px;
    margin-bottom: 26px;
    background: #fafbfd;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
}
.report-grid .item .k { font-size: 11.5px; text-transform: uppercase; letter-spacing:.04em; color: var(--text-muted); font-weight:700; }
.report-grid .item .v { font-size: 15px; margin-top: 3px; }

.report-section-title {
    font-family:'Sora',sans-serif;
    font-size: 14.5px;
    font-weight: 700;
    margin: 26px 0 12px;
    padding-bottom: 8px;
    padding-left: 12px;
    border-bottom: 1px solid var(--border);
    border-left: 3px solid var(--gold-500);
    break-after: avoid;
    break-inside: avoid;
}

.report-footer {
    margin-top: 34px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

.chart-bar-row { display:flex; align-items:center; gap:12px; margin-bottom:13px; font-size:13px; break-inside: avoid; }
.chart-bar-row:last-child { margin-bottom: 0; }
.chart-bar-row .name {
    width: 148px;
    flex-shrink:0;
    color: var(--text);
    font-weight: 600;
    font-size: 12.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chart-bar-row .track { flex:1; background:#eef0f5; border-radius:999px; height:11px; overflow:hidden; }
.chart-bar-row .fillbar {
    height:100%;
    background: linear-gradient(90deg, var(--navy-700), var(--gold-500));
    border-radius:999px;
    transition: width .5s ease;
}
.chart-bar-row .qty {
    min-width: 34px;
    text-align:center;
    font-family:'JetBrains Mono',monospace;
    font-weight:700;
    font-size: 11.5px;
    color: var(--navy-900);
    background: #f2f3f7;
    padding: 4px 10px;
    border-radius: 999px;
    flex-shrink: 0;
}

.stat-mini-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}
.stat-mini-card {
    background: #fafbfd;
    border: 1px solid var(--border);
    border-top: 2px solid var(--gold-500);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
    box-shadow: 0 4px 12px -6px rgba(16,26,48,0.12);
}
.stat-mini-card .k { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; }
.stat-mini-card .v { font-family: 'JetBrains Mono', monospace; font-size: 19px; font-weight: 700; color: var(--navy-900); margin-top: 4px; }

.print-toolbar { display:flex; justify-content:flex-end; gap:10px; margin-bottom:16px; max-width:780px; margin-left:auto; margin-right:auto; }

table { break-inside: avoid; }
.photo-grid { break-inside: avoid; }

.so-print { display: none; }

@media print {
    .sidebar, .no-print { display: none !important; }
    .bottom-nav, .mais-overlay, .mais-sheet, #btn-instalar-pwa { display: none !important; }
    main { margin-left: 0 !important; padding: 0 !important; }
    body { background: #fff !important; }
    .report-card { box-shadow: none; border: none; max-width: 100%; }
    .report-card::before { margin-left: 0; margin-right: 0; }
    .so-print { display: flex !important; }
    @page { margin: 10mm; }
}

/* ---------- navegação mobile (barra inferior + menu "Mais") ---------- */
.bottom-nav { display: none; }
.mais-overlay { display: none; }
.mais-sheet { display: none; }

@media (max-width: 780px) {
    .login-hero { display: none; }
    .sidebar { display: none; }
    main { margin-left: 0; padding: 16px 16px 90px; }

    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 20px -8px rgba(16,26,48,0.15);
        z-index: 900;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    }
    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 10.5px;
        font-weight: 600;
        font-family: inherit;
        text-decoration: none;
        padding: 6px 2px;
        border-radius: 12px;
        position: relative;
    }
    .bottom-nav-item .ic { font-size: 20px; position: relative; }
    .bottom-nav-item.active { color: var(--navy-900); background: #fbf3e4; }
    .bottom-nav-dot {
        position: absolute;
        top: -2px; right: -6px;
        width: 8px; height: 8px;
        border-radius: 50%;
        background: var(--gold-500);
        border: 1.5px solid #fff;
    }

    .mais-overlay.aberto, .mais-sheet.aberto { display: block; }
    .mais-overlay {
        position: fixed; inset: 0;
        background: rgba(16,26,48,0.45);
        z-index: 950;
    }
    .mais-sheet {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        background: var(--surface);
        border-radius: 20px 20px 0 0;
        padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
        z-index: 960;
        max-height: 75vh;
        overflow-y: auto;
        box-shadow: 0 -10px 30px -10px rgba(16,26,48,0.3);
    }
    .mais-sheet-handle {
        width: 40px; height: 4px;
        background: var(--border);
        border-radius: 999px;
        margin: 6px auto 16px;
        cursor: pointer;
    }
    .mais-fechar {
        position: absolute;
        top: 14px; right: 16px;
        width: 30px; height: 30px;
        border-radius: 50%;
        border: none;
        background: #f0f1f5;
        color: var(--text-muted);
        font-size: 15px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .mais-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 13px 10px;
        border-radius: 10px;
        color: var(--text);
        text-decoration: none;
        font-size: 15px;
        font-weight: 600;
        border-bottom: 1px solid var(--border);
    }
    .mais-item:last-child { border-bottom: none; }
    .mais-item span:first-child { font-size: 19px; }

    #btn-instalar-pwa { bottom: calc(84px + env(safe-area-inset-bottom)); }

    /* ---------- tabelas viram cartões no celular ---------- */
    .table-responsive table, .table-responsive thead, .table-responsive tbody,
    .table-responsive th, .table-responsive tr, .table-responsive td {
        display: block;
        width: 100%;
    }
    .table-responsive thead { display: none; }
    .table-responsive tr {
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px 14px;
        background: var(--surface);
    }
    .table-responsive tr:last-child { margin-bottom: 0; }
    .table-responsive td {
        border: none;
        padding: 7px 0;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        font-size: 13.5px;
        text-align: right;
    }
    .table-responsive td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: .03em;
        flex-shrink: 0;
        text-align: left;
    }
    .table-responsive td[data-label=""]::before,
    .table-responsive td:not([data-label])::before { display: none; }
    .table-responsive .actions-cell { justify-content: flex-end; width: 100%; flex-wrap: wrap; }

    .form-grid { grid-template-columns: 1fr; }
    .equip-row { grid-template-columns: 1fr 80px 40px; }
    .equip-row-4col { grid-template-columns: 1fr 50px 80px 36px; gap: 6px; }
    .peca-row { grid-template-columns: 1fr; }
    .report-grid { grid-template-columns: 1fr; }
    .cards-split, .cards-split-wide { grid-template-columns: 1fr !important; }
    .stat-mini-cards { grid-template-columns: 1fr; }

    /* ---------- deixa tudo mais compacto e "de app" no celular ---------- */
    main { padding-top: 12px; }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 20px;
    }
    .topbar h1 { font-size: 20px; }
    .topbar .eyebrow { font-size: 11px; }
    .topbar .user-chip { align-self: flex-start; }

    .panel { padding: 16px; border-radius: 14px; }
    .panel h2 { font-size: 15px; }

    .cards { gap: 12px; margin-bottom: 20px; }
    .card, .card-kpi { padding: 14px 16px; border-radius: 13px; }
    .card-kpi .card-icon { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
    .card-kpi .value { font-size: 18px; }

    .dash-section-title { font-size: 14px; margin: 24px 0 12px; }
    .dash-section-title .icone-secao { width: 26px; height: 26px; font-size: 13px; }

    /* gráfico de barra: nome menor e sem cortar valor */
    .chart-bar-row { gap: 8px; margin-bottom: 12px; }
    .chart-bar-row .name { width: 92px; font-size: 11.5px; }
    .chart-bar-row .qty { font-size: 10.5px; padding: 3px 8px; min-width: auto; }

    /* pizza: menor e legenda ocupando a largura toda embaixo */
    .pie-wrap { gap: 16px; }
    .pie-chart { width: 108px; height: 108px; }
    .pie-centro { width: 58px; height: 58px; }
    .pie-centro .pie-total-num { font-size: 15px; }
    .pie-legend { min-width: 100%; gap: 10px; }
    .pie-label { font-size: 12.5px; }

    /* linha "buscar + botão" empilha e os botões ficam largura total */
    .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .page-head > div { display: flex; flex-direction: column; gap: 8px; }
    .page-head .btn-secondary, .page-head .btn-ghost { justify-content: center; }
    .search-box { width: 100%; }

    /* filtros de relatório empilhados e largura total */
    .panel form[method="get"] { flex-direction: column; align-items: stretch !important; }
    .panel form[method="get"] .field { width: 100%; }
    .panel form[method="get"] button[type="submit"] { width: 100% !important; }

    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn-primary, .form-actions .btn-ghost, .form-actions .btn-secondary { width: 100%; justify-content: center; }

    /* relatório em PDF: menos espaço nas bordas na tela do celular */
    .report-card { padding: 0 16px 20px; }
    .report-card::before { margin-left: -16px; margin-right: -16px; }
    .report-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .report-header .meta { text-align: left; }
    .report-grid { padding: 12px 14px; }

    .actions-cell .btn-ghost, .actions-cell .btn-danger-ghost, .actions-cell .btn-secondary, .actions-cell .btn-primary {
        padding: 8px 10px;
        font-size: 12px;
    }
}

.cards-split { grid-template-columns: 1fr 1fr; }
.cards-split-wide { grid-template-columns: 1.3fr 1fr; }
