/* IMAS - estilos gerais */
:root {
    --bg: #f6f4f8;
    --card: #ffffff;
    --txt: #241f2d;
    --muted: #6d6778;
    --line: #e5e0ea;
    --brand: #d6246e;
    --brand-dark: #b21a58;
    --brand-soft: #fce7f0;
    --ok: #1c8f5e;
    --ok-soft: #e3f5ec;
    --warn: #b86e00;
    --warn-soft: #fff1d9;
    --erro: #c9303a;
    --erro-soft: #fde8ea;
    --info-soft: #e8f0fe;
    --raio: 12px;
    --sombra: 0 1px 2px rgba(36, 31, 45, .06), 0 4px 14px rgba(36, 31, 45, .05);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--txt);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
small, .muted { color: var(--muted); }
code { background: #efeaf3; padding: 1px 5px; border-radius: 5px; font-size: .9em; }

/* ---------- topo ---------- */
.topo { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topo-in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.marca { font-weight: 800; font-size: 1.25rem; color: var(--txt); text-decoration: none; display: flex; align-items: center; gap: 9px; letter-spacing: .02em; }
.marca small { font-weight: 500; font-size: .72rem; letter-spacing: 0; color: var(--muted); }
.marca-logo { width: 26px; height: 26px; border-radius: 8px; background: var(--brand); position: relative; display: inline-block; }
.marca-logo::after { content: ""; position: absolute; inset: 6px; background: #fff; border-radius: 3px; }
.menu { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.menu a { text-decoration: none; color: var(--txt); padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.menu a:hover { background: var(--bg); }
.menu a.ativo { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.sair { display: flex; align-items: center; gap: 10px; margin: 0; }
.usuario { color: var(--muted); font-size: .9rem; }

.pagina { max-width: 1180px; margin: 0 auto; padding: 22px 16px 70px; }
.pagina-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.pagina-cab h1 { margin-bottom: 2px; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
    font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2;
    background: var(--brand); color: #fff; transition: background .12s, box-shadow .12s;
}
.btn:hover { background: var(--brand-dark); }
.btn:focus-visible, .link:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .ima-foto:focus-visible {
    outline: 3px solid rgba(214, 36, 110, .35); outline-offset: 1px;
}
.btn-claro { background: #fff; color: var(--txt); border-color: var(--line); }
.btn-claro:hover { background: var(--bg); }
.btn-perigo { background: #fff; color: var(--erro); border-color: #f0c5c9; }
.btn-perigo:hover { background: var(--erro-soft); }
.btn-pequeno { padding: 6px 12px; font-size: .88rem; }
.btn-grande { padding: 12px 22px; font-size: 1.02rem; }
.btn[disabled], .btn.desativado { opacity: .5; pointer-events: none; }

.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-dark); cursor: pointer; text-decoration: underline; }
.link.perigo { color: var(--erro); }

/* ---------- cartões e formulários ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--raio); box-shadow: var(--sombra); padding: 18px; margin-bottom: 18px; }
.card > h2:first-child { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }

label.campo { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 12px; }
label.campo > span.dica, .dica { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; margin-top: 3px; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=tel], select, textarea {
    width: 100%; margin-top: 5px; padding: 9px 11px; font: inherit; color: var(--txt);
    border: 1px solid #cfc8d8; border-radius: 9px; background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
.linha-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.linha-form > * { flex: 1 1 160px; }
.linha-form > .btn { flex: 0 0 auto; }

.alerta { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.alerta-ok { background: var(--ok-soft); border-color: #bfe5d1; color: #135d3d; }
.alerta-erro { background: var(--erro-soft); border-color: #f2c2c6; color: #8c1e26; }
.alerta-aviso { background: var(--warn-soft); border-color: #f3d9a4; color: #7a4a00; }
.alerta-info { background: var(--info-soft); border-color: #c9daf8; color: #1c3f7a; }

/* ---------- tabelas ---------- */
.tabela-wrap { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; background: #fff; }
.tabela th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabela td { padding: 11px 12px; border-bottom: 1px solid #f0ecf3; vertical-align: middle; }
.tabela tr:hover td { background: #fbf9fc; }
.tabela .num { font-weight: 700; white-space: nowrap; }
.tabela .direita { text-align: right; white-space: nowrap; }
.vazio { text-align: center; color: var(--muted); padding: 34px 10px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.st-novo { background: var(--info-soft); color: #1c3f7a; }
.st-pronto { background: var(--warn-soft); color: #7a4a00; }
.st-impresso { background: var(--brand-soft); color: var(--brand-dark); }
.st-entregue { background: var(--ok-soft); color: #135d3d; }
.st-cancelado { background: #eee; color: #555; }
.exp-ok { color: var(--muted); }
.exp-aviso { color: var(--warn); font-weight: 600; }
.exp-perigo { color: var(--erro); font-weight: 700; }

.numeros { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.numero { background: #fff; border: 1px solid var(--line); border-radius: var(--raio); padding: 14px 16px; }
.numero b { display: block; font-size: 1.9rem; line-height: 1.1; }
.numero span { color: var(--muted); font-size: .86rem; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filtros input[type=search] { flex: 2 1 220px; margin: 0; }
.filtros select { flex: 1 1 170px; margin: 0; }
.paginacao { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; color: var(--muted); }

/* ---------- login / instalador ---------- */
.caixa-centro { max-width: 420px; margin: 40px auto; }
.caixa-larga { max-width: 640px; margin: 30px auto; }
.checklist { list-style: none; margin: 0 0 14px; padding: 0; }
.checklist li { padding: 6px 0; border-bottom: 1px solid #f0ecf3; display: flex; gap: 8px; }
.checklist .sim { color: var(--ok); font-weight: 700; }
.checklist .nao { color: var(--erro); font-weight: 700; }

/* ---------- editor da encomenda ---------- */
.faixa-info { display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); margin-top: 6px; }
.faixa-info strong { color: var(--txt); }

.dropzone {
    display: block; text-align: center; border: 2px dashed #d3a7bd; background: #fff8fb;
    border-radius: var(--raio); padding: 26px 14px; cursor: pointer; color: var(--brand-dark); font-weight: 600;
    transition: background .12s, border-color .12s;
}
.dropzone small { display: block; font-weight: 400; margin-top: 3px; }
.dropzone.sobre, .dropzone:hover { background: var(--brand-soft); border-color: var(--brand); }
.dropzone input { display: none; }

.resumo { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 12px; }
.resumo-txt { font-size: 1.02rem; }
.resumo-txt small { margin-left: 6px; }

.grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.ima { background: #fff; border: 1px solid var(--line); border-radius: var(--raio); padding: 8px; box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 7px; }
.ima-foto { position: relative; display: block; width: 100%; aspect-ratio: 1 / 1; border: 0; padding: 0; background: #eee; border-radius: 8px; overflow: hidden; cursor: pointer; }
.ima-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ima-ajustar { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(36, 31, 45, .72); color: #fff; font-size: .78rem; padding: 4px; opacity: 0; transition: opacity .12s; }
.ima-foto:hover .ima-ajustar, .ima-foto:focus-visible .ima-ajustar { opacity: 1; }
.qtd { display: flex; align-items: stretch; border: 1px solid #cfc8d8; border-radius: 9px; overflow: hidden; }
.qtd button { width: 38px; border: 0; background: var(--bg); font-size: 1.15rem; cursor: pointer; color: var(--txt); }
.qtd button:hover { background: var(--brand-soft); }
.qtd input { flex: 1; min-width: 0; margin: 0; border: 0; border-radius: 0; text-align: center; font-weight: 700; padding: 6px 2px; -moz-appearance: textfield; }
.qtd input::-webkit-outer-spin-button, .qtd input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ima-rodape { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .8rem; }
.ima-nome { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.ima-botoes { display: flex; gap: 10px; flex-shrink: 0; }
.ima-enviando { align-items: center; justify-content: center; text-align: center; min-height: 190px; color: var(--muted); font-size: .85rem; }
.ima-enviando.erro { color: var(--erro); }
.ima-enviando .nome { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.zona-perigo { border-color: #f0c5c9; }
.zona-perigo .acoes { margin-top: 10px; }

/* diálogo de recorte */
dialog.recorte { border: 0; border-radius: 16px; padding: 0; width: min(520px, 96vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); color: var(--txt); }
dialog.recorte::backdrop { background: rgba(20, 14, 28, .6); }
.recorte-in { padding: 18px; }
.recorte-in h2 { margin-bottom: 4px; }
.recorte-palco {
    position: relative; width: min(100%, 420px); aspect-ratio: 1 / 1; margin: 12px auto 8px; overflow: hidden;
    background: #222; border-radius: 6px; touch-action: none; cursor: grab; user-select: none;
    outline: 2px solid var(--brand);
}
.recorte-palco.arrastando { cursor: grabbing; }
.recorte-palco.carregando::after { content: "Carregando foto…"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: .95rem; pointer-events: none; }
.recorte-palco img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; -webkit-user-drag: none; pointer-events: none; }
.recorte-grade { position: absolute; inset: 0; pointer-events: none; background:
    linear-gradient(to right, transparent 33.2%, rgba(255,255,255,.35) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.35) 66.6%, transparent 66.8%),
    linear-gradient(to bottom, transparent 33.2%, rgba(255,255,255,.35) 33.3%, transparent 33.5%, transparent 66.5%, rgba(255,255,255,.35) 66.6%, transparent 66.8%); }
.recorte-ctl { display: flex; align-items: center; gap: 10px; width: min(100%, 420px); margin: 0 auto; }
.recorte-ctl input[type=range] { flex: 1; accent-color: var(--brand); }
.recorte-botoes { display: flex; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-top: 16px; }
.recorte-botoes .grupo { display: flex; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #241f2d; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 8px 28px rgba(0, 0, 0, .3); max-width: 92vw; }
.toast.erro { background: var(--erro); }

@media (max-width: 640px) {
    .pagina { padding-top: 16px; }
    .topo { position: static; }
    .topo-in { gap: 6px 10px; }
    .marca small { display: none; }
    .usuario { display: none; }
    .sair { margin-left: auto; }
    .menu { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; gap: 2px; padding-bottom: 2px; }
    .menu a { white-space: nowrap; padding: 6px 10px; }
    h1 { font-size: 1.35rem; }
}
