:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #14181f;
  --ink-soft: #5b6472;
  --line: #e4e7ec;
  --brand: #1a2b4a;
  --brand-soft: #eef1f7;
  --green: #1f9d57;
  --green-bg: #e7f6ee;
  --amber: #c9820a;
  --amber-bg: #fbf1de;
  --red: #d23b3b;
  --red-bg: #fbe8e8;
  --blue: #2b6cb0;
  --blue-bg: #e7f0f9;
  --purple: #6b46c1;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
a { color: var(--blue); }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.login-card {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 32px; width: 100%; max-width: 360px; text-align: center;
}
.login-card .logo { font-size: 13px; letter-spacing: .18em; color: var(--ink-soft); text-transform: uppercase; }
.login-card h1 { font-size: 24px; margin: 6px 0 2px; }
.login-card p { color: var(--ink-soft); font-size: 13px; margin: 0 0 20px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; margin-bottom: 12px;
}
.login-card button {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--brand);
  color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---------- Shell ---------- */
.app { display: none; }
.app.visible { display: block; }
header.top {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
}
header.top .brand { font-weight: 700; letter-spacing: -.01em; font-size: 16px; }
header.top .brand small { display: block; font-weight: 400; font-size: 11px; opacity: .7; letter-spacing: .04em; }
header.top .phase-pill {
  margin-left: auto; font-size: 12px; background: rgba(255,255,255,.14);
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
header.top button.logout {
  background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff;
  border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer;
}

nav.tabs {
  position: sticky; top: 49px; z-index: 15; background: var(--panel);
  border-bottom: 1px solid var(--line); display: flex; gap: 2px; overflow-x: auto;
  padding: 0 8px; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: 0; background: transparent; padding: 13px 14px; font-size: 14px; font-weight: 550;
  color: var(--ink-soft); cursor: pointer; border-bottom: 2.5px solid transparent; white-space: nowrap;
}
nav.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

main { padding: 16px; max-width: 1080px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 4px 0 10px; }
.muted { color: var(--ink-soft); }
.hint { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Cards / KPIs ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; border-left: 4px solid var(--line);
}
.kpi.daily { border-left-color: var(--brand); }
.kpi .label { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.kpi .target { font-size: 12px; color: var(--ink-soft); }
.kpi.ok { border-left-color: var(--green); }
.kpi.warn { border-left-color: var(--amber); }
.kpi.alarm { border-left-color: var(--red); }
.kpi .flag { font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.kpi.ok .flag { background: var(--green-bg); color: var(--green); }
.kpi.warn .flag { background: var(--amber-bg); color: var(--amber); }
.kpi.alarm .flag { background: var(--red-bg); color: var(--red); }

.band { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.band > h3 { font-size: 16px; margin-bottom: 4px; }
.band .sub { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 14px; }

/* ---------- Funnel ---------- */
.funnel-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.funnel-row:last-child { border-bottom: 0; }
.funnel-row .n { font-size: 12px; color: #fff; background: var(--brand); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.funnel-row .name { flex: 1; font-weight: 550; }
.funnel-row .name small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; }
.funnel-bar { flex: 2; height: 10px; background: var(--brand-soft); border-radius: 999px; overflow: hidden; min-width: 60px; }
.funnel-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.funnel-row .count { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 650; min-width: 74px; text-align: right; }
.funnel-row .count small { color: var(--ink-soft); font-weight: 400; }

/* ---------- Lists ---------- */
.list { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list .row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list .row:last-child { border-bottom: 0; }
.list .row .main { flex: 1; min-width: 0; }
.list .row .main .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row .main .s { font-size: 12.5px; color: var(--ink-soft); }
.list .row .actions { display: flex; gap: 6px; flex: 0 0 auto; }
.empty { text-align: center; color: var(--ink-soft); padding: 26px 14px; font-size: 14px; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.pill.a { background: var(--red-bg); color: var(--red); }
.pill.b { background: var(--amber-bg); color: var(--amber); }
.pill.c { background: var(--blue-bg); color: var(--blue); }
.pill.grey { background: var(--brand-soft); color: var(--ink-soft); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.flag { background: var(--red-bg); color: var(--red); }

/* ---------- Buttons ---------- */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 9px; padding: 7px 12px; font-size: 13px; font-weight: 550; cursor: pointer; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { opacity: .92; }
.btn.small { padding: 5px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: var(--brand-soft); }
.btn.danger { color: var(--red); border-color: var(--red-bg); }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input.search { flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }
.toolbar select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; background: var(--panel); }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(16,24,40,.42); display: none; align-items: flex-end; justify-content: center; z-index: 40; }
.modal-back.open { display: flex; }
.modal {
  background: var(--panel); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0;
  max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); animation: up .2s ease;
}
@keyframes up { from { transform: translateY(20px); } to { transform: none; } }
.modal .m-head { position: sticky; top: 0; background: var(--panel); padding: 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal .m-head h3 { font-size: 17px; }
.modal .m-head button { margin-left: auto; border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 50%; font-size: 17px; cursor: pointer; color: var(--ink-soft); }
.modal .m-body { padding: 16px; }
.modal .m-foot { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }
.modal .m-foot .btn { flex: 1; justify-content: center; text-align: center; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; font-family: inherit; background: var(--panel);
}
.field textarea { min-height: 66px; resize: vertical; }
.field .checks { display: flex; flex-wrap: wrap; gap: 6px; }
.field .checks label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--ink); background: var(--bg); border: 1px solid var(--line); padding: 6px 10px; border-radius: 8px; margin: 0; cursor: pointer; }
.field .checks input { width: auto; }
.field.inline-check label { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.field.inline-check input { width: auto; }

/* ---------- Qualificação na ficha da pessoa ---------- */
.qz { border-top: 1px solid var(--line); margin-top: 6px; }
.qz-card { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.qz-head { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.qz-row { display: flex; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.qz-row:last-child { border-bottom: 0; }
.qz-row span { color: var(--ink-soft); flex: 0 0 42%; }
.qz-row b { font-weight: 600; flex: 1; word-break: break-word; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { background: var(--red); }

.loading { text-align: center; padding: 40px; color: var(--ink-soft); }

.date-crit { font-size: 12.5px; color: var(--red); font-weight: 600; }

@media (min-width: 620px) {
  .modal { border-radius: 16px; align-self: center; }
  .modal-back { align-items: center; }
}
