:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e6e8ec;
  --border-strong: #d7dbe1;
  --text: #121826;
  --text-2: #374151;
  --muted: #6b7280;
  --primary: #0e5c45;
  --primary-hover: #0a4a37;
  --green: #12924f;
  --green-soft: #e6f6ec;
  --accent: #ea580c;
  --accent-soft: #fff1e8;
  --danger: #c0262d;
  --danger-soft: #fdecec;
  --warn: #9a6400;
  --warn-soft: #fff5dc;
  --info: #2456a6;
  --info-soft: #eaf1fb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --rail: 72px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; }
a { color: var(--primary); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sub { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.green { color: var(--green); }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ------------------------------------------------ botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.outline { color: var(--primary); border-color: var(--border); }
.btn.outline:hover { border-color: var(--primary); background: var(--green-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.btn.sm svg { width: 15px; height: 15px; }
.btn.lg { padding: 12px 18px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--primary); cursor: pointer;
}
.icon-btn:hover { border-color: var(--primary); background: var(--green-soft); }

.field { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
input, select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px 12px; width: 100%;
  margin-top: 6px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #9aa1ad; }
input:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(18, 146, 79, .14); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.error { color: var(--danger); font-size: 13px; margin: 0; }
.hint { font-size: 13px; margin: 10px 0 0; color: var(--muted); }
.hint.ok { color: var(--green); }
.hint.bad { color: var(--danger); }

/* ------------------------------------------------ login */
.login { display: grid; grid-template-columns: minmax(340px, 400px) 1fr; min-height: 100%; background: #04361d; }
.login-panel {
  background: var(--surface); border-radius: 0 24px 24px 0; padding: 36px 36px 22px;
  display: flex; flex-direction: column; position: relative; z-index: 1;
}
.logo { font-size: 30px; font-weight: 800; letter-spacing: -.05em; color: #0b3f2d; position: relative; display: inline-block; }
.logo-ai { position: relative; margin-left: -.06em; }
.logo-spark { position: absolute; width: 12px; height: 12px; right: -9px; top: -6px; fill: currentColor; stroke: none; }
.login-form { margin: auto 0; display: grid; gap: 16px; }
.login-form h1 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.pwd-wrap { position: relative; display: block; }
.pwd-wrap input { padding-right: 44px; }
.pwd-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(calc(-50% + 3px));
  border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; display: grid;
}
.pwd-toggle:hover { color: var(--text); }
.login-foot { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.login-art { position: relative; overflow: hidden; display: grid; place-items: center; }
.login-art .waves { position: absolute; inset: 0; width: 100%; height: 100%; }
.art-logo {
  position: relative; color: #fff; font-size: clamp(56px, 7.5vw, 112px); font-weight: 800; letter-spacing: -.06em;
  text-shadow: 0 10px 40px rgba(0, 40, 20, .35);
}
.art-logo span { position: relative; margin-left: -.06em; }
.art-logo .logo-spark { width: .32em; height: .32em; right: -.2em; top: -.14em; }

/* ------------------------------------------------ estrutura */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100%; }
.rail {
  position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; z-index: 5;
}
.rail-mark {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; position: relative;
  background: linear-gradient(140deg, #0e5c45, #17a35a); color: #fff; font-weight: 800; font-size: 20px;
  box-shadow: 0 6px 16px rgba(14, 92, 69, .3);
}
.rail-mark svg { position: absolute; width: 10px; height: 10px; right: 7px; top: 7px; fill: #c9ffd9; stroke: none; }
.rail-nav { margin: auto 0; display: grid; gap: 14px; }
.rail-nav a {
  position: relative; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px;
  color: #6b7280; text-decoration: none; transition: background .15s, color .15s;
}
.rail-nav a svg { width: 20px; height: 20px; }
.rail-nav a:hover { background: var(--surface-2); color: var(--text); }
.rail-nav a.active { background: var(--accent-soft); color: var(--accent); }
.rail-nav a.active::before {
  content: ""; position: absolute; left: -13px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--accent);
}
.tip {
  position: absolute; left: 56px; top: 50%; transform: translateY(-50%); background: var(--text); color: #fff;
  font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.rail-nav a:hover .tip { opacity: 1; }
.rail-bottom { position: relative; display: grid; justify-items: center; gap: 6px; padding-top: 12px; border-top: 1px solid var(--border); width: 44px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; font: inherit;
  font-weight: 700; font-size: 15px; background: linear-gradient(140deg, #0e5c45, #1fae63);
  box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--border);
}
.version { font-size: 11px; color: var(--muted); }
.user-menu {
  position: absolute; left: 56px; bottom: 0; width: 240px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px; z-index: 30;
}
.um-name { font-weight: 700; }
.um-mail, .um-company { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.um-company { margin-bottom: 10px; }
.um-logout {
  width: 100%; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface);
  padding: 8px 10px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--danger); cursor: pointer;
}
.um-logout:hover { background: var(--danger-soft); }

.main { min-width: 0; display: flex; flex-direction: column; }
.content { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 4; height: 56px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 24px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 15px; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 11px; font-size: 12px; color: var(--text-2); background: var(--surface); white-space: nowrap;
}
.pill.strong { font-weight: 700; color: var(--text); }
.pill.warn { background: var(--warn-soft); border-color: #f3dfae; color: var(--warn); font-weight: 600; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.content { padding: 16px 24px 32px; }
.view { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h3 { font-size: 16px; font-weight: 700; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.table-card { padding: 18px 0 0; }
.table-card .card-head { padding: 0 18px; }
.page-head h2 { font-size: 22px; font-weight: 700; }

/* ------------------------------------------------ filtros */
.filters { display: grid; grid-template-columns: 1.6fr 1.1fr 1fr .9fr 1fr; gap: 12px; padding: 14px 16px; background: var(--surface); }
.filters.six { grid-template-columns: 1.5fr 1.2fr 1fr .8fr 1fr 1fr; }
.filters .field { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.filters input, .filters select { padding: 8px 10px; font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 500; }

/* ------------------------------------------------ início */
.welcome { min-height: calc(100vh - 140px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; }
.greet { margin: 0; color: var(--muted); font-size: 14px; }
.welcome h2 { font-size: clamp(30px, 4vw, 46px); font-weight: 800; letter-spacing: -.04em; }
.quick { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 170px)); gap: 12px; margin-top: 36px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; text-align: left; }
.stat .value { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.stat .label { font-size: 12px; color: var(--muted); }

/* ------------------------------------------------ consulta */
.search-card { display: grid; gap: 12px; }
.cpf-input { font-size: 17px; letter-spacing: .04em; padding: 11px 14px; }
.search-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.search-foot .hint { margin: 0; min-height: 18px; }

.result { display: grid; gap: 16px; }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.result-person { display: flex; gap: 14px; align-items: center; }
.result-avatar {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: var(--primary);
  background: var(--green-soft); font-size: 16px; flex: none;
}
.result-head h3 { font-size: 18px; }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.result-col { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.result-col h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.item { padding: 9px 0; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 8px; }
.item:first-of-type { border-top: 0; }
.item > div { min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.item small { color: var(--muted); display: block; font-weight: 400; }
.score { font-size: 12px; font-weight: 700; white-space: nowrap; }
.score.high { color: var(--green); }
.score.mid { color: var(--warn); }
.score.low { color: var(--muted); }

/* ------------------------------------------------ tabelas */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.grid th, .grid td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid th:first-child, .grid td:first-child { padding-left: 18px; }
.grid th:last-child, .grid td:last-child { padding-right: 18px; }
.grid th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-top: 1px solid var(--border); }
.grid td { font-size: 13.5px; color: var(--text-2); }
.grid tbody tr:hover td { background: #fbfcfc; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid .right { text-align: right; }
.grid td.name { color: var(--text); font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.grid td.mono { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.empty { text-align: center; color: var(--muted); padding: 28px; margin: 0; }
.more { display: flex; justify-content: center; padding: 10px 0 14px; }
.more:empty { padding: 0; }

.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.tag.plain::before { display: none; }
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.blue { background: var(--info-soft); color: var(--info); }
.tag.red { background: var(--danger-soft); color: var(--danger); }
.tag.amber { background: var(--warn-soft); color: var(--warn); }
.tag.gray { background: #f1f2f4; color: var(--muted); }

/* ------------------------------------------------ planilha */
.dropzone {
  display: grid; place-items: center; gap: 4px; text-align: center; padding: 40px 20px; cursor: pointer;
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--green); background: var(--green-soft); }
.dropzone.loading { opacity: .6; pointer-events: none; }
.dropzone strong { font-size: 15px; }
.dz-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--primary); margin-bottom: 6px; }
.preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.file-name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.extra-cols { margin-top: 14px; }
#extra-cols { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 8px; }
.sample-wrap { margin-top: 14px; border: 1px solid var(--border); border-radius: 12px; }
.sample th, .sample td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 13px; }
.sample th { font-size: 12px; color: var(--muted); background: var(--surface-2); font-weight: 600; }
.sample .cpf-col { background: var(--green-soft); }
.sample td.bad { color: var(--danger); }
.actions { display: flex; justify-content: flex-end; margin-top: 16px; gap: 8px; }
.jobs .file { font-weight: 700; color: var(--text); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
#jobs-body td:first-child { white-space: normal; min-width: 200px; max-width: 300px; }
.progress { width: 150px; height: 6px; background: #eceef1; border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress div { height: 100%; background: linear-gradient(90deg, #0e5c45, #22c55e); transition: width .4s; }
.counts { font-size: 12.5px; color: var(--muted); }
.counts b { color: var(--text); font-weight: 700; }
.highlight td { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--green-soft); } to { background: transparent; } }

/* ------------------------------------------------ configurações */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.subnav { display: grid; gap: 2px; padding: 12px; }
.subnav-title { font-size: 12px; font-weight: 600; color: var(--muted); padding: 8px 8px 4px; }
.subnav-title:not(:first-child) { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; }
.subnav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.subnav a:hover { background: var(--surface-2); }
.subnav a.active { background: var(--green-soft); color: var(--primary); font-weight: 700; }
.settings-body { display: grid; gap: 16px; min-width: 0; }
.subpanel { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
#sub-dados { display: grid; gap: 14px; }
.box { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 16px; margin: 0; }
.box legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
#user-form { display: grid; gap: 14px; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; }
.inline-form .field { flex: 1; max-width: 420px; }
.row-actions { display: flex; gap: 14px; justify-content: flex-end; white-space: nowrap; }
.inactive td { opacity: .55; }

/* ------------------------------------------------ modais e avisos */
.modal { position: fixed; inset: 0; background: rgba(12, 20, 30, .45); display: grid; place-items: center; padding: 16px; z-index: 40; }
.modal-card {
  position: relative; background: var(--surface); border-radius: 18px; padding: 22px; width: 100%; max-width: 560px;
  display: grid; gap: 14px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px); overflow-y: auto;
}
.modal-card.wide { max-width: 980px; }
.modal-card.wide .result-head { padding-right: 40px; }
.modal-card p { margin: 0; }
.modal-x { position: absolute; right: 14px; top: 14px; border: 0; background: var(--surface-2); border-radius: 9px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.modal-x:hover { color: var(--text); }
.copy-row { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.copy-row input { margin: 0; font-family: Consolas, monospace; font-size: 12.5px; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff;
  padding: 11px 18px; border-radius: 10px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 50;
  max-width: calc(100% - 32px);
}
.toast.bad { background: var(--danger); }

/* ------------------------------------------------ telas menores */
@media (max-width: 1100px) {
  .filters, .filters.six { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
  .result-grid { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-panel { border-radius: 0; min-height: 100vh; padding: 28px 16px 18px; }
  .login-art { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); padding-bottom: 68px; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 64px; flex-direction: row; padding: 0 10px;
    border-right: 0; border-top: 1px solid var(--border); justify-content: space-between;
  }
  .rail-mark, .version, .tip { display: none; }
  .rail-nav { margin: 0; display: flex; gap: 2px; flex: 1; justify-content: space-around; }
  .rail-nav a.active::before { left: 12px; right: 12px; top: auto; bottom: -9px; width: auto; height: 3px; }
  .rail-bottom { border: 0; padding: 0; width: auto; }
  .avatar { width: 38px; height: 38px; font-size: 13px; }
  .user-menu { left: auto; right: 0; bottom: 54px; }
  .topbar { padding: 0 16px; }
  .hide-sm { display: none; }
  .content { padding: 12px 16px 24px; }
  .filters, .filters.six { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .settings { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .field { max-width: none; }
  .welcome { min-height: calc(100vh - 200px); }
}
@media (max-width: 520px) {
  .top-right .pill:not(.warn) { display: none; }
  .head-actions { width: 100%; justify-content: space-between; }
}
