/* base.css — Identidade do Make it Flow.
   Estilo "neo-brutalista" tirado do formulário de login (Uiverse, andrew-demchenk0):
   borda sólida de 2px, sombra dura deslocada (4px 4px) e o "afundar" ao clicar.
   Toda tela usa estes tokens e componentes (.nb-*); não repetir sombra/borda na mão. */

:root {
  color-scheme: light;
  --ink: #1f1d1a;          /* borda, sombra e texto principal */
  --sub: #5f5a52;
  --muted: #8c867c;
  --bg: #f4efe6;           /* fundo creme */
  --surface: #fffaf0;
  --surface2: #fbf3e2;
  --primary: #1fb57a;      /* verde "fluxo" */
  --primary-soft: #d6f5e7;
  --yellow: #ffcf33;
  --coral: #ff7a59;
  --blue: #5b8def;
  --danger: #d6453d;
  --ok: #1f8a5b;

  --border: 2px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --radius: 6px;

  --font: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }
a { color: inherit; }

/* ── Cartão ─────────────────────────────────────────────── */
.nb-card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Campo ─────────────────────────────────────────────── */
.nb-input {
  width: 100%;
  height: 44px;
  border-radius: var(--radius);
  border: var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  padding: 5px 12px;
  outline: none;
  transition: border-color .12s ease;
}
.nb-input::placeholder { color: var(--sub); opacity: .75; font-weight: 500; }
.nb-input:focus { border-color: var(--primary); }

/* ── Botões ─────────────────────────────────────────────── */
.nb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease, box-shadow .06s ease;
}
.nb-btn--primary { background: var(--primary); }
.nb-btn--yellow { background: var(--yellow); }
.nb-btn--perigo { background: #ffe1dc; }
.nb-btn--sm { height: 36px; padding: 0 14px; font-size: 14px; box-shadow: var(--shadow-sm); }
.nb-btn:disabled,
.nb-icon-btn:disabled { opacity: .6; cursor: default; }

.nb-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 100%;
  border: var(--border);
  background: #fff;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease;
}

/* O "afundar": a sombra some e o elemento anda o mesmo tanto, como no original. */
.nb-btn:active:not(:disabled),
.nb-icon-btn:active:not(:disabled),
.nb-press:active {
  box-shadow: 0 0 0 var(--ink);
  transform: translate(3px, 3px);
}

/* ── Controles de formulário ─────────────────────────────
   Padrão do sistema inteiro (ver /componentes). Nunca usar o controle nativo sem estas classes:
   <select class="nb-select">        → lista personalizada (js/controles.js monta o resto)
   <input type="checkbox" class="nb-check">  · <input type="radio" class="nb-radio">
   <label class="nb-switch">          → chave liga/desliga
   <div class="nb-segmentos">         → escolha única em botões lado a lado
   <label class="nb-opcao">           → linha com check/radio + texto (+ <small> de ajuda)      */

textarea.nb-input { height: auto; min-height: 96px; padding: 10px 12px; line-height: 1.45; resize: vertical; }
.nb-input:disabled { opacity: .6; cursor: not-allowed; background: var(--surface2); }
.nb-input--sm { height: 36px; font-size: 14px; box-shadow: var(--shadow-sm); }

.nb-campo { display: flex; flex-direction: column; gap: 6px; }
.nb-rotulo { font-size: 13.5px; font-weight: 700; }
.nb-rotulo em { font-style: normal; font-weight: 500; color: var(--sub); }
.nb-ajuda { font-size: 12.5px; color: var(--sub); line-height: 1.4; }

