/* RB Metais — App do Gestor (PWA, mobile-first) */
:root {
  --bg: #0b0c10; --bg2: #111318; --card: rgba(255,255,255,.045); --card2: rgba(255,255,255,.07);
  --line: rgba(255,255,255,.08); --txt: #f3f4f6; --mut: #9aa1ad; --mut2: #6b7280;
  --red: #e3262d; --red2: #ff5a4f; --ora: #ff7a1a; --grn: #22c55e; --amb: #f5b301; --blu: #3b82f6; --vio: #a855f7;
  --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; overscroll-behavior-y: none; }
button { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 32px 24px calc(32px + var(--safe-b));
  background: radial-gradient(120% 70% at 50% -10%, rgba(227,38,45,.35), transparent 60%), radial-gradient(90% 60% at 100% 110%, rgba(255,122,26,.18), transparent 60%), var(--bg); }
.login .marca { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 34px; animation: sobe .7s ease both; }
.login .marca .lg { width: 112px; height: 76px; border-radius: 16px; background: #000; display: grid; place-items: center; box-shadow: 0 20px 50px rgba(227,38,45,.35); overflow: hidden; }
.login .marca .lg img { width: 100%; height: 100%; object-fit: contain; }
.login h1 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -.5px; }
.login p.sub { margin: 0; color: var(--mut); font-size: 14px; }
.login form { display: flex; flex-direction: column; gap: 12px; animation: sobe .7s .12s ease both; }
.campo { position: relative; }
.campo input { width: 100%; padding: 16px 16px 16px 46px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.05);
  color: var(--txt); font-size: 16px; outline: none; transition: .2s; }
.campo input:focus { border-color: var(--red); background: rgba(227,38,45,.08); box-shadow: 0 0 0 4px rgba(227,38,45,.15); }
.campo svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--mut); }
.btn { border: 0; border-radius: 14px; padding: 16px; font-size: 16px; font-weight: 800; color: #fff; cursor: pointer;
  background: linear-gradient(135deg, var(--red), #b0151b); box-shadow: 0 12px 30px rgba(227,38,45,.35); transition: transform .12s; }
.btn:active { transform: scale(.98); }
.btn.sec { background: var(--card2); box-shadow: none; border: 1px solid var(--line); font-weight: 700; }
.login .erro { color: var(--red2); font-size: 13px; text-align: center; min-height: 18px; }
.login .rodape { text-align: center; color: var(--mut2); font-size: 11px; margin-top: 30px; }

/* ---------- shell ---------- */
.topo { position: sticky; top: 0; z-index: 20; padding: calc(10px + var(--safe-t)) 18px 10px; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, rgba(11,12,16,.96), rgba(11,12,16,.82)); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); }
.topo .lg { width: 46px; height: 32px; border-radius: 8px; background: #000; overflow: hidden; display: grid; place-items: center; flex: none; }
.topo .lg img { width: 100%; height: 100%; object-fit: contain; }
.topo .tt { flex: 1; min-width: 0; }
.topo .tt b { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo .tt small { color: var(--mut); font-size: 12px; }
.ico-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--txt); display: grid; place-items: center; cursor: pointer; flex: none; }
.ico-btn svg { width: 19px; height: 19px; }
.ico-btn.av { background: linear-gradient(135deg, var(--red), var(--ora)); border: 0; font-weight: 900; font-size: 15px; }
main { padding: 14px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.tela { animation: entra .35s ease both; }

/* filtros (empresa / período) */
.filtros { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--mut); border-radius: 999px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: .2s; }
.chip.on { background: var(--txt); color: #0b0c10; border-color: var(--txt); }
.chip.emp { color: var(--txt); display: inline-flex; align-items: center; gap: 6px; }
.chip.emp svg { width: 14px; height: 14px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--mut); display: flex; align-items: center; justify-content: space-between; letter-spacing: .2px; }
.card h3 a { color: var(--red2); font-size: 12.5px; text-decoration: none; font-weight: 700; cursor: pointer; }
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 20px; margin-bottom: 14px;
  background: radial-gradient(120% 120% at 100% 0%, rgba(255,122,26,.55), transparent 55%), linear-gradient(135deg, #e3262d 0%, #8f0f14 100%);
  box-shadow: 0 20px 50px rgba(227,38,45,.30); }
