/* ============================================================================
   Projetos Dinâmicos — base compartilhada
   Tokens, reset, tipografia, botões, formulários e componentes.
   ========================================================================== */

:root {
  --bg: #f5f2ea;
  --bg-deep: #ece7db;
  --panel: #fffdf8;
  --panel-2: #f0ece1;
  --panel-3: #e7e1d3;
  --ink: #16241e;
  --ink-2: #43534b;
  --muted: #77827b;
  --line: #e0dacd;
  --line-strong: #cfc7b6;
  --brand: #123b32;
  --brand-2: #1d5a4a;
  --brand-3: #2f7a64;
  --accent: #d36c45;
  --accent-soft: #f6e3d8;
  --ok: #2c7a58;
  --ok-soft: #e2f0e8;
  --warn: #a9751c;
  --warn-soft: #f7ecd2;
  --danger: #b03a3a;
  --danger-soft: #f8e1de;
  --info: #2c6b8a;
  --info-soft: #e0eef5;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(22, 36, 30, .06), 0 1px 1px rgba(22, 36, 30, .04);
  --shadow: 0 10px 30px -18px rgba(22, 36, 30, .28), 0 2px 8px rgba(22, 36, 30, .05);
  --shadow-lg: 0 30px 80px -40px rgba(22, 36, 30, .45), 0 8px 24px -16px rgba(22, 36, 30, .18);
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sidebar-w: 264px;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, h4 {
  margin: 0 0 .35em;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--ink);
}
h1 { font-size: clamp(1.7rem, 2.6vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
h4 { font-size: .95rem; font-family: var(--font-body); font-weight: 700; letter-spacing: 0; }

p { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
strong, b { font-weight: 650; }
small { font-size: .82rem; }
em { font-style: italic; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.1rem 0; }
img, svg { max-width: 100%; vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: #cfe6da; color: var(--brand); }

:focus-visible {
  outline: 2px solid var(--brand-3);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 10px;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; }

/* ------------------------------- Utilidades ------------------------------- */
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.block { display: block; }
.mono { font-family: var(--font-mono); font-size: .8rem; }
.row { display: flex; align-items: center; gap: .55rem; }
.row.wrap { flex-wrap: wrap; }
.row.center { align-items: center; }
.span-full { grid-column: 1 / -1; }
.danger-text { color: var(--danger) !important; }
.warn-text { color: var(--warn) !important; }
.ok-text { color: var(--ok) !important; }
.hidden { display: none !important; }
.divider { border-top: 1px solid var(--line); margin: 1.2rem 0; }
.link { display: inline-flex; align-items: center; gap: .3rem; font-size: .84rem; font-weight: 600; color: var(--brand-2); white-space: nowrap; }
.link:hover { text-decoration: none; color: var(--brand); }
.eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .5rem;
}
.bullets { margin: .4rem 0 1rem; padding-left: 1.1rem; }
.bullets li { margin-bottom: .45rem; }
.bullets li::marker { color: var(--brand-3); }

/* --------------------------------- Marca ---------------------------------- */
.brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 12px; color: #f6efe1;
  background: radial-gradient(120% 120% at 20% 10%, var(--brand-3), var(--brand) 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 4px 10px -6px rgba(18,59,50,.7);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong { font-family: var(--font-display); font-size: 1.12rem; font-weight: 600; letter-spacing: -.01em; }
.brand-text em { color: var(--brand-3); font-style: italic; }
.brand-text small { font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }

/* --------------------------------- Botões --------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .58rem .95rem; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); font-size: .86rem; font-weight: 600;
  line-height: 1.2; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--panel-2); text-decoration: none; border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn svg { flex: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #f8f3e7; box-shadow: 0 6px 16px -10px rgba(18,59,50,.8); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--brand-2); }
.btn.ghost:hover { background: rgba(18,59,50,.06); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { background: #983131; border-color: #983131; }
.btn.danger-text { background: transparent; border-color: var(--line); }
.btn.danger-text:hover { background: var(--danger-soft); border-color: #e5b9b2; }
.btn.sm { padding: .42rem .7rem; font-size: .79rem; border-radius: 9px; }
.btn.lg { padding: .8rem 1.35rem; font-size: .95rem; border-radius: 12px; }
.btn.full { width: 100%; }
.btn .hide-sm { display: inline; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--ink-2); transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn.small { width: 27px; height: 27px; border-radius: 7px; }
.icon-btn.danger-text:hover { background: var(--danger-soft); color: var(--danger); }

.link-btn {
  background: none; border: 0; padding: 0; color: var(--brand-2);
  font-weight: 650; font-size: inherit; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--brand); }

/* -------------------------------- Formulários ----------------------------- */
.input {
  width: 100%; padding: .6rem .75rem; border-radius: 10px;
  border: 1px solid var(--line-strong); background: #fffefb; color: var(--ink);
  font-size: .88rem; line-height: 1.35; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:hover { border-color: #bdb4a1; }
.input:focus { outline: none; border-color: var(--brand-3); box-shadow: 0 0 0 3px rgba(47,122,100,.15); }
.input:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 78px; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
.file-input { padding: .45rem; background: var(--panel-2); font-size: .8rem; }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field-label { font-size: .78rem; font-weight: 650; color: var(--ink-2); }
.field-hint { font-size: .73rem; color: var(--muted); }
.form-grid { display: flex; flex-direction: column; gap: .85rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form-error, .form-ok {
  padding: .6rem .75rem; border-radius: 9px; font-size: .82rem; line-height: 1.4;
}
.form-error { background: var(--danger-soft); color: #7d2828; border: 1px solid #ecc4be; }
.form-ok { background: var(--ok-soft); color: #1f5c42; border: 1px solid #bfdcc9; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-size: .84rem; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check span { line-height: 1.4; }
.pw-strength { display: flex; flex-direction: column; gap: .25rem; margin-top: -.35rem; }
.pw-bar { height: 5px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.pw-bar span { display: block; height: 100%; background: var(--danger); border-radius: 99px; transition: width .2s ease, background .2s ease; }
.pw-bar.s3 span { background: var(--warn); }
.pw-bar.s4 span, .pw-bar.s5 span { background: var(--ok); }
.pw-strength small { color: var(--muted); font-size: .72rem; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.shake { animation: shake .35s ease; }

/* -------------------------------- Cartões --------------------------------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .4rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 1.25rem 0 .7rem; }
.section-title:first-child { margin-top: 0; }
.section-title h2 { margin: 0; font-size: 1.08rem; font-family: var(--font-body); font-weight: 700; letter-spacing: -.01em; }

/* --------------------------------- Selos ---------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .5rem;
  border-radius: 999px; font-size: .7rem; font-weight: 700; letter-spacing: .02em;
  background: var(--panel-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: #1f5c42; border-color: #c6e0d1; }
.badge.warn { background: var(--warn-soft); color: #7d560f; border-color: #ecd7a9; }
.badge.danger { background: var(--danger-soft); color: #872d2d; border-color: #edc6c0; }
.badge.info { background: var(--info-soft); color: #1f5570; border-color: #c3deea; }
.badge.tag { background: transparent; color: var(--muted); border-color: var(--line); font-weight: 600; }

.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .38rem .7rem;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel);
  font-size: .78rem; font-weight: 600; color: var(--ink-2);
}
.chip:hover { border-color: var(--brand-3); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #f6f1e5; }
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }

.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%;
  background: hsl(var(--h, 150) 34% 88%); color: hsl(var(--h, 150) 40% 28%);
  font-weight: 700; letter-spacing: .02em; border: 1px solid rgba(255,255,255,.7);
  box-shadow: 0 0 0 1px rgba(22,36,30,.05);
}

/* --------------------------------- Tabelas -------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: .84rem; min-width: 560px; }
.data-table th {
  text-align: left; padding: .65rem .8rem; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--line);
  font-weight: 700; white-space: nowrap;
}
.data-table td { padding: .68rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbf8f0; }
.data-table tr.clickable { cursor: pointer; }
.data-table .person { display: flex; align-items: center; gap: .55rem; }
.data-table .person div { display: flex; flex-direction: column; line-height: 1.25; }
.data-table .person small { color: var(--muted); font-size: .73rem; }

/* -------------------------------- Progresso ------------------------------- */
.progress-wrap { display: flex; align-items: center; gap: .6rem; }
.progress { flex: 1; height: 6px; background: var(--panel-3); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--brand-3), var(--brand-2)); border-radius: 99px; transition: width .3s ease; }
.progress-label { font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------------------------------- Abas ---------------------------------- */
.tabs {
  display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); margin: 1rem 0 1.2rem;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: .4rem; padding: .62rem .8rem;
  border: 0; border-bottom: 2px solid transparent; background: none;
  color: var(--muted); font-size: .84rem; font-weight: 600; white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count { font-size: .68rem; background: var(--panel-2); color: var(--muted); padding: .05rem .35rem; border-radius: 99px; }
.tab.active .tab-count { background: var(--brand); color: #fff; }

/* ---------------------------------- Modal --------------------------------- */
.modal-host {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  padding: 1rem; background: rgba(18, 30, 25, .48); backdrop-filter: blur(3px);
  animation: fadeIn .16s ease;
}
.modal {
  width: min(560px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column;
  background: var(--panel); border-radius: var(--radius-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); animation: popIn .18s ease;
}
.modal.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.2rem .6rem; }
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-sub { margin: .2rem 0 0; color: var(--muted); font-size: .8rem; }
.modal-body { padding: .5rem 1.2rem 1rem; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1.2rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(8px) scale(.99); } }

/* --------------------------------- Toasts --------------------------------- */
.toast-host { position: fixed; z-index: 120; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .45rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  display: flex; align-items: flex-start; gap: .5rem; padding: .65rem .8rem;
  border-radius: 11px; background: var(--brand); color: #f8f4e9; font-size: .82rem; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast svg { margin-top: 1px; flex: none; }
.toast.danger { background: #7e2b2b; }
.toast.warn { background: #7a5410; }

/* --------------------------------- Estados -------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 2.6rem 1rem; gap: .3rem; }
.empty-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px; background: var(--panel-2); color: var(--brand-2); margin-bottom: .4rem; }
.empty h3 { margin: 0; font-size: 1.05rem; }
.empty p { color: var(--muted); font-size: .84rem; max-width: 40ch; margin: .2rem 0 .7rem; }
.loading { display: flex; align-items: center; justify-content: center; gap: .6rem; padding: 3rem 1rem; color: var(--muted); font-size: .85rem; }
.spinner { width: 17px; height: 17px; border: 2px solid var(--line-strong); border-top-color: var(--brand-3); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.json-block {
  background: #182620; color: #d9e6dc; padding: .8rem .9rem; border-radius: 10px;
  font-family: var(--font-mono); font-size: .74rem; line-height: 1.5; overflow-x: auto; margin: .5rem 0;
}
.kv { display: flex; flex-direction: column; gap: .1rem; }
.kv span { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.kv strong { font-size: .85rem; font-weight: 600; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .8rem 1rem; margin: .8rem 0; }
.info-box, .warning-box {
  display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .8rem; border-radius: 10px;
  font-size: .8rem; line-height: 1.45; margin-top: .8rem;
}
.info-box { background: var(--info-soft); color: #1d4f68; border: 1px solid #c5deea; }
.warning-box { background: var(--warn-soft); color: #6f4c0e; border: 1px solid #ead6a8; }
.info-box svg, .warning-box svg { flex: none; margin-top: 1px; }
.score-ring { display: grid; place-items: center; border-radius: 50%; flex: none; }
.score-inner { display: grid; place-items: center; width: 76%; height: 76%; border-radius: 50%; background: var(--panel); line-height: 1; }
.score-inner strong { font-family: var(--font-display); font-size: 1.3rem; }
.score-inner small { font-size: .58rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ----------------------------------- Boot --------------------------------- */
.app-root { min-height: 100vh; }
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; padding: 2rem; }
.boot-mark { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; color: #f7f1e2; background: radial-gradient(120% 120% at 20% 10%, var(--brand-3), var(--brand) 70%); margin-bottom: .6rem; }
.boot h1 { font-size: 1.7rem; margin: 0; }
.boot h1 em { color: var(--brand-3); }
.boot-bar { width: 160px; height: 4px; background: var(--panel-3); border-radius: 99px; overflow: hidden; margin: .8rem 0 .2rem; }
.boot-bar span { display: block; width: 40%; height: 100%; background: var(--brand-3); border-radius: 99px; animation: bootSlide 1.1s ease-in-out infinite; }
@keyframes bootSlide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.fatal { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.fatal-card { max-width: 540px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.6rem; box-shadow: var(--shadow); }
.fatal-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: var(--danger-soft); color: var(--danger); margin-bottom: .8rem; }
.noscript { max-width: 560px; margin: 15vh auto; padding: 1.5rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.external-change {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem .5rem .9rem;
  background: var(--brand); color: #f7f2e6; border-radius: 999px; box-shadow: var(--shadow-lg); font-size: .82rem;
}

/* -------------------------------- Responsivo ------------------------------ */
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .form-row { grid-template-columns: 1fr; }
  .btn .hide-sm { display: none; }
  .toast-host { left: .75rem; right: .75rem; bottom: .75rem; max-width: none; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; align-self: end; }
  .modal-host { padding: 0; align-items: end; }
  .section-title { margin-top: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
