@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

:root {
  --bg:       #0b0d11;
  --bg2:      #13161d;
  --bg3:      #1a1e27;
  --bg4:      #222633;
  --border:   rgba(255,255,255,0.06);
  --border2:  rgba(255,255,255,0.11);
  --text:     #dde1ec;
  --muted:    #5c6278;
  --muted2:   #8b92a8;
  --accent:   #00dfa2;
  --accent2:  #00b882;
  --warn:     #f0a030;
  --danger:   #f04060;
  --info:     #4090f0;
  --purple:   #9b7dea;
  --fh:       'Syne', sans-serif;
  --fb:       'DM Sans', sans-serif;
  --r:        10px;
  --rl:       16px;
  --nav-h:    64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--fb); font-weight: 400;
  min-height: 100vh; min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── LOGIN ─────────────────────────────────── */
#login {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100dvh; padding: 1.5rem;
}
.login-mark {
  font-family: var(--fh); font-size: 1rem; font-weight: 800;
  letter-spacing: 0.15em; color: var(--accent);
  margin-bottom: 0.25rem;
}
.login-tagline { font-size: 0.75rem; color: var(--muted); margin-bottom: 2.5rem; letter-spacing: 0.04em; }
.login-card {
  width: 100%; max-width: 340px;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--rl); padding: 2rem 1.75rem;
}
.login-card p { font-size: 0.78rem; color: var(--muted2); margin-bottom: 1.25rem; }
.login-card input {
  width: 100%; padding: 0.85rem 1rem;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r); color: var(--text);
  font-family: var(--fb); font-size: 1rem;
  letter-spacing: 0.12em; text-align: center;
  outline: none; transition: border 0.2s; margin-bottom: 1rem;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 0.85rem;
  background: var(--accent); color: #000;
  font-family: var(--fh); font-weight: 800;
  font-size: 0.85rem; letter-spacing: 0.1em;
  border: none; border-radius: var(--r); cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.login-card button:active { transform: scale(0.97); background: var(--accent2); }
.login-err { font-size: 0.75rem; color: var(--danger); text-align: center; margin-top: 0.75rem; min-height: 1rem; }

/* ── APP SHELL ─────────────────────────────── */
#app { display: none; flex-direction: column; min-height: 100dvh; }
#app.on { display: flex; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.1rem 0.7rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11,13,17,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; flex-direction: column; }
.topbar-title { font-family: var(--fh); font-size: 1.05rem; font-weight: 800; }
.topbar-sub { font-size: 0.7rem; color: var(--muted); margin-top: 1px; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg3); border: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--muted2); font-size: 1rem;
  -webkit-tap-highlight-color: transparent;
}

.pages { flex: 1; overflow-y: auto; padding-bottom: calc(var(--nav-h) + 12px); }
.page { display: none; padding: 1rem 1rem 0.5rem; animation: fadeUp 0.22s ease both; }
.page.on { display: block; }
@keyframes fadeUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }

/* ── BOTTOM NAV ────────────────────────────── */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(13,16,22,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border2);
  display: flex; align-items: center; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  cursor: pointer; padding: 6px 10px; border-radius: var(--r);
  transition: all 0.15s; border: none; background: none;
  -webkit-tap-highlight-color: transparent; min-width: 52px;
}
.nav-btn .icon { font-size: 1.25rem; color: var(--muted); transition: color 0.15s; }
.nav-btn .lbl { font-size: 0.6rem; color: var(--muted); letter-spacing: 0.04em; transition: color 0.15s; }
.nav-btn.on .icon, .nav-btn.on .lbl { color: var(--accent); }
.nav-btn .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--danger); position: absolute; top: 2px; right: 2px;
  display: none;
}
.nav-btn.has-dot { position: relative; }
.nav-btn.has-dot .dot { display: block; }

/* ── METRIC CARDS ──────────────────────────── */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 1rem; }
.mc {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rl); padding: 1rem;
  position: relative; overflow: hidden;
}
.mc::after {
  content:''; position:absolute; bottom:0; left:0; right:0; height:2px;
  background: var(--accent); transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s;
}
.mc:active::after { transform: scaleX(1); }
.mc-label { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 5px; }
.mc-val { font-family: var(--fh); font-size: 1.5rem; font-weight: 700; line-height: 1; }
.mc-val.g { color: var(--accent); }
.mc-val.w { color: var(--warn); }
.mc-val.d { color: var(--danger); }
.mc-val.i { color: var(--info); }
.mc-sub { font-size: 0.68rem; color: var(--muted); margin-top: 4px; }

