:root {
  --bg: #f4f6f8; --card: #fff; --txt: #1d2733; --muted: #6b7785; --linha: #e2e7ec;
  --azul: #1f6feb; --azul-esc: #1757bd; --verde: #1a8f4c; --verm: #c62828; --amar: #b7791f;
  --raio: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--txt); font-size: 15px; }
.topo { background: #14202e; color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 5; }
.marca { font-weight: 700; margin-bottom: 6px; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a { color: #cfd8e3; text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
nav a:hover { background: #22344a; }
nav a.ativo { background: var(--azul); color: #fff; }
main { max-width: 1100px; margin: 16px auto; padding: 0 12px 60px; }
h2 { margin: 6px 0 14px; }
h3 { margin: 0 0 8px; }
.card { background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px; margin-bottom: 14px; }
.card.erro { border-color: var(--verm); color: var(--verm); }
.card.aviso { border-color: var(--amar); background: #fff8e8; }
.card.ok { border-color: var(--verde); background: #eefaf2; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.tile { background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); padding: 14px; }
.tile .n { font-size: 26px; font-weight: 700; }
.tile .l { color: var(--muted); font-size: 13px; }
.tile.perigo .n { color: var(--verm); }
.tile.bom .n { color: var(--verde); }
.linha { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.linha > label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 3px; }
.linha > label.grande { flex: 1; min-width: 220px; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #c9d2db; border-radius: 8px; background: #fff; color: var(--txt); }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ec1ff; border-color: var(--azul); }
input[type=checkbox] { width: 18px; height: 18px; padding: 0; }
textarea { width: 100%; min-height: 90px; }
.w70 { width: 70px; } .w100 { width: 110px; } .w140 { width: 150px; }
button { font: inherit; cursor: pointer; border: 1px solid #c9d2db; background: #fff; padding: 7px 12px; border-radius: 8px; }
button:hover { background: #eef3f8; }
button.primario { background: var(--azul); color: #fff; border-color: var(--azul); font-weight: 600; }
button.primario:hover { background: var(--azul-esc); }
button.verde { background: var(--verde); color: #fff; border-color: var(--verde); }
button.perigo { color: var(--verm); border-color: #e6b3b3; }
button.x { padding: 4px 8px; color: var(--verm); }
button.mini { padding: 3px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); border-bottom: 1px solid var(--linha); padding: 6px 6px; }
td { padding: 6px; border-bottom: 1px solid var(--linha); vertical-align: middle; }
td input { width: 100%; }
.tabela { overflow-x: auto; }
.num { text-align: right; white-space: nowrap; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #e8edf2; color: #425061; white-space: nowrap; }
.tag.verde { background: #dcf5e6; color: #146c3a; }
.tag.verm { background: #fde3e3; color: #a31f1f; }
.tag.amar { background: #fdf0d3; color: #8a5a07; }
.tag.azul { background: #dfeaff; color: #1450b8; }
.abas { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.abas button.ativa { background: var(--azul); color: #fff; border-color: var(--azul); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.chip { background: #eef3fb; border: 1px solid #c8d8f5; border-radius: 99px; padding: 4px 10px; font-size: 13px; cursor: pointer; }
.total { font-size: 18px; font-weight: 700; }
.dif { color: var(--verm); font-weight: 600; }
.sub { text-align: right; white-space: nowrap; color: var(--muted); }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #14202e; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#toast.erro { background: var(--verm); }
#toast.ok { background: var(--verde); }
#busy { position: fixed; inset: 0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; z-index: 40; }
.busybox { background: #fff; border: 1px solid var(--linha); border-radius: 12px; padding: 18px 24px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
.spin { width: 20px; height: 20px; border: 3px solid #cfe0ff; border-top-color: var(--azul); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.overlay { position: fixed; inset: 0; background: rgba(20,32,46,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px; overflow: auto; z-index: 20; }
.modal { background: #fff; border-radius: 12px; padding: 18px; width: 100%; max-width: 520px; }
.progresso { height: 10px; background: #e5ebf1; border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progresso > div { height: 100%; background: var(--azul); width: 0; transition: width .3s; }
pre.log { background: #14202e; color: #d5e1ee; padding: 10px; border-radius: 8px; max-height: 220px; overflow: auto; font-size: 13px; white-space: pre-wrap; }
[hidden] { display: none !important; }
@media (max-width: 640px) { nav a { padding: 5px 8px; font-size: 13px; } .tile .n { font-size: 22px; } }

/* ===== visual moderno + celular (iPhone) ===== */
body { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
.topo { background: rgba(20, 32, 46, .94); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px); padding-top: calc(10px + env(safe-area-inset-top)); }
.card, .tile { box-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .04); border-radius: 14px; }
.tile { transition: transform .12s, box-shadow .12s; }
a.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(16, 24, 40, .1); }
button { border-radius: 10px; transition: background .12s, transform .05s; }
button:active { transform: scale(.98); }
nav a .ico { display: none; }
@media (max-width: 760px) {
  .marca { margin: 0; font-size: 15px; }
  .topo { padding-bottom: 8px; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(20, 32, 46, .97); flex-wrap: nowrap; overflow-x: auto; gap: 2px;
        padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 10; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  nav::-webkit-scrollbar { display: none; }
  nav a { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; min-width: 66px; font-size: 11px; padding: 6px 8px; white-space: nowrap; }
  nav a .ico { display: block; font-size: 20px; line-height: 1.2; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); margin-top: 10px; }
  input, select, textarea { font-size: 16px; }
  .linha > label.grande { min-width: 100%; }
  .modal { max-width: 100%; }
  #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .w70 { width: 64px; } .w100 { width: 96px; }
  th, td { padding: 6px 4px; }
}
