@layer fv.tokens, fv.base, fv.components, fv.motion;
/* Única fonte de valores visuais. Cor literal só aqui (o teste cobra). */
@layer fv.tokens {
  :root {
    color-scheme: dark;
    --fv-bg: #0a0a0b; --fv-surface: #161618; --fv-raised: #202023; --fv-line: #2c2c30;
    --fv-text: #f5f5f7; --fv-muted: #a3a3ab;
    --fv-glass: rgb(22 22 24 / .78); --fv-scrim: rgb(0 0 0 / .55); --fv-shadow: 0 -20px 60px rgb(0 0 0 / .4);
    --fv-danger: #c9342f; --fv-on-danger: #ffffff; --fv-danger-text: #ff8b85;
    --fv-success-text: #5fd39b; --fv-warning-text: #f2b65a;

    --fv-font: system-ui, -apple-system, "Segoe UI", sans-serif;
    --fv-text-xs: .75rem; --fv-text-sm: .84rem; --fv-text-md: 1rem; --fv-text-lg: 1.15rem; --fv-text-xl: 1.35rem;
    --fv-text-display: clamp(1.9rem, 6vw, 3rem);
    --fv-weight-title: 650; --fv-weight-strong: 600;

    --fv-1: .25rem; --fv-2: .5rem; --fv-3: .75rem; --fv-4: 1rem; --fv-5: 1.25rem; --fv-6: 1.5rem; --fv-8: 2rem; --fv-10: 2.5rem;
    --fv-radius: 16px; --fv-radius-sm: 10px; --fv-radius-full: 99px;
    --fv-tap: 44px; --fv-control: 46px;
    --fv-fast: .15s; --fv-base: .22s; --fv-ease: cubic-bezier(.2, .8, .2, 1);
  }
  :root[data-theme=light] {
    color-scheme: light;
    --fv-bg: #f4f4f6; --fv-surface: #ffffff; --fv-raised: #ececf0; --fv-line: #dcdce1;
    --fv-text: #161618; --fv-muted: #5d5d66;
    --fv-glass: rgb(255 255 255 / .82); --fv-shadow: 0 -20px 60px rgb(0 0 0 / .18);
    --fv-danger: #b92722; --fv-danger-text: #ab211c;
    --fv-success-text: #0f6b41; --fv-warning-text: #7a4d00;
  }
  /* Destaque por projeto: <html data-accent="green">. Azul é o padrão. */
  :root, :root[data-accent=blue] { --fv-accent: #1f6feb; --fv-on-accent: #ffffff; --fv-accent-text: #6fb0ff; }
  :root[data-accent=green] { --fv-accent: #14794c; --fv-on-accent: #ffffff; --fv-accent-text: #5fd39b; }
  :root[data-accent=violet] { --fv-accent: #7650e6; --fv-on-accent: #ffffff; --fv-accent-text: #b49cff; }
  :root[data-accent=rose] { --fv-accent: #c9305a; --fv-on-accent: #ffffff; --fv-accent-text: #ff8fab; }
  :root[data-accent=amber] { --fv-accent: #a85a0b; --fv-on-accent: #ffffff; --fv-accent-text: #f2b065; }
  :root[data-theme=light], :root[data-theme=light][data-accent=blue] { --fv-accent: #1a5fd0; --fv-accent-text: #1556bf; }
  :root[data-theme=light][data-accent=green] { --fv-accent: #146c45; --fv-accent-text: #0f6b41; }
  :root[data-theme=light][data-accent=violet] { --fv-accent: #6540d4; --fv-accent-text: #5a35c8; }
  :root[data-theme=light][data-accent=rose] { --fv-accent: #b32550; --fv-accent-text: #a61f48; }
  :root[data-theme=light][data-accent=amber] { --fv-accent: #8f4a06; --fv-accent-text: #804205; }
  /* Cores de ícone por projeto: style="--fv-tint: var(--fv-tint-green)" */
  :root { --fv-tint: var(--fv-accent); --fv-tint-blue: #3f9bff; --fv-tint-green: #2fb380; --fv-tint-violet: #8b6cff; --fv-tint-rose: #f0597a; --fv-tint-amber: #f59a3c; }
  @media (prefers-contrast: more) { :root, :root[data-theme=light] { --fv-line: var(--fv-muted); } }
  @media (prefers-reduced-transparency: reduce) { :root, :root[data-theme=light] { --fv-glass: var(--fv-surface); } }
}

@layer fv.base {
  *, ::before, ::after { box-sizing: border-box; }
  * { margin: 0; }
  html { font: 100%/1.5 var(--fv-font); background: var(--fv-bg); color: var(--fv-text); -webkit-text-size-adjust: 100%; }
  body { min-height: 100dvh; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  a { color: var(--fv-accent-text); }
  h1, h2, h3 { font-weight: var(--fv-weight-title); text-wrap: balance; }
  h1 { font-size: var(--fv-text-display); line-height: 1.08; letter-spacing: -.022em; }
  h2 { font-size: var(--fv-text-lg); line-height: 1.3; }
  h3 { font-size: var(--fv-text-md); line-height: 1.4; }
  :focus-visible { outline: 2px solid var(--fv-accent-text); outline-offset: 2px; }
  main:focus { outline: 0; }
  [hidden] { display: none !important; }
}
@layer fv.motion {
  @media (prefers-reduced-motion: reduce) {
    *, ::before, ::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
  }
}

@layer fv.components {
  .fv-icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
  .fv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .fv-muted { color: var(--fv-muted); }
  .fv-link { min-height: var(--fv-tap); display: inline-flex; align-items: center; justify-content: center; }

  /* Estrutura da página */
  .fv-app { max-width: 1360px; padding: var(--fv-5) var(--fv-4) calc(112px + env(safe-area-inset-bottom)); }
  .fv-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--fv-3); margin: var(--fv-2) 0 var(--fv-6); }
  .fv-header p { color: var(--fv-muted); margin-top: var(--fv-1); }
  .fv-section { margin: var(--fv-8) 0 var(--fv-3); }
  .fv-nav { position: fixed; z-index: 10; inset: auto 0 0; display: flex; padding: 6px var(--fv-2) calc(6px + env(safe-area-inset-bottom)); background: var(--fv-glass); -webkit-backdrop-filter: blur(22px) saturate(170%); backdrop-filter: blur(22px) saturate(170%); border-top: 1px solid var(--fv-line); }
  .fv-nav__brand { display: none; }
  .fv-nav__item { flex: 1; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: var(--fv-text-xs); color: var(--fv-muted); text-decoration: none; border-radius: var(--fv-radius-sm); }
  .fv-nav__item[aria-current=page] { color: var(--fv-accent-text); }

  /* Ações */
  .fv-btn { min-height: var(--fv-control); padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: 1px solid transparent; border-radius: var(--fv-radius-sm); background: var(--fv-raised); color: var(--fv-text); font-weight: var(--fv-weight-strong); text-decoration: none; }
  .fv-btn--primary { background: var(--fv-accent); color: var(--fv-on-accent); }
  .fv-btn--outline { background: none; border-color: var(--fv-line); }
  .fv-btn--danger { background: var(--fv-danger); color: var(--fv-on-danger); }
  .fv-icon-btn { min-width: var(--fv-tap); min-height: var(--fv-tap); display: grid; place-items: center; border: 1px solid var(--fv-line); border-radius: var(--fv-radius-sm); background: var(--fv-surface); }
  :is(.fv-btn, .fv-icon-btn, .fv-card, .fv-nav__item) { transition: transform .18s ease-out, background-color var(--fv-fast); }
  :is(.fv-btn, .fv-icon-btn, .fv-card, .fv-nav__item):active:not(:disabled) { transform: scale(.97); }
  :is(.fv-btn, .fv-icon-btn):disabled { opacity: .45; cursor: not-allowed; }

  /* Conteúdo */
  .fv-grid { display: grid; gap: var(--fv-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fv-card { min-height: 148px; padding: var(--fv-4); display: flex; flex-direction: column; gap: var(--fv-1); text-align: left; text-decoration: none; color: var(--fv-text); background: var(--fv-surface); border: 1px solid var(--fv-line); border-radius: var(--fv-radius); }
  .fv-card__icon { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: auto; border-radius: var(--fv-radius-sm); background: color-mix(in srgb, var(--fv-tint) 20%, var(--fv-surface)); color: color-mix(in srgb, var(--fv-tint) 70%, var(--fv-text)); }
  .fv-card__title { margin-top: var(--fv-3); font-size: 1.08rem; font-weight: var(--fv-weight-title); line-height: 1.3; }
  .fv-card__meta { font-size: var(--fv-text-sm); color: var(--fv-muted); }
  .fv-list { overflow: hidden; background: var(--fv-surface); border: 1px solid var(--fv-line); border-radius: var(--fv-radius); }
  .fv-row { width: 100%; min-height: 64px; padding: 10px var(--fv-4); display: flex; align-items: center; gap: var(--fv-3); text-align: left; color: var(--fv-text); text-decoration: none; }
  button.fv-row { padding: 10px var(--fv-4); }
  .fv-row + .fv-row { border-top: 1px solid var(--fv-line); }
  .fv-row__main { flex: 1; min-width: 0; }
  .fv-row__title { display: block; font-weight: var(--fv-weight-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fv-row__meta { font-size: var(--fv-text-sm); color: var(--fv-muted); }
  .fv-row__actions { display: flex; gap: var(--fv-2); }
  .fv-row:is(button, a):focus-visible { outline-offset: -3px; }
  .fv-empty { padding: var(--fv-5) var(--fv-4); color: var(--fv-muted); }
  .fv-badge { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: var(--fv-radius-full); background: var(--fv-raised); font-size: var(--fv-text-xs); font-weight: var(--fv-weight-strong); }
  .fv-badge--success { color: var(--fv-success-text); }
  .fv-badge--warning { color: var(--fv-warning-text); }
  .fv-badge--danger { color: var(--fv-danger-text); }
  .fv-center { min-height: 70dvh; padding: var(--fv-4); display: grid; place-items: center; }
  .fv-panel { width: min(100%, 380px); display: grid; gap: var(--fv-3); padding: 28px 22px; background: var(--fv-surface); border: 1px solid var(--fv-line); border-radius: var(--fv-radius); }

  /* Formulários */
  .fv-field { display: grid; gap: 6px; font-weight: var(--fv-weight-strong); }
  .fv-input { width: 100%; min-width: 0; min-height: var(--fv-control); padding: 0 14px; font-size: var(--fv-text-md); font-weight: 400; background: var(--fv-bg); border: 1px solid var(--fv-line); border-radius: var(--fv-radius-sm); }
  .fv-input::placeholder { color: var(--fv-muted); opacity: 1; }
  .fv-input[aria-invalid=true] { border-color: var(--fv-danger-text); }
  .fv-error { color: var(--fv-danger-text); font-size: var(--fv-text-sm); font-weight: 400; }
  .fv-inline { display: flex; gap: var(--fv-2); }
  .fv-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; padding: 4px; background: var(--fv-raised); border-radius: var(--fv-radius-sm); }
  .fv-seg button { min-height: var(--fv-control); padding: 4px; border-radius: calc(var(--fv-radius-sm) - 2px); font-size: .88rem; font-weight: var(--fv-weight-strong); line-height: 1.15; color: var(--fv-muted); }
  .fv-seg [aria-checked=true] { background: var(--fv-accent); color: var(--fv-on-accent); }
  .fv-seg button:disabled { opacity: .45; cursor: not-allowed; }
  .fv-switch { width: 52px; height: 32px; flex: none; position: relative; border: 1px solid var(--fv-line); border-radius: var(--fv-radius-full); background: var(--fv-raised); }
  .fv-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--fv-muted); transition: transform var(--fv-base) var(--fv-ease); }
  [aria-checked=true] > .fv-switch { background: var(--fv-accent); }
  [aria-checked=true] > .fv-switch::after { transform: translateX(20px); background: var(--fv-on-accent); }

  /* Camadas */
  .fv-scrim { position: fixed; inset: 0; z-index: 40; background: var(--fv-scrim); opacity: 0; }
  .fv-sheet { position: fixed; z-index: 41; inset: auto 0 0; max-height: 90dvh; display: flex; flex-direction: column; background: var(--fv-surface); border: 1px solid var(--fv-line); border-bottom: 0; border-radius: var(--fv-radius) var(--fv-radius) 0 0; box-shadow: var(--fv-shadow); will-change: transform; }
  .fv-sheet::after { content: ""; position: absolute; inset: 100% 0 auto; height: 50vh; background: var(--fv-surface); }
  .fv-sheet__grab { padding: 10px 20px 14px; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
  .fv-sheet__grab::before { content: ""; display: block; width: 38px; height: 5px; margin: 0 auto 14px; border-radius: var(--fv-radius-full); background: var(--fv-line); }
  .fv-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--fv-3); }
  .fv-sheet__head h2 { font-size: var(--fv-text-xl); }
  .fv-sheet__body { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; gap: var(--fv-4); padding: 0 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  .fv-dialog { width: min(94vw, 540px); margin: 12vh auto auto; padding: 0; overflow: hidden; color: var(--fv-text); background: var(--fv-surface); border: 1px solid var(--fv-line); border-radius: var(--fv-radius); }
  .fv-dialog::backdrop { background: var(--fv-scrim); }
  .fv-dialog__search { width: 100%; min-height: 58px; padding: 0 var(--fv-4); background: none; border: 0; border-bottom: 1px solid var(--fv-line); outline-offset: -2px; }
  .fv-toast { position: fixed; z-index: 60; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); max-width: 90vw; padding: 12px 18px; border-radius: var(--fv-radius-sm); background: var(--fv-text); color: var(--fv-bg); font-weight: var(--fv-weight-strong); translate: -50% 12px; opacity: 0; pointer-events: none; transition: opacity var(--fv-base), translate var(--fv-base); }
  .fv-toast[data-on] { opacity: 1; translate: -50% 0; }

  @media (hover: hover) { :is(a, button):is(.fv-card, .fv-row):hover { background: var(--fv-raised); } }
  @media (max-width: 560px) {
    .fv-row--stack { flex-wrap: wrap; }
    .fv-row--stack .fv-row__main { flex-basis: 100%; }
    .fv-row--stack .fv-row__actions { width: 100%; }
    .fv-row--stack .fv-btn { flex: 1; }
  }
  @media (min-width: 860px) {
    .fv-app { padding: 36px 40px 64px 272px; }
    .fv-nav { inset: 0 auto 0 0; width: 232px; flex-direction: column; gap: 4px; padding: 24px 14px; border-top: 0; border-right: 1px solid var(--fv-line); }
    .fv-nav__brand { display: block; padding: 0 12px 20px; font-size: var(--fv-text-xl); font-weight: var(--fv-weight-title); letter-spacing: -.02em; }
    .fv-nav__item { flex: none; min-height: var(--fv-tap); flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 12px; font-size: .95rem; }
    .fv-nav__item[aria-current=page] { background: var(--fv-raised); }
    .fv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .fv-sheet { inset: 0 0 0 auto; width: 460px; max-height: none; border: 0; border-left: 1px solid var(--fv-line); border-radius: 0; }
    .fv-sheet::after { inset: 0 auto 0 100%; width: 50vw; height: auto; }
    .fv-sheet__grab { padding-top: 24px; }
    .fv-sheet__grab::before { display: none; }
  }
}
