:root {
    --bg: #0f172a;
    --card: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #b91c1c;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    color: var(--text);
    padding: 2rem 1rem;
}

.container {
    max-width: 720px;
    margin: 0 auto;
}

.topo {
    text-align: center;
    color: #f1f5f9;
    margin-bottom: 1.5rem;
}
.topo h1 { margin: 0 0 .25rem; font-size: 1.9rem; }
.topo p  { margin: 0; color: #94a3b8; }

.card {
    background: var(--card);
    border-radius: 14px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
    margin-bottom: 1.25rem;
}

.form-consulta label {
    display: block;
    font-weight: 600;
    margin-bottom: .5rem;
}
.linha {
    display: flex;
    gap: .5rem;
}
input[type="text"] {
    flex: 1;
    padding: .8rem 1rem;
    font-size: 1.1rem;
    letter-spacing: 2px;
    border: 2px solid var(--border);
    border-radius: 10px;
    outline: none;
    transition: border-color .15s;
}
input[type="text"]:focus { border-color: var(--primary); }

button {
    padding: .8rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
}
button:hover { background: var(--primary-hover); }

.dica { display: block; margin-top: .5rem; color: var(--muted); }

.alerta {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger-text);
}
.alerta p { margin: .5rem 0 0; }

.resultado h2 { margin-top: 0; }

.cabecalho-veiculo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.logo-marca { width: 56px; height: 56px; object-fit: contain; }
.cabecalho-veiculo h2 { margin: 0 0 .35rem; font-size: 1.25rem; }
.placa-badge {
    display: inline-block;
    font-family: "Consolas", monospace;
    font-weight: 700;
    letter-spacing: 2px;
    background: #1e293b;
    color: #fbbf24;
    padding: .2rem .7rem;
    border-radius: 6px;
    border: 2px solid #334155;
}

.restricoes {
    margin-top: 1.25rem;
    padding: .8rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
}
.restricoes ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.restricoes li { color: #92400e; }

.fipe { margin-top: 1.5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fipe h3 { margin: 0 0 .6rem; }
.fipe table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: .88rem; }
.fipe th, .fipe td {
    text-align: left;
    padding: .5rem .6rem;
    border-bottom: 1px solid var(--border);
}
.fipe th { color: var(--muted); text-transform: uppercase; font-size: .72rem; letter-spacing: .5px; }
.fipe .valor-fipe { font-weight: 700; color: #15803d; white-space: nowrap; }
.fipe tbody tr:hover { background: #f8fafc; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: .75rem;
}
.campo {
    display: flex;
    flex-direction: column;
    padding: .6rem .8rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
}
.rotulo {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    margin-bottom: .2rem;
}
.valor { font-size: 1.05rem; font-weight: 600; word-break: break-word; }

.campo-chassi .valor {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.chassi-texto { font-family: "Consolas", monospace; letter-spacing: 1px; }
.btn-chassi {
    padding: .25rem .6rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--primary);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.btn-chassi:hover { background: #dbeafe; }
.vazio { color: #cbd5e1; font-weight: 400; }

.bruto { margin-top: 1.25rem; }
.bruto summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.bruto pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 10px;
    overflow-x: auto;
    font-size: .85rem;
}

/* ---- Peças em estoque ---- */
.pecas h2 { margin-top: 0; }
.sem-pecas { color: var(--muted); margin: 0; }
.resumo-pecas { margin: 0 0 1rem; color: var(--text); }
.verde { color: #15803d; }
.cinza { color: var(--muted); }

.lista-pecas { list-style: none; margin: 0; padding: 0; }
.peca {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .8rem .6rem;
    border-bottom: 1px solid var(--border);
}
.peca:last-child { border-bottom: none; }
.peca-sem { opacity: .72; }
.peca-status { font-size: 1.2rem; flex: 0 0 auto; }
.peca-info { flex: 1 1 auto; display: flex; flex-direction: column; gap: .15rem; }
.peca-nome { font-weight: 600; }
.peca-marca {
    font-weight: 500;
    color: var(--muted);
    background: #f1f5f9;
    padding: .05rem .4rem;
    border-radius: 5px;
    margin-left: .3rem;
    font-size: .78rem;
}
.peca-detalhe { font-size: .8rem; color: var(--muted); }
.peca-estoque { flex: 0 0 auto; text-align: right; display: flex; flex-direction: column; gap: .15rem; }
.peca-preco { font-weight: 700; font-size: 1.05rem; }
.peca-saldo { font-size: .8rem; font-weight: 600; }

.rodape {
    text-align: center;
    color: #94a3b8;
    margin-top: 1rem;
}
.rodape a { color: #60a5fa; text-decoration: none; }
.rodape a:hover { text-decoration: underline; }

/* ---- Responsivo (celular) ---- */
@media (max-width: 600px) {
    body { padding: 1.25rem .75rem; }

    .topo h1 { font-size: 1.5rem; }
    .topo p { font-size: .95rem; }

    .card { padding: 1.1rem; border-radius: 12px; }

    /* Formulário: input e botão empilhados, botão em largura total */
    .linha { flex-direction: column; align-items: stretch; }
    .linha button { width: 100%; }
    input[type="text"] { font-size: 1rem; }

    /* Cabeçalho do veículo com quebra */
    .cabecalho-veiculo { gap: .75rem; }
    .cabecalho-veiculo h2 { font-size: 1.1rem; }
    .logo-marca { width: 44px; height: 44px; }

    /* Grid de dados em coluna única */
    .grid { grid-template-columns: 1fr; }

    /* Lista de peças: empilha info e estoque */
    .peca { flex-wrap: wrap; }
    .peca-info { flex: 1 1 100%; order: 2; }
    .peca-status { order: 1; }
    .peca-estoque { flex: 1 1 100%; order: 3; flex-direction: row; justify-content: space-between; text-align: left; margin-left: 2.1rem; }
}

@media (max-width: 380px) {
    .topo h1 { font-size: 1.3rem; }
    .card { padding: .9rem; }
    .placa-badge { font-size: .9rem; }
}