.hero .lbl { font-size: 13px; font-weight: 600; opacity: .85; display: flex; align-items: center; gap: 6px; }
.hero .val { font-size: 34px; font-weight: 900; letter-spacing: -1px; margin: 6px 0 4px; }
.hero .det { font-size: 13px; opacity: .85; }
.hero .spark { position: absolute; right: -6px; bottom: -6px; width: 58%; height: 70px; opacity: .45; }
.hero .pill { position: absolute; top: 16px; right: 16px; background: rgba(0,0,0,.22); border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; position: relative; overflow: hidden; cursor: pointer; }
.kpi .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; margin-bottom: 10px; }
.kpi .ic svg { width: 18px; height: 18px; }
.kpi .t { font-size: 12px; color: var(--mut); font-weight: 600; }
.kpi .v { font-size: 20px; font-weight: 800; margin-top: 2px; letter-spacing: -.4px; }
.kpi .s { font-size: 11.5px; color: var(--mut); margin-top: 2px; }
.kpi .s b { color: var(--txt); }
.c-red { background: rgba(227,38,45,.15); color: var(--red2); } .c-ora { background: rgba(255,122,26,.15); color: var(--ora); }
.c-grn { background: rgba(34,197,94,.14); color: var(--grn); } .c-amb { background: rgba(245,179,1,.14); color: var(--amb); }
.c-blu { background: rgba(59,130,246,.15); color: #60a5fa; } .c-vio { background: rgba(168,85,247,.15); color: #c084fc; }

/* gráficos */
.graf { width: 100%; height: 190px; display: block; }
.leg { display: flex; gap: 14px; font-size: 12px; color: var(--mut); margin-top: 6px; flex-wrap: wrap; }
.leg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 16px; }
.donut-wrap svg { width: 132px; height: 132px; flex: none; }
.donut-leg { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 13px; min-width: 0; }
.donut-leg div { display: flex; align-items: center; gap: 8px; }
.donut-leg span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--mut); }
.donut-leg b { font-weight: 700; }
.gauges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gauge { text-align: center; }
.gauge svg { width: 100%; max-width: 130px; height: auto; }
.gauge .gl { font-size: 12px; color: var(--mut); margin-top: -4px; }

/* ranking / barras */
.rank { display: flex; flex-direction: column; gap: 12px; }
.rk { display: flex; align-items: center; gap: 12px; }
.rk .av { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex: none; }
.rk .md { flex: 1; min-width: 0; }
.rk .nm { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk .br { height: 7px; background: rgba(255,255,255,.07); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.rk .br i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--red), var(--ora)); width: 0; transition: width 1s cubic-bezier(.2,.8,.2,1); }
.rk .vl { text-align: right; font-weight: 800; font-size: 14px; }
.rk .vl small { display: block; color: var(--mut); font-weight: 600; font-size: 11px; }
.rk .nmf { display: flex; align-items: center; }
.rk .nmf span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.abc { flex: none; font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; margin-left: 6px; }
.abc.A { background: rgba(34,197,94,.18); color: var(--grn); } .abc.B { background: rgba(245,179,1,.18); color: var(--amb); } .abc.C { background: rgba(255,255,255,.1); color: var(--mut); }

