:root {
  color-scheme: light;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f5f6f8;
  --card: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --new: #1d4ed8;
  --danger: #b91c1c;
  /* marca (padrão = neutro/admin) */
  --brand: #0f172a;
  --brand-ink: #ffffff;
  --brand-strong: #0f172a;
  --brand-soft: #eef2f7;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --radius: 16px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.04), 0 8px 24px -12px rgb(15 23 42 / 0.12);
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --text: 'Figtree', system-ui, sans-serif;
}
[data-marca='UNIASSELVI'] {
  --brand: #ffc20e;
  --brand-ink: #161616;
  --brand-strong: #7a5800;
  --brand-soft: #fff6d9;
}
[data-marca='UNICESUMAR'] {
  --brand: #0b3d91;
  --brand-ink: #ffffff;
  --brand-strong: #0b3d91;
  --brand-soft: #e9f0fb;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); margin: 0; letter-spacing: -0.02em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand-strong); outline-offset: 2px; border-radius: 8px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 12px;
  font-weight: 600; cursor: pointer; user-select: none; white-space: nowrap;
  background: var(--card); border-color: var(--line);
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, opacity 150ms ease;
}
a.btn { text-decoration: none; color: inherit; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-danger { color: var(--danger); }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 1.0625rem; border-radius: 14px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { border-color: #cbd5e1; }
  .btn-primary:hover { filter: brightness(1.04); border-color: var(--brand); }
  .btn-ghost:hover { background: rgb(15 23 42 / 0.05); border-color: transparent; }
  .btn-danger:hover { background: #fef2f2; }
}

/* ---------- Landing ---------- */
.landing {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  min-height: 100dvh;
}
.hero-brand {
  background: var(--brand); color: var(--brand-ink);
  padding: clamp(28px, 6vw, 88px);
  display: flex; flex-direction: column; justify-content: center; gap: 28px;
  position: relative; overflow: hidden;
}
.hero-brand::after { /* anel decorativo */
  content: ''; position: absolute; right: -180px; bottom: -180px;
  width: 460px; height: 460px; border-radius: 50%;
  border: 64px solid currentColor; opacity: 0.06; pointer-events: none;
}
.hero-brand .logo { height: 52px; width: auto; align-self: flex-start; }
[data-marca='UNIASSELVI'] .hero-brand .logo { height: 84px; }
[data-marca='UNICESUMAR'] .hero-brand .logo { box-sizing: content-box; background: #fff; padding: 12px 16px; border-radius: 14px; }
[data-marca='UNIASSELVI'] .topbar .logo { height: 40px; }
.eyebrow {
  margin: 0; font-size: 0.8125rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.75;
}
.hero-brand h1 {
  font-size: clamp(2.4rem, 5.6vw, 5.4rem); line-height: 0.98; letter-spacing: -0.035em;
  font-weight: 800; text-transform: uppercase; text-wrap: balance; max-width: 14ch;
}
.city { display: flex; align-items: center; gap: 10px; margin: 0; font-size: clamp(1.25rem, 2.2vw, 1.75rem); font-weight: 600; }
.city svg { width: 26px; height: 26px; flex: none; }
.btn-hero { background: var(--brand-ink); color: var(--brand); border-color: var(--brand-ink); align-self: flex-start; }
.btn-hero svg { transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .btn-hero:hover { border-color: var(--brand-ink); }
  .btn-hero:hover svg { transform: translateX(3px); }
}
.hint { margin: 0; font-size: 0.95rem; opacity: 0.8; }
.hero-photo { margin: 0; position: relative; background: #1e293b; overflow: hidden; }
.hero-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-photo::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--brand) 0%, transparent 35%), linear-gradient(0deg, rgb(0 0 0 / 0.35), transparent 50%);
}
.hero-photo figcaption {
  position: absolute; z-index: 1; left: 24px; bottom: 20px; right: 24px;
  color: #fff; font-size: 0.75rem; opacity: 0.8;
}
.hero-photo figcaption a { color: inherit; }
.reveal > * { animation: rise 600ms var(--ease-out) both; }
.reveal > *:nth-child(2) { animation-delay: 60ms; }
.reveal > *:nth-child(3) { animation-delay: 120ms; }
.reveal > *:nth-child(4) { animation-delay: 180ms; }
.reveal > *:nth-child(5) { animation-delay: 240ms; }
.reveal > *:nth-child(6) { animation-delay: 300ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

@media (max-width: 860px) {
  .landing { grid-template-columns: 1fr; grid-template-rows: 30dvh auto; }
  .hero-photo { order: -1; }
  .hero-photo::after { background: linear-gradient(0deg, var(--brand) 0%, transparent 45%); }
  .hero-brand { justify-content: flex-start; padding: 28px 20px 40px; }
  .hero-brand .logo { height: 40px; }
  .btn-hero { align-self: stretch; }
}

/* ---------- Estado de erro / carregando ---------- */
.center-screen {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px; text-align: center;
}
.center-screen h1 { font-size: 1.75rem; margin-bottom: 8px; }
.center-screen p { color: var(--muted); max-width: 42ch; margin: 0 auto; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--ink);
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  height: 68px; padding: 0 20px;
  background: rgb(255 255 255 / 0.9); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .logo { height: 34px; width: auto; }
.topbar .ies { min-width: 0; line-height: 1.2; }
.topbar .ies strong { display: block; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .ies span { font-size: 0.8125rem; color: var(--muted); }
.progress { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 0.875rem; color: var(--ink-2); white-space: nowrap; }
.bar { width: 160px; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand-strong); border-radius: inherit; transform-origin: left; transition: transform 400ms var(--ease-out); }
[data-marca='UNIASSELVI'] .bar i { background: #e0a800; }

.layout {
  display: grid; grid-template-columns: 340px minmax(0, 1fr);
  height: calc(100dvh - 68px);
}
.sidebar { border-right: 1px solid var(--line); background: var(--card); display: flex; flex-direction: column; min-height: 0; }
.side-head { padding: 16px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.search {
  width: 100%; height: 44px; padding: 0 14px 0 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 14px center;
  font-size: 16px; /* evita zoom no iOS */
}
.search:focus { outline: none; border-color: var(--brand-strong); background-color: #fff; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button {
  border: 1px solid var(--line); background: #fff; border-radius: 99px;
  padding: 4px 10px; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: transform 160ms var(--ease-out), background-color 150ms ease;
}
.filters button:active { transform: scale(0.96); }
.filters button[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters small { opacity: 0.7; margin-left: 2px; }
.lista { position: relative; list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.lista button {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
}
.lista button[aria-current='true'] { background: var(--brand-soft); }
@media (hover: hover) and (pointer: fine) {
  .lista button:hover:not([aria-current='true']) { background: var(--bg); }
}
.lista .nm { flex: 1; min-width: 0; font-size: 0.875rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .excl .nm { text-decoration: line-through; color: var(--muted); }
.empty { padding: 24px 16px; color: var(--muted); font-size: 0.875rem; text-align: center; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px;
  background: #f1f5f9; color: var(--muted);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill[data-s='confirmado'] { background: #ecfdf3; color: var(--ok); }
.pill[data-s='alterado'] { background: var(--warn-soft); color: var(--warn); }
.pill[data-s='novo'] { background: #eff6ff; color: var(--new); }
.pill[data-s='excluido'] { background: #fef2f2; color: var(--danger); }

.stage { overflow-y: auto; padding: clamp(20px, 3vw, 40px); }
.stage-inner { max-width: 1040px; margin: 0 auto; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.pos { font-size: 0.875rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.nav { display: flex; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  transition: transform 160ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
.d-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; }
.d-title h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); line-height: 1.15; }

.cards { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-edit { padding: 24px; display: grid; gap: 22px; }
.card-label { display: flex; align-items: center; gap: 10px; }
.card-label h3 { font-size: 1.125rem; }
.tag {
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 8px; background: var(--brand); color: var(--brand-ink);
}
.locked { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.locked div { background: var(--bg); border-radius: 12px; padding: 10px 14px; min-width: 0; }
.locked dt { font-size: 0.75rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.locked dt svg { width: 12px; height: 12px; }
.locked dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 700; font-size: 0.9375rem; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; padding: 0; }
.changed-badge {
  font-size: 0.6875rem; font-weight: 700; color: var(--warn); background: var(--warn-soft);
  padding: 2px 8px; border-radius: 99px; opacity: 0; transform: translateY(2px);
  transition: opacity 180ms ease, transform 180ms var(--ease-out);
}
fieldset.changed .changed-badge { opacity: 1; transform: none; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 14px;
  border: 1.5px solid var(--line); border-radius: 12px; font-size: 0.9375rem; font-weight: 500;
  transition: border-color 150ms ease, background-color 150ms ease, transform 160ms var(--ease-out);
}
.chip span::before {
  content: ''; width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid #cbd5e1; background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.chip input:checked + span { border-color: var(--brand-strong); background: var(--brand-soft); font-weight: 700; }
.chip input:checked + span::before { border-color: var(--brand-strong); box-shadow: inset 0 0 0 4px #fff; background: var(--brand-strong); }
.chip input:active + span { transform: scale(0.98); }
.chip input:focus-visible + span { outline: 3px solid var(--brand-strong); outline-offset: 2px; }
.chip .was { margin-left: auto; font-size: 0.6875rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
@media (hover: hover) and (pointer: fine) {
  .chip input:not(:checked):hover + span { border-color: #94a3b8; }
}
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 4px; border-top: 1px solid var(--line); padding-top: 18px; }
.card-actions .btn-primary { flex: 1 1 220px; }
.btn-label { transition: filter 200ms ease, opacity 200ms ease; }
.btn.swapping .btn-label { filter: blur(2px); opacity: 0.6; }

.banner-excl {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 14px 16px; border-radius: 12px; background: #fef2f2; color: var(--danger); font-weight: 600;
}

.card-2025 { padding: 24px; background: linear-gradient(180deg, var(--brand-soft), #fff 60%); }
.year {
  font-family: var(--display); font-weight: 800; font-size: 4.5rem; line-height: 0.9;
  letter-spacing: -0.05em; color: var(--brand-strong);
}
.card-2025 .sub { color: var(--muted); font-size: 0.875rem; margin: 6px 0 18px; }
.card-2025 dl { margin: 0; display: grid; gap: 14px; }
.card-2025 dt { font-size: 0.75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.card-2025 dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.card-2025 .none { color: var(--muted); font-weight: 500; font-size: 0.9375rem; }

.done { text-align: center; max-width: 560px; margin: 6vh auto 0; }
.done-icon {
  width: 84px; height: 84px; margin: 0 auto 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand); color: var(--brand-ink);
}
.done-icon svg { width: 40px; height: 40px; }
.done h2 { font-size: 2rem; margin-bottom: 8px; }
.done p { color: var(--muted); margin: 0 0 24px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 28px; }
.stats div { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 8px; }
.stats b { display: block; font-family: var(--display); font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats span { font-size: 0.75rem; color: var(--muted); font-weight: 600; }

@media (max-width: 960px) {
  .cards { grid-template-columns: 1fr; }
  .card-2025 { order: -1; }
  .year { font-size: 3rem; }
}
@media (max-width: 760px) {
  .topbar { position: static; height: auto; flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .topbar .logo { height: 30px; }
  .topbar .btn { margin-left: auto; min-height: 38px; padding: 0 12px; font-size: 0.875rem; }
  .topbar .ies { order: 2; flex-basis: 100%; }
  .topbar .ies strong { white-space: normal; }
  .progress { margin-left: 0; width: 100%; order: 3; }
  .bar { flex: 1; }
  .layout { display: flex; flex-direction: column; height: auto; }
  .sidebar { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .lista { max-height: 50dvh; }
  .stage { padding: 20px 16px; overflow: visible; }
  .chips { grid-template-columns: 1fr; }
  .locked { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Dialog ---------- */
dialog {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 20px;
  box-shadow: 0 24px 64px -16px rgb(15 23 42 / 0.35);
  opacity: 0; transform: scale(0.96);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), overlay 200ms allow-discrete, display 200ms allow-discrete;
}
dialog[open] { opacity: 1; transform: none; }
@starting-style { dialog[open] { opacity: 0; transform: scale(0.96); } }
dialog::backdrop { background: rgb(15 23 42 / 0.4); backdrop-filter: blur(3px); }
.dlg { padding: 24px; display: grid; gap: 16px; }
.dlg h3 { font-size: 1.375rem; }
.dlg p { margin: 0; color: var(--ink-2); }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: 0.875rem; }
.field input, .field select {
  height: 46px; padding: 0 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; font-size: 16px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--brand-strong); box-shadow: 0 0 0 3px var(--brand-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-size: 0.875rem; font-weight: 600; min-height: 1.3em; margin: 0; }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 14px; background: var(--ink); color: #fff;
  font-weight: 600; font-size: 0.9375rem; box-shadow: 0 12px 32px -8px rgb(15 23 42 / 0.4);
  opacity: 0; transform: translate(-50%, 16px); pointer-events: none;
  transition: opacity 200ms ease, transform 300ms var(--ease-out);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-property: opacity, background-color, border-color, color !important; }
}
