:root {
  --bg: #0b0e14; --card: #141926; --card2: #1b2233; --border: #232c42;
  --text: #e7ecf5; --muted: #8b96ad; --green: #22c55e; --red: #ef4444;
  --accent: #3b82f6; --amber: #f59e0b;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 15px; }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }

/* LOGIN */
.login-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 100; }
.login-box { width: min(340px, 88vw); text-align: center; }
.logo { font-size: 28px; font-weight: 800; }
.logo span, .logo-sm span { color: var(--green); }
.login-sub { color: var(--muted); margin: 6px 0 24px; }
.login-box input { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-size: 16px; margin-bottom: 12px; }
.btn-primary { width: 100%; padding: 14px; border-radius: 12px; border: 0; background: var(--green); color: #04120a; font-weight: 700; font-size: 16px; }
.err { color: var(--red); margin-top: 10px; min-height: 18px; font-size: 13px; }

/* HEADER */
header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: rgba(11,14,20,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.logo-sm { font-weight: 800; font-size: 17px; }
.header-controls { display: flex; gap: 8px; }
.header-controls select, .header-controls input { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 7px 9px; font-size: 13px; }

main { padding: 14px 14px 90px; max-width: 760px; margin: 0 auto; }

/* CARDS */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.big { font-size: 24px; font-weight: 800; }
.green { color: var(--green); } .red { color: var(--red); } .muted { color: var(--muted); }
.sm { font-size: 12px; }

/* LISTAS */
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--card2); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.row .mid { flex: 1; min-width: 0; }
.row .t1 { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 12px; color: var(--muted); }
.row .val { font-weight: 700; font-size: 14px; text-align: right; flex-shrink: 0; }

/* BARRAS CATEGORIA */
.catbar { margin: 8px 0; }
.catbar .cb-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.catbar .cb-track { height: 8px; border-radius: 6px; background: var(--card2); overflow: hidden; }
.catbar .cb-fill { height: 100%; border-radius: 6px; }

/* GRAFICO DIARIO */
.daily { display: flex; align-items: flex-end; gap: 2px; height: 90px; margin-top: 8px; }
.daily .db { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; height: 100%; }
.daily .db i { display: block; border-radius: 2px 2px 0 0; }
.daily .db .r { background: var(--green); }
.daily .db .d { background: var(--red); }

/* TABBAR */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: rgba(11,14,20,.95); backdrop-filter: blur(10px); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 30; }
.tabbar button { flex: 1; background: none; border: 0; color: var(--muted); padding: 9px 0 7px; font-size: 18px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button span { font-size: 10px; font-weight: 600; }
.tabbar button.active { color: var(--green); }

#fab { position: fixed; right: 16px; bottom: 76px; width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--green); color: #04120a; font-size: 28px; font-weight: 700; box-shadow: 0 6px 20px rgba(34,197,94,.35); z-index: 25; }

/* MODAL */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: 18px 18px 0 0; width: min(560px, 100vw); max-height: 86vh; overflow-y: auto; padding: 18px; padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
.modal h2 { font-size: 17px; margin-bottom: 14px; }
.modal label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 11px; border-radius: 10px; border: 1px solid var(--border); background: var(--card2); color: var(--text); font-size: 15px; }
.modal .btn-row { display: flex; gap: 10px; margin-top: 16px; }
.modal .btn-row button { flex: 1; padding: 12px; border-radius: 11px; border: 0; font-weight: 700; font-size: 15px; }
.btn-ok { background: var(--green); color: #04120a; }
.btn-cancel { background: var(--card2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.seg { display: flex; background: var(--card2); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 9px; border: 0; border-radius: 8px; background: none; color: var(--muted); font-weight: 700; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }
.seg button.on.exp { background: var(--red); }
.seg button.on.rec { background: var(--green); color: #04120a; }

/* avisos */
.alert-row { display: flex; gap: 9px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; font-size: 13.5px; line-height: 1.35; }
.alert-row.red { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); }
.alert-row.warn { background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.3); }
.alert-row.info { background: var(--card2); border: 1px solid var(--border); }

/* misc */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; background: var(--card2); color: var(--muted); }
.pill.pj { background: #1d2a4a; color: #7fa7ff; }
.pill.pf { background: #16321f; color: #6fdc95; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input, .filters select { background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.filters input[type=search] { flex: 1; min-width: 130px; }
.btn-sm { padding: 8px 13px; border-radius: 10px; border: 1px solid var(--border); background: var(--card2); color: var(--text); font-size: 13px; font-weight: 600; }
.btn-sm.primary { background: var(--green); color: #04120a; border: 0; }
.sync-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 14px; }
.toast { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--border); color: var(--text); padding: 11px 18px; border-radius: 12px; z-index: 200; font-size: 14px; max-width: 90vw; }
h4.sec { font-size: 13px; color: var(--muted); margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .4px; }

@media (min-width: 700px) {
  main { padding-top: 20px; }
  .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .modal-bg { align-items: center; }
  .modal { border-radius: 18px; }
}