/* ── CARDS ─────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rl); margin-bottom: 1rem; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--fh); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted2);
}
.card-action { font-size: 0.72rem; color: var(--accent); cursor: pointer; }

/* ── ROW ITEMS ─────────────────────────────── */
.row-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer; transition: background 0.12s;
}
.row-item:last-child { border-bottom: none; }
.row-item:active { background: var(--bg3); }
.row-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg4); display: flex; align-items: center; justify-content: center;
  font-family: var(--fh); font-size: 0.72rem; font-weight: 700;
  color: var(--muted2); flex-shrink: 0;
}
.row-body { flex: 1; min-width: 0; }
.row-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 0.72rem; color: var(--muted2); margin-top: 1px; }
.row-right { text-align: right; flex-shrink: 0; }
.row-val { font-family: var(--fh); font-size: 0.9rem; font-weight: 700; }
.row-date { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

/* ── BADGES ────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 99px;
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.02em;
}
.b-ok   { background: rgba(0,223,162,0.12); color: var(--accent); }
.b-pend { background: rgba(240,160,48,0.12); color: var(--warn); }
.b-miss { background: rgba(240,64,96,0.12);  color: var(--danger); }
.b-parc { background: rgba(64,144,240,0.12); color: var(--info); }
.b-sim  { background: rgba(155,125,234,0.12);color: var(--purple); }

/* ── PROGRESS ──────────────────────────────── */
.prog-wrap { background: var(--bg3); border-radius: 99px; height: 5px; overflow: hidden; }
.prog-fill { height: 100%; border-radius: 99px; transition: width 0.6s ease; }

/* ── TIMELINE ──────────────────────────────── */
.tl { padding: 0 1rem; }
.tl-group { margin-bottom: 1.25rem; }
.tl-group-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}
.tl-group-name { font-family: var(--fh); font-size: 0.72rem; font-weight: 700; color: var(--muted2); letter-spacing: 0.06em; text-transform: uppercase; }
.tl-group-total { font-family: var(--fh); font-size: 0.82rem; font-weight: 700; color: var(--accent); }
.tl-item { display: flex; align-items: flex-start; gap: 10px; padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: none; }
.tl-line { display: flex; flex-direction: column; align-items: center; gap: 0; flex-shrink: 0; padding-top: 3px; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.tl-dot.g  { background: var(--accent); }
.tl-dot.w  { background: var(--warn); }
.tl-dot.i  { background: var(--info); }
.tl-dot.d  { background: var(--danger); }
.tl-body { flex: 1; min-width: 0; }
.tl-name { font-size: 0.83rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-prod { font-size: 0.7rem; color: var(--muted2); margin-top: 1px; }
.tl-right { text-align: right; flex-shrink: 0; }
.tl-val { font-family: var(--fh); font-size: 0.88rem; font-weight: 700; }
.tl-when { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

/* ── SECTION TITLE ─────────────────────────── */
.sec-title {
  font-family: var(--fh); font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
  padding: 0.25rem 0 0.6rem;
}

/* ── FORM ──────────────────────────────────── */
.form-card {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--rl); padding: 1.1rem; margin-bottom: 1rem;
}
.form-label { font-size: 0.7rem; color: var(--muted); display: block; margin-bottom: 4px; }
.form-input {
  width: 100%; padding: 0.75rem 0.85rem;
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--r); color: var(--text);
  font-family: var(--fb); font-size: 0.9rem; outline: none;
  transition: border 0.2s; margin-bottom: 0.65rem;
}
.form-input:focus { border-color: var(--accent); }
.form-input option { background: var(--bg2); }
.form-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 0.25rem; }

/* ── BUTTONS ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0.7rem 1.1rem; border-radius: var(--r);
  font-family: var(--fh); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.06em; cursor: pointer; transition: all 0.15s;
  border: none; -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.btn:active { transform: scale(0.96); }
.btn-a { background: var(--accent); color: #000; }
.btn-a:active { background: var(--accent2); }
.btn-g { background: transparent; border: 1px solid var(--border2); color: var(--muted2); }
.btn-g:active { border-color: var(--accent); color: var(--accent); }
.btn-d { background: rgba(240,64,96,0.1); border: 1px solid rgba(240,64,96,0.25); color: var(--danger); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.7rem; min-height: 34px; }

/* ── ALERT STRIP ───────────────────────────── */
.alert-strip {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 0.75rem; border-radius: var(--r);
  border: 1px solid; margin-bottom: 0.6rem;
}
.alert-strip.d { border-color: rgba(240,64,96,0.25); background: rgba(240,64,96,0.06); }
.alert-strip.w { border-color: rgba(240,160,48,0.25); background: rgba(240,160,48,0.06); }
.alert-strip.i { border-color: rgba(64,144,240,0.25); background: rgba(64,144,240,0.06); }
.alert-icon { font-size: 0.9rem; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-size: 0.8rem; font-weight: 500; }
.alert-sub { font-size: 0.7rem; color: var(--muted2); margin-top: 1px; }

/* ── COMISSÃO OP CARD ──────────────────────── */
.op-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 1rem; }
.op-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rl); padding: 0.9rem;
}
.op-name { font-family: var(--fh); font-size: 0.85rem; font-weight: 700; }
.op-taxa { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.op-liq { font-family: var(--fh); font-size: 1.2rem; font-weight: 700; color: var(--accent); margin-top: 6px; }
.op-ded { font-size: 0.68rem; color: var(--danger); margin-top: 2px; }

/* ── CHART ─────────────────────────────────── */
.chart-wrap { position: relative; padding: 0.75rem 0.75rem 0.5rem; }

/* ── MODAL ─────────────────────────────────── */
.overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200; align-items: flex-end;
}
.overlay.on { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--rl) var(--rl) 0 0;
  padding: 1.25rem 1.1rem calc(1.5rem + env(safe-area-inset-bottom));
  width: 100%; max-height: 92dvh; overflow-y: auto;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.modal-handle { width: 36px; height: 4px; background: var(--border2); border-radius: 99px; margin: 0 auto 1.1rem; }
.modal-title { font-family: var(--fh); font-size: 1rem; font-weight: 800; margin-bottom: 1rem; }

/* ── EMPTY ─────────────────────────────────── */
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); font-size: 0.82rem; }
.empty-icon { font-size: 1.8rem; opacity: 0.25; margin-bottom: 0.5rem; }

/* ── DESKTOP OVERRIDE ──────────────────────── */
@media (min-width: 600px) {
  body { display: flex; justify-content: center; background: #070809; }
  #login, #app { max-width: 420px; width: 100%; }
  #app { box-shadow: 0 0 0 1px var(--border2); }
}
