:root {
  --blue: #1e63d0;
  --blue-dark: #164da3;
  --blue-soft: #eaf1fc;
  --ink: #1a2233;
  --muted: #6b7688;
  --line: #e4e8f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ok: #1f9d57;
  --warn: #d98a00;
  --danger: #d63a3a;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 40, 80, .06);
  --nav-h: 62px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--blue);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.app-header .title { font-size: 18px; font-weight: 700; flex: 1; display: flex; align-items: center; gap: 8px; }
.app-header .back { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 20px; display: grid; place-items: center; }
.app-header .icon-btn { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 9px; font-size: 17px; display: grid; place-items: center; }

.screen { padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); max-width: 780px; margin: 0 auto; }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: #fff;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; padding-top: 8px;
}
.bottom-nav a .ic { font-size: 21px; line-height: 1; }
.bottom-nav a.active { color: var(--blue); }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card.tap { cursor: pointer; transition: transform .06s; }
.card.tap:active { transform: scale(.99); }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 2px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mono { font-variant-numeric: tabular-nums; }

/* Stat grid (dashboard) */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 4px; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 800; color: var(--blue); line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat.danger .n { color: var(--danger); }
.stat.ok .n { color: var(--ok); }

/* List item */
.item { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .avatar { width: 40px; height: 40px; border-radius: 11px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: none; }
.item .main { flex: 1; min-width: 0; }
.item .main .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .main .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .val { text-align: right; font-weight: 700; white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.rascunho { background: #eef0f4; color: #59606e; }
.badge.enviado { background: #e6f0ff; color: #1e63d0; }
.badge.aprovado { background: #e4f6ea; color: #1f9d57; }
.badge.concluido { background: #e4f6ea; color: #147a42; }
.badge.recusado { background: #fdeaea; color: #d63a3a; }
.badge.aberta { background: #fff1de; color: #b8770a; }
.badge.paga { background: #e4f6ea; color: #1f9d57; }
.badge.low { background: #fdeaea; color: #d63a3a; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 11px; padding: 12px 16px; font-size: 15px; font-weight: 600; background: var(--blue-soft); color: var(--blue); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-dark); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: #fdeaea; color: var(--danger); }
.btn.ok { background: var(--ok); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; }

/* FAB */
.fab { position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 35; width: 58px; height: 58px; border-radius: 50%; background: var(--blue); color: #fff; border: 0; font-size: 30px; box-shadow: 0 6px 18px rgba(30,99,208,.4); display: grid; place-items: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px; font-size: 15px; background: #fff; color: var(--ink); font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.field textarea { resize: vertical; min-height: 70px; }
.field.inline-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Quote item editor row */
.qitem { border: 1px solid var(--line); border-radius: 11px; padding: 10px; margin-bottom: 10px; background: #fbfcfe; }
.qitem .qgrid { display: grid; grid-template-columns: 60px 1fr 70px; gap: 8px; align-items: end; }
.qitem .qgrid.full { grid-template-columns: 1fr; }
.totbar { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 2px; }
.totbar.big { font-size: 20px; font-weight: 800; color: var(--blue); border-top: 2px solid var(--line); padding-top: 12px; margin-top: 4px; }

/* ---------- Modal / sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(15,25,45,.45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px); max-height: 90vh; overflow-y: auto; animation: up .18s ease; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .grabber { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 12px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .mark { width: 76px; height: 76px; border-radius: 20px; background: var(--blue); color: #fff; font-size: 38px; display: grid; place-items: center; margin: 0 auto 12px; box-shadow: 0 8px 20px rgba(30,99,208,.35); }
.login-logo h1 { margin: 0; font-size: 22px; }
.login-logo p { margin: 4px 0 0; color: var(--muted); }

/* Misc */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--blue-soft); border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 30px); transform: translateX(-50%); background: #222b3d; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 90; box-shadow: 0 6px 18px rgba(0,0,0,.25); max-width: 90%; }
.toast.err { background: var(--danger); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.pill-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.pill { white-space: nowrap; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.pill.active { background: var(--blue); color: #fff; border-color: var(--blue); }