/* listas */
.busca { position: relative; margin-bottom: 10px; }
.busca input { width: 100%; padding: 13px 14px 13px 42px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--txt); font-size: 15px; outline: none; }
.busca input:focus { border-color: var(--red); }
.busca svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--mut); }
.resumo { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--mut); margin: 4px 2px 10px; }
.resumo b { color: var(--txt); font-size: 15px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; margin-bottom: 9px; cursor: pointer; transition: transform .12s, background .2s; animation: entra .3s ease both; }
.item:active { transform: scale(.985); background: var(--card2); }
.item .nr { width: 46px; height: 46px; border-radius: 13px; background: rgba(255,255,255,.06); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; color: var(--txt); }
.item .md { flex: 1; min-width: 0; }
.item .cl { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .mt { font-size: 12px; color: var(--mut); margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.item .vl { text-align: right; flex: none; }
.item .vl b { display: block; font-size: 15px; font-weight: 800; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 800; padding: 3px 8px; border-radius: 99px; letter-spacing: .2px; white-space: nowrap; }
.b-ab { background: rgba(59,130,246,.16); color: #7cb1ff; } .b-ba { background: rgba(245,179,1,.16); color: var(--amb); }
.b-fa { background: rgba(34,197,94,.16); color: var(--grn); } .b-ca { background: rgba(255,90,79,.14); color: var(--red2); }
.b-ne { background: rgba(255,255,255,.08); color: var(--mut); } .b-vi { background: rgba(168,85,247,.16); color: #c084fc; }
.vazio { text-align: center; color: var(--mut); padding: 40px 10px; font-size: 14px; }
.vazio svg { width: 44px; height: 44px; opacity: .4; display: block; margin: 0 auto 10px; }
.grupo { font-size: 12px; font-weight: 800; color: var(--mut); text-transform: uppercase; letter-spacing: 1px; margin: 16px 2px 8px; }

/* segmentado */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; color: var(--mut); padding: 10px; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; transition: .2s; }
.seg button.on { background: var(--txt); color: #0b0c10; }

/* abas inferiores */
.abas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 8px 6px calc(8px + var(--safe-b)); background: rgba(11,12,16,.9); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.abas button { border: 0; background: transparent; color: var(--mut2); display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 700; cursor: pointer; padding: 4px 0; position: relative; }
.abas button svg { width: 23px; height: 23px; transition: transform .2s; }
.abas button.on { color: var(--txt); }
.abas button.on svg { color: var(--red2); transform: translateY(-1px); }
.abas button.on::before { content: ""; position: absolute; top: -9px; width: 28px; height: 3px; border-radius: 3px; background: var(--red); }

/* bottom sheet */
.veu { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); opacity: 0; transition: opacity .25s; }
.veu.on { opacity: 1; }
.folha { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 92vh; overflow-y: auto; background: #14161c; border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line); padding: 10px 18px calc(24px + var(--safe-b)); transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1); max-width: 640px; margin: 0 auto; }
.folha.on { transform: translateY(0); }
.folha .pega { width: 42px; height: 5px; border-radius: 9px; background: rgba(255,255,255,.18); margin: 4px auto 14px; }
.folha h2 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -.4px; }
.folha .sub { color: var(--mut); font-size: 13px; margin-top: 4px; }
.linha { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.linha span { color: var(--mut); } .linha b { text-align: right; }
.linha.total { border: 0; padding-top: 14px; font-size: 18px; } .linha.total b { color: var(--txt); font-weight: 900; }
.prod { padding: 12px 0; border-bottom: 1px solid var(--line); }
.prod .pn { font-weight: 700; font-size: 14px; }
.prod .pd { color: var(--mut); font-size: 12.5px; margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.prod .pd b { color: var(--txt); font-size: 14px; }
.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.acoes .btn { padding: 14px; font-size: 14.5px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.acoes .btn svg { width: 18px; height: 18px; }
.secao { font-size: 12px; font-weight: 800; color: var(--mut); text-transform: uppercase; letter-spacing: 1px; margin: 20px 0 4px; }
.menu-it { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px; font-weight: 600; }
.menu-it .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.menu-it .ic svg { width: 18px; height: 18px; }
.menu-it span { flex: 1; } .menu-it small { color: var(--mut); font-weight: 500; }
.menu-it.on span { color: var(--red2); }

/* skeleton / toast / refresh */
.sk { background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 37%, rgba(255,255,255,.04) 63%); background-size: 400% 100%; animation: brilho 1.3s ease infinite; border-radius: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: #fff; color: #111; padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 60; opacity: 0; transition: .3s; box-shadow: 0 10px 30px rgba(0,0,0,.4); white-space: nowrap; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.ptr { height: 0; overflow: hidden; display: grid; place-items: center; color: var(--mut); font-size: 12px; transition: height .2s; }
.ptr svg { width: 20px; height: 20px; }
.gira { animation: gira 0.8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
@keyframes brilho { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes entra { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sobe { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