/* Lista personalizada (select). O <select> real continua no DOM, escondido, e é quem guarda o valor. */
.nb-select { position: relative; display: inline-flex; min-width: 0; width: 100%; }
.nb-select-nativo {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; opacity: 0;
}
.nb-select-btn {
  width: 100%;
  min-width: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .06s ease, border-color .12s ease;
}
.nb-select-btn:active:not(:disabled) { box-shadow: 0 0 0 var(--ink); transform: translate(3px, 3px); }
.nb-select-btn[aria-expanded="true"] { border-color: var(--primary); }
.nb-select-btn:disabled { opacity: .6; cursor: not-allowed; background: var(--surface2); }
.nb-select-btn > .bi:first-child { flex: none; font-size: 15px; }
.nb-select-valor { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-select-valor.vazio { color: var(--sub); font-weight: 500; }
.nb-select-seta { flex: none; font-size: 13px; transition: transform .15s ease; }
.nb-select-btn[aria-expanded="true"] .nb-select-seta { transform: rotate(180deg); }
.nb-select--sm .nb-select-btn { height: 36px; font-size: 13.5px; box-shadow: var(--shadow-sm); padding: 0 10px; }

.nb-select-lista {
  position: fixed;
  z-index: 1000;
  max-height: 300px;
  overflow-y: auto;
  list-style: none;
  padding: 6px;
  margin: 0;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font);
}
.nb-select-opcao {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: 5px;
  color: var(--ink);
  cursor: pointer;
}
.nb-select-opcao .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nb-select-opcao strong { font-size: 14px; font-weight: 600; }
.nb-select-opcao small { font-size: 12.5px; color: var(--sub); line-height: 1.35; }
.nb-select-opcao .marca { flex: none; width: 16px; margin-top: 2px; font-size: 15px; visibility: hidden; }
.nb-select-opcao[aria-selected="true"] { background: var(--primary-soft); }
.nb-select-opcao[aria-selected="true"] strong { font-weight: 700; }
.nb-select-opcao[aria-selected="true"] .marca { visibility: visible; }
.nb-select-opcao.ativa { border-color: var(--ink); background: #fff; }
.nb-select-opcao.ativa[aria-selected="true"] { background: var(--primary-soft); }
.nb-select-opcao[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* Caixa de seleção e opção única */
.nb-check, .nb-radio {
  appearance: none;
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: var(--border);
  background: #fff;
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  transition: background-color .1s ease, transform .06s ease, box-shadow .06s ease;
}
.nb-check { border-radius: 5px; }
.nb-radio { border-radius: 100%; }
.nb-check:checked {
  background: var(--primary) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5l3 3 6-7' fill='none' stroke='%231f1d1a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.nb-check:indeterminate {
  background: var(--yellow) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' stroke='%231f1d1a' stroke-width='2.4' stroke-linecap='round'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.nb-radio:checked { background: radial-gradient(circle, var(--ink) 0 4px, var(--primary) 4.5px); }
.nb-check:active:not(:disabled), .nb-radio:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.nb-check:disabled, .nb-radio:disabled { opacity: .5; cursor: not-allowed; }

.nb-opcao { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14.5px; font-weight: 600; line-height: 1.35; }
.nb-opcao > span { display: flex; flex-direction: column; gap: 2px; padding-top: 1px; }
.nb-opcao small { font-size: 12.5px; font-weight: 500; color: var(--sub); }
.nb-opcao:has(input:disabled) { cursor: not-allowed; opacity: .6; }

/* Chave liga/desliga: <label class="nb-switch"><input type="checkbox"><span class="nb-switch-trilho"></span><span>Texto</span></label> */
.nb-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.nb-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.nb-switch-trilho {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  border: var(--border);
  border-radius: 999px;
  background: #e2dccf;
  box-shadow: 2px 2px 0 var(--ink);
  transition: background-color .15s ease;
}
.nb-switch-trilho::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border: 2px solid var(--ink);
  border-radius: 100%;
  background: #fff;
  transition: left .15s ease;
}
.nb-switch input:checked + .nb-switch-trilho { background: var(--primary); }
.nb-switch input:checked + .nb-switch-trilho::after { left: 22px; }
.nb-switch input:focus-visible + .nb-switch-trilho { outline: 3px solid var(--blue); outline-offset: 2px; }
.nb-switch:has(input:disabled) { cursor: not-allowed; }
.nb-switch:has(input:disabled) > * { opacity: .55; }

/* Botões segmentados (escolha única): <div class="nb-segmentos"><label><input type="radio" name="x"><span>Dia</span></label>…</div> */
.nb-segmentos {
  display: inline-flex;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: #fff;
  overflow: hidden;
}
.nb-segmentos label { position: relative; cursor: pointer; }
.nb-segmentos label + label { border-left: var(--border); }
.nb-segmentos input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.nb-segmentos span { display: block; padding: 7px 14px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.nb-segmentos input:checked + span { background: var(--primary); font-weight: 700; }
.nb-segmentos input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: -4px; }
.nb-segmentos label:hover input:not(:checked) + span { background: var(--surface2); }

/* ── Logo "make it flow" (js/marca.js) ───────────────────── */
/* As cores vêm daqui: em fundo escuro, pôr .marca--escura num ancestral. */
.marca { display: block; width: 100%; height: auto; overflow: visible; }
.marca-letra { fill: var(--ink); }
.marca-anel { fill: none; stroke: var(--primary); }
.marca-pingo { fill: var(--yellow); stroke: var(--ink); }
.marca-linha { fill: none; stroke: var(--primary); stroke-linecap: round; opacity: 0; }
.marca-onda { fill: none; stroke: var(--primary); opacity: 0; }
.marca-onda--dado { stroke: var(--yellow); }
.marca-rastro { fill: none; stroke: var(--yellow); stroke-linecap: round; opacity: 0; }
.marca--escura .marca-letra { fill: var(--surface); }

/* ── Notificações (js/avisos.js) ───────────────────────── */
/* Pilha no rodapé, no meio. Uma tela pode subir a pilha com --avisos-base (ex.: acima da barra). */
.nb-avisos {
  position: fixed;
  z-index: 300;
  left: 50%;
  bottom: var(--avisos-base, 24px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.nb-toast {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
  max-width: 520px;
  padding: 10px 10px 12px 12px;
  background: var(--surface);
  border: var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  animation: toast-entra .5s cubic-bezier(.34, 1.56, .64, 1) both;
}
.nb-toast-txt { flex: 1; min-width: 0; }
.nb-toast-ic {
  flex: none;
  width: 34px;
  height: 34px;
  border: var(--border);
  border-radius: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  animation: toast-ic .55s cubic-bezier(.34, 1.56, .64, 1) .08s both;
}
.nb-toast-ic svg { width: 22px; height: 22px; overflow: visible; }
.nb-toast-ic .risca { fill: none; stroke: var(--ink); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 30; stroke-dashoffset: 30; animation: toast-risca .4s ease-out .3s forwards; }
.nb-toast-ic .ponto { fill: var(--ink); transform-box: fill-box; transform-origin: center; animation: toast-ponto .35s cubic-bezier(.34, 1.56, .64, 1) .45s both; }
.nb-toast-x {
  flex: none;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 100%;
  background: none;
  color: var(--sub);
  cursor: pointer;
}
.nb-toast-x:hover { background: var(--surface2); color: var(--ink); }
.nb-toast-tempo {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 4px;
  width: 100%;
  background: var(--primary);
  transform-origin: left;
  animation: toast-tempo linear forwards;
}
.nb-toast.pausado .nb-toast-tempo { animation-play-state: paused; }
.nb-toast.saindo { animation: toast-sai .35s cubic-bezier(.5, 0, .75, 0) forwards; }

/* Sucesso: o "ok" se risca. Salvo: o disquete afunda e ganha o selo, com um brilho passando. */
.nb-toast--salvo .nb-toast-ic { background: var(--yellow); }
.nb-toast--salvo .nb-toast-tempo { background: var(--yellow); }
.nb-toast--salvo .disco, .nb-toast--salvo .disco-tampa { fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; }
.nb-toast--salvo svg { animation: toast-afunda .5s ease-out .1s both; }
.nb-toast--salvo .selo { stroke-width: 2.4; animation-delay: .45s; }
.nb-toast--salvo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .7) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: toast-brilho .8s ease-out .35s forwards;
  pointer-events: none;
}
/* Erro: chega e balança ("não"). Info: azul, chega de lado. */
.nb-toast--erro { background: #fff1ee; animation: toast-entra .5s cubic-bezier(.34, 1.56, .64, 1) both, toast-balanca .45s ease-in-out .45s; }
.nb-toast--erro .nb-toast-ic { background: var(--danger); }
.nb-toast--erro .nb-toast-ic .risca { stroke: #fff; }
.nb-toast--erro .nb-toast-ic .ponto { fill: #fff; }
.nb-toast--erro .nb-toast-tempo { background: var(--danger); }
.nb-toast--info .nb-toast-ic { background: var(--blue); }
.nb-toast--info .nb-toast-ic .risca { stroke: #fff; }
.nb-toast--info .nb-toast-ic .ponto { fill: #fff; }
.nb-toast--info .nb-toast-tempo { background: var(--blue); }

@keyframes toast-entra { from { opacity: 0; transform: translateY(26px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toast-sai { to { opacity: 0; transform: translateY(14px) scale(.92); } }
@keyframes toast-ic { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
@keyframes toast-risca { to { stroke-dashoffset: 0; } }
@keyframes toast-ponto { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes toast-tempo { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes toast-afunda { 0% { transform: translateY(-7px); } 60% { transform: translateY(2px) scaleY(.9); } 100% { transform: none; } }
@keyframes toast-brilho { to { transform: translateX(100%); } }
@keyframes toast-balanca { 0%, 100% { transform: none; } 20% { transform: translateX(-7px) rotate(-1deg); } 40% { transform: translateX(6px) rotate(1deg); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }

/* ── Janela de confirmação (MIFAviso.confirmar) ───────── */
.nb-modal {
  margin: auto;
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 26px 24px 20px;
  color: var(--ink);
  text-align: center;
  overflow: visible;
}
.nb-modal[open] { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: modal-entra .45s cubic-bezier(.34, 1.56, .64, 1) both; }
.nb-modal::backdrop { background: rgba(31, 29, 26, .5); animation: modal-fundo .3s ease-out both; }
.nb-modal.saindo { animation: modal-sai .25s ease-in forwards; }
.nb-modal.saindo::backdrop { animation: modal-fundo .25s ease-in reverse forwards; }
.nb-modal-ic {
  width: 58px;
  height: 58px;
  margin-top: -56px;
  border: var(--border);
  border-radius: 100%;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--yellow);
  animation: modal-ic .6s cubic-bezier(.34, 1.56, .64, 1) .12s both;
}
.nb-modal--perigo .nb-modal-ic { background: var(--danger); color: #fff; }
.nb-modal-titulo { font-size: 20px; margin: 6px 0 0; }
.nb-modal-texto { margin: 0; color: var(--sub); font-size: 14.5px; line-height: 1.5; }
.nb-modal-acoes { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 12px; }
@keyframes modal-entra { from { opacity: 0; transform: translateY(24px) scale(.88) rotate(-1.5deg); } to { opacity: 1; transform: none; } }
@keyframes modal-sai { to { opacity: 0; transform: translateY(12px) scale(.94); } }
@keyframes modal-fundo { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-ic { 0% { transform: scale(0) rotate(-30deg); } 70% { transform: scale(1.12) rotate(6deg); } 100% { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .nb-toast, .nb-toast *, .nb-toast::after, .nb-modal, .nb-modal *, .nb-modal::backdrop { animation: none !important; }
  .nb-toast-ic .risca { stroke-dashoffset: 0; }
  .nb-toast--salvo::after { display: none; }
}

/* ── Dados (JSON) ─────────────────────────────────────── */
/* <pre class="nb-json">: entrada/saída de um módulo, com rolagem e texto selecionável. */
.nb-json {
  margin: 0;
  max-height: 340px;
  overflow: auto;
  padding: 10px 12px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
}

/* ── Escolha de cor (<div class="nb-cores"><label class="nb-cor"><input type="radio"><span>) ─ */
.nb-cores { display: flex; gap: 10px; flex-wrap: wrap; }
.nb-cor { position: relative; cursor: pointer; }
.nb-cor input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.nb-cor span { display: block; width: 30px; height: 30px; border: var(--border); border-radius: 999px; transition: transform .1s ease; }
.nb-cor input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); transform: scale(1.05); }
.nb-cor input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 4px; }
.nb-cor:hover span { transform: scale(1.1); }

/* ── Selo ─────────────────────────────────────────────── */
.nb-tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border: var(--border);
  border-radius: 999px;
  background: var(--yellow);
  line-height: 1.4;
  white-space: nowrap;
}

/* ── Avisos ─────────────────────────────────────────────── */
.nb-alert {
  display: none;
  width: 100%;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
  padding: 9px 12px;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.nb-alert.show { display: block; }
.nb-alert--err { background: #ffe1dc; color: #7a1f17; }
.nb-alert--warn { background: #fff3c4; color: #5c4400; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ── Carregando (js/carregando.js) ─────────────────────── */
.carregando {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 32px 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--sub);
}
.carregando-anim { width: 96px; height: 96px; color: var(--primary); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
